summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRupinder Singh Khokhar <rsk1coder99@gmail.com>2014-07-06 06:53:52 (GMT)
committer Rupinder Singh Khokhar <rsk1coder99@gmail.com>2014-08-01 16:14:31 (GMT)
commit5071b7de0bcef67bc9b996cbae3d3d187abe11b5 (patch)
tree6b72053307a9352f7b2529879995c6a6b1447164
parent822eeb3eb98a0346023222eab539138e61fd74eb (diff)
downloadlibhubbub-5071b7de0bcef67bc9b996cbae3d3d187abe11b5.tar.gz
libhubbub-5071b7de0bcef67bc9b996cbae3d3d187abe11b5.tar.bz2
Fixed enumerator entries & name-type mapping. Also fixed the option/optgroup tag starting handler. Also emitted on encountering a '<' in script related state. Also fixed the check for special element.
-rw-r--r--src/tokeniser/tokeniser.c2
-rw-r--r--src/treebuilder/in_body.c22
-rw-r--r--src/treebuilder/internal.h14
-rw-r--r--src/treebuilder/treebuilder.c38
4 files changed, 50 insertions, 26 deletions
diff --git a/src/tokeniser/tokeniser.c b/src/tokeniser/tokeniser.c
index 158d09a..1d16ba4 100644
--- a/src/tokeniser/tokeniser.c
+++ b/src/tokeniser/tokeniser.c
@@ -1339,6 +1339,8 @@ hubbub_error hubbub_tokeniser_handle_script_data_escaped_dash(hubbub_tokeniser *
tokeniser->context.pending += len;
} else if(c == '<') {
+ /*emit any pending characters*/
+ emit_current_chars(tokeniser);
if(tokeniser->state == STATE_SCRIPT_DATA_ESCAPED_DASH ||
tokeniser->state == STATE_SCRIPT_DATA_ESCAPED_DASH_DASH) {
tokeniser->state = STATE_SCRIPT_DATA_ESCAPED_LESS_THAN;
diff --git a/src/treebuilder/in_body.c b/src/treebuilder/in_body.c
index 69ec3d6..bdf2c0b 100644
--- a/src/treebuilder/in_body.c
+++ b/src/treebuilder/in_body.c
@@ -1361,12 +1361,21 @@ hubbub_error process_select_in_body(hubbub_treebuilder *treebuilder,
hubbub_error process_opt_in_body(hubbub_treebuilder *treebuilder,
const hubbub_token *token)
{
- hubbub_error err;
+ hubbub_error err;
- if (element_in_scope(treebuilder, OPTION, NONE)) {
- err = process_0generic_in_body(treebuilder, OPTION);
- /* Cannot fail */
- assert(err == HUBBUB_OK);
+ element_context *stack = treebuilder->context.element_stack;
+ uint32_t node = treebuilder->context.current_node;
+ element_type ntype = stack[node].type;
+
+ if(ntype == OPTION) {
+ hubbub_ns ns;
+ void *node;
+ element_type otype;
+ element_stack_pop(treebuilder, &ns, &otype, &node);
+
+ treebuilder->tree_handler->unref_node(
+ treebuilder->tree_handler->ctx,
+ node);
}
err = reconstruct_active_formatting_list(treebuilder);
@@ -2452,8 +2461,7 @@ hubbub_error process_0generic_in_body(hubbub_treebuilder *treebuilder,
}
break;
- } else if (!is_formatting_element(stack[node].type) &&
- !is_phrasing_element(stack[node].type)) {
+ } else if (is_special_element(stack[node].type)) {
/** \todo parse error */
break;
}
diff --git a/src/treebuilder/internal.h b/src/treebuilder/internal.h
index ccec4ed..2cd5e4a 100644
--- a/src/treebuilder/internal.h
+++ b/src/treebuilder/internal.h
@@ -14,20 +14,20 @@ typedef enum
{
/* Special */
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, HGROUP, HR, IFRAME, IMAGE, IMG,
+ BODY, BR, CENTER, COL, COLGROUP, DD, DETAILS,
+ DIR, DIV, DL, DT, EMBED, FIELDSET, FIGCAPTION, FIGURE, FOOTER, FORM, FRAME,
+ FRAMESET, H1, H2, H3, H4, H5, H6, HEAD, HEADER, HGROUP, HR, IFRAME, 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, SOURCE, STYLE, SUMMARY, TBODY, TEMPLATE, TEXTAREA, TFOOT, THEAD, TITLE,
- TR, UL, WBR,
+ NOSCRIPT, OL, P, PARAM, PLAINTEXT, PRE, SCRIPT,
+ SECTION, SELECT, SOURCE, STYLE, SUMMARY, TBODY, TEMPLATE, TEXTAREA, TFOOT, THEAD, TITLE,
+ TR, TRACK, UL, WBR, XMP,
/* Scoping */
APPLET, BUTTON, CAPTION, HTML, MARQUEE, OBJECT, TABLE, TD, TH,
/* Formatting */
A, B, BIG, CODE, EM, FONT, I, NOBR, S, SMALL, STRIKE, STRONG, TT, U,
/* Phrasing */
/**< \todo Enumerate phrasing elements */
- LABEL, OUTPUT, RP, RT, RUBY, SPAN, SUB, SUP, VAR, XMP,
+ COMMAND, DATAGRID, DIALOG, IMAGE,LABEL, OPTGROUP, OPTION, OUTPUT, RP, RT, RUBY, SPACER, SPAN, SUB, SUP, VAR,
/* MathML */
MATH, MGLYPH, MALIGNMARK, MI, MO, MN, MS, MTEXT, ANNOTATION_XML,
/* SVG */
diff --git a/src/treebuilder/treebuilder.c b/src/treebuilder/treebuilder.c
index 115e541..5d84ff0 100644
--- a/src/treebuilder/treebuilder.c
+++ b/src/treebuilder/treebuilder.c
@@ -24,52 +24,64 @@ static const struct {
size_t len;
element_type type;
} name_type_map[] = {
- { S("address"), ADDRESS }, { S("area"), AREA },
- { S("b"), B },
+ { S("address"), ADDRESS },
+ { S("area"), AREA }, { S("article"), ARTICLE },
+ { S("aside"), ASIDE }, { 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("details"), DETAILS },
{ S("dir"), DIR }, { S("div"), DIV },
{ S("dl"), DL }, { S("dt"), DT },
{ S("embed"), EMBED }, { S("fieldset"), FIELDSET },
+ { S("figcaption"), FIGCAPTION },{ S("figure"), FIGURE },
+ { S("footer"), FOOTER },
{ S("form"), FORM }, { S("frame"), FRAME },
{ S("frameset"), FRAMESET }, { S("h1"), H1 },
{ S("h2"), H2 }, { S("h3"), H3 },
{ S("h4"), H4 }, { S("h5"), H5 },
{ S("h6"), H6 }, { S("head"), HEAD },
+ { S("header"), HEADER }, { S("hgroup"), HGROUP },
{ S("hr"), HR }, { S("iframe"), IFRAME },
{ S("image"), IMAGE }, { S("img"), IMG },
{ S("input"), INPUT }, { S("isindex"), ISINDEX },
{ S("li"), LI }, { S("link"), LINK },
- { S("listing"), LISTING },
- { S("menu"), MENU },
- { S("meta"), META }, { S("noembed"), NOEMBED },
+ { S("listing"), LISTING }, { S("main"), MAIN },
+ { S("menu"), MENU }, { S("menuitem"), MENUITEM },
+ { S("meta"), META }, { S("nav"), NAV },
+ { S("noembed"), NOEMBED },
{ S("noframes"), NOFRAMES }, { S("noscript"), NOSCRIPT },
{ S("ol"), OL }, { S("optgroup"), OPTGROUP },
{ S("option"), OPTION }, { S("output"), OUTPUT },
{ S("p"), P }, { S("param"), PARAM },
{ S("plaintext"), PLAINTEXT }, { S("pre"), PRE },
- { S("script"), SCRIPT }, { S("select"), SELECT },
+ { S("script"), SCRIPT }, { S("section"), SECTION },
+ { S("select"), SELECT }, { S("source"), SOURCE },
{ S("spacer"), SPACER }, { S("style"), STYLE },
- { S("tbody"), TBODY }, { S("textarea"), TEXTAREA },
+ { S("summary"), SUMMARY }, { S("tbody"), TBODY },
+ { S("template"), TEMPLATE }, { S("textarea"), TEXTAREA },
{ S("tfoot"), TFOOT }, { S("thead"), THEAD },
{ S("title"), TITLE }, { S("tr"), TR },
+ { S("track"), TRACK },
{ S("ul"), UL }, { S("wbr"), WBR },
+ { S("xmp"), XMP },
{ S("applet"), APPLET }, { S("button"), BUTTON },
{ S("caption"), CAPTION }, { S("html"), HTML },
{ S("marquee"), MARQUEE }, { S("object"), OBJECT },
{ S("table"), TABLE }, { S("td"), TD },
{ S("th"), TH },
{ S("a"), A }, { S("b"), B },
- { S("big"), BIG }, { S("em"), EM },
+ { S("big"), BIG }, { S("code"), CODE },
+ { S("em"), EM },
{ S("font"), FONT }, { S("i"), I },
{ S("nobr"), NOBR }, { S("s"), S },
{ S("small"), SMALL }, { S("strike"), STRIKE },
- { S("strong"), STRONG }, { S("tt"), TT },
- { S("u"), U }, { S("xmp"), XMP },
+ { S("strong"), STRONG }, { S("span"), SPAN },
+ { S("tt"), TT },
+ { S("u"), U },
{ S("math"), MATH }, { S("mglyph"), MGLYPH },
{ S("malignmark"), MALIGNMARK },
@@ -78,7 +90,7 @@ static const struct {
{ S("mtext"), MTEXT }, { S("annotation-xml"), ANNOTATION_XML },
{ S("svg"), SVG }, { S("desc"), DESC },
- { S("foreignobject"), FOREIGNOBJECT },
+ { S("foreignobject"), FOREIGNOBJECT }
};
static bool is_form_associated(element_type type);
@@ -1037,7 +1049,9 @@ element_type element_type_from_name(hubbub_treebuilder *treebuilder,
*/
bool is_special_element(element_type type)
{
- return (type <= WBR);
+ return (type <= TH) ||
+ (type >= MI && type <= ANNOTATION_XML) ||
+ (type >=FOREIGNOBJECT && type <= DESC);
}
/**