[HTMLTemplateElement] <template> should be able to be a foster parent
authorrafaelw@chromium.org <rafaelw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Mar 2013 00:13:05 +0000 (00:13 +0000)
committerrafaelw@chromium.org <rafaelw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Mar 2013 00:13:05 +0000 (00:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=113541

Source/WebCore:

Reviewed by Eric Seidel

This adds to the check in findFosterSite to include whether the parent is a DocumentFragment which is a template contents.

Tests added to html5lib suite.

* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::findFosterSite):

LayoutTests:

Reviewed by Eric Seidel.

* html5lib/resources/template.dat:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@147185 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/html5lib/resources/template.dat
Source/WebCore/ChangeLog
Source/WebCore/html/parser/HTMLConstructionSite.cpp

index f9a2d4b..d505c4c 100644 (file)
@@ -1,3 +1,12 @@
+2013-03-28  Rafael Weinstein  <rafaelw@chromium.org>
+
+        [HTMLTemplateElement] <template> should be able to be a foster parent
+        https://bugs.webkit.org/show_bug.cgi?id=113541
+
+        Reviewed by Eric Seidel.
+
+        * html5lib/resources/template.dat:
+
 2013-03-28  Tony Chang  <tony@chromium.org>
 
         Convert some flexbox layout tests to using flexbox.css
index 50cde50..bc66ee8 100644 (file)
 |       content
 |         <template>
 |           content
-|             <table>
 |             "Foo"
+|             <table>
 |   <body>
 
 #data
index 31f97e8..c68f763 100644 (file)
@@ -1,3 +1,17 @@
+2013-03-28  Rafael Weinstein  <rafaelw@chromium.org>
+
+        [HTMLTemplateElement] <template> should be able to be a foster parent
+        https://bugs.webkit.org/show_bug.cgi?id=113541
+
+        Reviewed by Eric Seidel
+
+        This adds to the check in findFosterSite to include whether the parent is a DocumentFragment which is a template contents.
+
+        Tests added to html5lib suite.
+
+        * html/parser/HTMLConstructionSite.cpp:
+        (WebCore::HTMLConstructionSite::findFosterSite):
+
 2013-03-28  Xianzhu Wang  <wangxianzhu@chromium.org>
 
         [Chromium] Don't create SolidColorLayer for full transparent background
index 78a2e77..3192d35 100644 (file)
@@ -629,7 +629,11 @@ void HTMLConstructionSite::findFosterSite(HTMLConstructionSiteTask& task)
         ContainerNode* parent = lastTableElement->parentNode();
         // When parsing HTML fragments, we skip step 4.2 ("Let root be a new html element with no attributes") for efficiency,
         // and instead use the DocumentFragment as a root node. So we must treat the root node (DocumentFragment) as if it is a html element here.
-        if (parent && (parent->isElementNode() || (m_isParsingFragment && parent == m_openElements.rootNode()))) {
+        bool parentCanBeFosterParent = parent && (parent->isElementNode() || (m_isParsingFragment && parent == m_openElements.rootNode()));
+#if ENABLE(TEMPLATE_ELEMENT)
+        parentCanBeFosterParent = parentCanBeFosterParent || (parent && parent->isDocumentFragment() && static_cast<DocumentFragment*>(parent)->isTemplateContent());
+#endif
+        if (parentCanBeFosterParent) {
             task.parent = parent;
             task.nextChild = lastTableElement;
             return;