Unreviewed, rolling out r225969.
authorryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Dec 2017 02:05:42 +0000 (02:05 +0000)
committerryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Dec 2017 02:05:42 +0000 (02:05 +0000)
This change introduced LayoutTest crashes.

Reverted changeset:

"Introduce RenderTreeBuilder"
https://bugs.webkit.org/show_bug.cgi?id=180817
https://trac.webkit.org/changeset/225969

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

59 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderBlockFlow.cpp
Source/WebCore/rendering/RenderBlockFlow.h
Source/WebCore/rendering/RenderBoxModelObject.cpp
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/RenderFullScreen.h
Source/WebCore/rendering/RenderGrid.cpp
Source/WebCore/rendering/RenderGrid.h
Source/WebCore/rendering/RenderInline.cpp
Source/WebCore/rendering/RenderInline.h
Source/WebCore/rendering/RenderMenuList.cpp
Source/WebCore/rendering/RenderMenuList.h
Source/WebCore/rendering/RenderMultiColumnFlow.cpp
Source/WebCore/rendering/RenderQuote.cpp
Source/WebCore/rendering/RenderQuote.h
Source/WebCore/rendering/RenderRuby.cpp
Source/WebCore/rendering/RenderRuby.h
Source/WebCore/rendering/RenderRubyBase.h
Source/WebCore/rendering/RenderRubyRun.cpp
Source/WebCore/rendering/RenderRubyRun.h
Source/WebCore/rendering/RenderTable.cpp
Source/WebCore/rendering/RenderTable.h
Source/WebCore/rendering/RenderTableRow.cpp
Source/WebCore/rendering/RenderTableRow.h
Source/WebCore/rendering/RenderTableSection.cpp
Source/WebCore/rendering/RenderTableSection.h
Source/WebCore/rendering/RenderTreeBuilder.cpp [deleted file]
Source/WebCore/rendering/RenderTreeBuilder.h [deleted file]
Source/WebCore/rendering/TextAutoSizing.cpp
Source/WebCore/rendering/mathml/RenderMathMLFenced.cpp
Source/WebCore/rendering/mathml/RenderMathMLFenced.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/style/RenderTreePosition.cpp
Source/WebCore/style/RenderTreePosition.h
Source/WebCore/style/RenderTreeUpdater.cpp
Source/WebCore/style/RenderTreeUpdater.h
Source/WebCore/style/RenderTreeUpdaterFirstLetter.cpp
Source/WebCore/style/RenderTreeUpdaterGeneratedContent.cpp
Source/WebCore/style/RenderTreeUpdaterGeneratedContent.h
Source/WebCore/style/RenderTreeUpdaterListItem.cpp
Source/WebCore/style/RenderTreeUpdaterListItem.h
Source/WebCore/style/RenderTreeUpdaterMultiColumn.cpp

index 9abe3e7..6d0b38c 100644 (file)
@@ -1,3 +1,15 @@
+2017-12-15  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r225969.
+
+        This change introduced LayoutTest crashes.
+
+        Reverted changeset:
+
+        "Introduce RenderTreeBuilder"
+        https://bugs.webkit.org/show_bug.cgi?id=180817
+        https://trac.webkit.org/changeset/225969
+
 2017-12-15  Chris Dumez  <cdumez@apple.com>
 
         Support updating a service worker registration's updateViaCache flag
index b029278..177d0de 100644 (file)
@@ -1844,7 +1844,6 @@ rendering/RenderTextFragment.cpp
 rendering/RenderTextLineBoxes.cpp
 rendering/RenderTheme.cpp
 rendering/RenderTreeAsText.cpp
-rendering/RenderTreeBuilder.cpp
 rendering/RenderVTTCue.cpp
 rendering/RenderVideo.cpp
 rendering/RenderView.cpp
index 294e07f..b8c9095 100644 (file)
                E4E9B1191810916F003ACCDF /* SimpleLineLayoutResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = E4E9B1181810916F003ACCDF /* SimpleLineLayoutResolver.h */; };
                E4E9B11D1814569C003ACCDF /* SimpleLineLayoutFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = E4E9B11C1814569C003ACCDF /* SimpleLineLayoutFunctions.h */; };
                E4F9EEF3156DA00700D23E7E /* StyleSheetContents.h in Headers */ = {isa = PBXBuildFile; fileRef = E4F9EEF1156D84C400D23E7E /* StyleSheetContents.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               E4FC009B1FE00B90006A073E /* RenderTreeBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = E4FC009A1FE00B8F006A073E /* RenderTreeBuilder.h */; };
                E5BA7D63151437CA00FE1E3F /* LengthFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = E5BA7D62151437CA00FE1E3F /* LengthFunctions.h */; settings = {ATTRIBUTES = (Private, ); }; };
                EBF5121C1696496C0056BD25 /* JSTypeConversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EBF5121A1696496C0056BD25 /* JSTypeConversions.cpp */; };
                EBF5121D1696496C0056BD25 /* JSTypeConversions.h in Headers */ = {isa = PBXBuildFile; fileRef = EBF5121B1696496C0056BD25 /* JSTypeConversions.h */; };
                7C7903B01F86F95C00463A70 /* ImageBitmapRenderingContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageBitmapRenderingContext.h; sourceTree = "<group>"; };
                7C7903B11F86F95C00463A70 /* ImageBitmapRenderingContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ImageBitmapRenderingContext.cpp; sourceTree = "<group>"; };
                7C7903B21F86F95C00463A70 /* ImageBitmapRenderingContext.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ImageBitmapRenderingContext.idl; sourceTree = "<group>"; };
-               7C7903B51F86FDE400463A70 /* JSImageBitmapRenderingContextSettings.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSImageBitmapRenderingContextSettings.cpp; sourceTree = "<group>"; };
-               7C7903B61F86FDE600463A70 /* JSImageBitmapRenderingContextSettings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSImageBitmapRenderingContextSettings.h; sourceTree = "<group>"; };
                7C7903B71F86FDE400463A70 /* JSImageBitmapRenderingContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSImageBitmapRenderingContext.cpp; sourceTree = "<group>"; };
                7C7903B81F86FDE600463A70 /* JSImageBitmapRenderingContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSImageBitmapRenderingContext.h; sourceTree = "<group>"; };
+               7C7903B51F86FDE400463A70 /* JSImageBitmapRenderingContextSettings.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSImageBitmapRenderingContextSettings.cpp; sourceTree = "<group>"; };
+               7C7903B61F86FDE600463A70 /* JSImageBitmapRenderingContextSettings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSImageBitmapRenderingContextSettings.h; sourceTree = "<group>"; };
                7C7903BA1F86FF3300463A70 /* PlaceholderRenderingContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlaceholderRenderingContext.cpp; sourceTree = "<group>"; };
                7C7903BC1F86FF3400463A70 /* PlaceholderRenderingContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlaceholderRenderingContext.h; sourceTree = "<group>"; };
                7C7941E21C56C29300A4C58E /* DataDetectorsCoreSoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DataDetectorsCoreSoftLink.mm; sourceTree = "<group>"; };
                E4E9B11C1814569C003ACCDF /* SimpleLineLayoutFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutFunctions.h; sourceTree = "<group>"; };
                E4F9EEF0156D84C400D23E7E /* StyleSheetContents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleSheetContents.cpp; sourceTree = "<group>"; };
                E4F9EEF1156D84C400D23E7E /* StyleSheetContents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleSheetContents.h; sourceTree = "<group>"; };
-               E4FC00971FE00B83006A073E /* RenderTreeBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeBuilder.cpp; sourceTree = "<group>"; };
-               E4FC009A1FE00B8F006A073E /* RenderTreeBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTreeBuilder.h; sourceTree = "<group>"; };
                E51A81DE17298D7700BFCA61 /* JSPerformance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPerformance.cpp; sourceTree = "<group>"; };
                E526AF3E1727F8F200E41781 /* Performance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Performance.cpp; sourceTree = "<group>"; };
                E55F4979151B888000BB67DB /* LengthFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LengthFunctions.cpp; sourceTree = "<group>"; };
                                BCEA4849097D93020094C9E4 /* RenderThemeMac.mm */,
                                93955A4203D72932008635CE /* RenderTreeAsText.cpp */,
                                93955A4103D72932008635CE /* RenderTreeAsText.h */,
-                               E4FC00971FE00B83006A073E /* RenderTreeBuilder.cpp */,
-                               E4FC009A1FE00B8F006A073E /* RenderTreeBuilder.h */,
                                E4B41E330CBFB60900AF2ECE /* RenderVideo.cpp */,
                                E4B41E340CBFB60900AF2ECE /* RenderVideo.h */,
                                BCEA4828097D93020094C9E4 /* RenderView.cpp */,
                                416E6FE81BBD12DF000A6043 /* ReadableByteStreamInternalsBuiltins.h in Headers */,
                                416E6FE91BBD12E5000A6043 /* ReadableStreamBuiltins.h in Headers */,
                                4129C9A91F59C56B009D7403 /* ReadableStreamDefaultController.h in Headers */,
-                               E4FC009B1FE00B90006A073E /* RenderTreeBuilder.h in Headers */,
                                416E6FE81BBD12DF000A3F64 /* ReadableStreamInternalsBuiltins.h in Headers */,
                                4129C9AF1F59CF5B009D7403 /* ReadableStreamSink.h in Headers */,
                                4129C9AB1F59C573009D7403 /* ReadableStreamSource.h in Headers */,
index 336f425..adb67c1 100644 (file)
@@ -2916,7 +2916,8 @@ static void disconnectPseudoElement(PseudoElement* pseudoElement)
 {
     if (!pseudoElement)
         return;
-    ASSERT(!pseudoElement->renderer());
+    if (pseudoElement->renderer())
+        RenderTreeUpdater::tearDownRenderers(*pseudoElement);
     ASSERT(pseudoElement->hostElement());
     pseudoElement->clearHostElement();
 }
@@ -3394,6 +3395,12 @@ void Element::resetStyleRelations()
     elementRareData()->resetStyleRelations();
 }
 
+void Element::clearStyleDerivedDataBeforeDetachingRenderer()
+{
+    clearBeforePseudoElement();
+    clearAfterPseudoElement();
+}
+
 void Element::clearHoverAndActiveStatusBeforeDetachingRenderer()
 {
     if (!isUserActionElement())
index a128d27..215c95f 100644 (file)
@@ -515,6 +515,7 @@ public:
     void clearAfterPseudoElement();
     void resetComputedStyle();
     void resetStyleRelations();
+    void clearStyleDerivedDataBeforeDetachingRenderer();
     void clearHoverAndActiveStatusBeforeDetachingRenderer();
 
     WEBCORE_EXPORT URL absoluteLinkURL() const;
index e0aec8b..f492f18 100644 (file)
@@ -61,7 +61,6 @@
 #include "RenderTableCell.h"
 #include "RenderTextFragment.h"
 #include "RenderTheme.h"
-#include "RenderTreeBuilder.h"
 #include "RenderTreePosition.h"
 #include "RenderView.h"
 #include "Settings.h"
@@ -469,7 +468,7 @@ RenderBlock* RenderBlock::continuationBefore(RenderObject* beforeChild)
     return last;
 }
 
-void RenderBlock::addChildToContinuation(RenderTreeBuilder& builder, RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
+void RenderBlock::addChildToContinuation(RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
 {
     RenderBlock* flow = continuationBefore(beforeChild);
     ASSERT(!beforeChild || is<RenderBlock>(*beforeChild->parent()));
@@ -485,7 +484,7 @@ void RenderBlock::addChildToContinuation(RenderTreeBuilder& builder, RenderPtr<R
     }
 
     if (newChild->isFloatingOrOutOfFlowPositioned()) {
-        beforeChildParent->addChildIgnoringContinuation(builder, WTFMove(newChild), beforeChild);
+        beforeChildParent->addChildIgnoringContinuation(WTFMove(newChild), beforeChild);
         return;
     }
 
@@ -494,21 +493,21 @@ void RenderBlock::addChildToContinuation(RenderTreeBuilder& builder, RenderPtr<R
     bool flowIsNormal = flow->isInline() || !flow->style().columnSpan();
 
     if (flow == beforeChildParent) {
-        flow->addChildIgnoringContinuation(builder, WTFMove(newChild), beforeChild);
+        flow->addChildIgnoringContinuation(WTFMove(newChild), beforeChild);
         return;
     }
     
     // The goal here is to match up if we can, so that we can coalesce and create the
     // minimal # of continuations needed for the inline.
     if (childIsNormal == bcpIsNormal) {
-        beforeChildParent->addChildIgnoringContinuation(builder, WTFMove(newChild), beforeChild);
+        beforeChildParent->addChildIgnoringContinuation(WTFMove(newChild), beforeChild);
         return;
     }
     if (flowIsNormal == childIsNormal) {
-        flow->addChildIgnoringContinuation(builder, WTFMove(newChild), 0); // Just treat like an append.
+        flow->addChildIgnoringContinuation(WTFMove(newChild), 0); // Just treat like an append.
         return;
     }
-    beforeChildParent->addChildIgnoringContinuation(builder, WTFMove(newChild), beforeChild);
+    beforeChildParent->addChildIgnoringContinuation(WTFMove(newChild), beforeChild);
 }
 
 RenderPtr<RenderBlock> RenderBlock::clone() const
@@ -531,15 +530,15 @@ RenderPtr<RenderBlock> RenderBlock::clone() const
     return cloneBlock;
 }
 
-void RenderBlock::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
+void RenderBlock::addChild(RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
 {
     if (continuation() && !isAnonymousBlock())
-        addChildToContinuation(builder, WTFMove(newChild), beforeChild);
+        addChildToContinuation(WTFMove(newChild), beforeChild);
     else
-        addChildIgnoringContinuation(builder, WTFMove(newChild), beforeChild);
+        addChildIgnoringContinuation(WTFMove(newChild), beforeChild);
 }
 
-void RenderBlock::addChildIgnoringContinuation(RenderTreeBuilder& builder, RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
+void RenderBlock::addChildIgnoringContinuation(RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
 {
     if (beforeChild && beforeChild->parent() != this) {
         RenderElement* beforeChildContainer = beforeChild->parent();
@@ -562,9 +561,9 @@ void RenderBlock::addChildIgnoringContinuation(RenderTreeBuilder& builder, Rende
                 ) {
                 // Insert the child into the anonymous block box instead of here.
                 if (newChild->isInline() || beforeChild->parent()->firstChild() != beforeChild)
-                    beforeChild->parent()->addChild(builder, WTFMove(newChild), beforeChild);
+                    beforeChild->parent()->addChild(WTFMove(newChild), beforeChild);
                 else
-                    addChild(builder, WTFMove(newChild), beforeChild->parent());
+                    addChild(WTFMove(newChild), beforeChild->parent());
                 return;
             }
 
@@ -572,7 +571,7 @@ void RenderBlock::addChildIgnoringContinuation(RenderTreeBuilder& builder, Rende
 
             if (newChild->isTablePart()) {
                 // Insert into the anonymous table.
-                beforeChildAnonymousContainer->addChild(builder, WTFMove(newChild), beforeChild);
+                beforeChildAnonymousContainer->addChild(WTFMove(newChild), beforeChild);
                 return;
             }
 
@@ -604,7 +603,7 @@ void RenderBlock::addChildIgnoringContinuation(RenderTreeBuilder& builder, Rende
         RenderObject* afterChild = beforeChild ? beforeChild->previousSibling() : lastChild();
 
         if (afterChild && afterChild->isAnonymousBlock()) {
-            builder.insertChild(downcast<RenderBlock>(*afterChild), WTFMove(newChild));
+            downcast<RenderBlock>(*afterChild).addChild(WTFMove(newChild));
             return;
         }
 
@@ -612,15 +611,15 @@ void RenderBlock::addChildIgnoringContinuation(RenderTreeBuilder& builder, Rende
             // No suitable existing anonymous box - create a new one.
             auto newBox = createAnonymousBlock();
             auto& box = *newBox;
-            RenderBox::addChild(builder, WTFMove(newBox), beforeChild);
-            builder.insertChild(box, WTFMove(newChild));
+            RenderBox::addChild(WTFMove(newBox), beforeChild);
+            box.addChild(WTFMove(newChild));
             return;
         }
     }
 
     invalidateLineLayoutPath();
 
-    RenderBox::addChild(builder, WTFMove(newChild), beforeChild);
+    RenderBox::addChild(WTFMove(newChild), beforeChild);
  
     if (madeBoxesNonInline && is<RenderBlock>(parent()) && isAnonymousBlock())
         downcast<RenderBlock>(*parent()).removeLeftoverAnonymousBlock(this);
index ba5bac3..de7bfc4 100644 (file)
@@ -73,7 +73,7 @@ public:
     // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow
     virtual void deleteLines();
 
-    void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> newChild, RenderObject* beforeChild = 0) override;
+    void addChild(RenderPtr<RenderObject> newChild, RenderObject* beforeChild = 0) override;
     RenderPtr<RenderObject> takeChild(RenderObject&) override;
 
     virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0);
@@ -440,8 +440,8 @@ private:
     // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow
     virtual void moveAllChildrenIncludingFloatsTo(RenderBlock& toBlock, RenderBoxModelObject::NormalizeAfterInsertion normalizeAfterInsertion) { moveAllChildrenTo(&toBlock, normalizeAfterInsertion); }
 
-    void addChildToContinuation(RenderTreeBuilder&, RenderPtr<RenderObject> newChild, RenderObject* beforeChild);
-    void addChildIgnoringContinuation(RenderTreeBuilder&, RenderPtr<RenderObject> newChild, RenderObject* beforeChild) override;
+    void addChildToContinuation(RenderPtr<RenderObject> newChild, RenderObject* beforeChild);
+    void addChildIgnoringContinuation(RenderPtr<RenderObject> newChild, RenderObject* beforeChild) override;
 
     bool isSelfCollapsingBlock() const override;
     virtual bool childrenPreventSelfCollapsing() const;
index bc8f58f..985a744 100644 (file)
@@ -48,7 +48,6 @@
 #include "RenderMultiColumnSet.h"
 #include "RenderTableCell.h"
 #include "RenderText.h"
-#include "RenderTreeBuilder.h"
 #include "RenderView.h"
 #include "Settings.h"
 #include "SimpleLineLayoutFunctions.h"
@@ -3829,14 +3828,14 @@ void RenderBlockFlow::layoutExcludedChildren(bool relayoutChildren)
     determineLogicalLeftPositionForChild(*fragmentedFlow);
 }
 
-void RenderBlockFlow::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
+void RenderBlockFlow::addChild(RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
 {
     if (multiColumnFlow() && (!isFieldset() || !newChild->isLegend()))
-        return builder.insertChild(*multiColumnFlow(), WTFMove(newChild), beforeChild);
+        return multiColumnFlow()->addChild(WTFMove(newChild), beforeChild);
     auto* beforeChildOrPlaceholder = beforeChild;
     if (auto* containingFragmentedFlow = enclosingFragmentedFlow())
         beforeChildOrPlaceholder = containingFragmentedFlow->resolveMovedChild(beforeChild);
-    RenderBlock::addChild(builder, WTFMove(newChild), beforeChildOrPlaceholder);
+    RenderBlock::addChild(WTFMove(newChild), beforeChildOrPlaceholder);
 }
 
 RenderPtr<RenderObject> RenderBlockFlow::takeChild(RenderObject& oldChild)
index 14f0970..97a9204 100644 (file)
@@ -378,7 +378,7 @@ public:
     LayoutUnit logicalHeightForChildForFragmentation(const RenderBox& child) const;
     bool hasNextPage(LayoutUnit logicalOffset, PageBoundaryRule = ExcludePageBoundary) const;
 
-    void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> newChild, RenderObject* beforeChild = 0) override;
+    void addChild(RenderPtr<RenderObject> newChild, RenderObject* beforeChild = 0) override;
     RenderPtr<RenderObject> takeChild(RenderObject&) override;
 
     void updateColumnProgressionFromStyle(RenderStyle&);
index e4f5886..a8a1120 100644 (file)
@@ -53,7 +53,6 @@
 #include "RenderTableRow.h"
 #include "RenderText.h"
 #include "RenderTextFragment.h"
-#include "RenderTreeBuilder.h"
 #include "RenderView.h"
 #include "ScrollingConstraints.h"
 #include "Settings.h"
@@ -2697,7 +2696,7 @@ void RenderBoxModelObject::moveChildTo(RenderBoxModelObject* toBoxModelObject, R
         // Takes care of adding the new child correctly if toBlock and fromBlock
         // have different kind of children (block vs inline).
         auto childToMove = takeChildInternal(*child);
-        RenderTreeBuilder::current()->insertChild(*toBoxModelObject, WTFMove(childToMove), beforeChild);
+        toBoxModelObject->addChild(WTFMove(childToMove), beforeChild);
     } else {
         auto childToMove = takeChildInternal(*child);
         toBoxModelObject->insertChildInternal(WTFMove(childToMove), beforeChild);
index df3e5c7..22dc477 100644 (file)
@@ -27,7 +27,6 @@
 #include "HTMLNames.h"
 #include "RenderTextFragment.h"
 #include "RenderTheme.h"
-#include "RenderTreeBuilder.h"
 #include "StyleInheritedData.h"
 #include <wtf/IsoMallocInlines.h>
 
@@ -63,7 +62,7 @@ bool RenderButton::hasLineIfEmpty() const
     return is<HTMLInputElement>(formControlElement());
 }
 
-void RenderButton::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
+void RenderButton::addChild(RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
 {
     if (!m_inner) {
         // Create an anonymous block.
@@ -71,9 +70,9 @@ void RenderButton::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject>
         auto newInner = createAnonymousBlock(style().display());
         updateAnonymousChildStyle(*newInner, newInner->mutableStyle());
         m_inner = makeWeakPtr(*newInner);
-        RenderFlexibleBox::addChild(builder, WTFMove(newInner));
+        RenderFlexibleBox::addChild(WTFMove(newInner));
     }    
-    builder.insertChild(*m_inner, WTFMove(newChild), beforeChild);
+    m_inner->addChild(WTFMove(newChild), beforeChild);
 }
 
 RenderPtr<RenderObject> RenderButton::takeChild(RenderObject& oldChild)
@@ -123,7 +122,7 @@ void RenderButton::setText(const String& str)
     if (!m_buttonText) {
         auto newButtonText = createRenderer<RenderTextFragment>(document(), str);
         m_buttonText = makeWeakPtr(*newButtonText);
-        RenderTreeBuilder::current()->insertChild(*this, WTFMove(newButtonText));
+        addChild(WTFMove(newButtonText));
         return;
     }
 
index 6ef043d..7d40716 100644 (file)
@@ -41,7 +41,7 @@ public:
 
     bool canBeSelectionLeaf() const override;
 
-    void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> newChild, RenderObject *beforeChild = 0) override;
+    void addChild(RenderPtr<RenderObject> newChild, RenderObject *beforeChild = 0) override;
     RenderPtr<RenderObject> takeChild(RenderObject&) override;
     void removeLeftoverAnonymousBlock(RenderBlock*) override { }
     bool createsAnonymousWrapper() const override { return true; }
index 31a3611..9d22d57 100644 (file)
@@ -66,7 +66,6 @@
 #include "RenderTableRow.h"
 #include "RenderText.h"
 #include "RenderTheme.h"
-#include "RenderTreeBuilder.h"
 #include "RenderView.h"
 #include "SVGRenderSupport.h"
 #include "Settings.h"
@@ -476,7 +475,7 @@ bool RenderElement::childRequiresTable(const RenderObject& child) const
     return false;
 }
 
-void RenderElement::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
+void RenderElement::addChild(RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
 {
     auto& child = *newChild;
     if (childRequiresTable(child)) {
@@ -485,12 +484,12 @@ void RenderElement::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject>
         if (afterChild && afterChild->isAnonymous() && is<RenderTable>(*afterChild) && !afterChild->isBeforeContent())
             table = downcast<RenderTable>(afterChild);
         else {
-            auto newTable = RenderTable::createAnonymousWithParentRenderer(*this);
+            auto newTable =  RenderTable::createAnonymousWithParentRenderer(*this);
             table = newTable.get();
-            builder.insertChild(*this, WTFMove(newTable), beforeChild);
+            addChild(WTFMove(newTable), beforeChild);
         }
 
-        builder.insertChild(*table, WTFMove(newChild));
+        table->addChild(WTFMove(newChild));
     } else
         insertChildInternal(WTFMove(newChild), beforeChild);
 
index 5e66e51..a867d2d 100644 (file)
@@ -29,7 +29,6 @@ namespace WebCore {
 
 class ControlStates;
 class RenderBlock;
-class RenderTreeBuilder;
 
 class RenderElement : public RenderObject {
     WTF_MAKE_ISO_ALLOCATED(RenderElement);
@@ -87,8 +86,8 @@ 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& builder, RenderPtr<RenderObject> newChild, RenderObject* beforeChild = nullptr) { addChild(builder, WTFMove(newChild), beforeChild); }
+    virtual void addChild(RenderPtr<RenderObject>, RenderObject* beforeChild = nullptr);
+    virtual void addChildIgnoringContinuation(RenderPtr<RenderObject> newChild, RenderObject* beforeChild = nullptr) { addChild(WTFMove(newChild), beforeChild); }
     virtual RenderPtr<RenderObject> takeChild(RenderObject&) WARN_UNUSED_RETURN;
     void removeAndDestroyChild(RenderObject&);
 
index 431a307..451d5fa 100644 (file)
@@ -31,7 +31,6 @@
 #include "RenderBlockFlow.h"
 #include "RenderLayer.h"
 #include "RenderLayerCompositor.h"
-#include "RenderTreeBuilder.h"
 #include <wtf/IsoMallocInlines.h>
 
 namespace WebCore {
@@ -94,7 +93,7 @@ static RenderStyle createFullScreenStyle()
     return fullscreenStyle;
 }
 
-RenderPtr<RenderFullScreen> RenderFullScreen::wrapNewRenderer(RenderTreeBuilder& builder, RenderPtr<RenderElement> renderer, RenderElement& parent, Document& document)
+RenderPtr<RenderFullScreen> RenderFullScreen::wrapNewRenderer(RenderPtr<RenderElement> renderer, RenderElement& parent, Document& document)
 {
     auto newFullscreenRenderer = createRenderer<RenderFullScreen>(document, createFullScreenStyle());
     newFullscreenRenderer->initializeStyle();
@@ -103,7 +102,7 @@ RenderPtr<RenderFullScreen> RenderFullScreen::wrapNewRenderer(RenderTreeBuilder&
     if (!parent.isChildAllowed(fullscreenRenderer, fullscreenRenderer.style()))
         return nullptr;
 
-    builder.insertChild(fullscreenRenderer, WTFMove(renderer));
+    fullscreenRenderer.addChild(WTFMove(renderer));
     fullscreenRenderer.setNeedsLayoutAndPrefWidthsRecalc();
 
     document.setFullScreenRenderer(&fullscreenRenderer);
@@ -113,9 +112,6 @@ RenderPtr<RenderFullScreen> RenderFullScreen::wrapNewRenderer(RenderTreeBuilder&
 
 void RenderFullScreen::wrapExistingRenderer(RenderElement& renderer, Document& document)
 {
-    // FIXME: This should be done by RenderTreeUpdater.
-    RenderTreeBuilder builder;
-
     auto newFullscreenRenderer = createRenderer<RenderFullScreen>(document, createFullScreenStyle());
     newFullscreenRenderer->initializeStyle();
 
@@ -130,7 +126,7 @@ void RenderFullScreen::wrapExistingRenderer(RenderElement& renderer, Document& d
     // the line box tree underneath our |containingBlock| is not longer valid.
     containingBlock->deleteLines();
 
-    builder.insertChild(parent, WTFMove(newFullscreenRenderer), &renderer);
+    parent.addChild(WTFMove(newFullscreenRenderer), &renderer);
 
     auto toMove = parent.takeChild(renderer);
 
@@ -140,7 +136,7 @@ void RenderFullScreen::wrapExistingRenderer(RenderElement& renderer, Document& d
     parent.setNeedsLayoutAndPrefWidthsRecalc();
     containingBlock->setNeedsLayoutAndPrefWidthsRecalc();
 
-    builder.insertChild(fullscreenRenderer, WTFMove(toMove));
+    fullscreenRenderer.addChild(WTFMove(toMove));
     fullscreenRenderer.setNeedsLayoutAndPrefWidthsRecalc();
 
     document.setFullScreenRenderer(&fullscreenRenderer);
@@ -148,8 +144,6 @@ void RenderFullScreen::wrapExistingRenderer(RenderElement& renderer, Document& d
 
 void RenderFullScreen::unwrapRenderer(bool& requiresRenderTreeRebuild)
 {
-    RenderTreeBuilder builder;
-
     requiresRenderTreeRebuild = false;
     if (parent()) {
         auto* child = firstChild();
@@ -179,7 +173,7 @@ void RenderFullScreen::unwrapRenderer(bool& requiresRenderTreeRebuild)
             if (is<RenderBox>(*child))
                 downcast<RenderBox>(*child).clearOverrideSize();
             auto childToMove = child->parent()->takeChild(*child);
-            builder.insertChild(*parent(), WTFMove(childToMove), this);
+            parent()->addChild(WTFMove(childToMove), this);
             parent()->setNeedsLayoutAndPrefWidthsRecalc();
         }
     }
@@ -210,7 +204,7 @@ void RenderFullScreen::createPlaceholder(std::unique_ptr<RenderStyle> style, con
 
     m_placeholder = makeWeakPtr(*newPlaceholder);
 
-    RenderTreeBuilder::current()->insertChild(*parent(), WTFMove(newPlaceholder), this);
+    parent()->addChild(WTFMove(newPlaceholder), this);
     parent()->setNeedsLayoutAndPrefWidthsRecalc();
 }
 
index 5f9c129..dce83ac 100644 (file)
@@ -40,7 +40,7 @@ public:
     RenderBlock* placeholder() { return m_placeholder.get(); }
     void createPlaceholder(std::unique_ptr<RenderStyle>, const LayoutRect& frameRect);
 
-    static RenderPtr<RenderFullScreen> wrapNewRenderer(RenderTreeBuilder&, RenderPtr<RenderElement>, RenderElement& parent, Document&);
+    static RenderPtr<RenderFullScreen> wrapNewRenderer(RenderPtr<RenderElement>, RenderElement& parent, Document&);
     static void wrapExistingRenderer(RenderElement&, Document&);
     void unwrapRenderer(bool& requiresRenderTreeRebuild);
 
index 7765420..c1ec915 100644 (file)
@@ -69,10 +69,10 @@ RenderGrid::RenderGrid(Element& element, RenderStyle&& style)
 
 RenderGrid::~RenderGrid() = default;
 
-void RenderGrid::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
+void RenderGrid::addChild(RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
 {
     auto& child = *newChild;
-    RenderBlock::addChild(builder, WTFMove(newChild), beforeChild);
+    RenderBlock::addChild(WTFMove(newChild), beforeChild);
 
     // 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 added.
index 2a495fd..7a303c8 100644 (file)
@@ -79,7 +79,7 @@ private:
     bool isRenderGrid() const override { return true; }
     void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const override;
 
-    void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> newChild, RenderObject* beforeChild) final;
+    void addChild(RenderPtr<RenderObject> newChild, RenderObject* beforeChild) final;
     RenderPtr<RenderObject> takeChild(RenderObject&) final;
 
     StyleSelfAlignmentData selfAlignmentForChild(GridAxis, const RenderBox&, const RenderStyle* = nullptr) const;
index 944a89a..f6fb45b 100644 (file)
@@ -42,7 +42,6 @@
 #include "RenderListMarker.h"
 #include "RenderTable.h"
 #include "RenderTheme.h"
-#include "RenderTreeBuilder.h"
 #include "RenderView.h"
 #include "Settings.h"
 #include "StyleInheritedData.h"
@@ -255,16 +254,16 @@ LayoutRect RenderInline::localCaretRect(InlineBox* inlineBox, unsigned, LayoutUn
     return caretRect;
 }
 
-void RenderInline::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
+void RenderInline::addChild(RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
 {
     auto* beforeChildOrPlaceholder = beforeChild;
     if (auto* fragmentedFlow = enclosingFragmentedFlow())
         beforeChildOrPlaceholder = fragmentedFlow->resolveMovedChild(beforeChild);
     if (continuation()) {
-        addChildToContinuation(builder, WTFMove(newChild), beforeChildOrPlaceholder);
+        addChildToContinuation(WTFMove(newChild), beforeChildOrPlaceholder);
         return;
     }
-    addChildIgnoringContinuation(builder, WTFMove(newChild), beforeChildOrPlaceholder);
+    addChildIgnoringContinuation(WTFMove(newChild), beforeChildOrPlaceholder);
 }
 
 static RenderBoxModelObject* nextContinuation(RenderObject* renderer)
@@ -305,7 +304,7 @@ static bool newChildIsInline(const RenderObject& newChild, const RenderInline& p
     return newChild.isInline() | (parent.childRequiresTable(newChild) && parent.style().display() == INLINE);
 }
 
-void RenderInline::addChildIgnoringContinuation(RenderTreeBuilder& builder, RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
+void RenderInline::addChildIgnoringContinuation(RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
 {
     // Make sure we don't append things after :after-generated content if we have it.
     if (!beforeChild && isAfterContent(lastChild()))
@@ -333,12 +332,12 @@ void RenderInline::addChildIgnoringContinuation(RenderTreeBuilder& builder, Rend
             oldContinuation->removeFromContinuationChain();
         newBox->insertIntoContinuationChainAfter(*this);
 
-        splitFlow(builder, beforeChild, WTFMove(newBox), WTFMove(newChild), oldContinuation);
+        splitFlow(beforeChild, WTFMove(newBox), WTFMove(newChild), oldContinuation);
         return;
     }
 
     auto& child = *newChild;
-    RenderBoxModelObject::addChild(builder, WTFMove(newChild), beforeChild);
+    RenderBoxModelObject::addChild(WTFMove(newChild), beforeChild);
     child.setNeedsLayoutAndPrefWidthsRecalc();
 }
 
@@ -352,7 +351,7 @@ RenderPtr<RenderInline> RenderInline::cloneAsContinuation() const
     return cloneInline;
 }
 
-void RenderInline::splitInlines(RenderTreeBuilder& builder, RenderBlock* fromBlock, RenderBlock* toBlock,
+void RenderInline::splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock,
                                 RenderBlock* middleBlock,
                                 RenderObject* beforeChild, RenderBoxModelObject* oldCont)
 {
@@ -400,7 +399,7 @@ void RenderInline::splitInlines(RenderTreeBuilder& builder, RenderBlock* fromBlo
             // every time, which is a bit wasteful.
         }
         auto childToMove = rendererToMove->parent()->takeChildInternal(*rendererToMove);
-        cloneInline->addChildIgnoringContinuation(builder, WTFMove(childToMove));
+        cloneInline->addChildIgnoringContinuation(WTFMove(childToMove));
         rendererToMove->setNeedsLayoutAndPrefWidthsRecalc();
         rendererToMove = nextSibling;
     }
@@ -428,7 +427,7 @@ void RenderInline::splitInlines(RenderTreeBuilder& builder, RenderBlock* fromBlo
             cloneInline = downcast<RenderInline>(*current).cloneAsContinuation();
 
             // Insert our child clone as the first child.
-            cloneInline->addChildIgnoringContinuation(builder, WTFMove(cloneChild));
+            cloneInline->addChildIgnoringContinuation(WTFMove(cloneChild));
 
             // Hook the clone up as a continuation of |curr|.
             cloneInline->insertIntoContinuationChainAfter(*current);
@@ -438,7 +437,7 @@ void RenderInline::splitInlines(RenderTreeBuilder& builder, RenderBlock* fromBlo
             for (auto* sibling = currentChild->nextSibling(); sibling;) {
                 auto* next = sibling->nextSibling();
                 auto childToMove = current->takeChildInternal(*sibling);
-                cloneInline->addChildIgnoringContinuation(builder, WTFMove(childToMove));
+                cloneInline->addChildIgnoringContinuation(WTFMove(childToMove));
                 sibling->setNeedsLayoutAndPrefWidthsRecalc();
                 sibling = next;
             }
@@ -467,7 +466,7 @@ void RenderInline::splitInlines(RenderTreeBuilder& builder, RenderBlock* fromBlo
     }
 }
 
-void RenderInline::splitFlow(RenderTreeBuilder& builder, RenderObject* beforeChild, RenderPtr<RenderBlock> newBlockBox, RenderPtr<RenderObject> newChild, RenderBoxModelObject* oldCont)
+void RenderInline::splitFlow(RenderObject* beforeChild, RenderPtr<RenderBlock> newBlockBox, RenderPtr<RenderObject> newChild, RenderBoxModelObject* oldCont)
 {
     auto& addedBlockBox = *newBlockBox;
     RenderBlock* pre = nullptr;
@@ -516,7 +515,7 @@ void RenderInline::splitFlow(RenderTreeBuilder& builder, RenderObject* beforeChi
         }
     }
 
-    splitInlines(builder, pre, &post, &addedBlockBox, beforeChild, oldCont);
+    splitInlines(pre, &post, &addedBlockBox, beforeChild, oldCont);
 
     // We already know the newBlockBox isn't going to contain inline kids, so avoid wasting
     // time in makeChildrenNonInline by just setting this explicitly up front.
@@ -525,7 +524,7 @@ void RenderInline::splitFlow(RenderTreeBuilder& builder, RenderObject* beforeChi
     // We delayed adding the newChild until now so that the |newBlockBox| would be fully
     // connected, thus allowing newChild access to a renderArena should it need
     // to wrap itself in additional boxes (e.g., table construction).
-    builder.insertChild(addedBlockBox, WTFMove(newChild));
+    addedBlockBox.addChild(WTFMove(newChild));
 
     // Always just do a full layout in order to ensure that line boxes (especially wrappers for images)
     // get deleted properly.  Because objects moves from the pre block into the post block, we want to
@@ -546,7 +545,7 @@ static bool canUseAsParentForContinuation(const RenderObject* renderer)
     return true;
 }
 
-void RenderInline::addChildToContinuation(RenderTreeBuilder& builder, RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
+void RenderInline::addChildToContinuation(RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
 {
     auto* flow = continuationBefore(beforeChild);
     // It may or may not be the direct parent of the beforeChild.
@@ -571,20 +570,20 @@ void RenderInline::addChildToContinuation(RenderTreeBuilder& builder, RenderPtr<
         ASSERT_NOT_REACHED();
 
     if (newChild->isFloatingOrOutOfFlowPositioned())
-        return beforeChildAncestor->addChildIgnoringContinuation(builder, WTFMove(newChild), beforeChild);
+        return beforeChildAncestor->addChildIgnoringContinuation(WTFMove(newChild), beforeChild);
 
     if (flow == beforeChildAncestor)
-        return flow->addChildIgnoringContinuation(builder, WTFMove(newChild), beforeChild);
+        return flow->addChildIgnoringContinuation(WTFMove(newChild), beforeChild);
     // A continuation always consists of two potential candidates: an inline or an anonymous
     // block box holding block children.
     bool childInline = newChildIsInline(*newChild, *this);
     // The goal here is to match up if we can, so that we can coalesce and create the
     // minimal # of continuations needed for the inline.
     if (childInline == beforeChildAncestor->isInline())
-        return beforeChildAncestor->addChildIgnoringContinuation(builder, WTFMove(newChild), beforeChild);
+        return beforeChildAncestor->addChildIgnoringContinuation(WTFMove(newChild), beforeChild);
     if (flow->isInline() == childInline)
-        return flow->addChildIgnoringContinuation(builder, WTFMove(newChild)); // Just treat like an append.
-    return beforeChildAncestor->addChildIgnoringContinuation(builder, WTFMove(newChild), beforeChild);
+        return flow->addChildIgnoringContinuation(WTFMove(newChild)); // Just treat like an append.
+    return beforeChildAncestor->addChildIgnoringContinuation(WTFMove(newChild), beforeChild);
 }
 
 void RenderInline::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
@@ -1369,7 +1368,7 @@ void RenderInline::childBecameNonInline(RenderElement& child)
     newBox->insertIntoContinuationChainAfter(*this);
     RenderObject* beforeChild = child.nextSibling();
     auto removedChild = takeChildInternal(child);
-    splitFlow(*RenderTreeBuilder::current(), beforeChild, WTFMove(newBox), WTFMove(removedChild), oldContinuation);
+    splitFlow(beforeChild, WTFMove(newBox), WTFMove(removedChild), oldContinuation);
 }
 
 void RenderInline::updateHitTestResult(HitTestResult& result, const LayoutPoint& point)
index 827f6e6..757556c 100644 (file)
@@ -37,7 +37,7 @@ public:
     RenderInline(Element&, RenderStyle&&);
     RenderInline(Document&, RenderStyle&&);
 
-    void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> newChild, RenderObject* beforeChild = 0) override;
+    void addChild(RenderPtr<RenderObject> newChild, RenderObject* beforeChild = 0) override;
 
     LayoutUnit marginLeft() const final;
     LayoutUnit marginRight() const final;
@@ -116,11 +116,11 @@ private:
     template<typename GeneratorContext>
     void generateCulledLineBoxRects(GeneratorContext& yield, const RenderInline* container) const;
 
-    void addChildToContinuation(RenderTreeBuilder&, RenderPtr<RenderObject> newChild, RenderObject* beforeChild);
-    void addChildIgnoringContinuation(RenderTreeBuilder&, RenderPtr<RenderObject> newChild, RenderObject* beforeChild = nullptr) final;
+    void addChildToContinuation(RenderPtr<RenderObject> newChild, RenderObject* beforeChild);
+    void addChildIgnoringContinuation(RenderPtr<RenderObject> newChild, RenderObject* beforeChild = nullptr) final;
 
-    void splitInlines(RenderTreeBuilder&, RenderBlock* fromBlock, RenderBlock* toBlock, RenderBlock* middleBlock, RenderObject* beforeChild, RenderBoxModelObject* oldCont);
-    void splitFlow(RenderTreeBuilder&, RenderObject* beforeChild, RenderPtr<RenderBlock> newBlockBox, RenderPtr<RenderObject> newChild, RenderBoxModelObject* oldCont);
+    void splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock, RenderBlock* middleBlock, RenderObject* beforeChild, RenderBoxModelObject* oldCont);
+    void splitFlow(RenderObject* beforeChild, RenderPtr<RenderBlock> newBlockBox, RenderPtr<RenderObject> newChild, RenderBoxModelObject* oldCont);
 
     void layout() final { ASSERT_NOT_REACHED(); } // Do nothing for layout()
 
index b60ef8b..24cd323 100644 (file)
@@ -42,7 +42,6 @@
 #include "RenderScrollbar.h"
 #include "RenderText.h"
 #include "RenderTheme.h"
-#include "RenderTreeBuilder.h"
 #include "RenderView.h"
 #include "StyleResolver.h"
 #include "TextRun.h"
@@ -113,7 +112,7 @@ void RenderMenuList::createInnerBlock()
     auto newInnerBlock = createAnonymousBlock();
     m_innerBlock = makeWeakPtr(*newInnerBlock.get());
     adjustInnerStyle();
-    RenderFlexibleBox::addChild(*RenderTreeBuilder::current(), WTFMove(newInnerBlock));
+    RenderFlexibleBox::addChild(WTFMove(newInnerBlock));
 }
 
 void RenderMenuList::adjustInnerStyle()
@@ -175,11 +174,11 @@ HTMLSelectElement& RenderMenuList::selectElement() const
     return downcast<HTMLSelectElement>(nodeForNonAnonymous());
 }
 
-void RenderMenuList::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
+void RenderMenuList::addChild(RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
 {
     createInnerBlock();
     auto& child = *newChild;
-    builder.insertChild(*m_innerBlock, WTFMove(newChild), beforeChild);
+    m_innerBlock->addChild(WTFMove(newChild), beforeChild);
     ASSERT(m_innerBlock == firstChild());
 
     if (AXObjectCache* cache = document().existingAXObjectCache())
@@ -299,7 +298,7 @@ void RenderMenuList::setText(const String& s)
     else {
         auto newButtonText = createRenderer<RenderText>(document(), textToUse);
         m_buttonText = makeWeakPtr(*newButtonText);
-        RenderTreeBuilder::current()->insertChild(*this, WTFMove(newButtonText));
+        addChild(WTFMove(newButtonText));
     }
 
     adjustInnerStyle();
index acf60aa..3b16cc5 100644 (file)
@@ -66,7 +66,7 @@ private:
 
     bool isMenuList() const override { return true; }
 
-    void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> newChild, RenderObject* beforeChild = 0) override;
+    void addChild(RenderPtr<RenderObject> newChild, RenderObject* beforeChild = 0) override;
     RenderPtr<RenderObject> takeChild(RenderObject&) override;
     bool createsAnonymousWrapper() const override { return true; }
 
index c274812..a374224 100644 (file)
@@ -31,7 +31,6 @@
 #include "RenderIterator.h"
 #include "RenderMultiColumnSet.h"
 #include "RenderMultiColumnSpannerPlaceholder.h"
-#include "RenderTreeBuilder.h"
 #include "RenderView.h"
 #include "TransformState.h"
 #include <wtf/IsoMallocInlines.h>
@@ -293,12 +292,12 @@ RenderObject* RenderMultiColumnFlow::processPossibleSpannerDescendant(RenderObje
         // end flowing one column set and move to the next one.
         auto newPlaceholder = RenderMultiColumnSpannerPlaceholder::createAnonymous(*this, downcast<RenderBox>(descendant), container->style());
         auto& placeholder = *newPlaceholder;
-        RenderTreeBuilder::current()->insertChild(*container, WTFMove(newPlaceholder), descendant.nextSibling());
+        container->addChild(WTFMove(newPlaceholder), descendant.nextSibling());
         auto takenDescendant = container->takeChild(descendant);
         
         // This is a guard to stop an ancestor flow thread from processing the spanner.
         gShiftingSpanner = true;
-        multicolContainer->RenderBlock::addChild(*RenderTreeBuilder::current(), WTFMove(takenDescendant), insertBeforeMulticolChild);
+        multicolContainer->RenderBlock::addChild(WTFMove(takenDescendant), insertBeforeMulticolChild);
         gShiftingSpanner = false;
         
         // The spanner has now been moved out from the flow thread, but we don't want to
@@ -335,7 +334,7 @@ RenderObject* RenderMultiColumnFlow::processPossibleSpannerDescendant(RenderObje
     auto newSet = createRenderer<RenderMultiColumnSet>(*this, RenderStyle::createAnonymousStyleWithDisplay(multicolContainer->style(), BLOCK));
     newSet->initializeStyle();
     auto& set = *newSet;
-    multicolContainer->RenderBlock::addChild(*RenderTreeBuilder::current(), WTFMove(newSet), insertBeforeMulticolChild);
+    multicolContainer->RenderBlock::addChild(WTFMove(newSet), insertBeforeMulticolChild);
     invalidateFragments();
 
     // We cannot handle immediate column set siblings at the moment (and there's no need for
index 797318e..dd02ec3 100644 (file)
 
 #include "QuotesData.h"
 #include "RenderTextFragment.h"
-#include "RenderTreeBuilder.h"
 #include "RenderView.h"
 #include <wtf/IsoMallocInlines.h>
 #include <wtf/unicode/CharacterNames.h>
 
+
 namespace WebCore {
 using namespace WTF::Unicode;
 
@@ -350,7 +350,7 @@ static RenderTextFragment* quoteTextRenderer(RenderObject* lastChild)
     return downcast<RenderTextFragment>(lastChild);
 }
 
-void RenderQuote::updateTextRenderer(RenderTreeBuilder& builder)
+void RenderQuote::updateTextRenderer()
 {
     ASSERT_WITH_SECURITY_IMPLICATION(document().inRenderTreeUpdate());
     String text = computeText();
@@ -362,7 +362,7 @@ void RenderQuote::updateTextRenderer(RenderTreeBuilder& builder)
         renderText->dirtyLineBoxes(false);
         return;
     }
-    builder.insertChild(*this, createRenderer<RenderTextFragment>(document(), m_text));
+    addChild(createRenderer<RenderTextFragment>(document(), m_text));
 }
 
 String RenderQuote::computeText() const
@@ -403,7 +403,7 @@ bool RenderQuote::isOpen() const
     return false;
 }
 
-void RenderQuote::updateRenderer(RenderTreeBuilder& builder, RenderQuote* previousQuote)
+void RenderQuote::updateRenderer(RenderQuote* previousQuote)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(document().inRenderTreeUpdate());
     int depth = -1;
@@ -423,7 +423,7 @@ void RenderQuote::updateRenderer(RenderTreeBuilder& builder, RenderQuote* previo
 
     m_depth = depth;
     m_needsTextUpdate = false;
-    updateTextRenderer(builder);
+    updateTextRenderer();
 }
 
 } // namespace WebCore
index ad18782..50e956f 100644 (file)
@@ -32,7 +32,7 @@ public:
     RenderQuote(Document&, RenderStyle&&, QuoteType);
     virtual ~RenderQuote();
 
-    void updateRenderer(RenderTreeBuilder&, RenderQuote* previousQuote);
+    void updateRenderer(RenderQuote* previousQuote);
 
 private:
     const char* renderName() const override { return "RenderQuote"; }
@@ -43,7 +43,7 @@ private:
     void willBeRemovedFromTree() override;
 
     String computeText() const;
-    void updateTextRenderer(RenderTreeBuilder&);
+    void updateTextRenderer();
 
     const QuoteType m_type;
     int m_depth { -1 };
index c5dff07..518c0bd 100644 (file)
@@ -35,7 +35,6 @@
 #include "RenderIterator.h"
 #include "RenderRubyRun.h"
 #include "RenderStyle.h"
-#include "RenderTreeBuilder.h"
 #include "StyleInheritedData.h"
 #include <wtf/IsoMallocInlines.h>
 #include <wtf/RefPtr.h>
@@ -140,45 +139,45 @@ void RenderRubyAsInline::styleDidChange(StyleDifference diff, const RenderStyle*
     propagateStyleToAnonymousChildren(PropagateToAllChildren);
 }
 
-void RenderRubyAsInline::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> child, RenderObject* beforeChild)
+void RenderRubyAsInline::addChild(RenderPtr<RenderObject> child, RenderObject* beforeChild)
 {
     // Insert :before and :after content before/after the RenderRubyRun(s)
     if (child->isBeforeContent()) {
         if (child->isInline()) {
             // Add generated inline content normally
-            RenderInline::addChild(builder, WTFMove(child), firstChild());
+            RenderInline::addChild(WTFMove(child), firstChild());
         } else {
             // Wrap non-inline content with an anonymous inline-block.
             RenderBlock* beforeBlock = rubyBeforeBlock(this);
             if (!beforeBlock) {
                 auto newBlock = createAnonymousRubyInlineBlock(*this);
                 beforeBlock = newBlock.get();
-                RenderInline::addChild(builder, WTFMove(newBlock), firstChild());
+                RenderInline::addChild(WTFMove(newBlock), firstChild());
             }
-            builder.insertChild(*beforeBlock, WTFMove(child));
+            beforeBlock->addChild(WTFMove(child));
         }
         return;
     }
     if (child->isAfterContent()) {
         if (child->isInline()) {
             // Add generated inline content normally
-            RenderInline::addChild(builder, WTFMove(child));
+            RenderInline::addChild(WTFMove(child));
         } else {
             // Wrap non-inline content with an anonymous inline-block.
             RenderBlock* afterBlock = rubyAfterBlock(this);
             if (!afterBlock) {
                 auto newBlock = createAnonymousRubyInlineBlock(*this);
                 afterBlock = newBlock.get();
-                RenderInline::addChild(builder, WTFMove(newBlock));
+                RenderInline::addChild(WTFMove(newBlock));
             }
-            builder.insertChild(*afterBlock, WTFMove(child));
+            afterBlock->addChild(WTFMove(child));
         }
         return;
     }
 
     // If the child is a ruby run, just add it normally.
     if (child->isRubyRun()) {
-        RenderInline::addChild(builder, WTFMove(child), beforeChild);
+        RenderInline::addChild(WTFMove(child), beforeChild);
         return;
     }
 
@@ -189,7 +188,7 @@ void RenderRubyAsInline::addChild(RenderTreeBuilder& builder, RenderPtr<RenderOb
         while (run && !run->isRubyRun())
             run = run->parent();
         if (run) {
-            builder.insertChild(*run, WTFMove(child), beforeChild);
+            run->addChild(WTFMove(child), beforeChild);
             return;
         }
         ASSERT_NOT_REACHED(); // beforeChild should always have a run as parent!
@@ -203,9 +202,9 @@ void RenderRubyAsInline::addChild(RenderTreeBuilder& builder, RenderPtr<RenderOb
     if (!lastRun || lastRun->hasRubyText()) {
         auto newRun = RenderRubyRun::staticCreateRubyRun(this);
         lastRun = newRun.get();
-        RenderInline::addChild(builder, WTFMove(newRun), beforeChild);
+        RenderInline::addChild(WTFMove(newRun), beforeChild);
     }
-    builder.insertChild(*lastRun, WTFMove(child));
+    lastRun->addChild(WTFMove(child));
 }
 
 RenderPtr<RenderObject> RenderRubyAsInline::takeChild(RenderObject& child)
@@ -247,45 +246,45 @@ void RenderRubyAsBlock::styleDidChange(StyleDifference diff, const RenderStyle*
     propagateStyleToAnonymousChildren(PropagateToAllChildren);
 }
 
-void RenderRubyAsBlock::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> child, RenderObject* beforeChild)
+void RenderRubyAsBlock::addChild(RenderPtr<RenderObject> child, RenderObject* beforeChild)
 {
     // Insert :before and :after content before/after the RenderRubyRun(s)
     if (child->isBeforeContent()) {
         if (child->isInline()) {
             // Add generated inline content normally
-            RenderBlockFlow::addChild(builder, WTFMove(child), firstChild());
+            RenderBlockFlow::addChild(WTFMove(child), firstChild());
         } else {
             // Wrap non-inline content with an anonymous inline-block.
             RenderBlock* beforeBlock = rubyBeforeBlock(this);
             if (!beforeBlock) {
                 auto newBlock = createAnonymousRubyInlineBlock(*this);
                 beforeBlock = newBlock.get();
-                RenderBlockFlow::addChild(builder, WTFMove(newBlock), firstChild());
+                RenderBlockFlow::addChild(WTFMove(newBlock), firstChild());
             }
-            builder.insertChild(*beforeBlock, WTFMove(child));
+            beforeBlock->addChild(WTFMove(child));
         }
         return;
     }
     if (child->isAfterContent()) {
         if (child->isInline()) {
             // Add generated inline content normally
-            RenderBlockFlow::addChild(builder, WTFMove(child));
+            RenderBlockFlow::addChild(WTFMove(child));
         } else {
             // Wrap non-inline content with an anonymous inline-block.
             RenderBlock* afterBlock = rubyAfterBlock(this);
             if (!afterBlock) {
                 auto newBlock = createAnonymousRubyInlineBlock(*this);
                 afterBlock = newBlock.get();
-                RenderBlockFlow::addChild(builder, WTFMove(newBlock));
+                RenderBlockFlow::addChild(WTFMove(newBlock));
             }
-            builder.insertChild(*afterBlock, WTFMove(child));
+            afterBlock->addChild(WTFMove(child));
         }
         return;
     }
 
     // If the child is a ruby run, just add it normally.
     if (child->isRubyRun()) {
-        RenderBlockFlow::addChild(builder, WTFMove(child), beforeChild);
+        RenderBlockFlow::addChild(WTFMove(child), beforeChild);
         return;
     }
 
@@ -296,7 +295,7 @@ void RenderRubyAsBlock::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObj
         while (run && !run->isRubyRun())
             run = run->parent();
         if (run) {
-            builder.insertChild(*run, WTFMove(child), beforeChild);
+            run->addChild(WTFMove(child), beforeChild);
             return;
         }
         ASSERT_NOT_REACHED(); // beforeChild should always have a run as parent!
@@ -310,9 +309,9 @@ void RenderRubyAsBlock::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObj
     if (!lastRun || lastRun->hasRubyText()) {
         auto newRun = RenderRubyRun::staticCreateRubyRun(this);
         lastRun = newRun.get();
-        RenderBlockFlow::addChild(builder, WTFMove(newRun), beforeChild);
+        RenderBlockFlow::addChild(WTFMove(newRun), beforeChild);
     }
-    builder.insertChild(*lastRun, WTFMove(child));
+    lastRun->addChild(WTFMove(child));
 }
 
 RenderPtr<RenderObject> RenderRubyAsBlock::takeChild(RenderObject& child)
index 19c195e..a53b59c 100644 (file)
@@ -56,7 +56,7 @@ public:
     RenderRubyAsInline(Element&, RenderStyle&&);
     virtual ~RenderRubyAsInline();
 
-    void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) override;
+    void addChild(RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) override;
     RenderPtr<RenderObject> takeChild(RenderObject& child) override;
 
 protected:
@@ -77,7 +77,7 @@ public:
 
     Element& element() const { return downcast<Element>(nodeForNonAnonymous()); }
 
-    void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) override;
+    void addChild(RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) override;
     RenderPtr<RenderObject> takeChild(RenderObject& child) override;
 
 protected:
index 8e402bb..92212bb 100644 (file)
@@ -59,8 +59,6 @@ public:
     
     void cachePriorCharactersIfNeeded(const LazyLineBreakIterator&) override;
 
-    void moveChildren(RenderRubyBase* toBase, RenderObject* beforeChild = 0);
-
 private:
     bool isRubyBase() const override { return true; }
     bool isChildAllowed(const RenderObject&, const RenderStyle&) const override;
@@ -68,6 +66,7 @@ private:
     void adjustInlineDirectionLineBounds(int expansionOpportunityCount, float& logicalLeft, float& logicalWidth) const override;
     void mergeChildrenWithBase(RenderRubyBase& toBlock);
 
+    void moveChildren(RenderRubyBase* toBase, RenderObject* beforeChild = 0);
     void moveInlineChildren(RenderRubyBase* toBase, RenderObject* beforeChild = 0);
     void moveBlockChildren(RenderRubyBase* toBase, RenderObject* beforeChild = 0);
 
index f1b0024..7d5cd35 100644 (file)
@@ -93,7 +93,7 @@ RenderRubyBase* RenderRubyRun::rubyBaseSafe()
     if (!base) {
         auto newBase = createRubyBase();
         base = newBase.get();
-        RenderBlockFlow::addChild(*RenderTreeBuilder::current(), WTFMove(newBase));
+        RenderBlockFlow::addChild(WTFMove(newBase));
     }
     return base;
 }
@@ -108,6 +108,51 @@ bool RenderRubyRun::isChildAllowed(const RenderObject& child, const RenderStyle&
     return child.isInline() || child.isRubyText();
 }
 
+void RenderRubyRun::addChild(RenderPtr<RenderObject> child, RenderObject* beforeChild)
+{
+    ASSERT(child);
+
+    if (child->isRubyText()) {
+        if (!beforeChild) {
+            // RenderRuby has already ascertained that we can add the child here.
+            ASSERT(!hasRubyText());
+            // prepend ruby texts as first child
+            RenderBlockFlow::addChild(WTFMove(child), firstChild());
+        }  else if (beforeChild->isRubyText()) {
+            // New text is inserted just before another.
+            // In this case the new text takes the place of the old one, and
+            // the old text goes into a new run that is inserted as next sibling.
+            ASSERT(beforeChild->parent() == this);
+            RenderElement* ruby = parent();
+            ASSERT(isRuby(ruby));
+            auto newRun = staticCreateRubyRun(ruby);
+            ruby->addChild(WTFMove(newRun), nextSibling());
+            // Add the new ruby text and move the old one to the new run
+            // Note: Doing it in this order and not using RenderRubyRun's methods,
+            // in order to avoid automatic removal of the ruby run in case there is no
+            // other child besides the old ruby text.
+            RenderBlockFlow::addChild(WTFMove(child), beforeChild);
+            auto takenBeforeChild = RenderBlockFlow::takeChild(*beforeChild);
+            newRun->addChild(WTFMove(takenBeforeChild));
+        } else if (hasRubyBase()) {
+            // Insertion before a ruby base object.
+            // In this case we need insert a new run before the current one and split the base.
+            RenderElement* ruby = parent();
+            auto newRun = staticCreateRubyRun(ruby);
+            auto& run = *newRun;
+            ruby->addChild(WTFMove(newRun), this);
+            run.addChild(WTFMove(child));
+            rubyBaseSafe()->moveChildren(run.rubyBaseSafe(), beforeChild);
+        }
+    } else {
+        // child is not a text -> insert it into the base
+        // (append it instead if beforeChild is the ruby text)
+        if (beforeChild && beforeChild->isRubyText())
+            beforeChild = 0;
+        rubyBaseSafe()->addChild(WTFMove(child), beforeChild);
+    }
+}
+
 RenderPtr<RenderObject> RenderRubyRun::takeChild(RenderObject& child)
 {
     // If the child is a ruby text, then merge the ruby base with the base of
index e26f14b..febf3c3 100644 (file)
@@ -57,6 +57,7 @@ public:
     void layoutBlock(bool relayoutChildren, LayoutUnit pageHeight = 0) override;
 
     bool isChildAllowed(const RenderObject&, const RenderStyle&) const override;
+    void addChild(RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) override;
     RenderPtr<RenderObject> takeChild(RenderObject&) override;
 
     RenderBlock* firstLineBlock() const override;
index c21b9af..5bda411 100644 (file)
@@ -45,7 +45,6 @@
 #include "RenderTableCell.h"
 #include "RenderTableCol.h"
 #include "RenderTableSection.h"
-#include "RenderTreeBuilder.h"
 #include "RenderView.h"
 #include "StyleInheritedData.h"
 #include <wtf/IsoMallocInlines.h>
@@ -133,7 +132,7 @@ static inline void resetSectionPointerIfNotBefore(WeakPtr<RenderTableSection>& s
         section.clear();
 }
 
-void RenderTable::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> child, RenderObject* beforeChild)
+void RenderTable::addChild(RenderPtr<RenderObject> child, RenderObject* beforeChild)
 {
     bool wrapInAnonymousSection = !child->isOutOfFlowPositioned();
 
@@ -184,19 +183,19 @@ void RenderTable::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> c
         if (beforeChild && beforeChild->parent() != this)
             beforeChild = splitAnonymousBoxesAroundChild(beforeChild);
 
-        RenderBox::addChild(builder, WTFMove(child), beforeChild);
+        RenderBox::addChild(WTFMove(child), beforeChild);
         return;
     }
 
     if (!beforeChild && is<RenderTableSection>(lastChild()) && lastChild()->isAnonymous() && !lastChild()->isBeforeContent()) {
-        builder.insertChild(downcast<RenderTableSection>(*lastChild()), WTFMove(child));
+        downcast<RenderTableSection>(*lastChild()).addChild(WTFMove(child));
         return;
     }
 
     if (beforeChild && !beforeChild->isAnonymous() && beforeChild->parent() == this) {
         RenderObject* section = beforeChild->previousSibling();
         if (is<RenderTableSection>(section) && section->isAnonymous()) {
-            builder.insertChild(downcast<RenderTableSection>(*section), WTFMove(child));
+            downcast<RenderTableSection>(*section).addChild(WTFMove(child));
             return;
         }
     }
@@ -208,7 +207,7 @@ void RenderTable::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> c
         RenderTableSection& section = downcast<RenderTableSection>(*lastBox);
         if (beforeChild == &section)
             beforeChild = section.firstRow();
-        builder.insertChild(section, WTFMove(child), beforeChild);
+        section.addChild(WTFMove(child), beforeChild);
         return;
     }
 
@@ -217,8 +216,8 @@ void RenderTable::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> c
 
     auto newSection = RenderTableSection::createAnonymousWithParentRenderer(*this);
     auto& section = *newSection;
-    builder.insertChild(*this, WTFMove(newSection), beforeChild);
-    builder.insertChild(section, WTFMove(child));
+    addChild(WTFMove(newSection), beforeChild);
+    section.addChild(WTFMove(child));
 }
 
 void RenderTable::addCaption(RenderTableCaption& caption)
index 40c6c8a..01ccc5d 100644 (file)
@@ -127,7 +127,7 @@ public:
     LayoutUnit calcBorderEnd() const;
     void recalcBordersInRowDirection();
 
-    void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) final;
+    void addChild(RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) final;
 
     struct ColumnStruct {
         explicit ColumnStruct(unsigned initialSpan = 1)
index 05a493e..ef22379 100644 (file)
@@ -31,7 +31,6 @@
 #include "LayoutState.h"
 #include "PaintInfo.h"
 #include "RenderTableCell.h"
-#include "RenderTreeBuilder.h"
 #include "RenderView.h"
 #include "StyleInheritedData.h"
 #include <wtf/IsoMallocInlines.h>
@@ -111,7 +110,7 @@ const BorderValue& RenderTableRow::borderAdjoiningEndCell(const RenderTableCell&
     return style().borderEnd();
 }
 
-void RenderTableRow::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> child, RenderObject* beforeChild)
+void RenderTableRow::addChild(RenderPtr<RenderObject> child, RenderObject* beforeChild)
 {
     if (!is<RenderTableCell>(*child)) {
         RenderObject* last = beforeChild;
@@ -121,14 +120,14 @@ void RenderTableRow::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject
             RenderTableCell& cell = downcast<RenderTableCell>(*last);
             if (beforeChild == &cell)
                 beforeChild = cell.firstChild();
-            builder.insertChild(cell, WTFMove(child), beforeChild);
+            cell.addChild(WTFMove(child), beforeChild);
             return;
         }
 
         if (beforeChild && !beforeChild->isAnonymous() && beforeChild->parent() == this) {
             RenderObject* cell = beforeChild->previousSibling();
             if (is<RenderTableCell>(cell) && cell->isAnonymous()) {
-                builder.insertChild(downcast<RenderTableCell>(*cell), WTFMove(child));
+                downcast<RenderTableCell>(*cell).addChild(WTFMove(child));
                 return;
             }
         }
@@ -137,7 +136,7 @@ void RenderTableRow::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject
         if (last && last->parent() && last->parent()->isAnonymous() && !last->parent()->isBeforeOrAfterContent()) {
             // If beforeChild is inside an anonymous cell, insert into the cell.
             if (!is<RenderTableCell>(*last)) {
-                builder.insertChild(*last->parent(), WTFMove(child), beforeChild);
+                last->parent()->addChild(WTFMove(child), beforeChild);
                 return;
             }
             // If beforeChild is inside an anonymous row, insert into the row.
@@ -145,15 +144,15 @@ void RenderTableRow::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject
             if (is<RenderTableRow>(parent)) {
                 auto newCell = RenderTableCell::createAnonymousWithParentRenderer(*this);
                 auto& cell = *newCell;
-                builder.insertChild(parent, WTFMove(newCell), beforeChild);
-                builder.insertChild(cell, WTFMove(child));
+                parent.addChild(WTFMove(newCell), beforeChild);
+                cell.addChild(WTFMove(child));
                 return;
             }
         }
         auto newCell = RenderTableCell::createAnonymousWithParentRenderer(*this);
         auto& cell = *newCell;
-        builder.insertChild(*this, WTFMove(newCell), beforeChild);
-        builder.insertChild(cell, WTFMove(child));
+        addChild(WTFMove(newCell), beforeChild);
+        cell.addChild(WTFMove(child));
         return;
     } 
 
@@ -167,7 +166,7 @@ void RenderTableRow::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject
         section->addCell(&cell, this);
 
     ASSERT(!beforeChild || is<RenderTableCell>(*beforeChild));
-    RenderBox::addChild(builder, WTFMove(child), beforeChild);
+    RenderBox::addChild(WTFMove(child), beforeChild);
 
     if (beforeChild || nextRow())
         section()->setNeedsCellRecalc();
index 8dbff55..9e54771 100644 (file)
@@ -59,7 +59,7 @@ public:
     const BorderValue& borderAdjoiningStartCell(const RenderTableCell&) const;
     const BorderValue& borderAdjoiningEndCell(const RenderTableCell&) const;
 
-    void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) override;
+    void addChild(RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) override;
 
     bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override;
 
index 3a465f8..810b032 100644 (file)
@@ -35,7 +35,6 @@
 #include "RenderTableCol.h"
 #include "RenderTableRow.h"
 #include "RenderTextControl.h"
-#include "RenderTreeBuilder.h"
 #include "RenderView.h"
 #include "StyleInheritedData.h"
 #include <limits>
@@ -121,7 +120,7 @@ void RenderTableSection::willBeRemovedFromTree()
     setNeedsCellRecalc();
 }
 
-void RenderTableSection::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> child, RenderObject* beforeChild)
+void RenderTableSection::addChild(RenderPtr<RenderObject> child, RenderObject* beforeChild)
 {
     if (!is<RenderTableRow>(*child)) {
         RenderObject* last = beforeChild;
@@ -131,14 +130,14 @@ void RenderTableSection::addChild(RenderTreeBuilder& builder, RenderPtr<RenderOb
             RenderTableRow& row = downcast<RenderTableRow>(*last);
             if (beforeChild == &row)
                 beforeChild = row.firstCell();
-            builder.insertChild(row, WTFMove(child), beforeChild);
+            row.addChild(WTFMove(child), beforeChild);
             return;
         }
 
         if (beforeChild && !beforeChild->isAnonymous() && beforeChild->parent() == this) {
             RenderObject* row = beforeChild->previousSibling();
             if (is<RenderTableRow>(row) && row->isAnonymous()) {
-                builder.insertChild(downcast<RenderTableRow>(*row), WTFMove(child));
+                downcast<RenderTableRow>(*row).addChild(WTFMove(child));
                 return;
             }
         }
@@ -149,14 +148,14 @@ void RenderTableSection::addChild(RenderTreeBuilder& builder, RenderPtr<RenderOb
         while (lastBox && lastBox->parent()->isAnonymous() && !is<RenderTableRow>(*lastBox))
             lastBox = lastBox->parent();
         if (is<RenderTableRow>(lastBox) && lastBox->isAnonymous() && !lastBox->isBeforeOrAfterContent()) {
-            builder.insertChild(downcast<RenderTableRow>(*lastBox), WTFMove(child), beforeChild);
+            downcast<RenderTableRow>(*lastBox).addChild(WTFMove(child), beforeChild);
             return;
         }
 
         auto newRow = RenderTableRow::createAnonymousWithParentRenderer(*this);
         auto& row = *newRow;
-        builder.insertChild(*this, WTFMove(newRow), beforeChild);
-        builder.insertChild(row, WTFMove(child));
+        addChild(WTFMove(newRow), beforeChild);
+        row.addChild(WTFMove(child));
         return;
     }
 
@@ -180,7 +179,7 @@ void RenderTableSection::addChild(RenderTreeBuilder& builder, RenderPtr<RenderOb
         beforeChild = splitAnonymousBoxesAroundChild(beforeChild);
 
     ASSERT(!beforeChild || is<RenderTableRow>(*beforeChild));
-    RenderBox::addChild(builder, WTFMove(child), beforeChild);
+    RenderBox::addChild(WTFMove(child), beforeChild);
 }
 
 void RenderTableSection::ensureRows(unsigned numRows)
index 037d804..1ce473e 100644 (file)
@@ -62,7 +62,7 @@ public:
     RenderTableRow* firstRow() const;
     RenderTableRow* lastRow() const;
 
-    void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) override;
+    void addChild(RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) override;
 
     std::optional<int> firstLineBaseline() const override;
 
diff --git a/Source/WebCore/rendering/RenderTreeBuilder.cpp b/Source/WebCore/rendering/RenderTreeBuilder.cpp
deleted file mode 100644 (file)
index 25c6ced..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "RenderTreeBuilder.h"
-
-#include "RenderElement.h"
-#include "RenderRuby.h"
-#include "RenderRubyBase.h"
-#include "RenderRubyRun.h"
-#include "RenderText.h"
-#include "RenderTreeUpdater.h"
-
-namespace WebCore {
-
-RenderTreeBuilder* RenderTreeBuilder::m_current;
-
-RenderTreeBuilder::RenderTreeBuilder()
-{
-    RELEASE_ASSERT(!m_current);
-    m_current = this;
-}
-
-RenderTreeBuilder::~RenderTreeBuilder()
-{
-    m_current = nullptr;
-}
-
-void RenderTreeBuilder::insertChild(RenderElement& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
-{
-    // We don't yet have any local access, ensure we are still called with non-null this ptr.
-    ASSERT(this);
-
-    if (is<RenderText>(beforeChild)) {
-        if (auto* wrapperInline = downcast<RenderText>(*beforeChild).inlineWrapperForDisplayContents())
-            beforeChild = wrapperInline;
-    }
-
-    if (is<RenderRubyRun>(parent)) {
-        rubyRunInsertChild(downcast<RenderRubyRun>(parent), WTFMove(child), beforeChild);
-        return;
-    }
-
-    parent.addChild(*this, WTFMove(child), beforeChild);
-}
-
-void RenderTreeBuilder::insertChild(RenderTreePosition& position, RenderPtr<RenderObject> child)
-{
-    insertChild(position.parent(), WTFMove(child), position.nextSibling());
-}
-
-void RenderTreeBuilder::rubyRunInsertChild(RenderRubyRun& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
-{
-    if (child->isRubyText()) {
-        if (!beforeChild) {
-            // RenderRuby has already ascertained that we can add the child here.
-            ASSERT(!parent.hasRubyText());
-            // prepend ruby texts as first child
-            parent.addChild(*this, WTFMove(child), parent.firstChild());
-            return;
-        }
-        if (beforeChild->isRubyText()) {
-            // New text is inserted just before another.
-            // In this case the new text takes the place of the old one, and
-            // the old text goes into a new run that is inserted as next sibling.
-            ASSERT(beforeChild->parent() == &parent);
-            RenderElement* ruby = parent.parent();
-            ASSERT(isRuby(ruby));
-            auto newRun = RenderRubyRun::staticCreateRubyRun(ruby);
-            insertChild(*ruby, WTFMove(newRun), parent.nextSibling());
-            // Add the new ruby text and move the old one to the new run
-            // Note: Doing it in this order and not using RenderRubyRun's methods,
-            // in order to avoid automatic removal of the ruby run in case there is no
-            // other child besides the old ruby text.
-            parent.addChild(*this, WTFMove(child), beforeChild);
-            auto takenBeforeChild = parent.RenderBlockFlow::takeChild(*beforeChild);
-            insertChild(*newRun, WTFMove(takenBeforeChild));
-            return;
-        }
-        if (parent.hasRubyBase()) {
-            // Insertion before a ruby base object.
-            // In this case we need insert a new run before the current one and split the base.
-            RenderElement* ruby = parent.parent();
-            auto newRun = RenderRubyRun::staticCreateRubyRun(ruby);
-            auto& run = *newRun;
-            insertChild(*ruby, WTFMove(newRun), &parent);
-            insertChild(run, WTFMove(child));
-            parent.rubyBaseSafe()->moveChildren(run.rubyBaseSafe(), beforeChild);
-        }
-        return;
-    }
-    // child is not a text -> insert it into the base
-    // (append it instead if beforeChild is the ruby text)
-    if (beforeChild && beforeChild->isRubyText())
-        beforeChild = nullptr;
-    insertChild(*parent.rubyBaseSafe(), WTFMove(child), beforeChild);
-}
-
-}
diff --git a/Source/WebCore/rendering/RenderTreeBuilder.h b/Source/WebCore/rendering/RenderTreeBuilder.h
deleted file mode 100644 (file)
index 2da4f74..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include "RenderTreePosition.h"
-
-namespace WebCore {
-
-class RenderRubyRun;
-class RenderTreeUpdater;
-
-class RenderTreeBuilder {
-public:
-    RenderTreeBuilder();
-    ~RenderTreeBuilder();
-
-    void insertChild(RenderElement& parent, RenderPtr<RenderObject>, RenderObject* beforeChild = nullptr);
-    void insertChild(RenderTreePosition&, RenderPtr<RenderObject>);
-
-    // This avoids having to convert all sites that need RenderTreeBuilder in one go.
-    // FIXME: Remove.
-    static RenderTreeBuilder* current() { return m_current; }
-
-private:
-    void rubyRunInsertChild(RenderRubyRun&, RenderPtr<RenderObject> child, RenderObject* beforeChild);
-
-    static RenderTreeBuilder* m_current;
-};
-
-}
index f6802d4..db44f41 100644 (file)
@@ -36,7 +36,6 @@
 #include "RenderListMarker.h"
 #include "RenderText.h"
 #include "RenderTextFragment.h"
-#include "RenderTreeBuilder.h"
 #include "RenderTreeUpdaterFirstLetter.h"
 #include "RenderTreeUpdaterListItem.h"
 #include "StyleResolver.h"
@@ -99,9 +98,6 @@ auto TextAutoSizingValue::adjustTextNodeSizes() -> StillHasNodes
 
     float averageSize = std::round(cumulativeSize / m_autoSizedNodes.size());
 
-    // FIXME: Figure out how to make this code use RenderTreeUpdater/Builder properly.
-    RenderTreeBuilder builder;
-
     // Adjust sizes.
     bool firstPass = true;
     for (auto& node : m_autoSizedNodes) {
@@ -163,7 +159,7 @@ auto TextAutoSizingValue::adjustTextNodeSizes() -> StillHasNodes
         parentRenderer->setStyle(WTFMove(newParentStyle));
 
         if (is<RenderListItem>(*parentRenderer))
-            RenderTreeUpdater::ListItem::updateMarker(builder, downcast<RenderListItem>(*parentRenderer));
+            RenderTreeUpdater::ListItem::updateMarker(downcast<RenderListItem>(*parentRenderer));
     }
 
     for (auto& node : m_autoSizedNodes) {
index 47c0ade..28fafdb 100644 (file)
@@ -76,7 +76,9 @@ void RenderMathMLFenced::updateFromElement()
         m_separators = StringImpl::create(",");
     }
 
-    if (firstChild()) {
+    if (!firstChild())
+        makeFences();
+    else {
         // FIXME: The mfenced element fails to update dynamically when its open, close and separators attributes are changed (https://bugs.webkit.org/show_bug.cgi?id=57696).
         if (is<RenderMathMLFencedOperator>(*firstChild()))
             downcast<RenderMathMLFencedOperator>(*firstChild()).updateOperatorContent(m_open);
@@ -91,23 +93,21 @@ RenderPtr<RenderMathMLFencedOperator> RenderMathMLFenced::createMathMLOperator(c
     return newOperator;
 }
 
-void RenderMathMLFenced::makeFences(RenderTreeBuilder& builder)
+void RenderMathMLFenced::makeFences()
 {
     auto openFence = createMathMLOperator(m_open, MathMLOperatorDictionary::Prefix, MathMLOperatorDictionary::Fence);
-    RenderMathMLRow::addChild(builder, WTFMove(openFence), firstChild());
+    RenderMathMLRow::addChild(WTFMove(openFence), firstChild());
 
     auto closeFence = createMathMLOperator(m_close, MathMLOperatorDictionary::Postfix, MathMLOperatorDictionary::Fence);
     m_closeFenceRenderer = makeWeakPtr(*closeFence);
-    RenderMathMLRow::addChild(builder, WTFMove(closeFence));
+    RenderMathMLRow::addChild(WTFMove(closeFence));
 }
 
-void RenderMathMLFenced::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> child, RenderObject* beforeChild)
+void RenderMathMLFenced::addChild(RenderPtr<RenderObject> child, RenderObject* beforeChild)
 {
     // make the fences if the render object is empty
-    if (!firstChild()) {
+    if (!firstChild())
         updateFromElement();
-        makeFences(builder);
-    }
 
     // FIXME: Adding or removing a child should possibly cause all later separators to shift places if they're different, as later child positions change by +1 or -1. This should also handle surrogate pairs. See https://bugs.webkit.org/show_bug.cgi?id=125938.
 
@@ -133,22 +133,22 @@ void RenderMathMLFenced::addChild(RenderTreeBuilder& builder, RenderPtr<RenderOb
             else
                 separator = (*m_separators.get())[count - 1];
 
-            StringBuilder stringBuilder;
-            stringBuilder.append(separator);
-            separatorRenderer = createMathMLOperator(stringBuilder.toString(), MathMLOperatorDictionary::Infix, MathMLOperatorDictionary::Separator);
+            StringBuilder builder;
+            builder.append(separator);
+            separatorRenderer = createMathMLOperator(builder.toString(), MathMLOperatorDictionary::Infix, MathMLOperatorDictionary::Separator);
         }
     }
 
     if (beforeChild) {
         // Adding |x| before an existing |y| e.g. in element (y) - first insert our new child |x|, then its separator, to get (x, y).
-        RenderMathMLRow::addChild(builder, WTFMove(child), beforeChild);
+        RenderMathMLRow::addChild(WTFMove(child), beforeChild);
         if (separatorRenderer)
-            RenderMathMLRow::addChild(builder, WTFMove(separatorRenderer), beforeChild);
+            RenderMathMLRow::addChild(WTFMove(separatorRenderer), beforeChild);
     } else {
         // Adding |y| at the end of an existing element e.g. (x) - insert the separator first before the closing fence, then |y|, to get (x, y).
         if (separatorRenderer)
-            RenderMathMLRow::addChild(builder, WTFMove(separatorRenderer), m_closeFenceRenderer.get());
-        RenderMathMLRow::addChild(builder, WTFMove(child), m_closeFenceRenderer.get());
+            RenderMathMLRow::addChild(WTFMove(separatorRenderer), m_closeFenceRenderer.get());
+        RenderMathMLRow::addChild(WTFMove(child), m_closeFenceRenderer.get());
     }
 }
 
index ef6ec96..77a63c9 100644 (file)
@@ -42,11 +42,11 @@ public:
 private:
     bool isRenderMathMLFenced() const final { return true; }
     const char* renderName() const final { return "RenderMathMLFenced"; }
-    void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> child, RenderObject* beforeChild) final;
-    void updateFromElement();
+    void addChild(RenderPtr<RenderObject> child, RenderObject* beforeChild) final;
+    void updateFromElement() final;
 
     RenderPtr<RenderMathMLFencedOperator> createMathMLOperator(const String& operatorString, MathMLOperatorDictionary::Form, MathMLOperatorDictionary::Flag);
-    void makeFences(RenderTreeBuilder&);
+    void makeFences();
 
     String m_open;
     String m_close;
index f09e380..814361f 100644 (file)
@@ -89,10 +89,10 @@ void RenderSVGContainer::layout()
     clearNeedsLayout();
 }
 
-void RenderSVGContainer::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
+void RenderSVGContainer::addChild(RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
 {
     auto& child = *newChild;
-    RenderSVGModelObject::addChild(builder, WTFMove(newChild), beforeChild);
+    RenderSVGModelObject::addChild(WTFMove(newChild), beforeChild);
     SVGResourcesCache::clientWasAddedToTree(child);
 }
 
index 43feda1..307f511 100644 (file)
@@ -48,7 +48,7 @@ protected:
 
     void layout() override;
 
-    void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) final;
+    void addChild(RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) final;
     RenderPtr<RenderObject> takeChild(RenderObject&) final;
     void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer = 0) final;
 
index 3029c78..2839a7f 100644 (file)
@@ -123,10 +123,10 @@ void RenderSVGInline::updateFromStyle()
     setInline(true);
 }
 
-void RenderSVGInline::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
+void RenderSVGInline::addChild(RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
 {
     auto& child = *newChild;
-    RenderInline::addChild(builder, WTFMove(newChild), beforeChild);
+    RenderInline::addChild(WTFMove(newChild), beforeChild);
     SVGResourcesCache::clientWasAddedToTree(child);
 
     if (auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this))
index 69b9d84..af9e23b 100644 (file)
@@ -61,7 +61,7 @@ private:
     void willBeDestroyed() final;
     void styleDidChange(StyleDifference, const RenderStyle* oldStyle) final;
 
-    void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> child, RenderObject* beforeChild = nullptr) final;
+    void addChild(RenderPtr<RenderObject> child, RenderObject* beforeChild = nullptr) final;
     RenderPtr<RenderObject> takeChild(RenderObject&) final;
 };
 
index 18794eb..8d53d8d 100644 (file)
@@ -302,10 +302,10 @@ void RenderSVGRoot::styleDidChange(StyleDifference diff, const RenderStyle* oldS
     SVGResourcesCache::clientStyleChanged(*this, diff, style());
 }
 
-void RenderSVGRoot::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
+void RenderSVGRoot::addChild(RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
 {
     auto& child = *newChild;
-    RenderReplaced::addChild(builder, WTFMove(newChild), beforeChild);
+    RenderReplaced::addChild(WTFMove(newChild), beforeChild);
     SVGResourcesCache::clientWasAddedToTree(child);
 }
 
index 374ed5e..4984262 100644 (file)
@@ -82,7 +82,7 @@ private:
     void willBeRemovedFromTree() override;
 
     void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
-    void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) override;
+    void addChild(RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) override;
     RenderPtr<RenderObject> takeChild(RenderObject&) override;
 
     const AffineTransform& localToParentTransform() const override;
index b75b48e..a52c07e 100644 (file)
@@ -520,10 +520,10 @@ FloatRect RenderSVGText::repaintRectInLocalCoordinates() const
     return repaintRect;
 }
 
-void RenderSVGText::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
+void RenderSVGText::addChild(RenderPtr<RenderObject> newChild, RenderObject* beforeChild)
 {
     auto& child = *newChild;
-    RenderSVGBlock::addChild(builder, WTFMove(newChild), beforeChild);
+    RenderSVGBlock::addChild(WTFMove(newChild), beforeChild);
 
     SVGResourcesCache::clientWasAddedToTree(child);
     subtreeChildWasAdded(&child);
index 5e1ddde..4fee655 100644 (file)
@@ -83,7 +83,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;
+    void addChild(RenderPtr<RenderObject> child, RenderObject* beforeChild = nullptr) override;
     RenderPtr<RenderObject> takeChild(RenderObject&) override;
     void willBeDestroyed() override;
 
index b3e86dd..067a763 100644 (file)
 
 namespace WebCore {
 
+void RenderTreePosition::insert(RenderPtr<RenderObject> renderer)
+{
+    ASSERT(m_hasValidNextSibling);
+    auto* insertBefore = m_nextSibling;
+    if (is<RenderText>(insertBefore)) {
+        if (auto* wrapperInline = downcast<RenderText>(*insertBefore).inlineWrapperForDisplayContents())
+            insertBefore = wrapperInline;
+    }
+    m_parent.addChild(WTFMove(renderer), insertBefore);
+}
+
 void RenderTreePosition::computeNextSibling(const Node& node)
 {
     ASSERT(!node.renderer());
index e0e09c0..8d89fae 100644 (file)
@@ -38,15 +38,11 @@ public:
         : m_parent(parent)
     {
     }
-    RenderTreePosition(RenderElement& parent, RenderObject* nextSibling)
-        : m_parent(parent)
-        , m_nextSibling(nextSibling)
-        , m_hasValidNextSibling(true)
-    {
-    }
 
     RenderElement& parent() const { return m_parent; }
-    RenderObject* nextSibling() const { ASSERT(m_hasValidNextSibling); return m_nextSibling; }
+    void insert(RenderPtr<RenderObject>);
+    bool canInsert(RenderElement&) const;
+    bool canInsert(RenderText&) const;
 
     void computeNextSibling(const Node&);
     void moveToLastChild();
@@ -70,4 +66,16 @@ inline void RenderTreePosition::moveToLastChild()
     m_hasValidNextSibling = true;
 }
 
+inline bool RenderTreePosition::canInsert(RenderElement& renderer) const
+{
+    ASSERT(!renderer.parent());
+    return m_parent.isChildAllowed(renderer, renderer.style());
+}
+
+inline bool RenderTreePosition::canInsert(RenderText& renderer) const
+{
+    ASSERT(!renderer.parent());
+    return m_parent.isChildAllowed(renderer, m_parent.style());
+}
+
 } // namespace WebCore
index c11ab6c..cc39f22 100644 (file)
@@ -274,7 +274,7 @@ void RenderTreeUpdater::updateAfterDescendants(Element& element, const Style::El
     if (is<RenderBlock>(*renderer))
         FirstLetter::update(downcast<RenderBlock>(*renderer));
     if (is<RenderListItem>(*renderer))
-        ListItem::updateMarker(m_builder, downcast<RenderListItem>(*renderer));
+        ListItem::updateMarker(downcast<RenderListItem>(*renderer));
     if (is<RenderBlockFlow>(*renderer))
         MultiColumn::update(downcast<RenderBlockFlow>(*renderer));
 
@@ -376,8 +376,7 @@ void RenderTreeUpdater::createRenderer(Element& element, RenderStyle&& style)
     auto newRenderer = element.createElementRenderer(WTFMove(style), insertionPosition);
     if (!newRenderer)
         return;
-
-    if (!insertionPosition.parent().isChildAllowed(*newRenderer, newRenderer->style()))
+    if (!insertionPosition.canInsert(*newRenderer))
         return;
 
     element.setRenderer(newRenderer.get());
@@ -386,13 +385,13 @@ void RenderTreeUpdater::createRenderer(Element& element, RenderStyle&& style)
 
 #if ENABLE(FULLSCREEN_API)
     if (m_document.webkitIsFullScreen() && m_document.webkitCurrentFullScreenElement() == &element) {
-        newRenderer = RenderFullScreen::wrapNewRenderer(m_builder, WTFMove(newRenderer), insertionPosition.parent(), m_document);
+        newRenderer = RenderFullScreen::wrapNewRenderer(WTFMove(newRenderer), insertionPosition.parent(), m_document);
         if (!newRenderer)
             return;
     }
 #endif
 
-    m_builder.insertChild(insertionPosition, WTFMove(newRenderer));
+    insertionPosition.insert(WTFMove(newRenderer));
 
     if (AXObjectCache* cache = m_document.axObjectCache())
         cache->updateCacheAfterNodeIsAttached(&element);
@@ -446,16 +445,15 @@ bool RenderTreeUpdater::textRendererIsNeeded(const Text& textNode)
     return true;
 }
 
-void RenderTreeUpdater::createTextRenderer(Text& textNode, const Style::TextUpdate* textUpdate)
+static void createTextRenderer(Text& textNode, RenderTreePosition& renderTreePosition, const Style::TextUpdate* textUpdate)
 {
     ASSERT(!textNode.renderer());
 
-    auto& renderTreePosition = this->renderTreePosition();
     auto textRenderer = textNode.createTextRenderer(renderTreePosition.parent().style());
 
     renderTreePosition.computeNextSibling(textNode);
 
-    if (!renderTreePosition.parent().isChildAllowed(*textRenderer, renderTreePosition.parent().style()))
+    if (!renderTreePosition.canInsert(*textRenderer))
         return;
 
     textNode.setRenderer(textRenderer.get());
@@ -463,17 +461,17 @@ void RenderTreeUpdater::createTextRenderer(Text& textNode, const Style::TextUpda
     if (textUpdate && textUpdate->inheritedDisplayContentsStyle && *textUpdate->inheritedDisplayContentsStyle) {
         // Wrap text renderer into anonymous inline so we can give it a style.
         // This is to support "<div style='display:contents;color:green'>text</div>" type cases
-        auto newDisplayContentsAnonymousWrapper = WebCore::createRenderer<RenderInline>(textNode.document(), RenderStyle::clone(**textUpdate->inheritedDisplayContentsStyle));
+        auto newDisplayContentsAnonymousWrapper = createRenderer<RenderInline>(textNode.document(), RenderStyle::clone(**textUpdate->inheritedDisplayContentsStyle));
         newDisplayContentsAnonymousWrapper->initializeStyle();
         auto& displayContentsAnonymousWrapper = *newDisplayContentsAnonymousWrapper;
-        m_builder.insertChild(renderTreePosition, WTFMove(newDisplayContentsAnonymousWrapper));
+        renderTreePosition.insert(WTFMove(newDisplayContentsAnonymousWrapper));
 
         textRenderer->setInlineWrapperForDisplayContents(&displayContentsAnonymousWrapper);
-        m_builder.insertChild(displayContentsAnonymousWrapper, WTFMove(textRenderer));
+        displayContentsAnonymousWrapper.addChild(WTFMove(textRenderer));
         return;
     }
 
-    m_builder.insertChild(renderTreePosition, WTFMove(textRenderer));
+    renderTreePosition.insert(WTFMove(textRenderer));
 }
 
 void RenderTreeUpdater::updateTextRenderer(Text& text, const Style::TextUpdate* textUpdate)
@@ -484,7 +482,7 @@ void RenderTreeUpdater::updateTextRenderer(Text& text, const Style::TextUpdate*
     if (existingRenderer && textUpdate && textUpdate->inheritedDisplayContentsStyle) {
         if (existingRenderer->inlineWrapperForDisplayContents() || *textUpdate->inheritedDisplayContentsStyle) {
             // FIXME: We could update without teardown.
-            tearDownTextRenderer(text);
+            tearDownRenderer(text);
             existingRenderer = nullptr;
         }
     }
@@ -495,13 +493,13 @@ void RenderTreeUpdater::updateTextRenderer(Text& text, const Style::TextUpdate*
                 existingRenderer->setTextWithOffset(text.data(), textUpdate->offset, textUpdate->length);
             return;
         }
-        tearDownTextRenderer(text);
+        tearDownRenderer(text);
         renderingParent().didCreateOrDestroyChildRenderer = true;
         return;
     }
     if (!needsRenderer)
         return;
-    createTextRenderer(text, textUpdate);
+    createTextRenderer(text, renderTreePosition(), textUpdate);
     renderingParent().didCreateOrDestroyChildRenderer = true;
 }
 
@@ -516,16 +514,9 @@ void RenderTreeUpdater::storePreviousRenderer(Node& node)
 
 void RenderTreeUpdater::tearDownRenderers(Element& root)
 {
-    RenderTreeBuilder builder;
     tearDownRenderers(root, TeardownType::Full);
 }
 
-void RenderTreeUpdater::tearDownRenderer(Text& text)
-{
-    RenderTreeBuilder builder;
-    tearDownTextRenderer(text);
-}
-
 void RenderTreeUpdater::tearDownRenderers(Element& root, TeardownType teardownType)
 {
     WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
@@ -550,8 +541,7 @@ void RenderTreeUpdater::tearDownRenderers(Element& root, TeardownType teardownTy
             if (teardownType == TeardownType::Full)
                 element.clearHoverAndActiveStatusBeforeDetachingRenderer();
 
-            GeneratedContent::removeBeforePseudoElement(element);
-            GeneratedContent::removeAfterPseudoElement(element);
+            element.clearStyleDerivedDataBeforeDetachingRenderer();
 
             if (auto* renderer = element.renderer()) {
                 renderer->removeFromParentAndDestroyCleaningUpAnonymousWrappers();
@@ -569,7 +559,7 @@ void RenderTreeUpdater::tearDownRenderers(Element& root, TeardownType teardownTy
         pop(it.depth());
 
         if (is<Text>(*it)) {
-            tearDownTextRenderer(downcast<Text>(*it));
+            tearDownRenderer(downcast<Text>(*it));
             continue;
         }
 
@@ -579,7 +569,7 @@ void RenderTreeUpdater::tearDownRenderers(Element& root, TeardownType teardownTy
     pop(0);
 }
 
-void RenderTreeUpdater::tearDownTextRenderer(Text& text)
+void RenderTreeUpdater::tearDownRenderer(Text& text)
 {
     auto* renderer = text.renderer();
     if (!renderer)
index afe5647..ca4000b 100644 (file)
@@ -25,7 +25,6 @@
 
 #pragma once
 
-#include "RenderTreeBuilder.h"
 #include "RenderTreePosition.h"
 #include "StyleChange.h"
 #include "StyleUpdate.h"
@@ -60,7 +59,6 @@ private:
 
     void updateRenderTree(ContainerNode& root);
     void updateTextRenderer(Text&, const Style::TextUpdate*);
-    void createTextRenderer(Text&, const Style::TextUpdate*);
     void updateElementRenderer(Element&, const Style::ElementUpdate&);
     void createRenderer(Element&, RenderStyle&&);
     void updateBeforeDescendants(Element&, const Style::ElementUpdates*);
@@ -91,7 +89,6 @@ private:
 
     enum class TeardownType { Full, RendererUpdate, RendererUpdateCancelingAnimations };
     static void tearDownRenderers(Element&, TeardownType);
-    static void tearDownTextRenderer(Text&);
 
     RenderView& renderView();
 
@@ -101,8 +98,6 @@ private:
     Vector<Parent> m_parentStack;
 
     std::unique_ptr<GeneratedContent> m_generatedContent;
-
-    RenderTreeBuilder m_builder;
 };
 
 } // namespace WebCore
index 9b7d4e8..476f4d7 100644 (file)
@@ -33,7 +33,6 @@
 #include "RenderStyle.h"
 #include "RenderTable.h"
 #include "RenderTextFragment.h"
-#include "RenderTreeBuilder.h"
 
 namespace WebCore {
 
@@ -125,7 +124,7 @@ static void updateFirstLetterStyle(RenderBlock& firstLetterBlock, RenderObject&
             if (is<RenderText>(*child))
                 downcast<RenderText>(*child).removeAndDestroyTextBoxes();
             auto toMove = firstLetter->takeChild(*child);
-            RenderTreeBuilder::current()->insertChild(*newFirstLetter, WTFMove(toMove));
+            newFirstLetter->addChild(WTFMove(toMove));
         }
 
         RenderObject* nextSibling = firstLetter->nextSibling();
@@ -136,7 +135,7 @@ static void updateFirstLetterStyle(RenderBlock& firstLetterBlock, RenderObject&
             newFirstLetter->setFirstLetterRemainingText(*remainingText);
         }
         firstLetterContainer->removeAndDestroyChild(*firstLetter);
-        RenderTreeBuilder::current()->insertChild(*firstLetterContainer, WTFMove(newFirstLetter), nextSibling);
+        firstLetterContainer->addChild(WTFMove(newFirstLetter), nextSibling);
     } else
         firstLetter->setStyle(WTFMove(pseudoStyle));
 }
@@ -154,7 +153,7 @@ static void createFirstLetterRenderer(RenderBlock& firstLetterBlock, RenderText&
     newFirstLetter->setIsFirstLetter();
 
     auto& firstLetter = *newFirstLetter;
-    RenderTreeBuilder::current()->insertChild(*firstLetterContainer, WTFMove(newFirstLetter), &currentTextChild);
+    firstLetterContainer->addChild(WTFMove(newFirstLetter), &currentTextChild);
 
     // The original string is going to be either a generated content string or a DOM node's
     // string. We want the original string before it got transformed in case first-letter has
@@ -198,14 +197,14 @@ static void createFirstLetterRenderer(RenderBlock& firstLetterBlock, RenderText&
             newRemainingText = createRenderer<RenderTextFragment>(firstLetterBlock.document(), oldText, length, oldText.length() - length);
 
         RenderTextFragment& remainingText = *newRemainingText;
-        RenderTreeBuilder::current()->insertChild(*firstLetterContainer, WTFMove(newRemainingText), beforeChild);
+        firstLetterContainer->addChild(WTFMove(newRemainingText), beforeChild);
         remainingText.setFirstLetter(firstLetter);
         firstLetter.setFirstLetterRemainingText(remainingText);
 
         // construct text fragment for the first letter
         auto letter = createRenderer<RenderTextFragment>(firstLetterBlock.document(), oldText, 0, length);
 
-        RenderTreeBuilder::current()->insertChild(firstLetter, WTFMove(letter));
+        firstLetter.addChild(WTFMove(letter));
     }
 }
 
index 9446b5a..05b3643 100644 (file)
@@ -61,7 +61,7 @@ void RenderTreeUpdater::GeneratedContent::updateQuotesUpTo(RenderQuote* lastQuot
     for (; it != end; ++it) {
         auto& quote = *it;
         // Quote character depends on quote depth so we chain the updates.
-        quote.updateRenderer(m_updater.m_builder, m_previousUpdatedQuote);
+        quote.updateRenderer(m_previousUpdatedQuote);
         m_previousUpdatedQuote = &quote;
         if (&quote == lastQuote)
             return;
@@ -69,14 +69,14 @@ void RenderTreeUpdater::GeneratedContent::updateQuotesUpTo(RenderQuote* lastQuot
     ASSERT(!lastQuote);
 }
 
-static void createContentRenderers(RenderTreeBuilder& builder, RenderElement& pseudoRenderer, const RenderStyle& style)
+static void createContentRenderers(RenderElement& pseudoRenderer, const RenderStyle& style)
 {
     ASSERT(style.contentData());
 
     for (const ContentData* content = style.contentData(); content; content = content->next()) {
         auto child = content->createContentRenderer(pseudoRenderer.document(), style);
         if (pseudoRenderer.isChildAllowed(*child, style))
-            builder.insertChild(pseudoRenderer, WTFMove(child));
+            pseudoRenderer.addChild(WTFMove(child));
     }
 }
 
@@ -100,9 +100,9 @@ void RenderTreeUpdater::GeneratedContent::updatePseudoElement(Element& current,
     if (!needsPseudoElement(update)) {
         if (pseudoElement) {
             if (pseudoId == BEFORE)
-                removeBeforePseudoElement(current);
+                current.clearBeforePseudoElement();
             else
-                removeAfterPseudoElement(current);
+                current.clearAfterPseudoElement();
         }
         return;
     }
@@ -144,7 +144,7 @@ void RenderTreeUpdater::GeneratedContent::updatePseudoElement(Element& current,
         return;
 
     if (update->change == Style::Detach)
-        createContentRenderers(m_updater.m_builder, *pseudoElementRenderer, *update->style);
+        createContentRenderers(*pseudoElementRenderer, *update->style);
     else
         updateStyleForContentRenderers(*pseudoElementRenderer, *update->style);
 
@@ -153,7 +153,7 @@ void RenderTreeUpdater::GeneratedContent::updatePseudoElement(Element& current,
             updateQuotesUpTo(&child);
     }
     if (is<RenderListItem>(*pseudoElementRenderer))
-        ListItem::updateMarker(m_updater.m_builder, downcast<RenderListItem>(*pseudoElementRenderer));
+        ListItem::updateMarker(downcast<RenderListItem>(*pseudoElementRenderer));
 }
 
 bool RenderTreeUpdater::GeneratedContent::needsPseudoElement(const std::optional<Style::ElementUpdate>& update)
@@ -167,22 +167,4 @@ bool RenderTreeUpdater::GeneratedContent::needsPseudoElement(const std::optional
     return true;
 }
 
-void RenderTreeUpdater::GeneratedContent::removeBeforePseudoElement(Element& element)
-{
-    auto* pseudoElement = element.beforePseudoElement();
-    if (!pseudoElement)
-        return;
-    tearDownRenderers(*pseudoElement, TeardownType::Full);
-    element.clearBeforePseudoElement();
-}
-
-void RenderTreeUpdater::GeneratedContent::removeAfterPseudoElement(Element& element)
-{
-    auto* pseudoElement = element.afterPseudoElement();
-    if (!pseudoElement)
-        return;
-    tearDownRenderers(*pseudoElement, TeardownType::Full);
-    element.clearAfterPseudoElement();
-}
-
 }
index 6bb134e..d1c2914 100644 (file)
@@ -40,9 +40,6 @@ public:
     void updatePseudoElement(Element&, const std::optional<Style::ElementUpdate>&, PseudoId);
     void updateRemainingQuotes();
 
-    static void removeBeforePseudoElement(Element&);
-    static void removeAfterPseudoElement(Element&);
-
 private:
     void updateQuotesUpTo(RenderQuote*);
     
index 2362b34..d1fab6f 100644 (file)
@@ -69,7 +69,7 @@ static RenderObject* firstNonMarkerChild(RenderBlock& parent)
     return child;
 }
 
-void RenderTreeUpdater::ListItem::updateMarker(RenderTreeBuilder& builder, RenderListItem& listItemRenderer)
+void RenderTreeUpdater::ListItem::updateMarker(RenderListItem& listItemRenderer)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(!listItemRenderer.view().frameView().layoutContext().layoutState());
 
@@ -110,9 +110,9 @@ void RenderTreeUpdater::ListItem::updateMarker(RenderTreeBuilder& builder, Rende
 
     if (newParent != currentParent) {
         if (currentParent)
-            builder.insertChild(*newParent, currentParent->takeChild(*markerRenderer), firstNonMarkerChild(*newParent));
+            newParent->addChild(currentParent->takeChild(*markerRenderer), firstNonMarkerChild(*newParent));
         else
-            builder.insertChild(*newParent, WTFMove(newMarkerRenderer), firstNonMarkerChild(*newParent));
+            newParent->addChild(WTFMove(newMarkerRenderer), firstNonMarkerChild(*newParent));
 
         // If current parent is an anonymous block that has lost all its children, destroy it.
         if (currentParent && currentParent->isAnonymousBlock() && !currentParent->firstChild() && !downcast<RenderBlock>(*currentParent).continuation())
index 56db047..40b4063 100644 (file)
@@ -32,7 +32,7 @@ namespace WebCore {
 
 class RenderTreeUpdater::ListItem {
 public:
-    static void updateMarker(RenderTreeBuilder&, RenderListItem&);
+    static void updateMarker(RenderListItem&);
 };
 
 }
index 630a5c8..2e1f712 100644 (file)
@@ -29,7 +29,6 @@
 #include "RenderMultiColumnFlow.h"
 #include "RenderMultiColumnSet.h"
 #include "RenderMultiColumnSpannerPlaceholder.h"
-#include "RenderTreeBuilder.h"
 
 namespace WebCore {
 
@@ -74,14 +73,14 @@ void RenderTreeUpdater::MultiColumn::createFragmentedFlow(RenderBlockFlow& flow)
             auto& spannerOriginalParent = *placeholder->parent();
             // Detaching the spanner takes care of removing the placeholder (and merges the RenderMultiColumnSets).
             auto spannerToReInsert = spanner->parent()->takeChild(*spanner);
-            RenderTreeBuilder::current()->insertChild(spannerOriginalParent, WTFMove(spannerToReInsert));
+            spannerOriginalParent.addChild(WTFMove(spannerToReInsert));
         }
     }
 
     auto newFragmentedFlow = WebCore::createRenderer<RenderMultiColumnFlow>(flow.document(), RenderStyle::createAnonymousStyleWithDisplay(flow.style(), BLOCK));
     newFragmentedFlow->initializeStyle();
     auto& fragmentedFlow = *newFragmentedFlow;
-    flow.RenderBlock::addChild(*RenderTreeBuilder::current(), WTFMove(newFragmentedFlow));
+    flow.RenderBlock::addChild(WTFMove(newFragmentedFlow));
 
     // Reparent children preceding the fragmented flow into the fragmented flow.
     flow.moveChildrenTo(&fragmentedFlow, flow.firstChild(), &fragmentedFlow, RenderBoxModelObject::NormalizeAfterInsertion::Yes);
@@ -122,7 +121,7 @@ void RenderTreeUpdater::MultiColumn::destroyFragmentedFlow(RenderBlockFlow& flow
     multiColumnFlow.moveAllChildrenTo(&flow, RenderBoxModelObject::NormalizeAfterInsertion::Yes);
     multiColumnFlow.removeFromParentAndDestroy();
     for (auto& parentAndSpanner : parentAndSpannerList)
-        RenderTreeBuilder::current()->insertChild(*parentAndSpanner.first, WTFMove(parentAndSpanner.second));
+        parentAndSpanner.first->addChild(WTFMove(parentAndSpanner.second));
 }
 
 }