r4452 takkaria - in /trunk/hubbub: include/hubbub/types.h src/tokeniser/tokeniser.c
by netsurf@semichrome.net
Author: takkaria
Date: Thu Jun 26 03:06:25 2008
New Revision: 4452
URL: http://source.netsurf-browser.org?rev=4452&view=rev
Log:
Add the basics of namespace support.
Modified:
trunk/hubbub/include/hubbub/types.h
trunk/hubbub/src/tokeniser/tokeniser.c
Modified: trunk/hubbub/include/hubbub/types.h
URL: http://source.netsurf-browser.org/trunk/hubbub/include/hubbub/types.h?rev...
==============================================================================
--- trunk/hubbub/include/hubbub/types.h (original)
+++ trunk/hubbub/include/hubbub/types.h Thu Jun 26 03:06:25 2008
@@ -94,9 +94,22 @@
} hubbub_doctype;
/**
+ * Possible namespaces
+ */
+typedef enum hubbub_ns {
+ HUBBUB_NS_HTML,
+ HUBBUB_NS_MATHML,
+ HUBBUB_NS_SVG,
+ HUBBUB_NS_XLINK,
+ HUBBUB_NS_XML,
+ HUBBUB_NS_XMLNS
+} hubbub_ns;
+
+/**
* Data for a tag
*/
typedef struct hubbub_tag {
+ hubbub_ns ns; /**< Tag namespace */
hubbub_string name; /**< Tag name */
uint32_t n_attributes; /**< Count of attributes */
hubbub_attribute *attributes; /**< Array of attribute data */
Modified: trunk/hubbub/src/tokeniser/tokeniser.c
URL: http://source.netsurf-browser.org/trunk/hubbub/src/tokeniser/tokeniser.c?...
==============================================================================
--- trunk/hubbub/src/tokeniser/tokeniser.c (original)
+++ trunk/hubbub/src/tokeniser/tokeniser.c Thu Jun 26 03:06:25 2008
@@ -3173,6 +3173,7 @@
if (token->type == HUBBUB_TOKEN_START_TAG) {
tokeniser->context.last_start_tag_name = token->data.tag.name;
+ token->data.tag.ns = HUBBUB_NS_HTML;
} else if (token->type == HUBBUB_TOKEN_END_TAG) {
tokeniser->content_model = HUBBUB_CONTENT_MODEL_PCDATA;
}
14 years, 11 months
r4451 takkaria - in /trunk/hubbub/src/treebuilder: in_head.c internal.h treebuilder.c
by netsurf@semichrome.net
Author: takkaria
Date: Thu Jun 26 02:58:56 2008
New Revision: 4451
URL: http://source.netsurf-browser.org?rev=4451&view=rev
Log:
Move some stuff internal to the "in head" mode to in_head.c.
Modified:
trunk/hubbub/src/treebuilder/in_head.c
trunk/hubbub/src/treebuilder/internal.h
trunk/hubbub/src/treebuilder/treebuilder.c
Modified: trunk/hubbub/src/treebuilder/in_head.c
URL: http://source.netsurf-browser.org/trunk/hubbub/src/treebuilder/in_head.c?...
==============================================================================
--- trunk/hubbub/src/treebuilder/in_head.c (original)
+++ trunk/hubbub/src/treebuilder/in_head.c Thu Jun 26 02:58:56 2008
@@ -12,6 +12,70 @@
#include "treebuilder/internal.h"
#include "treebuilder/treebuilder.h"
#include "utils/utils.h"
+
+
+/**
+ * Process a <base>, <link>, or <meta> start tag as if in "in head"
+ *
+ * \param treebuilder The treebuilder instance
+ * \param token The token to process
+ * \param type The type of element (BASE, LINK, or META)
+ */
+static void process_base_link_meta_in_head(hubbub_treebuilder *treebuilder,
+ const hubbub_token *token, element_type type)
+{
+ insert_element_no_push(treebuilder, &token->data.tag);
+
+ if (type == META) {
+ /** \todo charset extraction */
+ }
+}
+
+
+/**
+ * Process a <script> start tag as if in "in head"
+ *
+ * \param treebuilder The treebuilder instance
+ * \param token The token to process
+ */
+static void process_script_in_head(hubbub_treebuilder *treebuilder,
+ const hubbub_token *token)
+{
+ int success;
+ void *script;
+ hubbub_tokeniser_optparams params;
+
+ success = treebuilder->tree_handler->create_element(
+ treebuilder->tree_handler->ctx,
+ &token->data.tag, &script);
+ if (success != 0) {
+ /** \todo errors */
+ }
+
+ /** \todo mark script as parser-inserted */
+
+ /* It would be nice to be able to re-use the generic
+ * rcdata character collector here. Unfortunately, we
+ * can't as we need to do special processing after the
+ * script data has been collected, so we use an almost
+ * identical insertion mode which does the right magic
+ * at the end. */
+ params.content_model.model = HUBBUB_CONTENT_MODEL_CDATA;
+ hubbub_tokeniser_setopt(treebuilder->tokeniser,
+ HUBBUB_TOKENISER_CONTENT_MODEL,
+ ¶ms);
+
+ treebuilder->context.collect.mode = treebuilder->context.mode;
+ treebuilder->context.collect.node = script;
+ treebuilder->context.collect.type = SCRIPT;
+ treebuilder->context.collect.string.data.off = 0;
+ treebuilder->context.collect.string.len = 0;
+
+ treebuilder->context.mode = SCRIPT_COLLECT_CHARACTERS;
+}
+
+
+
/**
Modified: trunk/hubbub/src/treebuilder/internal.h
URL: http://source.netsurf-browser.org/trunk/hubbub/src/treebuilder/internal.h...
==============================================================================
--- trunk/hubbub/src/treebuilder/internal.h (original)
+++ trunk/hubbub/src/treebuilder/internal.h Thu Jun 26 02:58:56 2008
@@ -109,10 +109,6 @@
const hubbub_token *token, void *parent);
void parse_generic_rcdata(hubbub_treebuilder *treebuilder,
const hubbub_token *token, bool rcdata);
-void process_base_link_meta_in_head(hubbub_treebuilder *treebuilder,
- const hubbub_token *token, element_type type);
-void process_script_in_head(hubbub_treebuilder *treebuilder,
- const hubbub_token *token);
uint32_t element_in_scope(hubbub_treebuilder *treebuilder,
element_type type, bool in_table);
Modified: trunk/hubbub/src/treebuilder/treebuilder.c
URL: http://source.netsurf-browser.org/trunk/hubbub/src/treebuilder/treebuilde...
==============================================================================
--- trunk/hubbub/src/treebuilder/treebuilder.c (original)
+++ trunk/hubbub/src/treebuilder/treebuilder.c Thu Jun 26 02:58:56 2008
@@ -505,65 +505,6 @@
}
/**
- * Process a <base>, <link>, or <meta> start tag as if in "in head"
- *
- * \param treebuilder The treebuilder instance
- * \param token The token to process
- * \param type The type of element (BASE, LINK, or META)
- */
-void process_base_link_meta_in_head(hubbub_treebuilder *treebuilder,
- const hubbub_token *token, element_type type)
-{
- insert_element_no_push(treebuilder, &token->data.tag);
-
- if (type == META) {
- /** \todo charset extraction */
- }
-}
-
-/**
- * Process a <script> start tag as if in "in head"
- *
- * \param treebuilder The treebuilder instance
- * \param token The token to process
- */
-void process_script_in_head(hubbub_treebuilder *treebuilder,
- const hubbub_token *token)
-{
- int success;
- void *script;
- hubbub_tokeniser_optparams params;
-
- success = treebuilder->tree_handler->create_element(
- treebuilder->tree_handler->ctx,
- &token->data.tag, &script);
- if (success != 0) {
- /** \todo errors */
- }
-
- /** \todo mark script as parser-inserted */
-
- /* It would be nice to be able to re-use the generic
- * rcdata character collector here. Unfortunately, we
- * can't as we need to do special processing after the
- * script data has been collected, so we use an almost
- * identical insertion mode which does the right magic
- * at the end. */
- params.content_model.model = HUBBUB_CONTENT_MODEL_CDATA;
- hubbub_tokeniser_setopt(treebuilder->tokeniser,
- HUBBUB_TOKENISER_CONTENT_MODEL,
- ¶ms);
-
- treebuilder->context.collect.mode = treebuilder->context.mode;
- treebuilder->context.collect.node = script;
- treebuilder->context.collect.type = SCRIPT;
- treebuilder->context.collect.string.data.off = 0;
- treebuilder->context.collect.string.len = 0;
-
- treebuilder->context.mode = SCRIPT_COLLECT_CHARACTERS;
-}
-
-/**
* Determine if an element is in (table) scope
*
* \param treebuilder Treebuilder to look in
@@ -580,7 +521,7 @@
return false;
for (node = treebuilder->context.current_node; node > 0; node--) {
- element_type node_type =
+ element_type node_type =
treebuilder->context.element_stack[node].type;
if (node_type == type)
14 years, 11 months
r4450 dynis - in /branches/dynis/libnsgif: libnsgif.c libnsgif.h
by netsurf@semichrome.net
Author: dynis
Date: Thu Jun 26 02:00:01 2008
New Revision: 4450
URL: http://source.netsurf-browser.org?rev=4450&view=rev
Log:
Made non-critical bitmap callbacks optional (nullable in struct); assert on critical bitmap callbacks to ensure they are present
Modified:
branches/dynis/libnsgif/libnsgif.c
branches/dynis/libnsgif/libnsgif.h
Modified: branches/dynis/libnsgif/libnsgif.c
URL: http://source.netsurf-browser.org/branches/dynis/libnsgif/libnsgif.c?rev=...
==============================================================================
--- branches/dynis/libnsgif/libnsgif.c (original)
+++ branches/dynis/libnsgif/libnsgif.c Thu Jun 26 02:00:01 2008
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <assert.h>
#include "libnsgif.h"
#include "utils/log.h"
@@ -303,6 +304,7 @@
/* Initialise the sprite header
*/
+ assert(gif->bitmap_callbacks.bitmap_create);
if ((gif->frame_image = gif->bitmap_callbacks.bitmap_create(gif->width, gif->height)) == NULL) {
gif_finalise(gif);
return GIF_INSUFFICIENT_MEMORY;
@@ -382,8 +384,10 @@
/* Allocate some more memory
*/
+ assert(gif->bitmap_callbacks.bitmap_create);
if ((buffer = gif->bitmap_callbacks.bitmap_create(max_width, max_height)) == NULL)
return GIF_INSUFFICIENT_MEMORY;
+ assert(gif->bitmap_callbacks.bitmap_destroy);
gif->bitmap_callbacks.bitmap_destroy(gif->frame_image);
gif->frame_image = buffer;
gif->width = max_width;
@@ -850,6 +854,7 @@
/* Get the frame data
*/
+ assert(gif->bitmap_callbacks.bitmap_get_buffer);
frame_data = (unsigned int *)gif->bitmap_callbacks.bitmap_get_buffer(gif->frame_image);
if (!frame_data)
return GIF_INSUFFICIENT_MEMORY;
@@ -893,6 +898,7 @@
goto gif_decode_frame_exit;
/* Get this frame's data
*/
+ assert(gif->bitmap_callbacks.bitmap_get_buffer);
frame_data = (unsigned int *)gif->bitmap_callbacks.bitmap_get_buffer(gif->frame_image);
if (!frame_data)
return GIF_INSUFFICIENT_MEMORY;
@@ -987,11 +993,16 @@
/* Check if we should test for optimisation
*/
if (gif->frames[frame].virgin) {
- gif->frames[frame].opaque = gif->bitmap_callbacks.bitmap_test_opaque(gif->frame_image);
+ if (gif->bitmap_callbacks.bitmap_test_opaque)
+ gif->frames[frame].opaque = gif->bitmap_callbacks.bitmap_test_opaque(gif->frame_image);
+ else
+ gif->frames[frame].opaque = false;
gif->frames[frame].virgin = false;
}
- gif->bitmap_callbacks.bitmap_set_opaque(gif->frame_image, gif->frames[frame].opaque);
- gif->bitmap_callbacks.bitmap_modified(gif->frame_image);
+ if (gif->bitmap_callbacks.bitmap_set_opaque)
+ gif->bitmap_callbacks.bitmap_set_opaque(gif->frame_image, gif->frames[frame].opaque);
+ if (gif->bitmap_callbacks.bitmap_modified)
+ gif->bitmap_callbacks.bitmap_modified(gif->frame_image);
/* Restore the buffer position
*/
@@ -1076,8 +1087,10 @@
void gif_finalise(gif_animation *gif) {
/* Release all our memory blocks
*/
- if (gif->frame_image)
+ if (gif->frame_image) {
+ assert(gif->bitmap_callbacks.bitmap_destroy);
gif->bitmap_callbacks.bitmap_destroy(gif->frame_image);
+ }
gif->frame_image = NULL;
free(gif->frames);
gif->frames = NULL;
Modified: branches/dynis/libnsgif/libnsgif.h
URL: http://source.netsurf-browser.org/branches/dynis/libnsgif/libnsgif.h?rev=...
==============================================================================
--- branches/dynis/libnsgif/libnsgif.h (original)
+++ branches/dynis/libnsgif/libnsgif.h Thu Jun 26 02:00:01 2008
@@ -74,6 +74,8 @@
gif_bitmap_cb_create bitmap_create; /**< Create a bitmap. */
gif_bitmap_cb_destroy bitmap_destroy; /**< Free a bitmap. */
gif_bitmap_cb_get_buffer bitmap_get_buffer; /**< Return a pointer to the pixel data in a bitmap. */
+ /** Members below are optional
+ */
gif_bitmap_cb_set_opaque bitmap_set_opaque; /**< Sets whether a bitmap should be plotted opaque. */
gif_bitmap_cb_test_opaque bitmap_test_opaque; /**< Tests whether a bitmap has an opaque alpha channel. */
gif_bitmap_cb_modified bitmap_modified; /**< The bitmap image has changed, so flush any persistant cache. */
14 years, 11 months
r4449 dynis - in /branches/dynis/libnsgif: examples/decode_gif.c libnsgif.c libnsgif.h
by netsurf@semichrome.net
Author: dynis
Date: Thu Jun 26 01:30:44 2008
New Revision: 4449
URL: http://source.netsurf-browser.org?rev=4449&view=rev
Log:
Arranged gif_animation and gif_frame members, moved bitmap callbacks into gif_animation, and added gif_create() function
Modified:
branches/dynis/libnsgif/examples/decode_gif.c
branches/dynis/libnsgif/libnsgif.c
branches/dynis/libnsgif/libnsgif.h
Modified: branches/dynis/libnsgif/examples/decode_gif.c
URL: http://source.netsurf-browser.org/branches/dynis/libnsgif/examples/decode...
==============================================================================
--- branches/dynis/libnsgif/examples/decode_gif.c (original)
+++ branches/dynis/libnsgif/examples/decode_gif.c Thu Jun 26 01:30:44 2008
@@ -26,7 +26,7 @@
#include <sys/stat.h>
#include <libnsgif.h>
-char *load_file(const char *path, size_t *data_size);
+unsigned char *load_file(const char *path, size_t *data_size);
void warning(const char *context, int code);
void *bitmap_create(int width, int height);
void bitmap_set_opaque(void *bitmap, bool opaque);
@@ -36,19 +36,18 @@
void bitmap_modified(void *bitmap);
-gif_bitmap_callback_vt bitmap_callbacks = {
- bitmap_create,
- bitmap_destroy,
- bitmap_get_buffer,
- bitmap_set_opaque,
- bitmap_test_opaque,
- bitmap_modified
-};
-
-
int main(int argc, char *argv[])
{
- struct gif_animation gif;
+ gif_animation gif = {
+ .bitmap_callbacks = {
+ bitmap_create,
+ bitmap_destroy,
+ bitmap_get_buffer,
+ bitmap_set_opaque,
+ bitmap_test_opaque,
+ bitmap_modified
+ }
+ };
size_t size;
int code;
unsigned int i;
@@ -58,17 +57,15 @@
return 1;
}
+ /* create our gif animation */
+ gif_create(&gif);
+
/* load file into memory */
- char *data = load_file(argv[1], &size);
-
- /* initialise gif_animation structure */
- gif.buffer_size = size;
- gif.gif_data = (unsigned char *) data;
- gif.buffer_position = 0;
+ unsigned char *data = load_file(argv[1], &size);
/* begin decoding */
do {
- code = gif_initialise(&gif, &bitmap_callbacks);
+ code = gif_initialise(&gif, size, data);
if (code != GIF_OK && code != GIF_WORKING) {
warning("gif_initialise", code);
exit(1);
@@ -81,7 +78,6 @@
printf("# height %u \n", gif.height);
printf("# frame_count %u \n", gif.frame_count);
printf("# frame_count_partial %u \n", gif.frame_count_partial);
- printf("# background_colour %x \n", gif.background_colour);
printf("# loop_count %u \n", gif.loop_count);
printf("%u %u 256\n", gif.width, gif.height * gif.frame_count);
@@ -90,7 +86,7 @@
unsigned int row, col;
char *image;
- code = gif_decode_frame(&gif, i, &bitmap_callbacks);
+ code = gif_decode_frame(&gif, i);
if (code != GIF_OK)
warning("gif_decode_frame", code);
@@ -108,15 +104,18 @@
}
}
+ /* clean up */
+ gif_finalise(&gif);
+
return 0;
}
-char *load_file(const char *path, size_t *data_size)
+unsigned char *load_file(const char *path, size_t *data_size)
{
FILE *fd;
struct stat sb;
- char *buffer;
+ unsigned char *buffer;
size_t size;
size_t n;
Modified: branches/dynis/libnsgif/libnsgif.c
URL: http://source.netsurf-browser.org/branches/dynis/libnsgif/libnsgif.c?rev=...
==============================================================================
--- branches/dynis/libnsgif/libnsgif.c (original)
+++ branches/dynis/libnsgif/libnsgif.c Thu Jun 26 01:30:44 2008
@@ -110,19 +110,19 @@
/* Internal GIF routines
*/
-static gif_result gif_initialise_sprite(struct gif_animation *gif, unsigned int width, unsigned int height, gif_bitmap_callback_vt *bitmap_callbacks);
-static gif_result gif_initialise_frame(struct gif_animation *gif, gif_bitmap_callback_vt *bitmap_callbacks);
-static gif_result gif_initialise_frame_extensions(struct gif_animation *gif, const int frame);
-static gif_result gif_skip_frame_extensions(struct gif_animation *gif);
+static gif_result gif_initialise_sprite(gif_animation *gif, unsigned int width, unsigned int height);
+static gif_result gif_initialise_frame(gif_animation *gif);
+static gif_result gif_initialise_frame_extensions(gif_animation *gif, const int frame);
+static gif_result gif_skip_frame_extensions(gif_animation *gif);
static unsigned int gif_interlaced_line(int height, int y);
/* Internal LZW routines
*/
-static void gif_init_LZW(struct gif_animation *gif);
-static bool gif_next_LZW(struct gif_animation *gif);
-static int gif_next_code(struct gif_animation *gif, int code_size);
+static void gif_init_LZW(gif_animation *gif);
+static bool gif_next_LZW(gif_animation *gif);
+static int gif_next_code(gif_animation *gif, int code_size);
/* General LZW values. They are shared for all GIFs being decoded, and
thus we can't handle progressive decoding efficiently without having
@@ -147,6 +147,20 @@
*/
static bool clear_image = false;
+/** Initialises necessary gif_animation members.
+*/
+void gif_create(gif_animation *gif) {
+ gif->gif_data = NULL;
+ gif->frame_image = NULL;
+ gif->frames = NULL;
+ gif->local_colour_table = NULL;
+ gif->global_colour_table = NULL;
+ gif->buffer_position = 0;
+ gif->frame_count = 0;
+ gif->frame_count_partial = 0;
+ gif->decoded_frame = GIF_INVALID_FRAME;
+}
+
/** Initialises any workspace held by the animation and attempts to decode
any information that hasn't already been decoded.
If an error occurs, all previously decoded frames are retained.
@@ -160,15 +174,20 @@
GIF_OK for successful decoding
GIF_WORKING for successful decoding if more frames are expected
*/
-gif_result gif_initialise(struct gif_animation *gif, gif_bitmap_callback_vt *bitmap_callbacks) {
+gif_result gif_initialise(gif_animation *gif, size_t size, unsigned char *data) {
unsigned char *gif_data;
unsigned int index;
gif_result return_value;
- /* The GIF format is thoroughly documented; a full description
- * can be found at http://www.w3.org/Graphics/GIF/spec-gif89a.txt
- */
-
+ /* The GIF format is thoroughly documented; a full description
+ * can be found at http://www.w3.org/Graphics/GIF/spec-gif89a.txt
+ */
+
+ /* Initialize values
+ */
+ gif->buffer_size = size;
+ gif->gif_data = data;
+
/* Check for sufficient data to be a GIF (6-byte header + 7-byte logical screen descriptor)
*/
if (gif->buffer_size < 13) return GIF_INSUFFICIENT_DATA;
@@ -227,7 +246,7 @@
gif->height = gif_data[2] | (gif_data[3] << 8);
gif->global_colours = (gif_data[4] & GIF_COLOUR_TABLE_MASK);
gif->colour_table_size = (2 << (gif_data[4] & GIF_COLOUR_TABLE_SIZE_MASK));
- gif->background_colour = gif_data[5];
+ gif->background_index = gif_data[5];
gif->aspect_ratio = gif_data[6];
gif->loop_count = 1;
gif_data += 7;
@@ -255,7 +274,7 @@
gif->global_colour_table = (unsigned int *)calloc(GIF_MAX_COLOURS, sizeof(int));
gif->local_colour_table = (unsigned int *)calloc(GIF_MAX_COLOURS, sizeof(int));
if ((gif->global_colour_table == NULL) || (gif->local_colour_table == NULL)) {
- gif_finalise(gif, bitmap_callbacks);
+ gif_finalise(gif);
return GIF_INSUFFICIENT_MEMORY;
}
@@ -277,15 +296,15 @@
/* Initialise enough workspace for 4 frames initially
*/
if ((gif->frames = (gif_frame *)malloc(sizeof(gif_frame))) == NULL) {
- gif_finalise(gif, bitmap_callbacks);
+ gif_finalise(gif);
return GIF_INSUFFICIENT_MEMORY;
}
gif->frame_holders = 1;
/* Initialise the sprite header
*/
- if ((gif->frame_image = bitmap_callbacks->bitmap_create(gif->width, gif->height)) == NULL) {
- gif_finalise(gif, bitmap_callbacks);
+ if ((gif->frame_image = gif->bitmap_callbacks.bitmap_create(gif->width, gif->height)) == NULL) {
+ gif_finalise(gif);
return GIF_INSUFFICIENT_MEMORY;
}
@@ -320,7 +339,7 @@
/* Repeatedly try to initialise frames
*/
- while ((return_value = gif_initialise_frame(gif, bitmap_callbacks)) == GIF_WORKING);
+ while ((return_value = gif_initialise_frame(gif)) == GIF_WORKING);
/* If there was a memory error tell the caller
*/
@@ -346,7 +365,7 @@
@return GIF_INSUFFICIENT_MEMORY for a memory error
GIF_OK for success
*/
-static gif_result gif_initialise_sprite(struct gif_animation *gif, unsigned int width, unsigned int height, gif_bitmap_callback_vt *bitmap_callbacks) {
+static gif_result gif_initialise_sprite(gif_animation *gif, unsigned int width, unsigned int height) {
unsigned int max_width;
unsigned int max_height;
struct bitmap *buffer;
@@ -363,9 +382,9 @@
/* Allocate some more memory
*/
- if ((buffer = bitmap_callbacks->bitmap_create(max_width, max_height)) == NULL)
+ if ((buffer = gif->bitmap_callbacks.bitmap_create(max_width, max_height)) == NULL)
return GIF_INSUFFICIENT_MEMORY;
- bitmap_callbacks->bitmap_destroy(gif->frame_image);
+ gif->bitmap_callbacks.bitmap_destroy(gif->frame_image);
gif->frame_image = buffer;
gif->width = max_width;
gif->height = max_height;
@@ -387,7 +406,7 @@
GIF_OK for successful decoding
GIF_WORKING for successful decoding if more frames are expected
*/
-static gif_result gif_initialise_frame(struct gif_animation *gif, gif_bitmap_callback_vt *bitmap_callbacks) {
+static gif_result gif_initialise_frame(gif_animation *gif) {
int frame;
gif_frame *temp_buf;
@@ -517,7 +536,7 @@
/* Boundary checking - shouldn't ever happen except with junk data
*/
- if (gif_initialise_sprite(gif, (offset_x + width), (offset_y + height), bitmap_callbacks))
+ if (gif_initialise_sprite(gif, (offset_x + width), (offset_y + height)))
return GIF_INSUFFICIENT_MEMORY;
/* Decode the flags
@@ -581,7 +600,7 @@
@return GIF_INSUFFICIENT_FRAME_DATA for insufficient data to complete the frame
GIF_OK for successful initialisation
*/
-static gif_result gif_initialise_frame_extensions(struct gif_animation *gif, const int frame) {
+static gif_result gif_initialise_frame_extensions(gif_animation *gif, const int frame) {
unsigned char *gif_data, *gif_end;
int gif_bytes;
unsigned int block_size;
@@ -695,7 +714,7 @@
If a frame does not contain any image data, GIF_OK is returned and
gif->current_error is set to GIF_FRAME_NO_DISPLAY
*/
-gif_result gif_decode_frame(struct gif_animation *gif, unsigned int frame, gif_bitmap_callback_vt *bitmap_callbacks) {
+gif_result gif_decode_frame(gif_animation *gif, unsigned int frame) {
unsigned int index = 0;
unsigned char *gif_data, *gif_end;
int gif_bytes;
@@ -831,7 +850,7 @@
/* Get the frame data
*/
- frame_data = (unsigned int *)bitmap_callbacks->bitmap_get_buffer(gif->frame_image);
+ frame_data = (unsigned int *)gif->bitmap_callbacks.bitmap_get_buffer(gif->frame_image);
if (!frame_data)
return GIF_INSUFFICIENT_MEMORY;
@@ -854,10 +873,10 @@
* colour or this is the first frame, clear the frame data
*/
if ((frame == 0) || (gif->decoded_frame == GIF_INVALID_FRAME)) {
- memset((char*)frame_data, colour_table[gif->background_colour], gif->width * gif->height * sizeof(int));
+ memset((char*)frame_data, colour_table[gif->background_index], gif->width * gif->height * sizeof(int));
} else if ((frame != 0) && (gif->frames[frame - 1].disposal_method == GIF_FRAME_CLEAR)) {
clear_image = true;
- if ((return_value = gif_decode_frame(gif, (frame - 1), bitmap_callbacks)) != GIF_OK)
+ if ((return_value = gif_decode_frame(gif, (frame - 1))) != GIF_OK)
goto gif_decode_frame_exit;
clear_image = false;
/* If the previous frame's disposal method requires we restore the previous
@@ -868,13 +887,13 @@
/* If we don't find one, clear the frame data
*/
if (last_undisposed_frame == -1) {
- memset((char*)frame_data, colour_table[gif->background_colour], gif->width * gif->height * sizeof(int));
+ memset((char*)frame_data, colour_table[gif->background_index], gif->width * gif->height * sizeof(int));
} else {
- if ((return_value = gif_decode_frame(gif, last_undisposed_frame, bitmap_callbacks)) != GIF_OK)
+ if ((return_value = gif_decode_frame(gif, last_undisposed_frame)) != GIF_OK)
goto gif_decode_frame_exit;
/* Get this frame's data
*/
- frame_data = (unsigned int *)bitmap_callbacks->bitmap_get_buffer(gif->frame_image);
+ frame_data = (unsigned int *)gif->bitmap_callbacks.bitmap_get_buffer(gif->frame_image);
if (!frame_data)
return GIF_INSUFFICIENT_MEMORY;
}
@@ -940,7 +959,7 @@
if (gif->frames[frame].disposal_method == GIF_FRAME_CLEAR) {
for (y = 0; y < height; y++) {
frame_scanline = frame_data + offset_x + ((offset_y + y) * gif->width);
- memset(frame_scanline, colour_table[gif->background_colour], width * 4);
+ memset(frame_scanline, colour_table[gif->background_index], width * 4);
}
}
@@ -968,11 +987,11 @@
/* Check if we should test for optimisation
*/
if (gif->frames[frame].virgin) {
- gif->frames[frame].opaque = bitmap_callbacks->bitmap_test_opaque(gif->frame_image);
+ gif->frames[frame].opaque = gif->bitmap_callbacks.bitmap_test_opaque(gif->frame_image);
gif->frames[frame].virgin = false;
}
- bitmap_callbacks->bitmap_set_opaque(gif->frame_image, gif->frames[frame].opaque);
- bitmap_callbacks->bitmap_modified(gif->frame_image);
+ gif->bitmap_callbacks.bitmap_set_opaque(gif->frame_image, gif->frames[frame].opaque);
+ gif->bitmap_callbacks.bitmap_modified(gif->frame_image);
/* Restore the buffer position
*/
@@ -989,7 +1008,7 @@
@return GIF_INSUFFICIENT_FRAME_DATA for insufficient data to complete the frame
GIF_OK for successful decoding
*/
-static gif_result gif_skip_frame_extensions(struct gif_animation *gif) {
+static gif_result gif_skip_frame_extensions(gif_animation *gif) {
unsigned char *gif_data, *gif_end;
int gif_bytes;
unsigned int block_size;
@@ -1054,11 +1073,11 @@
/* Releases any workspace held by the animation
*/
-void gif_finalise(struct gif_animation *gif, gif_bitmap_callback_vt *bitmap_callbacks) {
+void gif_finalise(gif_animation *gif) {
/* Release all our memory blocks
*/
if (gif->frame_image)
- bitmap_callbacks->bitmap_destroy(gif->frame_image);
+ gif->bitmap_callbacks.bitmap_destroy(gif->frame_image);
gif->frame_image = NULL;
free(gif->frames);
gif->frames = NULL;
@@ -1066,12 +1085,14 @@
gif->local_colour_table = NULL;
free(gif->global_colour_table);
gif->global_colour_table = NULL;
+ free(gif->gif_data);
+ gif->gif_data = NULL;
}
/**
* Initialise LZW decoding
*/
-void gif_init_LZW(struct gif_animation *gif) {
+void gif_init_LZW(gif_animation *gif) {
int i;
gif->current_error = 0;
@@ -1098,7 +1119,7 @@
}
-static bool gif_next_LZW(struct gif_animation *gif) {
+static bool gif_next_LZW(gif_animation *gif) {
int code, incode;
int block_size;
int new_code;
@@ -1165,7 +1186,7 @@
return true;
}
-static int gif_next_code(struct gif_animation *gif, int code_size) {
+static int gif_next_code(gif_animation *gif, int code_size) {
int i, j, end, count, ret;
unsigned char *b;
Modified: branches/dynis/libnsgif/libnsgif.h
URL: http://source.netsurf-browser.org/branches/dynis/libnsgif/libnsgif.h?rev=...
==============================================================================
--- branches/dynis/libnsgif/libnsgif.h (original)
+++ branches/dynis/libnsgif/libnsgif.h Thu Jun 26 01:30:44 2008
@@ -42,9 +42,11 @@
/* The GIF frame data
*/
typedef struct gif_frame {
+ bool display; /**< whether the frame should be displayed/animated */
+ unsigned int frame_delay; /**< delay (in cs) before animating the frame */
+ /** Internal members are listed below
+ */
unsigned int frame_pointer; /**< offset (in bytes) to the GIF frame data */
- unsigned int frame_delay; /**< delay (in cs) before animating the frame */
- bool display; /**< whether the frame should be displayed/animated */
bool virgin; /**< whether the frame has previously been used */
bool opaque; /**< whether the frame is totally opaque */
bool redraw_required; /**< whether a forcable screen redraw is required */
@@ -68,41 +70,45 @@
/* The Bitmap callbacks function table
*/
-typedef struct gif_bitmap_callback_vt_s {
+typedef struct gif_bitmap_callback_vt {
gif_bitmap_cb_create bitmap_create; /**< Create a bitmap. */
gif_bitmap_cb_destroy bitmap_destroy; /**< Free a bitmap. */
gif_bitmap_cb_get_buffer bitmap_get_buffer; /**< Return a pointer to the pixel data in a bitmap. */
gif_bitmap_cb_set_opaque bitmap_set_opaque; /**< Sets whether a bitmap should be plotted opaque. */
gif_bitmap_cb_test_opaque bitmap_test_opaque; /**< Tests whether a bitmap has an opaque alpha channel. */
- gif_bitmap_cb_modified bitmap_modified; /**< The bitmap image has changed, so flush any persistant cache. */
+ gif_bitmap_cb_modified bitmap_modified; /**< The bitmap image has changed, so flush any persistant cache. */
} gif_bitmap_callback_vt;
/* The GIF animation data
*/
typedef struct gif_animation {
- unsigned char *gif_data; /**< pointer to GIF data */
- unsigned int buffer_position; /**< current index into GIF data */
- unsigned int buffer_size; /**< total number of bytes of GIF data available */
- unsigned int frame_holders; /**< current number of frame holders */
- int decoded_frame; /**< current frame decoded to bitmap */
- int loop_count; /**< number of times to loop animation */
- gif_frame *frames; /**< decoded frames */
- unsigned int width; /**< width of GIF (may increase during decoding) */
- unsigned int height; /**< heigth of GIF (may increase during decoding) */
- unsigned int frame_count; /**< number of frames decoded */
- unsigned int frame_count_partial; /**< number of frames partially decoded */
- unsigned int background_colour; /**< image background colour */
- unsigned int aspect_ratio; /**< image aspect ratio (ignored) */
- unsigned int colour_table_size; /**< size of colour table (in entries) */
- bool global_colours; /**< whether the GIF has a global colour table */
- unsigned int *global_colour_table; /**< global colour table */
- unsigned int *local_colour_table; /**< local colour table */
- void *frame_image; /**< currently decoded image; stored as bitmap from bitmap_create callback */
- gif_result current_error; /**< current error type, or 0 for none*/
+ gif_bitmap_callback_vt bitmap_callbacks; /**< callbacks for bitmap functions */
+ unsigned char *gif_data; /**< pointer to GIF data */
+ unsigned int width; /**< width of GIF (may increase during decoding) */
+ unsigned int height; /**< heigth of GIF (may increase during decoding) */
+ unsigned int frame_count; /**< number of frames decoded */
+ unsigned int frame_count_partial; /**< number of frames partially decoded */
+ gif_frame *frames; /**< decoded frames */
+ int decoded_frame; /**< current frame decoded to bitmap */
+ void *frame_image; /**< currently decoded image; stored as bitmap from bitmap_create callback */
+ int loop_count; /**< number of times to loop animation */
+ gif_result current_error; /**< current error type, or 0 for none*/
+ /** Internal members are listed below
+ */
+ unsigned int buffer_position; /**< current index into GIF data */
+ unsigned int buffer_size; /**< total number of bytes of GIF data available */
+ unsigned int frame_holders; /**< current number of frame holders */
+ unsigned int background_index; /**< index in the colour table for the background colour */
+ unsigned int aspect_ratio; /**< image aspect ratio (ignored) */
+ unsigned int colour_table_size; /**< size of colour table (in entries) */
+ bool global_colours; /**< whether the GIF has a global colour table */
+ unsigned int *global_colour_table; /**< global colour table */
+ unsigned int *local_colour_table; /**< local colour table */
} gif_animation;
-gif_result gif_initialise(struct gif_animation *gif, gif_bitmap_callback_vt *bitmap_callbacks);
-gif_result gif_decode_frame(struct gif_animation *gif, unsigned int frame, gif_bitmap_callback_vt *bitmap_callbacks);
-void gif_finalise(struct gif_animation *gif, gif_bitmap_callback_vt *bitmap_callbacks);
+void gif_create(gif_animation *gif);
+gif_result gif_initialise(gif_animation *gif, size_t size, unsigned char *data);
+gif_result gif_decode_frame(gif_animation *gif, unsigned int frame);
+void gif_finalise(gif_animation *gif);
#endif
14 years, 11 months
r4448 dynis - in /branches/dynis/libnsgif: libnsgif.c libnsgif.h
by netsurf@semichrome.net
Author: dynis
Date: Wed Jun 25 21:46:39 2008
New Revision: 4448
URL: http://source.netsurf-browser.org?rev=4448&view=rev
Log:
Removed unnecessary dirty_frame member of gif_animation struct; made unnecessary by correct frame disposal handling
Modified:
branches/dynis/libnsgif/libnsgif.c
branches/dynis/libnsgif/libnsgif.h
Modified: branches/dynis/libnsgif/libnsgif.c
URL: http://source.netsurf-browser.org/branches/dynis/libnsgif/libnsgif.c?rev=...
==============================================================================
--- branches/dynis/libnsgif/libnsgif.c (original)
+++ branches/dynis/libnsgif/libnsgif.c Wed Jun 25 21:46:39 2008
@@ -229,7 +229,6 @@
gif->colour_table_size = (2 << (gif_data[4] & GIF_COLOUR_TABLE_SIZE_MASK));
gif->background_colour = gif_data[5];
gif->aspect_ratio = gif_data[6];
- gif->dirty_frame = GIF_INVALID_FRAME;
gif->loop_count = 1;
gif_data += 7;
@@ -726,20 +725,6 @@
if ((!clear_image) && ((int)frame == gif->decoded_frame))
return GIF_OK;
- /* If the previous frame was dirty, remove it
- */
- if (!clear_image) {
- if (frame == 0)
- gif->dirty_frame = GIF_INVALID_FRAME;
- if (gif->decoded_frame == gif->dirty_frame) {
- clear_image = true;
- if (frame != 0)
- gif_decode_frame(gif, gif->dirty_frame, bitmap_callbacks);
- clear_image = false;
- }
- gif->dirty_frame = GIF_INVALID_FRAME;
- }
-
/* Get the start of our frame data and the end of the GIF data
*/
gif_data = gif->gif_data + gif->frames[frame].frame_pointer;
@@ -822,8 +807,7 @@
colour_table = gif->local_colour_table;
if (!clear_image) {
for (index = 0; index < colour_table_size; index++) {
- char colour[] = {gif_data[0], gif_data[1],
- gif_data[2], (char)0xff};
+ char colour[] = {gif_data[0], gif_data[1], gif_data[2], (char)0xff};
colour_table[index] = *((int *) colour);
gif_data += 3;
}
Modified: branches/dynis/libnsgif/libnsgif.h
URL: http://source.netsurf-browser.org/branches/dynis/libnsgif/libnsgif.h?rev=...
==============================================================================
--- branches/dynis/libnsgif/libnsgif.h (original)
+++ branches/dynis/libnsgif/libnsgif.h Wed Jun 25 21:46:39 2008
@@ -97,7 +97,6 @@
bool global_colours; /**< whether the GIF has a global colour table */
unsigned int *global_colour_table; /**< global colour table */
unsigned int *local_colour_table; /**< local colour table */
- int dirty_frame; /**< the current dirty frame, or -1 for none */
void *frame_image; /**< currently decoded image; stored as bitmap from bitmap_create callback */
gif_result current_error; /**< current error type, or 0 for none*/
} gif_animation;
14 years, 11 months
r4447 takkaria - in /trunk/hubbub/src/treebuilder: Makefile in_select_in_table.c modes.h
by netsurf@semichrome.net
Author: takkaria
Date: Wed Jun 25 09:55:20 2008
New Revision: 4447
URL: http://source.netsurf-browser.org?rev=4447&view=rev
Log:
Implement the "in select in table" insertion mode.
Added:
trunk/hubbub/src/treebuilder/in_select_in_table.c (with props)
Modified:
trunk/hubbub/src/treebuilder/Makefile
trunk/hubbub/src/treebuilder/modes.h
Modified: trunk/hubbub/src/treebuilder/Makefile
URL: http://source.netsurf-browser.org/trunk/hubbub/src/treebuilder/Makefile?r...
==============================================================================
--- trunk/hubbub/src/treebuilder/Makefile (original)
+++ trunk/hubbub/src/treebuilder/Makefile Wed Jun 25 09:55:20 2008
@@ -36,7 +36,7 @@
initial.c before_html.c before_head.c in_head.c \
in_head_noscript.c after_head.c in_body.c \
in_caption.c in_column_group.c in_table_body.c in_row.c \
- in_cell.c in_select.c \
+ in_cell.c in_select.c in_select_in_table.c \
generic_rcdata.c script_collect.c
# Append to sources for component
Added: trunk/hubbub/src/treebuilder/in_select_in_table.c
URL: http://source.netsurf-browser.org/trunk/hubbub/src/treebuilder/in_select_...
==============================================================================
--- trunk/hubbub/src/treebuilder/in_select_in_table.c (added)
+++ trunk/hubbub/src/treebuilder/in_select_in_table.c Wed Jun 25 09:55:20 2008
@@ -1,0 +1,60 @@
+/*
+ * This file is part of Hubbub.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2008 Andrew Sidwell
+ */
+
+#include <assert.h>
+#include <string.h>
+
+#include "treebuilder/modes.h"
+#include "treebuilder/internal.h"
+#include "treebuilder/treebuilder.h"
+#include "utils/utils.h"
+
+
+/**
+ * Handle token in "in select in table" insertion mode
+ *
+ * \param treebuilder The treebuilder instance
+ * \param token The token to handle
+ * \return True to reprocess token, false otherwise
+ */
+bool handle_in_select_in_table(hubbub_treebuilder *treebuilder,
+ const hubbub_token *token)
+{
+ bool handled = false;
+ bool reprocess = false;
+
+ if (token->type == HUBBUB_TOKEN_END_TAG ||
+ token->type == HUBBUB_TOKEN_START_TAG) {
+ element_type type = element_type_from_name(treebuilder,
+ &token->data.tag.name);
+
+ if (type == CAPTION || type == TABLE || type == TBODY ||
+ type == TFOOT || type == THEAD || type == TR ||
+ type == TD || type == TH) {
+ /** \todo parse error */
+
+ handled = true;
+
+ if ((token->type == HUBBUB_TOKEN_END_TAG &&
+ element_in_scope(treebuilder, type,
+ true)) ||
+ token->type == HUBBUB_TOKEN_START_TAG) {
+ /** \todo fragment case */
+
+ element_stack_pop_until(treebuilder, SELECT);
+ reset_insertion_mode(treebuilder);
+ reprocess = true;
+ }
+ }
+ }
+
+ if (!handled) {
+ reprocess = process_in_select(treebuilder, token);
+ }
+
+ return reprocess;
+}
Propchange: trunk/hubbub/src/treebuilder/in_select_in_table.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/hubbub/src/treebuilder/modes.h
URL: http://source.netsurf-browser.org/trunk/hubbub/src/treebuilder/modes.h?re...
==============================================================================
--- trunk/hubbub/src/treebuilder/modes.h (original)
+++ trunk/hubbub/src/treebuilder/modes.h Wed Jun 25 09:55:20 2008
@@ -65,6 +65,8 @@
const hubbub_token *token);
bool handle_in_select(hubbub_treebuilder *treebuilder,
const hubbub_token *token);
+bool handle_in_select_in_table(hubbub_treebuilder *treebuilder,
+ const hubbub_token *token);
bool handle_generic_rcdata(hubbub_treebuilder *treebuilder,
const hubbub_token *token);
bool handle_script_collect_characters(hubbub_treebuilder *treebuilder,
@@ -74,6 +76,8 @@
const hubbub_token *token);
bool process_in_table(hubbub_treebuilder *treebuilder,
const hubbub_token *token);
+bool process_in_select(hubbub_treebuilder *treebuilder,
+ const hubbub_token *token);
bool process_tag_in_body(hubbub_treebuilder *treebuilder,
const hubbub_token *token);
14 years, 11 months
r4446 takkaria - in /trunk/hubbub/src/treebuilder: Makefile in_select.c internal.h modes.h treebuilder.c
by netsurf@semichrome.net
Author: takkaria
Date: Wed Jun 25 07:10:33 2008
New Revision: 4446
URL: http://source.netsurf-browser.org?rev=4446&view=rev
Log:
Implement the "in select" insertion mode, and add some more utility functions.
Added:
trunk/hubbub/src/treebuilder/in_select.c (with props)
Modified:
trunk/hubbub/src/treebuilder/Makefile
trunk/hubbub/src/treebuilder/internal.h
trunk/hubbub/src/treebuilder/modes.h
trunk/hubbub/src/treebuilder/treebuilder.c
Modified: trunk/hubbub/src/treebuilder/Makefile
URL: http://source.netsurf-browser.org/trunk/hubbub/src/treebuilder/Makefile?r...
==============================================================================
--- trunk/hubbub/src/treebuilder/Makefile (original)
+++ trunk/hubbub/src/treebuilder/Makefile Wed Jun 25 07:10:33 2008
@@ -36,7 +36,7 @@
initial.c before_html.c before_head.c in_head.c \
in_head_noscript.c after_head.c in_body.c \
in_caption.c in_column_group.c in_table_body.c in_row.c \
- in_cell.c \
+ in_cell.c in_select.c \
generic_rcdata.c script_collect.c
# Append to sources for component
Added: trunk/hubbub/src/treebuilder/in_select.c
URL: http://source.netsurf-browser.org/trunk/hubbub/src/treebuilder/in_select....
==============================================================================
--- trunk/hubbub/src/treebuilder/in_select.c (added)
+++ trunk/hubbub/src/treebuilder/in_select.c Wed Jun 25 07:10:33 2008
@@ -1,0 +1,142 @@
+/*
+ * This file is part of Hubbub.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2008 Andrew Sidwell
+ */
+
+#include <assert.h>
+#include <string.h>
+
+#include "treebuilder/modes.h"
+#include "treebuilder/internal.h"
+#include "treebuilder/treebuilder.h"
+#include "utils/utils.h"
+
+
+/**
+ * Handle token in "in head" insertion mode
+ *
+ * \param treebuilder The treebuilder instance
+ * \param token The token to handle
+ * \return True to reprocess token, false otherwise
+ */
+bool handle_in_select(hubbub_treebuilder *treebuilder,
+ const hubbub_token *token)
+{
+ bool reprocess = false;
+
+ element_type otype;
+ void *node;
+
+ switch (token->type) {
+ case HUBBUB_TOKEN_CHARACTER:
+ append_text(treebuilder, &token->data.character);
+ break;
+ case HUBBUB_TOKEN_COMMENT:
+ process_comment_append(treebuilder, token,
+ treebuilder->context.element_stack[
+ treebuilder->context.current_node].node);
+ break;
+ case HUBBUB_TOKEN_DOCTYPE:
+ /** \todo parse error */
+ break;
+ case HUBBUB_TOKEN_START_TAG:
+ {
+ element_type type = element_type_from_name(treebuilder,
+ &token->data.tag.name);
+
+ if (type == HTML) {
+ /* Process as if "in body" */
+ process_tag_in_body(treebuilder, token);
+ } else if (type == OPTION) {
+ if (current_node(treebuilder) == OPTION) {
+ if (!element_stack_pop(treebuilder, &otype,
+ &node)) {
+ /** \todo errors */
+ }
+ }
+
+ insert_element(treebuilder, &token->data.tag);
+ } else if (type == OPTGROUP) {
+ if (current_node(treebuilder) == OPTION) {
+ if (!element_stack_pop(treebuilder, &otype,
+ &node)) {
+ /** \todo errors */
+ }
+ }
+
+ if (current_node(treebuilder) == OPTGROUP) {
+ if (!element_stack_pop(treebuilder, &otype,
+ &node)) {
+ /** \todo errors */
+ }
+ }
+
+ insert_element(treebuilder, &token->data.tag);
+ } else if (type == SELECT || type == INPUT ||
+ type == TEXTAREA) {
+
+ if (element_in_scope(treebuilder, SELECT, true)) {
+ element_stack_pop_until(treebuilder, SELECT);
+ reset_insertion_mode(treebuilder);
+ } else {
+ /* fragment case */
+ /** \todo parse error */
+ }
+
+ if (type != SELECT) reprocess = true;
+ } else {
+ /** \todo parse error */
+ }
+ }
+ break;
+ case HUBBUB_TOKEN_END_TAG:
+ {
+ element_type type = element_type_from_name(treebuilder,
+ &token->data.tag.name);
+
+ if (type == OPTGROUP) {
+ if (current_node(treebuilder) == OPTION &&
+ prev_node(treebuilder) == OPTGROUP) {
+ if (!element_stack_pop(treebuilder, &otype,
+ &node)) {
+ /** \todo errors */
+ }
+ }
+
+ if (current_node(treebuilder) == OPTGROUP) {
+ if (!element_stack_pop(treebuilder, &otype,
+ &node)) {
+ /** \todo errors */
+ }
+ } else {
+ /** \todo parse error */
+ }
+ } else if (type == OPTION) {
+ if (current_node(treebuilder) == OPTION) {
+ if (!element_stack_pop(treebuilder, &otype,
+ &node)) {
+ /** \todo errors */
+ }
+ } else {
+ /** \todo parse error */
+ }
+ } else if (type == SELECT) {
+ if (element_in_scope(treebuilder, SELECT, true)) {
+ element_stack_pop_until(treebuilder, SELECT);
+ reset_insertion_mode(treebuilder);
+ } else {
+ /* fragment case */
+ /** \todo parse error */
+ }
+ }
+ }
+ break;
+ case HUBBUB_TOKEN_EOF:
+ break;
+ }
+
+ return reprocess;
+}
+
Propchange: trunk/hubbub/src/treebuilder/in_select.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/hubbub/src/treebuilder/internal.h
URL: http://source.netsurf-browser.org/trunk/hubbub/src/treebuilder/internal.h...
==============================================================================
--- trunk/hubbub/src/treebuilder/internal.h (original)
+++ trunk/hubbub/src/treebuilder/internal.h Wed Jun 25 07:10:33 2008
@@ -141,7 +141,10 @@
element_type type, void *node);
bool element_stack_pop(hubbub_treebuilder *treebuilder,
element_type *type, void **node);
+bool element_stack_pop_until(hubbub_treebuilder *treebuilder,
+ element_type type);
element_type current_node(hubbub_treebuilder *treebuilder);
+element_type prev_node(hubbub_treebuilder *treebuilder);
bool formatting_list_append(hubbub_treebuilder *treebuilder,
element_type type, void *node, uint32_t stack_index);
Modified: trunk/hubbub/src/treebuilder/modes.h
URL: http://source.netsurf-browser.org/trunk/hubbub/src/treebuilder/modes.h?re...
==============================================================================
--- trunk/hubbub/src/treebuilder/modes.h (original)
+++ trunk/hubbub/src/treebuilder/modes.h Wed Jun 25 07:10:33 2008
@@ -63,6 +63,8 @@
const hubbub_token *token);
bool handle_in_cell(hubbub_treebuilder *treebuilder,
const hubbub_token *token);
+bool handle_in_select(hubbub_treebuilder *treebuilder,
+ const hubbub_token *token);
bool handle_generic_rcdata(hubbub_treebuilder *treebuilder,
const hubbub_token *token);
bool handle_script_collect_characters(hubbub_treebuilder *treebuilder,
Modified: trunk/hubbub/src/treebuilder/treebuilder.c
URL: http://source.netsurf-browser.org/trunk/hubbub/src/treebuilder/treebuilde...
==============================================================================
--- trunk/hubbub/src/treebuilder/treebuilder.c (original)
+++ trunk/hubbub/src/treebuilder/treebuilder.c Wed Jun 25 07:10:33 2008
@@ -1101,6 +1101,27 @@
}
/**
+ * Pop elements until an element of type "element" has been popped.
+ *
+ * \return True on success, false on memory exhaustion.
+ */
+bool element_stack_pop_until(hubbub_treebuilder *treebuilder,
+ element_type type)
+{
+ element_type otype = UNKNOWN;
+ void *node;
+
+ while (otype != type) {
+ if (!element_stack_pop(treebuilder, &otype, &node)) {
+ /** \todo error -- never happens */
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/**
* Peek at the top element of the element stack.
*
* \param treebuilder Treebuilder instance
@@ -1110,6 +1131,21 @@
{
return treebuilder->context.element_stack
[treebuilder->context.current_node].type;
+}
+
+/**
+ * Peek at the element below the top of the element stack.
+ *
+ * \param treebuilder Treebuilder instance
+ * \return Element type of the element one below the top of the stack
+ */
+element_type prev_node(hubbub_treebuilder *treebuilder)
+{
+ if (treebuilder->context.current_node == 0)
+ return UNKNOWN;
+
+ return treebuilder->context.element_stack
+ [treebuilder->context.current_node - 1].type;
}
14 years, 11 months
r4445 takkaria - in /trunk/hubbub/src/treebuilder: internal.h treebuilder.c
by netsurf@semichrome.net
Author: takkaria
Date: Wed Jun 25 06:41:33 2008
New Revision: 4445
URL: http://source.netsurf-browser.org?rev=4445&view=rev
Log:
Add a utility current_node() function which returns the current node.
Modified:
trunk/hubbub/src/treebuilder/internal.h
trunk/hubbub/src/treebuilder/treebuilder.c
Modified: trunk/hubbub/src/treebuilder/internal.h
URL: http://source.netsurf-browser.org/trunk/hubbub/src/treebuilder/internal.h...
==============================================================================
--- trunk/hubbub/src/treebuilder/internal.h (original)
+++ trunk/hubbub/src/treebuilder/internal.h Wed Jun 25 06:41:33 2008
@@ -141,6 +141,7 @@
element_type type, void *node);
bool element_stack_pop(hubbub_treebuilder *treebuilder,
element_type *type, void **node);
+element_type current_node(hubbub_treebuilder *treebuilder);
bool formatting_list_append(hubbub_treebuilder *treebuilder,
element_type type, void *node, uint32_t stack_index);
Modified: trunk/hubbub/src/treebuilder/treebuilder.c
URL: http://source.netsurf-browser.org/trunk/hubbub/src/treebuilder/treebuilde...
==============================================================================
--- trunk/hubbub/src/treebuilder/treebuilder.c (original)
+++ trunk/hubbub/src/treebuilder/treebuilder.c Wed Jun 25 06:41:33 2008
@@ -1101,6 +1101,20 @@
}
/**
+ * Peek at the top element of the element stack.
+ *
+ * \param treebuilder Treebuilder instance
+ * \return Element type on the top of the stack
+ */
+element_type current_node(hubbub_treebuilder *treebuilder)
+{
+ return treebuilder->context.element_stack
+ [treebuilder->context.current_node].type;
+}
+
+
+
+/**
* Append an element to the end of the list of active formatting elements
*
* \param treebuilder Treebuilder instance containing list
14 years, 11 months
r4444 takkaria - in /trunk/hubbub/src/treebuilder: Makefile in_cell.c modes.h
by netsurf@semichrome.net
Author: takkaria
Date: Wed Jun 25 05:52:12 2008
New Revision: 4444
URL: http://source.netsurf-browser.org?rev=4444&view=rev
Log:
Implement the "in cell" insertion mode.
Added:
trunk/hubbub/src/treebuilder/in_cell.c (with props)
Modified:
trunk/hubbub/src/treebuilder/Makefile
trunk/hubbub/src/treebuilder/modes.h
Modified: trunk/hubbub/src/treebuilder/Makefile
URL: http://source.netsurf-browser.org/trunk/hubbub/src/treebuilder/Makefile?r...
==============================================================================
--- trunk/hubbub/src/treebuilder/Makefile (original)
+++ trunk/hubbub/src/treebuilder/Makefile Wed Jun 25 05:52:12 2008
@@ -36,6 +36,7 @@
initial.c before_html.c before_head.c in_head.c \
in_head_noscript.c after_head.c in_body.c \
in_caption.c in_column_group.c in_table_body.c in_row.c \
+ in_cell.c \
generic_rcdata.c script_collect.c
# Append to sources for component
Added: trunk/hubbub/src/treebuilder/in_cell.c
URL: http://source.netsurf-browser.org/trunk/hubbub/src/treebuilder/in_cell.c?...
==============================================================================
--- trunk/hubbub/src/treebuilder/in_cell.c (added)
+++ trunk/hubbub/src/treebuilder/in_cell.c Wed Jun 25 05:52:12 2008
@@ -1,0 +1,136 @@
+/*
+ * This file is part of Hubbub.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2008 Andrew Sidwell
+ */
+
+#include <assert.h>
+#include <string.h>
+
+#include "treebuilder/modes.h"
+#include "treebuilder/internal.h"
+#include "treebuilder/treebuilder.h"
+#include "utils/utils.h"
+
+
+/**
+ * Clear the stack back to a table body context.
+ *
+ * \param treebuilder The treebuilder instance
+ */
+static inline void close_cell(hubbub_treebuilder *treebuilder)
+{
+ void *node;
+ element_type type;
+ element_type otype = UNKNOWN;
+
+ if (element_in_scope(treebuilder, TD, true)) {
+ type = TD;
+ } else {
+ type = TH;
+ }
+
+ /* Act as if an end tag token of type `type` has been seen */
+
+ close_implied_end_tags(treebuilder, UNKNOWN);
+ /** \todo parse error */
+
+ while (otype != type) {
+ if (!element_stack_pop(treebuilder, &otype, &node)) {
+ /** \todo errors */
+ }
+ }
+
+ clear_active_formatting_list_to_marker(treebuilder);
+ treebuilder->context.mode = IN_ROW;
+
+ return;
+}
+
+
+/**
+ * Handle tokens in "in cell" insertion mode
+ *
+ * Up to date with the spec as of 25 June 2008
+ *
+ * \param treebuilder The treebuilder instance
+ * \param token The token to process
+ * \return True to reprocess the token, false otherwise
+ */
+bool handle_in_cell(hubbub_treebuilder *treebuilder, const hubbub_token *token)
+{
+ bool reprocess = false;
+
+ switch (token->type) {
+ case HUBBUB_TOKEN_START_TAG:
+ {
+ element_type type = element_type_from_name(treebuilder,
+ &token->data.tag.name);
+
+ if (type == CAPTION || type == COL ||
+ type == COLGROUP || type == TBODY ||
+ type == TFOOT || type == TH || type == THEAD ||
+ type == TR) {
+ /** \todo fragment case */
+ close_cell(treebuilder);
+ reprocess = true;
+ } else {
+ reprocess = process_in_table(treebuilder, token);
+ }
+ }
+ break;
+ case HUBBUB_TOKEN_END_TAG:
+ {
+ element_type type = element_type_from_name(treebuilder,
+ &token->data.tag.name);
+
+ if (type == TH || TD) {
+ if (element_in_scope(treebuilder, type, true)) {
+ element_type otype = UNKNOWN;
+ void *node;
+
+ close_implied_end_tags(treebuilder, UNKNOWN);
+ /** \todo parse error */
+
+ while (otype != type) {
+ if (!element_stack_pop(treebuilder,
+ &otype, &node)) {
+ /** \todo errors */
+ }
+ }
+
+ clear_active_formatting_list_to_marker(
+ treebuilder);
+
+ treebuilder->context.mode = IN_ROW;
+ } else {
+ /** \todo parse error */
+ }
+ } else if (type == BODY || type == CAPTION || type == COL ||
+ type == COLGROUP || type == HTML) {
+ /** \todo parse error */
+ } else if (type == TABLE || type == TBODY || type == TFOOT ||
+ type == THEAD || type == TR) {
+ if (element_in_scope(treebuilder, type, true)) {
+ close_cell(treebuilder);
+ reprocess = true;
+ } else {
+ /** \todo parse error */
+ }
+ } else {
+ reprocess = process_in_table(treebuilder, token);
+ }
+ }
+ break;
+ case HUBBUB_TOKEN_CHARACTER:
+ case HUBBUB_TOKEN_COMMENT:
+ case HUBBUB_TOKEN_DOCTYPE:
+ case HUBBUB_TOKEN_EOF:
+ reprocess = process_in_table(treebuilder, token);
+ break;
+ }
+
+ return reprocess;
+}
+
Propchange: trunk/hubbub/src/treebuilder/in_cell.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/hubbub/src/treebuilder/modes.h
URL: http://source.netsurf-browser.org/trunk/hubbub/src/treebuilder/modes.h?re...
==============================================================================
--- trunk/hubbub/src/treebuilder/modes.h (original)
+++ trunk/hubbub/src/treebuilder/modes.h Wed Jun 25 05:52:12 2008
@@ -61,6 +61,8 @@
const hubbub_token *token);
bool handle_in_row(hubbub_treebuilder *treebuilder,
const hubbub_token *token);
+bool handle_in_cell(hubbub_treebuilder *treebuilder,
+ const hubbub_token *token);
bool handle_generic_rcdata(hubbub_treebuilder *treebuilder,
const hubbub_token *token);
bool handle_script_collect_characters(hubbub_treebuilder *treebuilder,
14 years, 11 months
r4443 takkaria - in /trunk/hubbub/src/treebuilder: Makefile in_row.c modes.h
by netsurf@semichrome.net
Author: takkaria
Date: Wed Jun 25 04:16:53 2008
New Revision: 4443
URL: http://source.netsurf-browser.org?rev=4443&view=rev
Log:
Implement the "in row" insertion mode.
Added:
trunk/hubbub/src/treebuilder/in_row.c (with props)
Modified:
trunk/hubbub/src/treebuilder/Makefile
trunk/hubbub/src/treebuilder/modes.h
Modified: trunk/hubbub/src/treebuilder/Makefile
URL: http://source.netsurf-browser.org/trunk/hubbub/src/treebuilder/Makefile?r...
==============================================================================
--- trunk/hubbub/src/treebuilder/Makefile (original)
+++ trunk/hubbub/src/treebuilder/Makefile Wed Jun 25 04:16:53 2008
@@ -35,7 +35,7 @@
SRCS_$(d) := treebuilder.c \
initial.c before_html.c before_head.c in_head.c \
in_head_noscript.c after_head.c in_body.c \
- in_caption.c in_column_group.c in_table_body.c \
+ in_caption.c in_column_group.c in_table_body.c in_row.c \
generic_rcdata.c script_collect.c
# Append to sources for component
Added: trunk/hubbub/src/treebuilder/in_row.c
URL: http://source.netsurf-browser.org/trunk/hubbub/src/treebuilder/in_row.c?r...
==============================================================================
--- trunk/hubbub/src/treebuilder/in_row.c (added)
+++ trunk/hubbub/src/treebuilder/in_row.c Wed Jun 25 04:16:53 2008
@@ -1,0 +1,135 @@
+/*
+ * This file is part of Hubbub.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2008 Andrew Sidwell
+ */
+
+#include <assert.h>
+#include <string.h>
+
+#include "treebuilder/modes.h"
+#include "treebuilder/internal.h"
+#include "treebuilder/treebuilder.h"
+#include "utils/utils.h"
+
+
+/**
+ * Clear the stack back to a table body context.
+ *
+ * \param treebuilder The treebuilder instance
+ */
+static void table_clear_stack(hubbub_treebuilder *treebuilder)
+{
+ element_type cur_node = treebuilder->context.element_stack[
+ treebuilder->context.current_node].type;
+
+ while (cur_node != TR && cur_node != HTML) {
+ element_type type;
+ void *node;
+
+ if (!element_stack_pop(treebuilder, &type, &node)) {
+ /** \todo errors */
+ }
+
+ cur_node = treebuilder->context.element_stack[
+ treebuilder->context.current_node].type;
+ }
+
+ return;
+}
+
+
+/**
+ * Handle </tr> and anything that acts "as if" </tr> was emitted.
+ *
+ * \param treebuilder The treebuilder instance
+ * \return True to reprocess the token, false otherwise
+ */
+static inline bool act_as_if_end_tag_tr(hubbub_treebuilder *treebuilder)
+{
+ element_type otype;
+ void *node;
+
+ /** \todo fragment case */
+
+ table_clear_stack(treebuilder);
+ if (!element_stack_pop(treebuilder, &otype, &node)) {
+ /** \todo errors */
+ }
+
+ treebuilder->context.mode = IN_TABLE_BODY;
+
+ return true;
+}
+
+
+/**
+ * Handle tokens in "in row" insertion mode
+ *
+ * Up to date with the spec as of 25 June 2008
+ *
+ * \param treebuilder The treebuilder instance
+ * \param token The token to process
+ * \return True to reprocess the token, false otherwise
+ */
+bool handle_in_row(hubbub_treebuilder *treebuilder,
+ const hubbub_token *token)
+{
+ bool reprocess = false;
+
+ switch (token->type) {
+ case HUBBUB_TOKEN_START_TAG:
+ {
+ element_type type = element_type_from_name(treebuilder,
+ &token->data.tag.name);
+
+ if (type == TH || TD) {
+ table_clear_stack(treebuilder);
+
+ insert_element(treebuilder, &token->data.tag);
+ treebuilder->context.mode = IN_CELL;
+
+ formatting_list_append(treebuilder, type,
+ treebuilder->context.element_stack[
+ treebuilder->context.current_node].node,
+ treebuilder->context.current_node);
+ } else if (type == CAPTION || type == COL ||
+ type == COLGROUP || type == TBODY ||
+ type == TFOOT || type == THEAD || type == TR) {
+ reprocess = act_as_if_end_tag_tr(treebuilder);
+ } else {
+ reprocess = process_in_table(treebuilder, token);
+ }
+ }
+ break;
+ case HUBBUB_TOKEN_END_TAG:
+ {
+ element_type type = element_type_from_name(treebuilder,
+ &token->data.tag.name);
+
+ if (type == TR) {
+ (void)act_as_if_end_tag_tr(treebuilder);
+ } else if (type == TABLE) {
+ reprocess = act_as_if_end_tag_tr(treebuilder);
+ } else if (type == BODY || type == CAPTION || type == COL ||
+ type == COLGROUP || type == HTML ||
+ type == TD || type == TH) {
+ /** \todo parse error */
+ /* Ignore the token */
+ } else {
+ reprocess = process_in_table(treebuilder, token);
+ }
+ }
+ break;
+ case HUBBUB_TOKEN_CHARACTER:
+ case HUBBUB_TOKEN_COMMENT:
+ case HUBBUB_TOKEN_DOCTYPE:
+ case HUBBUB_TOKEN_EOF:
+ reprocess = process_in_table(treebuilder, token);
+ break;
+ }
+
+ return reprocess;
+}
+
Propchange: trunk/hubbub/src/treebuilder/in_row.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/hubbub/src/treebuilder/modes.h
URL: http://source.netsurf-browser.org/trunk/hubbub/src/treebuilder/modes.h?re...
==============================================================================
--- trunk/hubbub/src/treebuilder/modes.h (original)
+++ trunk/hubbub/src/treebuilder/modes.h Wed Jun 25 04:16:53 2008
@@ -59,6 +59,8 @@
const hubbub_token *token);
bool handle_in_column_group(hubbub_treebuilder *treebuilder,
const hubbub_token *token);
+bool handle_in_row(hubbub_treebuilder *treebuilder,
+ const hubbub_token *token);
bool handle_generic_rcdata(hubbub_treebuilder *treebuilder,
const hubbub_token *token);
bool handle_script_collect_characters(hubbub_treebuilder *treebuilder,
14 years, 11 months