<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[160182] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/160182">160182</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2013-12-05 11:45:29 -0800 (Thu, 05 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Change how the form element pointer affects parsing template elements, to reduce weirdness in templates
https://bugs.webkit.org/show_bug.cgi?id=125279

Reviewed by Antti Koivisto.

Source/WebCore: 

Faithfully update the HTML5 parser after http://html5.org/tools/web-apps-tracker?from=8330&amp;to=8331.

Test: fast/dom/HTMLTemplateElement/no-form-association-2.html

* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::insertHTMLFormElement): Don't the form element pointer if the context
element or its ancestor is a template element.
(WebCore::HTMLConstructionSite::insideTemplateElement): Added.
(WebCore::HTMLConstructionSite::createHTMLElement): Renamed openElementsContainTemplateElement to
insideTemplateElement to reflect the true semantics of the boolean.

* html/parser/HTMLConstructionSite.h:

* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::processIsindexStartTagForInBody): Ignore the form element pointer if there
is a template element on the stack of open elements. This faithfully reflects what's being said in the
specification. We should probably make isParsingTemplateContents more efficient by storing a boolean
and then wrap from() in some helper function but that should probbaly happen in a separate patch.
(WebCore::HTMLTreeBuilder::processStartTagForInBody): Ditto.
(WebCore::HTMLTreeBuilder::processStartTagForInTable): Ditto.
(WebCore::HTMLTreeBuilder::processEndTagForInBody): Don't unset or rely on the form element pointer
when there is a template element on the stack of open elements.

* html/parser/HTMLTreeBuilder.h:
(WebCore::HTMLTreeBuilder::isParsingTemplateContents): Added a trivial implementation for when
TEMPLATE_ELEMENT is disabled.
(WebCore::HTMLTreeBuilder::isParsingFragmentOrTemplateContents): Merged two implementations.

LayoutTests: 

Added a regression test. Someone should port this test into web-platform-tests once the latest spec.
change has been refelcted to a working draft version of the HTML5 specification.

* fast/dom/HTMLTemplateElement/no-form-association-2-expected.txt: Added.
* fast/dom/HTMLTemplateElement/no-form-association-2.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLConstructionSitecpp">trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLConstructionSiteh">trunk/Source/WebCore/html/parser/HTMLConstructionSite.h</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLTreeBuildercpp">trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLTreeBuilderh">trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastdomHTMLTemplateElementnoformassociation2expectedtxt">trunk/LayoutTests/fast/dom/HTMLTemplateElement/no-form-association-2-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomHTMLTemplateElementnoformassociation2html">trunk/LayoutTests/fast/dom/HTMLTemplateElement/no-form-association-2.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (160181 => 160182)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2013-12-05 19:23:03 UTC (rev 160181)
+++ trunk/LayoutTests/ChangeLog        2013-12-05 19:45:29 UTC (rev 160182)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2013-12-04  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Change how the form element pointer affects parsing template elements, to reduce weirdness in templates
+        https://bugs.webkit.org/show_bug.cgi?id=125279
+
+        Reviewed by Antti Koivisto.
+
+        Added a regression test. Someone should port this test into web-platform-tests once the latest spec.
+        change has been refelcted to a working draft version of the HTML5 specification.
+
+        * fast/dom/HTMLTemplateElement/no-form-association-2-expected.txt: Added.
+        * fast/dom/HTMLTemplateElement/no-form-association-2.html: Added.
+
</ins><span class="cx"> 2013-12-05  Thiago de Barros Lacerda  &lt;thiago.lacerda@openbossa.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [MediaStream] Firing negotiationneeded event upon track add/remove on MediaStream
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLTemplateElementnoformassociation2expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/HTMLTemplateElement/no-form-association-2-expected.txt (0 => 160182)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLTemplateElement/no-form-association-2-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLTemplateElement/no-form-association-2-expected.txt        2013-12-05 19:45:29 UTC (rev 160182)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+PASS templateWithIsindex.innerHTML is containerWithIsindex.innerHTML
+PASS templateWithFormInsideForm.innerHTML is '&lt;form&gt;&lt;input&gt;&lt;/form&gt;'
+PASS formInsideTemplate = templateWithFormInsideForm.content.firstChild; formInsideTemplate.localName is 'form'
+PASS inputInsideTemplate = templateWithFormInsideForm.content.querySelector('input'); inputInsideTemplate.form is formInsideTemplate
+PASS formInsideTemplate.elements[0] is inputInsideTemplate
+PASS templateWithNestedForms.innerHTML is '&lt;form&gt;&lt;form&gt;&lt;/form&gt;&lt;/form&gt;'
+PASS templateWithIsindexInsideForm.innerHTML is '&lt;form&gt;' + containerWithIsindex.innerHTML + '&lt;/form&gt;'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomHTMLTemplateElementnoformassociation2html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/HTMLTemplateElement/no-form-association-2.html (0 => 160182)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/HTMLTemplateElement/no-form-association-2.html                                (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLTemplateElement/no-form-association-2.html        2013-12-05 19:45:29 UTC (rev 160182)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+&lt;div id=&quot;containerWithIsindex&quot; style=&quot;display:none&quot;&gt;&lt;isindex&gt;&lt;/div&gt;
+&lt;form&gt;&lt;template id=&quot;templateWithIsindex&quot;&gt;&lt;isindex&gt;&lt;/template&gt;&lt;/form&gt;
+&lt;form&gt;&lt;template id=&quot;templateWithFormInsideForm&quot;&gt;&lt;form&gt;&lt;input&gt;&lt;/form&gt;&lt;/template&gt;&lt;/form&gt;
+&lt;template id=&quot;templateWithNestedForms&quot;&gt;&lt;form&gt;&lt;form&gt;&lt;/form&gt;&lt;/form&gt;&lt;/template&gt;
+&lt;template id=&quot;templateWithIsindexInsideForm&quot;&gt;&lt;form&gt;&lt;isindex&gt;&lt;/form&gt;&lt;/template&gt;
+&lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+
+shouldBe(&quot;templateWithIsindex.innerHTML&quot;, &quot;containerWithIsindex.innerHTML&quot;);
+shouldBe(&quot;templateWithFormInsideForm.innerHTML&quot;, &quot;'&lt;form&gt;&lt;input&gt;&lt;/form&gt;'&quot;);
+shouldBe(&quot;formInsideTemplate = templateWithFormInsideForm.content.firstChild; formInsideTemplate.localName&quot;, &quot;'form'&quot;);
+shouldBe(&quot;inputInsideTemplate = templateWithFormInsideForm.content.querySelector('input'); inputInsideTemplate.form&quot;, &quot;formInsideTemplate&quot;);
+shouldBe(&quot;formInsideTemplate.elements[0]&quot;, &quot;inputInsideTemplate&quot;);
+shouldBe(&quot;templateWithNestedForms.innerHTML&quot;, &quot;'&lt;form&gt;&lt;form&gt;&lt;/form&gt;&lt;/form&gt;'&quot;)
+shouldBe(&quot;templateWithIsindexInsideForm.innerHTML&quot;, &quot;'&lt;form&gt;' + containerWithIsindex.innerHTML + '&lt;/form&gt;'&quot;)
+
+&lt;/script&gt;
+&lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (160181 => 160182)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2013-12-05 19:23:03 UTC (rev 160181)
+++ trunk/Source/WebCore/ChangeLog        2013-12-05 19:45:29 UTC (rev 160182)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2013-12-04  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Change how the form element pointer affects parsing template elements, to reduce weirdness in templates
+        https://bugs.webkit.org/show_bug.cgi?id=125279
+
+        Reviewed by Antti Koivisto.
+
+        Faithfully update the HTML5 parser after http://html5.org/tools/web-apps-tracker?from=8330&amp;to=8331.
+
+        Test: fast/dom/HTMLTemplateElement/no-form-association-2.html
+
+        * html/parser/HTMLConstructionSite.cpp:
+        (WebCore::HTMLConstructionSite::insertHTMLFormElement): Don't the form element pointer if the context
+        element or its ancestor is a template element.
+        (WebCore::HTMLConstructionSite::insideTemplateElement): Added.
+        (WebCore::HTMLConstructionSite::createHTMLElement): Renamed openElementsContainTemplateElement to
+        insideTemplateElement to reflect the true semantics of the boolean.
+
+        * html/parser/HTMLConstructionSite.h:
+
+        * html/parser/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processIsindexStartTagForInBody): Ignore the form element pointer if there
+        is a template element on the stack of open elements. This faithfully reflects what's being said in the
+        specification. We should probably make isParsingTemplateContents more efficient by storing a boolean
+        and then wrap from() in some helper function but that should probbaly happen in a separate patch.
+        (WebCore::HTMLTreeBuilder::processStartTagForInBody): Ditto.
+        (WebCore::HTMLTreeBuilder::processStartTagForInTable): Ditto.
+        (WebCore::HTMLTreeBuilder::processEndTagForInBody): Don't unset or rely on the form element pointer
+        when there is a template element on the stack of open elements.
+
+        * html/parser/HTMLTreeBuilder.h:
+        (WebCore::HTMLTreeBuilder::isParsingTemplateContents): Added a trivial implementation for when
+        TEMPLATE_ELEMENT is disabled.
+        (WebCore::HTMLTreeBuilder::isParsingFragmentOrTemplateContents): Merged two implementations.
+
</ins><span class="cx"> 2013-12-05  Thiago de Barros Lacerda  &lt;thiago.lacerda@openbossa.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [MediaStream] Firing negotiationneeded event upon track add/remove on MediaStream
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLConstructionSitecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp (160181 => 160182)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp        2013-12-05 19:23:03 UTC (rev 160181)
+++ trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp        2013-12-05 19:45:29 UTC (rev 160182)
</span><span class="lines">@@ -411,10 +411,12 @@
</span><span class="cx"> {
</span><span class="cx">     RefPtr&lt;Element&gt; element = createHTMLElement(token);
</span><span class="cx">     ASSERT(isHTMLFormElement(element.get()));
</span><del>-    m_form = static_pointer_cast&lt;HTMLFormElement&gt;(element.release());
-    m_form-&gt;setDemoted(isDemoted);
-    attachLater(currentNode(), m_form);
-    m_openElements.push(HTMLStackItem::create(m_form, token));
</del><ins>+    RefPtr&lt;HTMLFormElement&gt; form = static_pointer_cast&lt;HTMLFormElement&gt;(element.release());
+    if (!insideTemplateElement())
+        m_form = form;
+    form-&gt;setDemoted(isDemoted);
+    attachLater(currentNode(), form);
+    m_openElements.push(HTMLStackItem::create(form.release(), token));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLConstructionSite::insertHTMLElement(AtomicHTMLToken* token)
</span><span class="lines">@@ -537,6 +539,11 @@
</span><span class="cx">     return currentNode()-&gt;document();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline bool HTMLConstructionSite::insideTemplateElement()
+{
+    return !ownerDocumentForCurrentNode().frame();
+}
+
</ins><span class="cx"> PassRefPtr&lt;Element&gt; HTMLConstructionSite::createHTMLElement(AtomicHTMLToken* token)
</span><span class="cx"> {
</span><span class="cx">     QualifiedName tagName(nullAtom, token-&gt;name(), xhtmlNamespaceURI);
</span><span class="lines">@@ -545,8 +552,8 @@
</span><span class="cx">     // to occur after construction to allow better code sharing here.
</span><span class="cx">     // http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#create-an-element-for-the-token
</span><span class="cx">     Document&amp; ownerDocument = ownerDocumentForCurrentNode();
</span><del>-    bool openElementsContainTemplateElement = !ownerDocument.frame();
-    RefPtr&lt;Element&gt; element = HTMLElementFactory::createElement(tagName, ownerDocument, openElementsContainTemplateElement ? nullptr : form(), true);
</del><ins>+    bool insideTemplateElement = !ownerDocument.frame();
+    RefPtr&lt;Element&gt; element = HTMLElementFactory::createElement(tagName, ownerDocument, insideTemplateElement ? nullptr : form(), true);
</ins><span class="cx">     setAttributes(element.get(), token, m_parserContentPolicy);
</span><span class="cx">     ASSERT(element-&gt;isHTMLElement());
</span><span class="cx">     return element.release();
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLConstructionSiteh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLConstructionSite.h (160181 => 160182)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLConstructionSite.h        2013-12-05 19:23:03 UTC (rev 160181)
+++ trunk/Source/WebCore/html/parser/HTMLConstructionSite.h        2013-12-05 19:45:29 UTC (rev 160182)
</span><span class="lines">@@ -119,6 +119,7 @@
</span><span class="cx">     HTMLStackItem* currentStackItem() const { return m_openElements.topStackItem(); }
</span><span class="cx">     HTMLStackItem* oneBelowTop() const { return m_openElements.oneBelowTop(); }
</span><span class="cx">     Document&amp; ownerDocumentForCurrentNode();
</span><ins>+    bool insideTemplateElement();
</ins><span class="cx">     HTMLElementStack* openElements() const { return &amp;m_openElements; }
</span><span class="cx">     HTMLFormattingElementList* activeFormattingElements() const { return &amp;m_activeFormattingElements; }
</span><span class="cx">     bool currentIsRootNode() { return m_openElements.topNode() == m_openElements.rootNode(); }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLTreeBuildercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp (160181 => 160182)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp        2013-12-05 19:23:03 UTC (rev 160181)
+++ trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp        2013-12-05 19:45:29 UTC (rev 160182)
</span><span class="lines">@@ -462,7 +462,7 @@
</span><span class="cx">     ASSERT(token-&gt;type() == HTMLToken::StartTag);
</span><span class="cx">     ASSERT(token-&gt;name() == isindexTag);
</span><span class="cx">     parseError(token);
</span><del>-    if (m_tree.form())
</del><ins>+    if (m_tree.form() &amp;&amp; !isParsingTemplateContents())
</ins><span class="cx">         return;
</span><span class="cx">     notImplemented(); // Acknowledge self-closing flag
</span><span class="cx">     processFakeStartTag(formTag);
</span><span class="lines">@@ -700,7 +700,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (token-&gt;name() == formTag) {
</span><del>-        if (m_tree.form()) {
</del><ins>+        if (m_tree.form() &amp;&amp; !isParsingTemplateContents()) {
</ins><span class="cx">             parseError(token);
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="lines">@@ -1051,7 +1051,7 @@
</span><span class="cx">     }
</span><span class="cx">     if (token-&gt;name() == formTag) {
</span><span class="cx">         parseError(token);
</span><del>-        if (m_tree.form())
</del><ins>+        if (m_tree.form() &amp;&amp; !isParsingTemplateContents())
</ins><span class="cx">             return;
</span><span class="cx">         m_tree.insertHTMLFormElement(token, true);
</span><span class="cx">         m_tree.openElements()-&gt;pop();
</span><span class="lines">@@ -1864,15 +1864,26 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (token-&gt;name() == formTag) {
</span><del>-        RefPtr&lt;Element&gt; node = m_tree.takeForm();
-        if (!node || !m_tree.openElements()-&gt;inScope(node.get())) {
-            parseError(token);
-            return;
</del><ins>+        if (!isParsingTemplateContents()) {
+            RefPtr&lt;Element&gt; node = m_tree.takeForm();
+            if (!node || !m_tree.openElements()-&gt;inScope(node.get())) {
+                parseError(token);
+                return;
+            }
+            m_tree.generateImpliedEndTags();
+            if (m_tree.currentNode() != node.get())
+                parseError(token);
+            m_tree.openElements()-&gt;remove(node.get());
+        } else {
+            if (!m_tree.openElements()-&gt;inScope(token-&gt;name())) {
+                parseError(token);
+                return;
+            }
+            m_tree.generateImpliedEndTags();
+            if (!m_tree.currentNode()-&gt;hasTagName(formTag))
+                parseError(token);
+            m_tree.openElements()-&gt;popUntilPopped(token-&gt;name());
</ins><span class="cx">         }
</span><del>-        m_tree.generateImpliedEndTags();
-        if (m_tree.currentElement() != node.get())
-            parseError(token);
-        m_tree.openElements()-&gt;remove(node.get());
</del><span class="cx">     }
</span><span class="cx">     if (token-&gt;name() == pTag) {
</span><span class="cx">         if (!m_tree.openElements()-&gt;inButtonScope(token-&gt;name())) {
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLTreeBuilderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h (160181 => 160182)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h        2013-12-05 19:23:03 UTC (rev 160181)
+++ trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h        2013-12-05 19:45:29 UTC (rev 160182)
</span><span class="lines">@@ -72,10 +72,10 @@
</span><span class="cx">     bool isParsingFragment() const { return !!m_fragmentContext.fragment(); }
</span><span class="cx"> #if ENABLE(TEMPLATE_ELEMENT)
</span><span class="cx">     bool isParsingTemplateContents() const { return m_tree.openElements()-&gt;hasTemplateInHTMLScope(); }
</span><del>-    bool isParsingFragmentOrTemplateContents() const { return isParsingFragment() || isParsingTemplateContents(); }
</del><span class="cx"> #else
</span><del>-    bool isParsingFragmentOrTemplateContents() const { return isParsingFragment(); }
</del><ins>+    bool isParsingTemplateContents() const { return false; }
</ins><span class="cx"> #endif
</span><ins>+    bool isParsingFragmentOrTemplateContents() const { return isParsingFragment() || isParsingTemplateContents(); }
</ins><span class="cx"> 
</span><span class="cx">     void detach();
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>