summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRupinder Singh Khokhar <rsk1coder99@gmail.com>2014-06-26 15:29:16 (GMT)
committer Rupinder Singh Khokhar <rsk1coder99@gmail.com>2014-08-01 16:14:23 (GMT)
commit46802b46290a965d5828bb2a3402bba2393b178f (patch)
treed80abba3a552ecb638192235f4e1a1cd36dc904c
parent7692c69e500284e9ace13b486af8d5e6f1f4a9de (diff)
downloadlibhubbub-46802b46290a965d5828bb2a3402bba2393b178f.tar.gz
libhubbub-46802b46290a965d5828bb2a3402bba2393b178f.tar.bz2
Random rumblings-- unclean commit
-rw-r--r--src/treebuilder/in_body.c78
-rw-r--r--src/treebuilder/in_foreign_content.c38
-rw-r--r--src/treebuilder/internal.h6
-rw-r--r--src/treebuilder/treebuilder.c20
-rw-r--r--src/utils/string.c1
5 files changed, 87 insertions, 56 deletions
diff --git a/src/treebuilder/in_body.c b/src/treebuilder/in_body.c
index 5157e66..e685e0e 100644
--- a/src/treebuilder/in_body.c
+++ b/src/treebuilder/in_body.c
@@ -225,7 +225,8 @@ hubbub_error process_character(hubbub_treebuilder *treebuilder,
if (treebuilder->context.frameset_ok) {
for (p = dummy.ptr; p < dummy.ptr + dummy.len; p++) {
if (*p != 0x0009 && *p != 0x000a &&
- *p != 0x000c && *p != 0x0020) {
+ *p != 0x000c && *p != 0x0020 &&
+ *p != 0x000d) {
treebuilder->context.frameset_ok = false;
break;
}
@@ -324,7 +325,7 @@ hubbub_error process_start_tag(hubbub_treebuilder *treebuilder,
} else if (type == AREA || type == BASEFONT ||
type == BGSOUND || type == BR ||
type == EMBED || type == IMG || type == INPUT ||
- type == PARAM || type == SPACER || type == WBR) {
+ type == PARAM || type == WBR) {
err = reconstruct_active_formatting_list(treebuilder);
if (err != HUBBUB_OK)
return err;
@@ -997,36 +998,6 @@ hubbub_error process_button_in_body(hubbub_treebuilder *treebuilder,
if (err != HUBBUB_OK)
return err;
- treebuilder->tree_handler->ref_node(
- treebuilder->tree_handler->ctx,
- treebuilder->context.element_stack[
- treebuilder->context.current_node].node);
-
- err = formatting_list_append(treebuilder, token->data.tag.ns, BUTTON,
- treebuilder->context.element_stack[
- treebuilder->context.current_node].node,
- treebuilder->context.current_node);
- if (err != HUBBUB_OK) {
- hubbub_ns ns;
- element_type type;
- void *node;
-
- remove_node_from_dom(treebuilder,
- treebuilder->context.element_stack[
- treebuilder->context.current_node].node);
-
- element_stack_pop(treebuilder, &ns, &type, &node);
-
- /* Unref twice (once for stack, once for formatting list) */
- treebuilder->tree_handler->unref_node(
- treebuilder->tree_handler->ctx, node);
-
- treebuilder->tree_handler->unref_node(
- treebuilder->tree_handler->ctx, node);
-
- return err;
- }
-
treebuilder->context.frameset_ok = false;
return HUBBUB_OK;
@@ -1668,11 +1639,11 @@ hubbub_error process_0presentational_in_body(hubbub_treebuilder *treebuilder,
hubbub_error err;
/* Welcome to the adoption agency */
-
- while (true) {
+ uint32_t counter = 0;
+ while (counter++ < 8) {
element_context *stack = treebuilder->context.element_stack;
- formatting_list_entry *entry;
+ formatting_list_entry *entry = NULL;
uint32_t formatting_element;
uint32_t common_ancestor;
uint32_t furthest_block;
@@ -1843,6 +1814,7 @@ hubbub_error process_0presentational_in_body(hubbub_treebuilder *treebuilder,
/* 13 */
}
+ return HUBBUB_OK;
}
/**
@@ -1861,10 +1833,13 @@ hubbub_error aa_find_and_validate_formatting_element(
formatting_list_entry *entry;
entry = aa_find_formatting_element(treebuilder, type);
+ if (entry == NULL) {
+ return process_0generic_in_body(treebuilder, type);
+ }
- if (entry == NULL || (entry->stack_index != 0 &&
+ if (entry->stack_index != 0 &&
element_in_scope(treebuilder, entry->details.type,
- false) != entry->stack_index)) {
+ false) != entry->stack_index) {
/** \todo parse error */
return HUBBUB_OK;
}
@@ -2002,7 +1977,7 @@ hubbub_error aa_reparent_node(hubbub_treebuilder *treebuilder, void *node,
}
/**
- * Adoption agency: this is step 6
+ * Adoption agency: this is step 13
*
* \param treebuilder The treebuilder instance
* \param formatting_element The stack index of the formatting element
@@ -2018,7 +1993,7 @@ hubbub_error aa_find_bookmark_location_reparenting_misnested(
{
hubbub_error err;
element_context *stack = treebuilder->context.element_stack;
- uint32_t node, last, fb;
+ uint32_t node, last, fb, counter = 0;
formatting_list_entry *node_entry;
node = last = fb = *furthest_block;
@@ -2026,6 +2001,7 @@ hubbub_error aa_find_bookmark_location_reparenting_misnested(
while (true) {
void *reparented;
+ counter += 1;
/* i */
node--;
@@ -2037,6 +2013,25 @@ hubbub_error aa_find_bookmark_location_reparenting_misnested(
break;
}
+ /* iii */
+ if (node == formatting_element)
+ break;
+
+ if(node_entry != NULL && counter > 3) {
+ hubbub_ns ons;
+ element_type otype;
+ void *onode;
+ uint32_t oindex;
+
+ err = formatting_list_remove(treebuilder, node_entry,
+ &ons, &otype, &onode, &oindex);
+ assert(err == HUBBUB_OK);
+ treebuilder->tree_handler->unref_node(
+ treebuilder->tree_handler->ctx, onode);
+ node_entry = NULL;
+
+ }
+
/* Node is not in list of active formatting elements */
if (node_entry == NULL) {
err = aa_remove_element_stack_item(treebuilder,
@@ -2055,9 +2050,6 @@ hubbub_error aa_find_bookmark_location_reparenting_misnested(
continue;
}
- /* iii */
- if (node == formatting_element)
- break;
/* iv */
if (last == fb) {
@@ -2375,7 +2367,7 @@ hubbub_error process_0generic_in_body(hubbub_treebuilder *treebuilder,
uint32_t popped = 0;
element_type otype;
- close_implied_end_tags(treebuilder, UNKNOWN);
+ close_implied_end_tags(treebuilder, type);
while (treebuilder->context.current_node >= node) {
hubbub_ns ns;
diff --git a/src/treebuilder/in_foreign_content.c b/src/treebuilder/in_foreign_content.c
index d53be1f..25169ff 100644
--- a/src/treebuilder/in_foreign_content.c
+++ b/src/treebuilder/in_foreign_content.c
@@ -40,8 +40,6 @@ static const case_changes svg_attributes[] = {
{ S("contentstyletype"), "contentStyleType" },
{ S("diffuseconstant"), "diffuseConstant" },
{ S("edgemode"), "edgeMode" },
- { S("externalresourcesrequired"), "externalResourcesRequired" },
- { S("filterres"), "filterRes" },
{ S("filterunits"), "filterUnits" },
{ S("glyphref"), "glyphRef" },
{ S("gradienttransform"), "gradientTransform" },
@@ -110,6 +108,7 @@ static const case_changes svg_tagnames[] = {
{ S("fediffuselighting"), "feDiffuseLighting" },
{ S("fedisplacementmap"), "feDisplacementMap" },
{ S("fedistantlight"), "feDistantLight" },
+ { S("fedropshadow"), "feDropShadow"},
{ S("feflood"), "feFlood" },
{ S("fefunca"), "feFuncA" },
{ S("fefuncb"), "feFuncB" },
@@ -391,9 +390,15 @@ hubbub_error handle_in_foreign_content(hubbub_treebuilder *treebuilder,
const hubbub_token *token)
{
hubbub_error err = HUBBUB_OK;
+ const uint8_t *c;
switch (token->type) {
case HUBBUB_TOKEN_CHARACTER:
+ c = (token->data.character.ptr);
+ if(*c != '\t' && *c != '\r' && *c != ' ' && *c != '\n' && *c != '\f') {
+ treebuilder->context.frameset_ok = false;
+ }
+
err = append_text(treebuilder, &token->data.character);
break;
case HUBBUB_TOKEN_COMMENT:
@@ -472,13 +477,15 @@ hubbub_error handle_in_foreign_content(hubbub_treebuilder *treebuilder,
} else {
hubbub_tag tag = token->data.tag;
- adjust_foreign_attributes(treebuilder, &tag);
-
if (cur_node_ns == HUBBUB_NS_SVG) {
adjust_svg_tagname(treebuilder, &tag);
adjust_svg_attributes(treebuilder, &tag);
+ } else if(cur_node_ns == HUBBUB_NS_MATHML) {
+ adjust_mathml_attributes(treebuilder, &tag);
}
+ adjust_foreign_attributes(treebuilder, &tag);
+
/* Set to the right namespace and insert */
tag.ns = cur_node_ns;
@@ -492,8 +499,29 @@ hubbub_error handle_in_foreign_content(hubbub_treebuilder *treebuilder,
}
break;
case HUBBUB_TOKEN_END_TAG:
+ {
+ element_type type = element_type_from_name(treebuilder,
+ &token->data.tag.name);
+ uint32_t node;
+ element_context *stack = treebuilder->context.element_stack;
+
+ for (node = treebuilder->context.current_node; node > 0; node--) {
+ if(stack[node].type == type) {
+ hubbub_ns ns;
+ element_type type;
+ void *node_iterator;
+ while(node_iterator !=stack[node].node) {
+ element_stack_pop(treebuilder, &ns, &type, &node_iterator);
+ treebuilder->tree_handler->unref_node(
+ treebuilder->tree_handler->ctx,
+ node_iterator);
+ }
+ return HUBBUB_OK;
+ }
+ }
err = process_as_in_secondary(treebuilder, token);
- break;
+ }
+ break;
case HUBBUB_TOKEN_EOF:
foreign_break_out(treebuilder);
err = HUBBUB_REPROCESS;
diff --git a/src/treebuilder/internal.h b/src/treebuilder/internal.h
index 58c21d6..1b59267 100644
--- a/src/treebuilder/internal.h
+++ b/src/treebuilder/internal.h
@@ -16,10 +16,10 @@ typedef enum
ADDRESS, AREA, ARTICLE, ASIDE, BASE, BASEFONT, BGSOUND, BLOCKQUOTE,
BODY, BR, CENTER, COL, COLGROUP, COMMAND, DATAGRID, DD, DETAILS,
DIALOG, DIR, DIV, DL, DT, EMBED, FIELDSET, FIGURE, FOOTER, FORM, FRAME,
- FRAMESET, H1, H2, H3, H4, H5, H6, HEAD, HEADER, HR, IFRAME, IMAGE, IMG,
- INPUT, ISINDEX, LI, LINK, LISTING, MENU, META, NAV, NOEMBED, NOFRAMES,
+ FRAMESET, H1, H2, H3, H4, H5, H6, HEAD, HEADER, HGROUP, HR, IFRAME, IMAGE, IMG,
+ INPUT, ISINDEX, LI, LINK, LISTING, MAIN, MENU, MENUITEM, META, NAV, NOEMBED, NOFRAMES,
NOSCRIPT, OL, OPTGROUP, OPTION, P, PARAM, PLAINTEXT, PRE, SCRIPT,
- SECTION, SELECT, SPACER, STYLE, TBODY, TEXTAREA, TFOOT, THEAD, TITLE,
+ SECTION, SELECT, SPACER, SOURCE, STYLE, SUMMARY, TBODY, TEMPLATE, TEXTAREA, TFOOT, THEAD, TITLE,
TR, UL, WBR,
/* Scoping */
APPLET, BUTTON, CAPTION, HTML, MARQUEE, OBJECT, TABLE, TD, TH,
diff --git a/src/treebuilder/treebuilder.c b/src/treebuilder/treebuilder.c
index a6a4b43..2358ff9 100644
--- a/src/treebuilder/treebuilder.c
+++ b/src/treebuilder/treebuilder.c
@@ -25,10 +25,12 @@ static const struct {
element_type type;
} name_type_map[] = {
{ S("address"), ADDRESS }, { S("area"), AREA },
+ { S("b"), B },
{ S("base"), BASE }, { S("basefont"), BASEFONT },
{ S("bgsound"), BGSOUND }, { S("blockquote"), BLOCKQUOTE },
{ S("body"), BODY }, { S("br"), BR },
{ S("center"), CENTER }, { S("col"), COL },
+ { S("code"), CODE },
{ S("colgroup"), COLGROUP }, { S("dd"), DD },
{ S("dir"), DIR }, { S("div"), DIV },
{ S("dl"), DL }, { S("dt"), DT },
@@ -519,13 +521,22 @@ uint32_t element_in_scope(hubbub_treebuilder *treebuilder,
break;
/* The list of element types given in the spec here are the
- * scoping elements excluding TABLE and HTML. TABLE is handled
+ * scoping elements excluding TABLE and HTML and BUTTON. TABLE is handled
* in the previous conditional and HTML should only occur
* as the first node in the stack, which is never processed
* in this loop. */
- if (!in_table && (is_scoping_element(node_type) ||
- (node_type == FOREIGNOBJECT &&
- node_ns == HUBBUB_NS_SVG))) {
+ if (!in_table && node_type != BUTTON &&
+ (is_scoping_element(node_type) ||
+ (node_ns == HUBBUB_NS_SVG && (
+ node_type == FOREIGNOBJECT ||
+ node_type == DESC ||
+ node_type == TITLE)) ||
+ (node_ns ==HUBBUB_NS_MATHML && (
+ node_type == MI ||
+ node_type == MO ||
+ node_type == MN ||
+ node_type == MS ||
+ node_type == MTEXT)))) {
break;
}
}
@@ -1389,7 +1400,6 @@ hubbub_error formatting_list_remove(hubbub_treebuilder *treebuilder,
*type = entry->details.type;
*node = entry->details.node;
*stack_index = entry->stack_index;
-
if (entry->prev == NULL)
treebuilder->context.formatting_list = entry->next;
else
diff --git a/src/utils/string.c b/src/utils/string.c
index ce4f6a6..0ff069d 100644
--- a/src/utils/string.c
+++ b/src/utils/string.c
@@ -56,3 +56,4 @@ bool hubbub_string_match_ci(const uint8_t *a, size_t a_len,
return true;
}
+