[RenderTreeBuilder] Move RenderElement::addChild() to RenderTreeBuilder
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Feb 2018 19:25:18 +0000 (19:25 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Feb 2018 19:25:18 +0000 (19:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182878
<rdar://problem/37608349>

Reviewed by Antti Koivisto.

This patch removes the last addChild() related mutation logic from the renderers.

No change in functionality.

* rendering/RenderElement.cpp:
(WebCore::RenderElement::didInsertChild):
(WebCore::RenderElement::addChild): Deleted.
* rendering/RenderElement.h:
(WebCore::RenderElement::isChildAllowed const):
* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::insertChild):
(WebCore::RenderTreeBuilder::insertChildToRenderElement):
* rendering/updating/RenderTreeBuilder.h:
* rendering/updating/RenderTreeBuilderBlock.cpp:
(WebCore::RenderTreeBuilder::Block::insertChildIgnoringContinuation):
* rendering/updating/RenderTreeBuilderInline.cpp:
(WebCore::RenderTreeBuilder::Inline::insertChildIgnoringContinuation):
* rendering/updating/RenderTreeBuilderSVG.cpp:
(WebCore::RenderTreeBuilder::SVG::insertChild):
* rendering/updating/RenderTreeBuilderTable.cpp:
(WebCore::RenderTreeBuilder::Table::insertChild):

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderElement.h
Source/WebCore/rendering/updating/RenderTreeBuilder.cpp
Source/WebCore/rendering/updating/RenderTreeBuilder.h
Source/WebCore/rendering/updating/RenderTreeBuilderBlock.cpp
Source/WebCore/rendering/updating/RenderTreeBuilderInline.cpp
Source/WebCore/rendering/updating/RenderTreeBuilderSVG.cpp
Source/WebCore/rendering/updating/RenderTreeBuilderTable.cpp

index 6c48f70..ed5d7a2 100644 (file)
@@ -1,3 +1,33 @@
+2018-02-16  Zalan Bujtas  <zalan@apple.com>
+
+        [RenderTreeBuilder] Move RenderElement::addChild() to RenderTreeBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=182878
+        <rdar://problem/37608349>
+
+        Reviewed by Antti Koivisto.
+
+        This patch removes the last addChild() related mutation logic from the renderers.
+
+        No change in functionality.
+
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::didInsertChild):
+        (WebCore::RenderElement::addChild): Deleted.
+        * rendering/RenderElement.h:
+        (WebCore::RenderElement::isChildAllowed const):
+        * rendering/updating/RenderTreeBuilder.cpp:
+        (WebCore::RenderTreeBuilder::insertChild):
+        (WebCore::RenderTreeBuilder::insertChildToRenderElement):
+        * rendering/updating/RenderTreeBuilder.h:
+        * rendering/updating/RenderTreeBuilderBlock.cpp:
+        (WebCore::RenderTreeBuilder::Block::insertChildIgnoringContinuation):
+        * rendering/updating/RenderTreeBuilderInline.cpp:
+        (WebCore::RenderTreeBuilder::Inline::insertChildIgnoringContinuation):
+        * rendering/updating/RenderTreeBuilderSVG.cpp:
+        (WebCore::RenderTreeBuilder::SVG::insertChild):
+        * rendering/updating/RenderTreeBuilderTable.cpp:
+        (WebCore::RenderTreeBuilder::Table::insertChild):
+
 2018-02-16  Matt Lewis  <jlewis3@apple.com>
 
         Unreviewed, rolling out r228546.
index d1d3835..b4d0114 100644 (file)
@@ -456,11 +456,8 @@ void RenderElement::setStyle(RenderStyle&& style, StyleDifference minimalStyleDi
     }
 }
 
-void RenderElement::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
+void RenderElement::didInsertChild(RenderObject& child, RenderObject*)
 {
-    auto& child = *newChild;
-    builder.insertChildToRenderElement(*this, WTFMove(newChild), beforeChild);
-
     if (is<RenderText>(child))
         downcast<RenderText>(child).styleDidChange(StyleDifferenceEqual, nullptr);
     // SVG creates renderers for <g display="none">, as SVG requires children of hidden
index cb8c58b..0c3335d 100644 (file)
@@ -87,9 +87,9 @@ public:
     bool isRenderInline() const;
 
     virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const { return true; }
-    virtual void addChild(RenderTreeBuilder&, RenderPtr<RenderObject>, RenderObject* beforeChild);
     virtual void addChildIgnoringContinuation(RenderTreeBuilder&, RenderPtr<RenderObject> newChild, RenderObject* beforeChild = nullptr);
     void removeAndDestroyChild(RenderTreeBuilder&, RenderObject&);
+    void didInsertChild(RenderObject& child, RenderObject* beforeChild);
 
     // The following functions are used when the render tree hierarchy changes to make sure layers get
     // properly added and removed. Since containership can be implemented by any subclass, and since a hierarchy
index 653c665..adb4d77 100644 (file)
@@ -142,7 +142,7 @@ void RenderTreeBuilder::insertChild(RenderElement& parent, RenderPtr<RenderObjec
 {
     auto insertRecursiveIfNeeded = [&](RenderElement& parentCandidate) {
         if (&parent == &parentCandidate) {
-            parent.addChild(*this, WTFMove(child), beforeChild);
+            insertChildToRenderElement(parent, WTFMove(child), beforeChild);
             return;
         }
         insertChild(parentCandidate, WTFMove(child), beforeChild);
@@ -255,7 +255,7 @@ void RenderTreeBuilder::insertChild(RenderElement& parent, RenderPtr<RenderObjec
         return;
     }
 
-    parent.addChild(*this, WTFMove(child), beforeChild);
+    insertChildToRenderElement(parent, WTFMove(child), beforeChild);
 }
 
 RenderPtr<RenderObject> RenderTreeBuilder::takeChild(RenderElement& parent, RenderObject& child)
@@ -320,7 +320,9 @@ void RenderTreeBuilder::insertChildToRenderElement(RenderElement& parent, Render
         insertChild(*table, WTFMove(child));
         return;
     }
-    parent.RenderElement::insertChildInternal(WTFMove(child), beforeChild);
+    auto& newChild = *child.get();
+    parent.insertChildInternal(WTFMove(child), beforeChild);
+    parent.didInsertChild(newChild, beforeChild);
 }
 
 void RenderTreeBuilder::insertChildToRenderBlockIgnoringContinuation(RenderBlock& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
index 2562ab7..517b21e 100644 (file)
@@ -63,7 +63,6 @@ public:
     static RenderTreeBuilder* current() { return s_current; }
 
     // These functions are temporary until after all block/inline/continuation code is moved over.
-    void insertChildToRenderElement(RenderElement& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild = nullptr);
     void insertChildToRenderBlockIgnoringContinuation(RenderBlock& parent, RenderPtr<RenderObject>, RenderObject* beforeChild = nullptr);
     void insertChildToRenderInlineIgnoringContinuation(RenderInline& parent, RenderPtr<RenderObject>, RenderObject* beforeChild = nullptr);
 
@@ -95,6 +94,7 @@ private:
     RenderPtr<RenderObject> takeChildFromRenderGrid(RenderGrid& parent, RenderObject& child);
 
     void insertChildToRenderGrid(RenderGrid& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild = nullptr);
+    void insertChildToRenderElement(RenderElement& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild = nullptr);
 
     FirstLetter& firstLetterBuilder() { return *m_firstLetterBuilder; }
     List& listBuilder() { return *m_listBuilder; }
index 43e5706..2878732 100644 (file)
@@ -223,7 +223,7 @@ void RenderTreeBuilder::Block::insertChildIgnoringContinuation(RenderBlock& pare
             // No suitable existing anonymous box - create a new one.
             auto newBox = parent.createAnonymousBlock();
             auto& box = *newBox;
-            parent.RenderElement::addChild(m_builder, WTFMove(newBox), beforeChild);
+            m_builder.insertChildToRenderElement(parent, WTFMove(newBox), beforeChild);
             m_builder.insertChild(box, WTFMove(child));
             return;
         }
@@ -231,7 +231,7 @@ void RenderTreeBuilder::Block::insertChildIgnoringContinuation(RenderBlock& pare
 
     parent.invalidateLineLayoutPath();
 
-    parent.RenderElement::addChild(m_builder, WTFMove(child), beforeChild);
+    m_builder.insertChildToRenderElement(parent, WTFMove(child), beforeChild);
 
     if (madeBoxesNonInline && is<RenderBlock>(parent.parent()) && parent.isAnonymousBlock())
         removeLeftoverAnonymousBlock(parent);
index 904bcde..be55ac1 100644 (file)
@@ -188,7 +188,7 @@ void RenderTreeBuilder::Inline::insertChildIgnoringContinuation(RenderInline& pa
     }
 
     auto& childToAdd = *child;
-    parent.RenderElement::addChild(m_builder, WTFMove(child), beforeChild);
+    m_builder.insertChildToRenderElement(parent, WTFMove(child), beforeChild);
     childToAdd.setNeedsLayoutAndPrefWidthsRecalc();
 }
 
index 7cfb2d5..6a220da 100644 (file)
@@ -43,7 +43,7 @@ RenderTreeBuilder::SVG::SVG(RenderTreeBuilder& builder)
 void RenderTreeBuilder::SVG::insertChild(RenderSVGContainer& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
 {
     auto& childToAdd = *child;
-    parent.RenderElement::addChild(m_builder, WTFMove(child), beforeChild);
+    m_builder.insertChildToRenderElement(parent, WTFMove(child), beforeChild);
     SVGResourcesCache::clientWasAddedToTree(childToAdd);
 }
 
@@ -60,7 +60,7 @@ void RenderTreeBuilder::SVG::insertChild(RenderSVGInline& parent, RenderPtr<Rend
 void RenderTreeBuilder::SVG::insertChild(RenderSVGRoot& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
 {
     auto& childToAdd = *child;
-    parent.RenderElement::addChild(m_builder, WTFMove(child), beforeChild);
+    m_builder.insertChildToRenderElement(parent, WTFMove(child), beforeChild);
     SVGResourcesCache::clientWasAddedToTree(childToAdd);
 }
 
index 294a1fc..4975c30 100644 (file)
@@ -168,7 +168,7 @@ void RenderTreeBuilder::Table::insertChild(RenderTableRow& parent, RenderPtr<Ren
 
     auto& newChild = *child.get();
     ASSERT(!beforeChild || is<RenderTableCell>(*beforeChild));
-    parent.RenderElement::addChild(m_builder, WTFMove(child), beforeChild);
+    m_builder.insertChildToRenderElement(parent, WTFMove(child), beforeChild);
     // FIXME: child should always be a RenderTableCell at this point.
     if (is<RenderTableCell>(newChild))
         parent.didInsertTableCell(downcast<RenderTableCell>(newChild), beforeChild);
@@ -183,7 +183,7 @@ void RenderTreeBuilder::Table::insertChild(RenderTableSection& parent, RenderPtr
     if (is<RenderTableRow>(*child.get()))
         parent.willInsertTableRow(downcast<RenderTableRow>(*child.get()), beforeChild);
     ASSERT(!beforeChild || is<RenderTableRow>(*beforeChild));
-    parent.RenderElement::addChild(m_builder, WTFMove(child), beforeChild);
+    m_builder.insertChildToRenderElement(parent, WTFMove(child), beforeChild);
 }
 
 void RenderTreeBuilder::Table::insertChild(RenderTable& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
@@ -197,7 +197,7 @@ void RenderTreeBuilder::Table::insertChild(RenderTable& parent, RenderPtr<Render
     else if (is<RenderTableCol>(newChild))
         parent.willInsertTableColumn(downcast<RenderTableCol>(newChild), beforeChild);
 
-    parent.RenderElement::addChild(m_builder, WTFMove(child), beforeChild);
+    m_builder.insertChildToRenderElement(parent, WTFMove(child), beforeChild);
 }
 
 bool RenderTreeBuilder::Table::childRequiresTable(const RenderElement& parent, const RenderObject& child)