2010-07-06 Adam Barth <abarth@webkit.org>
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Jul 2010 01:34:16 +0000 (01:34 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Jul 2010 01:34:16 +0000 (01:34 +0000)
        Reviewed by Eric Seidel.

        Move fosterParent to HTMLConstructionSite
        https://bugs.webkit.org/show_bug.cgi?id=41728

        This paves the way for handling the default case of InTableMode
        properly.

        * html/HTMLConstructionSite.cpp:
        (WebCore::HTMLConstructionSite::fosterParent):
        * html/HTMLConstructionSite.h:
        * html/HTMLTreeBuilder.cpp:
        (WebCore::HTMLTreeBuilder::callTheAdoptionAgency):

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

WebCore/ChangeLog
WebCore/html/HTMLConstructionSite.cpp
WebCore/html/HTMLConstructionSite.h
WebCore/html/HTMLTreeBuilder.cpp

index c8fd98a..bb0b829 100644 (file)
@@ -1,5 +1,21 @@
 2010-07-06  Adam Barth  <abarth@webkit.org>
 
+        Reviewed by Eric Seidel.
+
+        Move fosterParent to HTMLConstructionSite
+        https://bugs.webkit.org/show_bug.cgi?id=41728
+
+        This paves the way for handling the default case of InTableMode
+        properly.
+
+        * html/HTMLConstructionSite.cpp:
+        (WebCore::HTMLConstructionSite::fosterParent):
+        * html/HTMLConstructionSite.h:
+        * html/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::callTheAdoptionAgency):
+
+2010-07-06  Adam Barth  <abarth@webkit.org>
+
         Rubber-stamped by Eric Seidel.
 
         Move HTMLConstructionSite to its own file.  No behavior change.
index baa9aca..f0e6cb2 100644 (file)
@@ -276,4 +276,26 @@ void HTMLConstructionSite::generateImpliedEndTags()
         m_openElements.pop();
 }
 
+void HTMLConstructionSite::fosterParent(Element* element)
+{
+    Element* fosterParentElement = 0;
+    HTMLElementStack::ElementRecord* lastTableElementRecord = m_openElements.topmost(tableTag.localName());
+    if (lastTableElementRecord) {
+        Element* lastTableElement = lastTableElementRecord->element();
+        if (lastTableElement->parent()) {
+            // FIXME: We need an insertElement which does not send mutation events.
+            ExceptionCode ec = 0;
+            lastTableElement->parent()->insertBefore(element, lastTableElement, ec);
+            ASSERT(!ec);
+            return;
+        }
+        fosterParentElement = lastTableElementRecord->next()->element();
+    } else {
+        // Fragment case
+        fosterParentElement = m_openElements.bottom(); // <html> element
+    }
+
+    fosterParentElement->parserAddChild(element);
+}
+
 }
index b7d50b6..a96a937 100644 (file)
@@ -63,6 +63,8 @@ public:
 
     PassRefPtr<Element> createElement(AtomicHTMLToken&);
 
+    void fosterParent(Element*);
+
     bool indexOfFirstUnopenFormattingElement(unsigned& firstUnopenElementIndex) const;
     void reconstructTheActiveFormattingElements();
 
index 66b5d50..d35fd45 100644 (file)
@@ -1193,28 +1193,6 @@ HTMLElementStack::ElementRecord* HTMLTreeBuilder::furthestBlockForFormattingElem
     return 0;
 }
 
-void HTMLTreeBuilder::findFosterParentFor(Element* element)
-{
-    Element* fosterParentElement = 0;
-    HTMLElementStack::ElementRecord* lastTableElementRecord = m_tree.openElements()->topmost(tableTag.localName());
-    if (lastTableElementRecord) {
-        Element* lastTableElement = lastTableElementRecord->element();
-        if (lastTableElement->parent()) {
-            // FIXME: We need an insertElement which does not send mutation events.
-            ExceptionCode ec = 0;
-            lastTableElement->parent()->insertBefore(element, lastTableElement, ec);
-            ASSERT(!ec);
-            return;
-        }
-        fosterParentElement = lastTableElementRecord->next()->element();
-    } else {
-        ASSERT(m_isParsingFragment);
-        fosterParentElement = m_tree.openElements()->bottom(); // <html> element
-    }
-
-    fosterParentElement->parserAddChild(element);
-}
-
 // FIXME: This should have a whitty name.
 // FIXME: This must be implemented in many other places in WebCore.
 void HTMLTreeBuilder::reparentChildren(Element* oldParent, Element* newParent)
@@ -1307,7 +1285,7 @@ void HTMLTreeBuilder::callTheAdoptionAgency(AtomicHTMLToken& token)
         if (commonAncestorTag == tableTag
             || commonAncestorTag == trTag
             || isTableBodyContextTag(commonAncestorTag))
-            findFosterParentFor(lastNode->element());
+            m_tree.fosterParent(lastNode->element());
         else {
             ExceptionCode ec;
             commonAncestor->appendChild(lastNode->element(), ec);