summaryrefslogtreecommitdiff
path: root/src/treebuilder
diff options
context:
space:
mode:
Diffstat (limited to 'src/treebuilder')
-rw-r--r--src/treebuilder/after_after_frameset.c17
-rw-r--r--src/treebuilder/in_body.c10
-rw-r--r--src/treebuilder/treebuilder.c34
3 files changed, 45 insertions, 16 deletions
diff --git a/src/treebuilder/after_after_frameset.c b/src/treebuilder/after_after_frameset.c
index f068714..e9d1176 100644
--- a/src/treebuilder/after_after_frameset.c
+++ b/src/treebuilder/after_after_frameset.c
@@ -25,23 +25,28 @@ hubbub_error handle_after_after_frameset(hubbub_treebuilder *treebuilder,
const hubbub_token *token)
{
hubbub_error err = HUBBUB_OK;
-
switch (token->type) {
case HUBBUB_TOKEN_CHARACTER:
- err = process_characters_expect_whitespace(treebuilder,
- token, true);
- if (err == HUBBUB_REPROCESS)
- treebuilder->context.mode = IN_FRAMESET;
+ {
+ const uint8_t *data = token->data.character.ptr;
+ uint8_t c = data[0];
+ if (c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == '\f') {
+ err = handle_in_body(treebuilder, token);
+ }
+
+ }
break;
case HUBBUB_TOKEN_COMMENT:
err = process_comment_append(treebuilder, token,
treebuilder->context.document);
break;
case HUBBUB_TOKEN_END_TAG:
- case HUBBUB_TOKEN_DOCTYPE:
/** \todo parse error */
/* ignore token */
break;
+ case HUBBUB_TOKEN_DOCTYPE:
+ err = handle_in_body(treebuilder, token);
+ break;
case HUBBUB_TOKEN_START_TAG:
{
element_type type = element_type_from_name(treebuilder,
diff --git a/src/treebuilder/in_body.c b/src/treebuilder/in_body.c
index f5fdc89..d684702 100644
--- a/src/treebuilder/in_body.c
+++ b/src/treebuilder/in_body.c
@@ -785,8 +785,7 @@ hubbub_error process_dd_dt_li_in_body(hubbub_treebuilder *treebuilder,
(ntype == DD || ntype == DT)))
break;
- if (!is_formatting_element(ntype) &&
- !is_phrasing_element(ntype) &&
+ if (is_special_element(ntype) &&
ntype != ADDRESS &&
ntype != DIV &&
ntype != P)
@@ -794,10 +793,11 @@ hubbub_error process_dd_dt_li_in_body(hubbub_treebuilder *treebuilder,
}
/* If we found one, then pop all nodes up to and including it */
- if (stack[node].type == LI || stack[node].type == DD ||
- stack[node].type == DT) {
+ if((stack[node].type == LI && type == LI) ||
+ ((stack[node].type == DT || stack[node].type == DD) &&
+ (type == DD || type == DT))) {
- close_implied_end_tags(treebuilder, type);
+ close_implied_end_tags(treebuilder, stack[node].type);
/* Check that we're only popping one node
* and emit a parse error if not */
if (treebuilder->context.current_node > node) {
diff --git a/src/treebuilder/treebuilder.c b/src/treebuilder/treebuilder.c
index a965c5a..568a589 100644
--- a/src/treebuilder/treebuilder.c
+++ b/src/treebuilder/treebuilder.c
@@ -966,8 +966,21 @@ void reset_insertion_mode(hubbub_treebuilder *treebuilder)
switch (stack[node].type) {
case SELECT:
+ {
/* fragment case */
- break;
+ uint32_t ancestor;
+ for(ancestor = node - 1; ancestor > 0; ancestor --) {
+ if(stack[node].type == TEMPLATE) {
+ break;
+ }
+ if(stack[node].type == TABLE) {
+ treebuilder->context.mode = IN_CELL;
+ return;
+ }
+ }
+ treebuilder->context.mode = IN_SELECT;
+ return;
+ }
case TD:
case TH:
treebuilder->context.mode = IN_CELL;
@@ -985,26 +998,37 @@ void reset_insertion_mode(hubbub_treebuilder *treebuilder)
return;
case COLGROUP:
/* fragment case */
- break;
+ treebuilder->context.mode = IN_COLUMN_GROUP;
+ return;
case TABLE:
treebuilder->context.mode = IN_TABLE;
return;
case HEAD:
/* fragment case */
- break;
+ treebuilder->context.mode = IN_HEAD;
+ return;
case BODY:
treebuilder->context.mode = IN_BODY;
return;
case FRAMESET:
/* fragment case */
- break;
+ treebuilder->context.mode = IN_FRAMESET;
+ return;
case HTML:
+ {
/* fragment case */
- break;
+ if(treebuilder->context.head_element == NULL) {
+ treebuilder->context.mode = BEFORE_HEAD;
+ } else {
+ treebuilder->context.mode = AFTER_HEAD;
+ }
+ }
+ return;
default:
break;
}
}
+ return;
}
/**