[RenderTreeBuilder] Introduce RenderTreeBuilder to takeChild()
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Feb 2018 19:42:32 +0000 (19:42 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Feb 2018 19:42:32 +0000 (19:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182373
<rdar://problem/37101484>

Reviewed by Antti Koivisto.

This is in preparation for moving mutation code out of takeChild.

No change in functionality.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::takeChild):
* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::takeChild):
* rendering/RenderBlockFlow.h:
* rendering/RenderButton.cpp:
(WebCore::RenderButton::takeChild):
* rendering/RenderButton.h:
* rendering/RenderElement.cpp:
(WebCore::RenderElement::takeChild):
(WebCore::RenderElement::removeAndDestroyChild):
(WebCore::RenderElement::destroyLeftoverChildren):
* rendering/RenderElement.h:
* rendering/RenderFullScreen.cpp:
(WebCore::RenderFullScreen::wrapExistingRenderer):
(WebCore::RenderFullScreen::unwrapRenderer):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::takeChild):
* rendering/RenderGrid.h:
* rendering/RenderMenuList.cpp:
(RenderMenuList::takeChild):
* rendering/RenderMenuList.h:
* rendering/RenderMultiColumnFlow.cpp:
(WebCore::RenderMultiColumnFlow::processPossibleSpannerDescendant):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::removeFromParentAndDestroy):
* rendering/RenderRuby.cpp:
(WebCore::RenderRubyAsInline::takeChild):
(WebCore::RenderRubyAsBlock::takeChild):
* rendering/RenderRuby.h:
* rendering/RenderRubyRun.cpp:
(WebCore::RenderRubyRun::takeChild):
* rendering/RenderRubyRun.h:
* rendering/RenderTableRow.cpp:
(WebCore::RenderTableRow::collapseAndDestroyAnonymousSiblingRows): Deleted.
* rendering/RenderTableRow.h:
* rendering/svg/RenderSVGContainer.cpp:
(WebCore::RenderSVGContainer::takeChild):
* rendering/svg/RenderSVGContainer.h:
* rendering/svg/RenderSVGInline.cpp:
(WebCore::RenderSVGInline::takeChild):
* rendering/svg/RenderSVGInline.h:
* rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::takeChild):
* rendering/svg/RenderSVGRoot.h:
* rendering/svg/RenderSVGText.cpp:
(WebCore::RenderSVGText::takeChild):
* rendering/svg/RenderSVGText.h:
* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::collapseAndDestroyAnonymousSiblingRows):
(WebCore::RenderTreeBuilder::removeFromParentAndDestroyCleaningUpAnonymousWrappers):
* rendering/updating/RenderTreeBuilder.h:
* rendering/updating/RenderTreeBuilderFirstLetter.cpp:
(WebCore::RenderTreeBuilder::FirstLetter::updateStyle):
(WebCore::RenderTreeBuilder::FirstLetter::createRenderers):
* rendering/updating/RenderTreeBuilderList.cpp:
(WebCore::RenderTreeBuilder::List::updateItemMarker):
* rendering/updating/RenderTreeBuilderMultiColumn.cpp:
(WebCore::RenderTreeBuilder::MultiColumn::createFragmentedFlow):
(WebCore::RenderTreeBuilder::MultiColumn::destroyFragmentedFlow):
* rendering/updating/RenderTreeBuilderRuby.cpp:
(WebCore::RenderTreeBuilder::Ruby::insertChild):

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

34 files changed:
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderBlockFlow.cpp
Source/WebCore/rendering/RenderBlockFlow.h
Source/WebCore/rendering/RenderButton.cpp
Source/WebCore/rendering/RenderButton.h
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderElement.h
Source/WebCore/rendering/RenderFullScreen.cpp
Source/WebCore/rendering/RenderGrid.cpp
Source/WebCore/rendering/RenderGrid.h
Source/WebCore/rendering/RenderMenuList.cpp
Source/WebCore/rendering/RenderMenuList.h
Source/WebCore/rendering/RenderMultiColumnFlow.cpp
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderRuby.cpp
Source/WebCore/rendering/RenderRuby.h
Source/WebCore/rendering/RenderRubyRun.cpp
Source/WebCore/rendering/RenderRubyRun.h
Source/WebCore/rendering/svg/RenderSVGContainer.cpp
Source/WebCore/rendering/svg/RenderSVGContainer.h
Source/WebCore/rendering/svg/RenderSVGInline.cpp
Source/WebCore/rendering/svg/RenderSVGInline.h
Source/WebCore/rendering/svg/RenderSVGRoot.cpp
Source/WebCore/rendering/svg/RenderSVGRoot.h
Source/WebCore/rendering/svg/RenderSVGText.cpp
Source/WebCore/rendering/svg/RenderSVGText.h
Source/WebCore/rendering/updating/RenderTreeBuilder.cpp
Source/WebCore/rendering/updating/RenderTreeBuilderFirstLetter.cpp
Source/WebCore/rendering/updating/RenderTreeBuilderList.cpp
Source/WebCore/rendering/updating/RenderTreeBuilderMultiColumn.cpp
Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp
Source/WebCore/rendering/updating/RenderTreeBuilderTable.cpp

index e7981ea..cee9e1e 100644 (file)
@@ -1,3 +1,79 @@
+2018-02-01  Zalan Bujtas  <zalan@apple.com>
+
+        [RenderTreeBuilder] Introduce RenderTreeBuilder to takeChild()
+        https://bugs.webkit.org/show_bug.cgi?id=182373
+        <rdar://problem/37101484>
+
+        Reviewed by Antti Koivisto.
+        
+        This is in preparation for moving mutation code out of takeChild. 
+
+        No change in functionality.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::takeChild):
+        * rendering/RenderBlock.h:
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::takeChild):
+        * rendering/RenderBlockFlow.h:
+        * rendering/RenderButton.cpp:
+        (WebCore::RenderButton::takeChild):
+        * rendering/RenderButton.h:
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::takeChild):
+        (WebCore::RenderElement::removeAndDestroyChild):
+        (WebCore::RenderElement::destroyLeftoverChildren):
+        * rendering/RenderElement.h:
+        * rendering/RenderFullScreen.cpp:
+        (WebCore::RenderFullScreen::wrapExistingRenderer):
+        (WebCore::RenderFullScreen::unwrapRenderer):
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::takeChild):
+        * rendering/RenderGrid.h:
+        * rendering/RenderMenuList.cpp:
+        (RenderMenuList::takeChild):
+        * rendering/RenderMenuList.h:
+        * rendering/RenderMultiColumnFlow.cpp:
+        (WebCore::RenderMultiColumnFlow::processPossibleSpannerDescendant):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::removeFromParentAndDestroy):
+        * rendering/RenderRuby.cpp:
+        (WebCore::RenderRubyAsInline::takeChild):
+        (WebCore::RenderRubyAsBlock::takeChild):
+        * rendering/RenderRuby.h:
+        * rendering/RenderRubyRun.cpp:
+        (WebCore::RenderRubyRun::takeChild):
+        * rendering/RenderRubyRun.h:
+        * rendering/RenderTableRow.cpp:
+        (WebCore::RenderTableRow::collapseAndDestroyAnonymousSiblingRows): Deleted.
+        * rendering/RenderTableRow.h:
+        * rendering/svg/RenderSVGContainer.cpp:
+        (WebCore::RenderSVGContainer::takeChild):
+        * rendering/svg/RenderSVGContainer.h:
+        * rendering/svg/RenderSVGInline.cpp:
+        (WebCore::RenderSVGInline::takeChild):
+        * rendering/svg/RenderSVGInline.h:
+        * rendering/svg/RenderSVGRoot.cpp:
+        (WebCore::RenderSVGRoot::takeChild):
+        * rendering/svg/RenderSVGRoot.h:
+        * rendering/svg/RenderSVGText.cpp:
+        (WebCore::RenderSVGText::takeChild):
+        * rendering/svg/RenderSVGText.h:
+        * rendering/updating/RenderTreeBuilder.cpp:
+        (WebCore::RenderTreeBuilder::collapseAndDestroyAnonymousSiblingRows):
+        (WebCore::RenderTreeBuilder::removeFromParentAndDestroyCleaningUpAnonymousWrappers):
+        * rendering/updating/RenderTreeBuilder.h:
+        * rendering/updating/RenderTreeBuilderFirstLetter.cpp:
+        (WebCore::RenderTreeBuilder::FirstLetter::updateStyle):
+        (WebCore::RenderTreeBuilder::FirstLetter::createRenderers):
+        * rendering/updating/RenderTreeBuilderList.cpp:
+        (WebCore::RenderTreeBuilder::List::updateItemMarker):
+        * rendering/updating/RenderTreeBuilderMultiColumn.cpp:
+        (WebCore::RenderTreeBuilder::MultiColumn::createFragmentedFlow):
+        (WebCore::RenderTreeBuilder::MultiColumn::destroyFragmentedFlow):
+        * rendering/updating/RenderTreeBuilderRuby.cpp:
+        (WebCore::RenderTreeBuilder::Ruby::insertChild):
+
 2018-02-01  Dean Jackson  <dino@apple.com>
 
         REGRESSION (r219342): Scaled HTML widget is not responding to a clicks outside the body
index ce92fbb..bdff483 100644 (file)
@@ -582,12 +582,12 @@ void RenderBlock::dropAnonymousBoxChild(RenderBlock& child)
     child.deleteLines();
 }
 
-RenderPtr<RenderObject> RenderBlock::takeChild(RenderObject& oldChild)
+RenderPtr<RenderObject> RenderBlock::takeChild(RenderTreeBuilder& builder, RenderObject& oldChild)
 {
     // No need to waste time in merging or removing empty anonymous blocks.
     // We can just bail out if our document is getting destroyed.
     if (renderTreeBeingDestroyed())
-        return RenderBox::takeChild(oldChild);
+        return RenderBox::takeChild(builder, oldChild);
 
     // If this child is a block, and if our previous and next siblings are both anonymous blocks
     // with inline content, then we can fold the inline content back together.
@@ -637,7 +637,7 @@ RenderPtr<RenderObject> RenderBlock::takeChild(RenderObject& oldChild)
 
     invalidateLineLayoutPath();
 
-    auto takenChild = RenderBox::takeChild(oldChild);
+    auto takenChild = RenderBox::takeChild(builder, oldChild);
 
     RenderObject* child = prev ? prev : next;
     if (canMergeAnonymousBlocks && child && !child->previousSibling() && !child->nextSibling() && canDropAnonymousBlockChild()) {
index 20a7204..3c8f139 100644 (file)
@@ -74,7 +74,7 @@ public:
     virtual void deleteLines();
 
     void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> newChild, RenderObject* beforeChild = 0) override;
-    RenderPtr<RenderObject> takeChild(RenderObject&) override;
+    RenderPtr<RenderObject> takeChild(RenderTreeBuilder&, RenderObject&) override;
 
     virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0);
 
index e0b49f1..1578788 100644 (file)
@@ -3849,14 +3849,14 @@ void RenderBlockFlow::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObjec
     builder.insertChildToRenderBlockFlow(*this, WTFMove(newChild), beforeChild);
 }
 
-RenderPtr<RenderObject> RenderBlockFlow::takeChild(RenderObject& oldChild)
+RenderPtr<RenderObject> RenderBlockFlow::takeChild(RenderTreeBuilder& builder, RenderObject& oldChild)
 {
     if (!renderTreeBeingDestroyed()) {
         RenderFragmentedFlow* fragmentedFlow = multiColumnFlow();
         if (fragmentedFlow && fragmentedFlow != &oldChild)
             fragmentedFlow->fragmentedFlowRelativeWillBeRemoved(oldChild);
     }
-    return RenderBlock::takeChild(oldChild);
+    return RenderBlock::takeChild(builder, oldChild);
 }
 
 void RenderBlockFlow::checkForPaginationLogicalHeightChange(bool& relayoutChildren, LayoutUnit& pageLogicalHeight, bool& pageLogicalHeightChanged)
index f29d8b3..86e295e 100644 (file)
@@ -379,7 +379,7 @@ public:
     bool hasNextPage(LayoutUnit logicalOffset, PageBoundaryRule = ExcludePageBoundary) const;
 
     void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> newChild, RenderObject* beforeChild = 0) override;
-    RenderPtr<RenderObject> takeChild(RenderObject&) override;
+    RenderPtr<RenderObject> takeChild(RenderTreeBuilder&, RenderObject&) override;
 
     void updateColumnProgressionFromStyle(RenderStyle&);
     void updateStylesForColumnChildren();
index 8c3b029..65ad34c 100644 (file)
@@ -70,16 +70,16 @@ void RenderButton::setInnerRenderer(RenderBlock& innerRenderer)
     updateAnonymousChildStyle(m_inner->mutableStyle());
 }
 
-RenderPtr<RenderObject> RenderButton::takeChild(RenderObject& oldChild)
+RenderPtr<RenderObject> RenderButton::takeChild(RenderTreeBuilder& builder, RenderObject& oldChild)
 {
     // m_inner should be the only child, but checking for direct children who
     // are not m_inner prevents security problems when that assumption is
     // violated.
     if (&oldChild == m_inner || !m_inner || oldChild.parent() == this) {
         ASSERT(&oldChild == m_inner || !m_inner);
-        return RenderFlexibleBox::takeChild(oldChild);
+        return RenderFlexibleBox::takeChild(builder, oldChild);
     }
-    return m_inner->takeChild(oldChild);
+    return m_inner->takeChild(builder, oldChild);
 }
     
 void RenderButton::updateAnonymousChildStyle(RenderStyle& childStyle) const
index 537f376..2e48d51 100644 (file)
@@ -41,7 +41,7 @@ public:
 
     bool canBeSelectionLeaf() const override;
 
-    RenderPtr<RenderObject> takeChild(RenderObject&) override;
+    RenderPtr<RenderObject> takeChild(RenderTreeBuilder&, RenderObject&) override;
     void removeLeftoverAnonymousBlock(RenderBlock*) override { }
     bool createsAnonymousWrapper() const override { return true; }
 
index b1001af..de43679 100644 (file)
@@ -480,14 +480,14 @@ void RenderElement::addChildIgnoringContinuation(RenderTreeBuilder& builder, Ren
     builder.insertChild(*this, WTFMove(newChild), beforeChild);
 }
 
-RenderPtr<RenderObject> RenderElement::takeChild(RenderObject& oldChild)
+RenderPtr<RenderObject> RenderElement::takeChild(RenderTreeBuilder&, RenderObject& oldChild)
 {
     return takeChildInternal(oldChild);
 }
 
-void RenderElement::removeAndDestroyChild(RenderObject& oldChild)
+void RenderElement::removeAndDestroyChild(RenderTreeBuilder& builder, RenderObject& oldChild)
 {
-    auto toDestroy = takeChild(oldChild);
+    auto toDestroy = takeChild(builder, oldChild);
 }
 
 void RenderElement::destroyLeftoverChildren()
@@ -495,7 +495,7 @@ void RenderElement::destroyLeftoverChildren()
     while (m_firstChild) {
         if (auto* node = m_firstChild->node())
             node->setRenderer(nullptr);
-        removeAndDestroyChild(*m_firstChild);
+        removeAndDestroyChild(*RenderTreeBuilder::current(), *m_firstChild);
     }
 }
 
index 5b1129e..4466d01 100644 (file)
@@ -89,8 +89,8 @@ public:
     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);
-    virtual RenderPtr<RenderObject> takeChild(RenderObject&) WARN_UNUSED_RETURN;
-    void removeAndDestroyChild(RenderObject&);
+    virtual RenderPtr<RenderObject> takeChild(RenderTreeBuilder&, RenderObject&) WARN_UNUSED_RETURN;
+    void removeAndDestroyChild(RenderTreeBuilder&, RenderObject&);
 
     // 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 74af3f7..8f0352d 100644 (file)
@@ -132,7 +132,7 @@ void RenderFullScreen::wrapExistingRenderer(RenderElement& renderer, Document& d
 
     builder.insertChild(parent, WTFMove(newFullscreenRenderer), &renderer);
 
-    auto toMove = parent.takeChild(renderer);
+    auto toMove = parent.takeChild(builder, renderer);
 
     // Always just do a full layout to ensure that line boxes get deleted properly.
     // Because objects moved from |parent| to |fullscreenRenderer|, we want to
@@ -178,7 +178,7 @@ void RenderFullScreen::unwrapRenderer(bool& requiresRenderTreeRebuild)
             // lying around on the child.
             if (is<RenderBox>(*child))
                 downcast<RenderBox>(*child).clearOverrideSize();
-            auto childToMove = child->parent()->takeChild(*child);
+            auto childToMove = child->parent()->takeChild(builder, *child);
             builder.insertChild(*parent(), WTFMove(childToMove), this);
             parent()->setNeedsLayoutAndPrefWidthsRecalc();
         }
index f9dae8c..9742684 100644 (file)
@@ -85,9 +85,9 @@ void RenderGrid::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> ne
     dirtyGrid();
 }
 
-RenderPtr<RenderObject> RenderGrid::takeChild(RenderObject& child)
+RenderPtr<RenderObject> RenderGrid::takeChild(RenderTreeBuilder& builder, RenderObject& child)
 {
-    auto takenChild = RenderBlock::takeChild(child);
+    auto takenChild = RenderBlock::takeChild(builder, child);
 
     // Positioned grid items do not take up space or otherwise participate in the layout of the grid,
     // for that reason we don't need to mark the grid as dirty when they are removed.
index 2a495fd..41586cd 100644 (file)
@@ -80,7 +80,7 @@ private:
     void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const override;
 
     void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> newChild, RenderObject* beforeChild) final;
-    RenderPtr<RenderObject> takeChild(RenderObject&) final;
+    RenderPtr<RenderObject> takeChild(RenderTreeBuilder&, RenderObject&) final;
 
     StyleSelfAlignmentData selfAlignmentForChild(GridAxis, const RenderBox&, const RenderStyle* = nullptr) const;
     bool selfAlignmentChangedToStretch(GridAxis, const RenderStyle& oldStyle, const RenderStyle& newStyle, const RenderBox&) const;
index d5176ce..407d2cb 100644 (file)
@@ -172,11 +172,11 @@ void RenderMenuList::addChild(RenderTreeBuilder&, RenderPtr<RenderObject> child,
         cache->childrenChanged(this, child.get());
 }
 
-RenderPtr<RenderObject> RenderMenuList::takeChild(RenderObject& oldChild)
+RenderPtr<RenderObject> RenderMenuList::takeChild(RenderTreeBuilder& builder, RenderObject& oldChild)
 {
     if (!m_innerBlock || &oldChild == m_innerBlock)
-        return RenderFlexibleBox::takeChild(oldChild);
-    return m_innerBlock->takeChild(oldChild);
+        return RenderFlexibleBox::takeChild(builder, oldChild);
+    return m_innerBlock->takeChild(builder, oldChild);
 }
 
 void RenderMenuList::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
index 01c7591..bdf4471 100644 (file)
@@ -70,7 +70,7 @@ private:
     bool isMenuList() const override { return true; }
 
     void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> newChild, RenderObject* beforeChild = 0) override;
-    RenderPtr<RenderObject> takeChild(RenderObject&) override;
+    RenderPtr<RenderObject> takeChild(RenderTreeBuilder&, RenderObject&) override;
     bool createsAnonymousWrapper() const override { return true; }
 
     void updateFromElement() override;
index d67cf57..f4d0a35 100644 (file)
@@ -274,7 +274,7 @@ RenderObject* RenderMultiColumnFlow::processPossibleSpannerDescendant(RenderObje
         auto newPlaceholder = RenderMultiColumnSpannerPlaceholder::createAnonymous(*this, downcast<RenderBox>(descendant), container->style());
         auto& placeholder = *newPlaceholder;
         RenderTreeBuilder::current()->insertChild(*container, WTFMove(newPlaceholder), descendant.nextSibling());
-        auto takenDescendant = container->takeChild(descendant);
+        auto takenDescendant = container->takeChild(*RenderTreeBuilder::current(), descendant);
         
         // This is a guard to stop an ancestor flow thread from processing the spanner.
         gShiftingSpanner = true;
index faa73b5..f7c5c11 100644 (file)
@@ -62,6 +62,7 @@
 #include "RenderScrollbarPart.h"
 #include "RenderTableRow.h"
 #include "RenderTheme.h"
+#include "RenderTreeBuilder.h"
 #include "RenderView.h"
 #include "RenderWidget.h"
 #include "SVGRenderSupport.h"
@@ -257,7 +258,7 @@ void RenderObject::setParent(RenderElement* parent)
 void RenderObject::removeFromParentAndDestroy()
 {
     ASSERT(m_parent);
-    m_parent->removeAndDestroyChild(*this);
+    m_parent->removeAndDestroyChild(*RenderTreeBuilder::current(), *this);
 }
 
 RenderObject* RenderObject::nextInPreOrder() const
index 7f57d97..7c04a86 100644 (file)
@@ -93,7 +93,7 @@ void RenderRubyAsInline::styleDidChange(StyleDifference diff, const RenderStyle*
     propagateStyleToAnonymousChildren(PropagateToAllChildren);
 }
 
-RenderPtr<RenderObject> RenderRubyAsInline::takeChild(RenderObject& child)
+RenderPtr<RenderObject> RenderRubyAsInline::takeChild(RenderTreeBuilder& builder, RenderObject& child)
 {
     // If the child's parent is *this (must be a ruby run or generated content or anonymous block),
     // just use the normal remove method.
@@ -101,20 +101,20 @@ RenderPtr<RenderObject> RenderRubyAsInline::takeChild(RenderObject& child)
 #ifndef ASSERT_DISABLED
         ASSERT(isRubyChildForNormalRemoval(child));
 #endif
-        return RenderInline::takeChild(child);
+        return RenderInline::takeChild(builder, child);
     }
     // If the child's parent is an anoymous block (must be generated :before/:after content)
     // just use the block's remove method.
     if (isAnonymousRubyInlineBlock(child.parent())) {
         ASSERT(child.isBeforeContent() || child.isAfterContent());
         auto& parent = *child.parent();
-        auto takenChild = parent.takeChild(child);
+        auto takenChild = parent.takeChild(builder, child);
         parent.removeFromParentAndDestroy();
         return takenChild;
     }
 
     // Otherwise find the containing run and remove it from there.
-    return findRubyRunParent(child).takeChild(child);
+    return findRubyRunParent(child).takeChild(builder, child);
 }
 
 //=== ruby as block object ===
@@ -132,7 +132,7 @@ void RenderRubyAsBlock::styleDidChange(StyleDifference diff, const RenderStyle*
     propagateStyleToAnonymousChildren(PropagateToAllChildren);
 }
 
-RenderPtr<RenderObject> RenderRubyAsBlock::takeChild(RenderObject& child)
+RenderPtr<RenderObject> RenderRubyAsBlock::takeChild(RenderTreeBuilder& builder, RenderObject& child)
 {
     // If the child's parent is *this (must be a ruby run or generated content or anonymous block),
     // just use the normal remove method.
@@ -140,20 +140,20 @@ RenderPtr<RenderObject> RenderRubyAsBlock::takeChild(RenderObject& child)
 #ifndef ASSERT_DISABLED
         ASSERT(isRubyChildForNormalRemoval(child));
 #endif
-        return RenderBlockFlow::takeChild(child);
+        return RenderBlockFlow::takeChild(builder, child);
     }
     // If the child's parent is an anoymous block (must be generated :before/:after content)
     // just use the block's remove method.
     if (isAnonymousRubyInlineBlock(child.parent())) {
         ASSERT(child.isBeforeContent() || child.isAfterContent());
         auto& parent = *child.parent();
-        auto takenChild = parent.takeChild(child);
+        auto takenChild = parent.takeChild(builder, child);
         parent.removeFromParentAndDestroy();
         return takenChild;
     }
 
     // Otherwise find the containing run and remove it from there.
-    return findRubyRunParent(child).takeChild(child);
+    return findRubyRunParent(child).takeChild(builder, child);
 }
 
 } // namespace WebCore
index cbfc23b..cdec13a 100644 (file)
@@ -56,7 +56,7 @@ public:
     RenderRubyAsInline(Element&, RenderStyle&&);
     virtual ~RenderRubyAsInline();
 
-    RenderPtr<RenderObject> takeChild(RenderObject& child) override;
+    RenderPtr<RenderObject> takeChild(RenderTreeBuilder&, RenderObject& child) override;
 
 protected:
     void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
@@ -76,7 +76,7 @@ public:
 
     Element& element() const { return downcast<Element>(nodeForNonAnonymous()); }
 
-    RenderPtr<RenderObject> takeChild(RenderObject& child) override;
+    RenderPtr<RenderObject> takeChild(RenderTreeBuilder&, RenderObject& child) override;
 
 protected:
     void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
index 87887b8..4aea59f 100644 (file)
@@ -97,7 +97,7 @@ bool RenderRubyRun::isChildAllowed(const RenderObject& child, const RenderStyle&
     return child.isInline() || child.isRubyText();
 }
 
-RenderPtr<RenderObject> RenderRubyRun::takeChild(RenderObject& child)
+RenderPtr<RenderObject> RenderRubyRun::takeChild(RenderTreeBuilder& builder, RenderObject& child)
 {
     // If the child is a ruby text, then merge the ruby base with the base of
     // the right sibling run, if possible.
@@ -119,13 +119,13 @@ RenderPtr<RenderObject> RenderRubyRun::takeChild(RenderObject& child)
         }
     }
 
-    auto takenChild = RenderBlockFlow::takeChild(child);
+    auto takenChild = RenderBlockFlow::takeChild(builder, child);
 
     if (!beingDestroyed() && !renderTreeBeingDestroyed()) {
         // Check if our base (if any) is now empty. If so, destroy it.
         RenderBlock* base = rubyBase();
         if (base && !base->firstChild()) {
-            auto takenBase = RenderBlockFlow::takeChild(*base);
+            auto takenBase = RenderBlockFlow::takeChild(builder, *base);
             base->deleteLines();
         }
     }
index fd48e33..71d98ea 100644 (file)
@@ -56,7 +56,7 @@ public:
     void layoutBlock(bool relayoutChildren, LayoutUnit pageHeight = 0) override;
 
     bool isChildAllowed(const RenderObject&, const RenderStyle&) const override;
-    RenderPtr<RenderObject> takeChild(RenderObject&) override;
+    RenderPtr<RenderObject> takeChild(RenderTreeBuilder&, RenderObject&) override;
 
     RenderBlock* firstLineBlock() const override;
 
index bc1998c..91ca2b4 100644 (file)
@@ -95,10 +95,10 @@ void RenderSVGContainer::addChild(RenderTreeBuilder& builder, RenderPtr<RenderOb
     builder.insertChildToSVGContainer(*this, WTFMove(newChild), beforeChild);
 }
 
-RenderPtr<RenderObject> RenderSVGContainer::takeChild(RenderObject& child)
+RenderPtr<RenderObject> RenderSVGContainer::takeChild(RenderTreeBuilder& builder, RenderObject& child)
 {
     SVGResourcesCache::clientWillBeRemovedFromTree(child);
-    return RenderSVGModelObject::takeChild(child);
+    return RenderSVGModelObject::takeChild(builder, child);
 }
 
 bool RenderSVGContainer::selfWillPaint()
index 43feda1..45ad930 100644 (file)
@@ -49,7 +49,7 @@ protected:
     void layout() override;
 
     void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) final;
-    RenderPtr<RenderObject> takeChild(RenderObject&) final;
+    RenderPtr<RenderObject> takeChild(RenderTreeBuilder&, RenderObject&) final;
     void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer = 0) final;
 
     FloatRect objectBoundingBox() const final { return m_objectBoundingBox; }
index 1b2e12c..dde4fdb 100644 (file)
@@ -128,17 +128,17 @@ void RenderSVGInline::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObjec
     builder.insertChildToSVGInline(*this, WTFMove(newChild), beforeChild);
 }
 
-RenderPtr<RenderObject> RenderSVGInline::takeChild(RenderObject& child)
+RenderPtr<RenderObject> RenderSVGInline::takeChild(RenderTreeBuilder& builder, RenderObject& child)
 {
     SVGResourcesCache::clientWillBeRemovedFromTree(child);
 
     auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this);
     if (!textAncestor)
-        return RenderInline::takeChild(child);
+        return RenderInline::takeChild(builder, child);
 
     Vector<SVGTextLayoutAttributes*, 2> affectedAttributes;
     textAncestor->subtreeChildWillBeRemoved(&child, affectedAttributes);
-    auto takenChild = RenderInline::takeChild(child);
+    auto takenChild = RenderInline::takeChild(builder, child);
     textAncestor->subtreeChildWasRemoved(affectedAttributes);
     return takenChild;
 }
index 69b9d84..979a82e 100644 (file)
@@ -62,7 +62,7 @@ private:
     void styleDidChange(StyleDifference, const RenderStyle* oldStyle) final;
 
     void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> child, RenderObject* beforeChild = nullptr) final;
-    RenderPtr<RenderObject> takeChild(RenderObject&) final;
+    RenderPtr<RenderObject> takeChild(RenderTreeBuilder&, RenderObject&) final;
 };
 
 } // namespace WebCore
index 5424c72..d0c192d 100644 (file)
@@ -308,10 +308,10 @@ void RenderSVGRoot::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject>
     builder.insertChildToSVGRoot(*this, WTFMove(newChild), beforeChild);
 }
 
-RenderPtr<RenderObject> RenderSVGRoot::takeChild(RenderObject& child)
+RenderPtr<RenderObject> RenderSVGRoot::takeChild(RenderTreeBuilder& builder, RenderObject& child)
 {
     SVGResourcesCache::clientWillBeRemovedFromTree(child);
-    return RenderReplaced::takeChild(child);
+    return RenderReplaced::takeChild(builder, child);
 }
 
 // RenderBox methods will expect coordinates w/o any transforms in coordinates
index 374ed5e..786707a 100644 (file)
@@ -83,7 +83,7 @@ private:
 
     void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
     void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) override;
-    RenderPtr<RenderObject> takeChild(RenderObject&) override;
+    RenderPtr<RenderObject> takeChild(RenderTreeBuilder&, RenderObject&) override;
 
     const AffineTransform& localToParentTransform() const override;
 
index d34a59c..b431d6c 100644 (file)
@@ -525,13 +525,13 @@ void RenderSVGText::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject>
     builder.insertChildToSVGText(*this, WTFMove(newChild), beforeChild);
 }
 
-RenderPtr<RenderObject> RenderSVGText::takeChild(RenderObject& child)
+RenderPtr<RenderObject> RenderSVGText::takeChild(RenderTreeBuilder& builder, RenderObject& child)
 {
     SVGResourcesCache::clientWillBeRemovedFromTree(child);
 
     Vector<SVGTextLayoutAttributes*, 2> affectedAttributes;
     subtreeChildWillBeRemoved(&child, affectedAttributes);
-    auto takenChild = RenderSVGBlock::takeChild(child);
+    auto takenChild = RenderSVGBlock::takeChild(builder, child);
     subtreeChildWasRemoved(affectedAttributes);
     return takenChild;
 }
index 5e1ddde..127290a 100644 (file)
@@ -84,7 +84,7 @@ private:
     void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags, bool* wasFixed) const override;
     const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const override;
     void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> child, RenderObject* beforeChild = nullptr) override;
-    RenderPtr<RenderObject> takeChild(RenderObject&) override;
+    RenderPtr<RenderObject> takeChild(RenderTreeBuilder&, RenderObject&) override;
     void willBeDestroyed() override;
 
     const AffineTransform& localToParentTransform() const override { return m_localTransform; }
index 172be07..bf6ac02 100644 (file)
@@ -358,7 +358,7 @@ void RenderTreeBuilder::removeFromParentAndDestroyCleaningUpAnonymousWrappers(Re
         tableBuilder().collapseAndDestroyAnonymousSiblingRows(downcast<RenderTableRow>(destroyRoot));
 
     auto& destroyRootParent = *destroyRoot.parent();
-    destroyRootParent.removeAndDestroyChild(destroyRoot);
+    destroyRootParent.removeAndDestroyChild(*this, destroyRoot);
     destroyRootParent.removeAnonymousWrappersForInlinesIfNecessary();
 
     // Anonymous parent might have become empty, try to delete it too.
index 3feabd5..199fb17 100644 (file)
@@ -174,7 +174,7 @@ void RenderTreeBuilder::FirstLetter::updateStyle(RenderBlock& firstLetterBlock,
         while (RenderObject* child = firstLetter->firstChild()) {
             if (is<RenderText>(*child))
                 downcast<RenderText>(*child).removeAndDestroyTextBoxes();
-            auto toMove = firstLetter->takeChild(*child);
+            auto toMove = firstLetter->takeChild(m_builder, *child);
             m_builder.insertChild(*newFirstLetter, WTFMove(toMove));
         }
 
@@ -185,7 +185,7 @@ void RenderTreeBuilder::FirstLetter::updateStyle(RenderBlock& firstLetterBlock,
             remainingText->setFirstLetter(*newFirstLetter);
             newFirstLetter->setFirstLetterRemainingText(*remainingText);
         }
-        firstLetterContainer->removeAndDestroyChild(*firstLetter);
+        firstLetterContainer->removeAndDestroyChild(m_builder, *firstLetter);
         m_builder.insertChild(*firstLetterContainer, WTFMove(newFirstLetter), nextSibling);
         return;
     }
@@ -241,7 +241,7 @@ void RenderTreeBuilder::FirstLetter::createRenderers(RenderBlock& firstLetterBlo
 
         auto* textNode = currentTextChild.textNode();
         auto* beforeChild = currentTextChild.nextSibling();
-        firstLetterContainer->removeAndDestroyChild(currentTextChild);
+        firstLetterContainer->removeAndDestroyChild(m_builder, currentTextChild);
 
         // Construct a text fragment for the text after the first letter.
         // This text fragment might be empty.
index 7dd2452..b008c5a 100644 (file)
@@ -115,7 +115,7 @@ void RenderTreeBuilder::List::updateItemMarker(RenderListItem& listItemRenderer)
         return;
 
     if (currentParent)
-        m_builder.insertChild(*newParent, currentParent->takeChild(*markerRenderer), firstNonMarkerChild(*newParent));
+        m_builder.insertChild(*newParent, currentParent->takeChild(m_builder, *markerRenderer), firstNonMarkerChild(*newParent));
     else
         m_builder.insertChild(*newParent, WTFMove(newMarkerRenderer), firstNonMarkerChild(*newParent));
 
index 52c2414..d222f6e 100644 (file)
@@ -79,7 +79,7 @@ void RenderTreeBuilder::MultiColumn::createFragmentedFlow(RenderBlockFlow& flow)
             // Move the spanner back to its original position.
             auto& spannerOriginalParent = *placeholder->parent();
             // Detaching the spanner takes care of removing the placeholder (and merges the RenderMultiColumnSets).
-            auto spannerToReInsert = spanner->parent()->takeChild(*spanner);
+            auto spannerToReInsert = spanner->parent()->takeChild(m_builder, *spanner);
             m_builder.insertChild(spannerOriginalParent, WTFMove(spannerToReInsert));
         }
     }
@@ -127,7 +127,7 @@ void RenderTreeBuilder::MultiColumn::destroyFragmentedFlow(RenderBlockFlow& flow
             spannerOriginalParent = &flow;
         // Detaching the spanner takes care of removing the placeholder (and merges the RenderMultiColumnSets).
         auto* spanner = placeholder->spanner();
-        parentAndSpannerList.append(std::make_pair(spannerOriginalParent, spanner->parent()->takeChild(*spanner)));
+        parentAndSpannerList.append(std::make_pair(spannerOriginalParent, spanner->parent()->takeChild(m_builder, *spanner)));
     }
     while (auto* columnSet = multiColumnFlow.firstMultiColumnSet())
         columnSet->removeFromParentAndDestroy();
index 2ab75c5..d59967b 100644 (file)
@@ -209,7 +209,7 @@ void RenderTreeBuilder::Ruby::insertChild(RenderRubyRun& parent, RenderPtr<Rende
             // in order to avoid automatic removal of the ruby run in case there is no
             // other child besides the old ruby text.
             parent.addChild(m_builder, WTFMove(child), beforeChild);
-            auto takenBeforeChild = parent.RenderBlockFlow::takeChild(*beforeChild);
+            auto takenBeforeChild = parent.RenderBlockFlow::takeChild(m_builder, *beforeChild);
             m_builder.insertChild(*newRun, WTFMove(takenBeforeChild));
             return;
         }
index 5d83ac4..05fbb58 100644 (file)
@@ -236,7 +236,7 @@ void RenderTreeBuilder::Table::collapseAndDestroyAnonymousSiblingRows(RenderTabl
             continue;
         }
         currentRow->moveAllChildrenTo(rowToInsertInto, RenderBoxModelObject::NormalizeAfterInsertion::No);
-        auto toDestroy = section->takeChild(*currentRow);
+        auto toDestroy = section->takeChild(m_builder, *currentRow);
         currentRow = currentRow->nextRow();
     }
     if (rowToInsertInto)