diff --git a/parser/html/javasrc/ElementName.java b/parser/html/javasrc/ElementName.java index 6619e47781c..1a24347bf1f 100644 --- a/parser/html/javasrc/ElementName.java +++ b/parser/html/javasrc/ElementName.java @@ -539,7 +539,7 @@ public final class ElementName public static final ElementName APPLET = new ElementName("applet", "applet", TreeBuilder.MARQUEE_OR_APPLET, false, true, false); public static final ElementName ARCCOT = new ElementName("arccot", "arccot", TreeBuilder.OTHER, false, false, false); public static final ElementName APPROX = new ElementName("approx", "approx", TreeBuilder.OTHER, false, false, false); - public static final ElementName BUTTON = new ElementName("button", "button", TreeBuilder.BUTTON, false, true, false); + public static final ElementName BUTTON = new ElementName("button", "button", TreeBuilder.BUTTON, false, false, false); public static final ElementName CIRCLE = new ElementName("circle", "circle", TreeBuilder.OTHER, false, false, false); public static final ElementName CENTER = new ElementName("center", "center", TreeBuilder.DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU, true, false, false); public static final ElementName CURSOR = new ElementName("cursor", "cursor", TreeBuilder.OTHER, false, false, false); diff --git a/parser/html/javasrc/TreeBuilder.java b/parser/html/javasrc/TreeBuilder.java index bbfa45743b5..78f75960409 100644 --- a/parser/html/javasrc/TreeBuilder.java +++ b/parser/html/javasrc/TreeBuilder.java @@ -1958,14 +1958,14 @@ public abstract class TreeBuilder implements TokenHandler, eltPos = findLastInScope(name); if (eltPos != TreeBuilder.NOT_FOUND_ON_STACK) { err("\u201Cbutton\u201D start tag seen when there was an open \u201Cbutton\u201D element in scope."); + generateImpliedEndTags(); - if (!isCurrent("button")) { - err("There was an open \u201Cbutton\u201D element in scope with unclosed children."); + if (!isCurrent(name)) { + err("End tag \u201Cbutton\u201D seen but there were unclosed elements."); } while (currentPtr >= eltPos) { pop(); } - clearTheListOfActiveFormattingElementsUpToTheLastMarker(); continue starttagloop; } else { reconstructTheActiveFormattingElements(); @@ -1973,7 +1973,6 @@ public abstract class TreeBuilder implements TokenHandler, "http://www.w3.org/1999/xhtml", elementName, attributes, formPointer); - insertMarker(); attributes = null; // CPP break starttagloop; } @@ -3375,6 +3374,7 @@ public abstract class TreeBuilder implements TokenHandler, case UL_OR_OL_OR_DL: case PRE_OR_LISTING: case FIELDSET: + case BUTTON: case ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_HGROUP_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION: eltPos = findLastInScope(name); if (eltPos == TreeBuilder.NOT_FOUND_ON_STACK) { @@ -3495,7 +3495,6 @@ public abstract class TreeBuilder implements TokenHandler, case NOBR: adoptionAgencyEndTag(name); break endtagloop; - case BUTTON: case OBJECT: case MARQUEE_OR_APPLET: eltPos = findLastInScope(name); diff --git a/parser/html/nsHtml5AtomList.h b/parser/html/nsHtml5AtomList.h index ca090f614dc..d78b85cc519 100644 --- a/parser/html/nsHtml5AtomList.h +++ b/parser/html/nsHtml5AtomList.h @@ -16,7 +16,6 @@ HTML5_ATOM(address, "address") HTML5_ATOM(div, "div") HTML5_ATOM(a, "a") HTML5_ATOM(nobr, "nobr") -HTML5_ATOM(button, "button") HTML5_ATOM(input, "input") HTML5_ATOM(option, "option") HTML5_ATOM(ruby, "ruby") @@ -836,6 +835,7 @@ HTML5_ATOM(arccos, "arccos") HTML5_ATOM(applet, "applet") HTML5_ATOM(arccot, "arccot") HTML5_ATOM(approx, "approx") +HTML5_ATOM(button, "button") HTML5_ATOM(circle, "circle") HTML5_ATOM(center, "center") HTML5_ATOM(canvas, "canvas") diff --git a/parser/html/nsHtml5ElementName.cpp b/parser/html/nsHtml5ElementName.cpp index 7c538158e7b..bb10689ab04 100644 --- a/parser/html/nsHtml5ElementName.cpp +++ b/parser/html/nsHtml5ElementName.cpp @@ -330,7 +330,7 @@ nsHtml5ElementName::initializeStatics() ELT_APPLET = new nsHtml5ElementName(nsHtml5Atoms::applet, nsHtml5Atoms::applet, NS_HTML5TREE_BUILDER_MARQUEE_OR_APPLET, PR_FALSE, PR_TRUE, PR_FALSE); ELT_ARCCOT = new nsHtml5ElementName(nsHtml5Atoms::arccot, nsHtml5Atoms::arccot, NS_HTML5TREE_BUILDER_OTHER, PR_FALSE, PR_FALSE, PR_FALSE); ELT_APPROX = new nsHtml5ElementName(nsHtml5Atoms::approx, nsHtml5Atoms::approx, NS_HTML5TREE_BUILDER_OTHER, PR_FALSE, PR_FALSE, PR_FALSE); - ELT_BUTTON = new nsHtml5ElementName(nsHtml5Atoms::button, nsHtml5Atoms::button, NS_HTML5TREE_BUILDER_BUTTON, PR_FALSE, PR_TRUE, PR_FALSE); + ELT_BUTTON = new nsHtml5ElementName(nsHtml5Atoms::button, nsHtml5Atoms::button, NS_HTML5TREE_BUILDER_BUTTON, PR_FALSE, PR_FALSE, PR_FALSE); ELT_CIRCLE = new nsHtml5ElementName(nsHtml5Atoms::circle, nsHtml5Atoms::circle, NS_HTML5TREE_BUILDER_OTHER, PR_FALSE, PR_FALSE, PR_FALSE); ELT_CENTER = new nsHtml5ElementName(nsHtml5Atoms::center, nsHtml5Atoms::center, NS_HTML5TREE_BUILDER_DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU, PR_TRUE, PR_FALSE, PR_FALSE); ELT_CURSOR = new nsHtml5ElementName(nsHtml5Atoms::cursor, nsHtml5Atoms::cursor, NS_HTML5TREE_BUILDER_OTHER, PR_FALSE, PR_FALSE, PR_FALSE); diff --git a/parser/html/nsHtml5TreeBuilder.cpp b/parser/html/nsHtml5TreeBuilder.cpp index b1defbebbf1..0781a45b1e7 100644 --- a/parser/html/nsHtml5TreeBuilder.cpp +++ b/parser/html/nsHtml5TreeBuilder.cpp @@ -1052,18 +1052,16 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu if (eltPos != NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) { generateImpliedEndTags(); - if (!isCurrent(nsHtml5Atoms::button)) { + if (!isCurrent(name)) { } while (currentPtr >= eltPos) { pop(); } - clearTheListOfActiveFormattingElementsUpToTheLastMarker(); goto starttagloop; } else { reconstructTheActiveFormattingElements(); appendToCurrentNodeAndPushElementMayFoster(kNameSpaceID_XHTML, elementName, attributes, formPointer); - insertMarker(); attributes = nsnull; goto starttagloop_end; } @@ -2271,6 +2269,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName) case NS_HTML5TREE_BUILDER_UL_OR_OL_OR_DL: case NS_HTML5TREE_BUILDER_PRE_OR_LISTING: case NS_HTML5TREE_BUILDER_FIELDSET: + case NS_HTML5TREE_BUILDER_BUTTON: case NS_HTML5TREE_BUILDER_ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_HGROUP_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION: { eltPos = findLastInScope(name); if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) { @@ -2381,7 +2380,6 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName) adoptionAgencyEndTag(name); goto endtagloop_end; } - case NS_HTML5TREE_BUILDER_BUTTON: case NS_HTML5TREE_BUILDER_OBJECT: case NS_HTML5TREE_BUILDER_MARQUEE_OR_APPLET: { eltPos = findLastInScope(name); diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_dat1.txt b/parser/htmlparser/tests/mochitest/html5lib_tree_dat1.txt index dbcc50b176e..42ac5058d37 100644 --- a/parser/htmlparser/tests/mochitest/html5lib_tree_dat1.txt +++ b/parser/htmlparser/tests/mochitest/html5lib_tree_dat1.txt @@ -227,7 +227,7 @@ Line: 1 Col: 30 Expected closing tag. Unexpected end of file. #data

Hello

World #errors -4: Start tag seen without seeing a doctype first. Expected “”. +4: Start tag seen without seeing a doctype first. Expected β€œβ€. 13: Heading cannot be a child of another heading. 18: End of file seen and there were open elements. #document @@ -270,6 +270,20 @@ Line: 1 Col: 15 End tag (b) violates step 1, paragraph 1 of the adoption agency | |