summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRupinder Singh Khokhar <rsk1coder99@gmail.com>2014-07-21 04:18:20 (GMT)
committer Rupinder Singh Khokhar <rsk1coder99@gmail.com>2014-08-01 16:14:34 (GMT)
commit32c36a8042713a3a25fe829f4839f06431d77295 (patch)
treea7db67146164757a40875ad07d508a7d15e8d31a
parentcf6875b854a8698e1bbc7d2783828d3c0994046b (diff)
downloadlibhubbub-32c36a8042713a3a25fe829f4839f06431d77295.tar.gz
libhubbub-32c36a8042713a3a25fe829f4839f06431d77295.tar.bz2
The foreign breakout method doesn't neccessarily break out of foreign state. Hence, it is only a candidate to do so. It will be decided during reprocessing whether to breakout or not.
-rw-r--r--src/treebuilder/in_body.c2
-rw-r--r--src/treebuilder/in_foreign_content.c33
-rw-r--r--test/data/tree-construction/INDEX4
3 files changed, 17 insertions, 22 deletions
diff --git a/src/treebuilder/in_body.c b/src/treebuilder/in_body.c
index edfc73b..5359364 100644
--- a/src/treebuilder/in_body.c
+++ b/src/treebuilder/in_body.c
@@ -1853,7 +1853,7 @@ hubbub_error process_0presentational_in_body(hubbub_treebuilder *treebuilder,
uint32_t common_ancestor;
uint32_t furthest_block;
bookmark bookmark;
- uint32_t last_node;
+ uint32_t last_node = 0;
void *reparented;
void *fe_clone = NULL;
void *clone_appended = NULL;
diff --git a/src/treebuilder/in_foreign_content.c b/src/treebuilder/in_foreign_content.c
index ddade53..681faeb 100644
--- a/src/treebuilder/in_foreign_content.c
+++ b/src/treebuilder/in_foreign_content.c
@@ -313,16 +313,6 @@ static bool element_in_scope_in_non_html_ns(hubbub_treebuilder *treebuilder)
assert((signed) treebuilder->context.current_node >= 0);
for (node = treebuilder->context.current_node; node > 0; node--) {
- element_type node_type = stack[node].type;
-
- /* The list of element types given in the spec here are the
- * scoping elements excluding TABLE and HTML. 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 (node_type == TABLE || is_scoping_element(node_type))
- break;
-
if (stack[node].ns != HUBBUB_NS_HTML)
return true;
}
@@ -363,9 +353,10 @@ static hubbub_error process_as_in_secondary(hubbub_treebuilder *treebuilder,
}
/**
- * Break out of foreign content as a result of certain start tags or EOF.
+ * Handle certain start tags. Reprocessing is a must
+ * after calling this function.
*/
-static void foreign_break_out(hubbub_treebuilder *treebuilder)
+static void candidate_foreign_breakout(hubbub_treebuilder *treebuilder)
{
element_context *stack = treebuilder->context.element_stack;
hubbub_ns ns;
@@ -375,6 +366,11 @@ static void foreign_break_out(hubbub_treebuilder *treebuilder)
/** \todo parse error */
/** todo fragment case */
+ element_stack_pop(treebuilder, &ns, &type, &node);
+ treebuilder->tree_handler->unref_node(
+ treebuilder->tree_handler->ctx,
+ node);
+
ns = stack[treebuilder->context.current_node].ns;
type = current_node(treebuilder);
size_t n_attrs = stack[
@@ -400,7 +396,6 @@ static void foreign_break_out(hubbub_treebuilder *treebuilder)
attrs = stack[treebuilder->context.current_node].
attributes;
}
- treebuilder->context.mode = treebuilder->context.second_mode;
}
@@ -490,7 +485,7 @@ hubbub_error handle_in_foreign_content(hubbub_treebuilder *treebuilder,
type == SUB || type == SUP || type == TABLE ||
type == TT || type == U || type == UL ||
type == VAR) {
- foreign_break_out(treebuilder);
+ candidate_foreign_breakout(treebuilder);
err = HUBBUB_REPROCESS;
handled = true;
} else if (type == FONT) {
@@ -518,7 +513,7 @@ hubbub_error handle_in_foreign_content(hubbub_treebuilder *treebuilder,
}
if (found) {
- foreign_break_out(treebuilder);
+ candidate_foreign_breakout(treebuilder);
err = HUBBUB_REPROCESS;
handled = true;
}
@@ -554,7 +549,7 @@ hubbub_error handle_in_foreign_content(hubbub_treebuilder *treebuilder,
uint32_t node;
element_context *stack = treebuilder->context.element_stack;
- for (node = treebuilder->context.current_node; node > 1; node--) {
+ for (node = treebuilder->context.current_node; node > 0;) {
if(stack[node].type == type) {
hubbub_ns ns;
element_type type;
@@ -568,17 +563,17 @@ hubbub_error handle_in_foreign_content(hubbub_treebuilder *treebuilder,
} while(node_iterator != vnode);
return HUBBUB_OK;
}
- if(stack[node].ns == HUBBUB_NS_HTML) {
+ if(stack[--node].ns == HUBBUB_NS_HTML) {
break;
}
}
- if(node > 1) {
+ if(node > 0) {
err = process_as_in_secondary(treebuilder, token);
}
}
break;
case HUBBUB_TOKEN_EOF:
- foreign_break_out(treebuilder);
+ candidate_foreign_breakout(treebuilder);
err = HUBBUB_REPROCESS;
break;
}
diff --git a/test/data/tree-construction/INDEX b/test/data/tree-construction/INDEX
index f8cb288..3ae35b4 100644
--- a/test/data/tree-construction/INDEX
+++ b/test/data/tree-construction/INDEX
@@ -1,4 +1,4 @@
-# Index file for tokeniser tests
+# Index file for treebuilder tests
#
# Test Description
@@ -27,7 +27,7 @@ scriptdata01.dat html5lib script related treebuilder tests
#scripted/webkit01.dat NA
tables01.dat html5lib treebuilder tests
#template.dat NA
-#tests10.dat NA
+tests10.dat html5lib treebuilder tests
tests11.dat html5lib treebuilder tests
tests12.dat html5lib treebuilder tests
tests14.dat html5lib treebuilder tests