2010-07-09 Adam Barth <abarth@webkit.org>
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 10 Jul 2010 03:47:55 +0000 (03:47 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 10 Jul 2010 03:47:55 +0000 (03:47 +0000)
        Reviewed by Eric Seidel.

        HTML5 tree builder should pass some LayoutTests
        https://bugs.webkit.org/show_bug.cgi?id=41991

        Before this patch, we weren't attaching text nodes to the render tree,
        which turns out to be important.  :)

        This patch fixes more than 10,000 LayoutTests.

        * html/HTMLConstructionSite.cpp:
        (WebCore::HTMLConstructionSite::attach):
        (WebCore::HTMLConstructionSite::attachAtSite):

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

WebCore/ChangeLog
WebCore/html/HTMLConstructionSite.cpp

index d5f9966..ae41f61 100644 (file)
@@ -1,3 +1,19 @@
+2010-07-09  Adam Barth  <abarth@webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        HTML5 tree builder should pass some LayoutTests
+        https://bugs.webkit.org/show_bug.cgi?id=41991
+
+        Before this patch, we weren't attaching text nodes to the render tree,
+        which turns out to be important.  :)
+
+        This patch fixes more than 10,000 LayoutTests.
+
+        * html/HTMLConstructionSite.cpp:
+        (WebCore::HTMLConstructionSite::attach):
+        (WebCore::HTMLConstructionSite::attachAtSite):
+
 2010-07-09  Patrick Gansterer  <paroga@paroga.com>
 
         Reviewed by Darin Adler.
index e4ad40a..5745625 100644 (file)
@@ -82,6 +82,7 @@ PassRefPtr<ChildType> HTMLConstructionSite::attach(Node* parent, PassRefPtr<Chil
     // doesn't.  It feels like we're missing a concept somehow.
     if (m_redirectAttachToFosterParent) {
         fosterParent(child.get());
+        ASSERT(child->attached());
         return child.release();
     }
 
@@ -91,22 +92,33 @@ PassRefPtr<ChildType> HTMLConstructionSite::attach(Node* parent, PassRefPtr<Chil
     // |parent| to hold a ref at this point.  In the common case (at least
     // for elements), however, we'll get to use this ref in the stack of
     // open elements.
+    ASSERT(parent->attached());
+    ASSERT(!child->attached());
     child->attach();
     return child.release();
 }
 
-void HTMLConstructionSite::attachAtSite(const AttachmentSite& site, PassRefPtr<Node> child)
+void HTMLConstructionSite::attachAtSite(const AttachmentSite& site, PassRefPtr<Node> prpChild)
 {
+    RefPtr<Node> child = prpChild;
+
     if (site.nextChild) {
         // FIXME: We need an insertElement which does not send mutation events.
         ExceptionCode ec = 0;
         site.parent->insertBefore(child, site.nextChild, ec);
-        // FIXME: Do we need to call attach()?
         ASSERT(!ec);
+        ASSERT(site.parent->attached());
+        if (!child->attached())
+            child->attach();
         return;
     }
     site.parent->parserAddChild(child);
-    // FIXME: Do we need to call attach()?
+    // It's slightly unfortunate that we need to hold a reference to child
+    // here to call attach().  We should investigate whether we can rely on
+    // |site.parent| to hold a ref at this point.
+    ASSERT(site.parent->attached());
+    if (!child->attached())
+        child->attach();
 }
 
 HTMLConstructionSite::HTMLConstructionSite(Document* document, FragmentScriptingPermission scriptingPermission)