[RenderTreeBuilder] Move childBecameNonInline to RenderTreeBuilder
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Jan 2018 18:01:48 +0000 (18:01 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Jan 2018 18:01:48 +0000 (18:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182265
<rdar://problem/37004459>

Reviewed by Antti Koivisto.

Move the mutation code that wraps/unwraps a child element when its flow state changes
from(to) in-flow to(from) floating/out-of-flow.

No change in functionality.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::childBecameNonInline): Deleted.
* rendering/RenderBlock.h:
* rendering/RenderBoxModelObject.h:
(WebCore::RenderBoxModelObject::childBecameNonInline): Deleted.
* rendering/RenderElement.cpp:
(WebCore::RenderElement::styleDidChange):
(WebCore::RenderElement::handleDynamicFloatPositionChange): Deleted.
* rendering/RenderInline.cpp:
(WebCore::RenderInline::childBecameNonInline): Deleted.
* rendering/RenderInline.h:
* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::childFlowStateChangesAndAffectsParentBlock):
(WebCore::RenderTreeBuilder::splitFlow): Deleted.
* rendering/updating/RenderTreeBuilder.h:
* rendering/updating/RenderTreeBuilderBlock.cpp:
(WebCore::RenderTreeBuilder::Block::childBecameNonInline):
* rendering/updating/RenderTreeBuilderBlock.h:
* rendering/updating/RenderTreeBuilderInline.cpp:
(WebCore::RenderTreeBuilder::Inline::childBecameNonInline):
* rendering/updating/RenderTreeBuilderInline.h:

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

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderBoxModelObject.h
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderInline.cpp
Source/WebCore/rendering/RenderInline.h
Source/WebCore/rendering/updating/RenderTreeBuilder.cpp
Source/WebCore/rendering/updating/RenderTreeBuilder.h
Source/WebCore/rendering/updating/RenderTreeBuilderBlock.cpp
Source/WebCore/rendering/updating/RenderTreeBuilderBlock.h
Source/WebCore/rendering/updating/RenderTreeBuilderInline.cpp
Source/WebCore/rendering/updating/RenderTreeBuilderInline.h

index d812626..520dfa2 100644 (file)
@@ -1,3 +1,38 @@
+2018-01-30  Zalan Bujtas  <zalan@apple.com>
+
+        [RenderTreeBuilder] Move childBecameNonInline to RenderTreeBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=182265
+        <rdar://problem/37004459>
+
+        Reviewed by Antti Koivisto.
+
+        Move the mutation code that wraps/unwraps a child element when its flow state changes
+        from(to) in-flow to(from) floating/out-of-flow.
+
+        No change in functionality.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::childBecameNonInline): Deleted.
+        * rendering/RenderBlock.h:
+        * rendering/RenderBoxModelObject.h:
+        (WebCore::RenderBoxModelObject::childBecameNonInline): Deleted.
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::styleDidChange):
+        (WebCore::RenderElement::handleDynamicFloatPositionChange): Deleted.
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::childBecameNonInline): Deleted.
+        * rendering/RenderInline.h:
+        * rendering/updating/RenderTreeBuilder.cpp:
+        (WebCore::RenderTreeBuilder::childFlowStateChangesAndAffectsParentBlock):
+        (WebCore::RenderTreeBuilder::splitFlow): Deleted.
+        * rendering/updating/RenderTreeBuilder.h:
+        * rendering/updating/RenderTreeBuilderBlock.cpp:
+        (WebCore::RenderTreeBuilder::Block::childBecameNonInline):
+        * rendering/updating/RenderTreeBuilderBlock.h:
+        * rendering/updating/RenderTreeBuilderInline.cpp:
+        (WebCore::RenderTreeBuilder::Inline::childBecameNonInline):
+        * rendering/updating/RenderTreeBuilderInline.h:
+
 2018-01-30  Brent Fulgham  <bfulgham@apple.com>
 
         Add telemetry to track storage access API adoption
index f85e275..ce92fbb 100644 (file)
@@ -2978,14 +2978,6 @@ const RenderStyle& RenderBlock::outlineStyleForRepaint() const
     return RenderElement::outlineStyleForRepaint();
 }
 
-void RenderBlock::childBecameNonInline(RenderElement&)
-{
-    RenderTreeBuilder::current()->makeChildrenNonInline(*this);
-    if (isAnonymousBlock() && is<RenderBlock>(parent()))
-        downcast<RenderBlock>(*parent()).removeLeftoverAnonymousBlock(this);
-    // |this| may be dead here
-}
-
 void RenderBlock::updateHitTestResult(HitTestResult& result, const LayoutPoint& point)
 {
     if (result.innerNode())
index 55d684d..20a7204 100644 (file)
@@ -466,7 +466,6 @@ private:
 
     RenderElement* hoverAncestor() const final;
     void updateDragState(bool dragOn) final;
-    void childBecameNonInline(RenderElement&) final;
 
     LayoutRect selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool /*clipToVisibleContent*/) final
     {
index cb7fb04..27f33d5 100644 (file)
@@ -202,8 +202,6 @@ public:
 
     virtual LayoutUnit containingBlockLogicalWidthForContent() const;
 
-    virtual void childBecameNonInline(RenderElement&) { }
-
     void paintBorder(const PaintInfo&, const LayoutRect&, const RenderStyle&, BackgroundBleedAvoidance = BackgroundBleedNone, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
     bool paintNinePieceImage(GraphicsContext&, const LayoutRect&, const RenderStyle&, const NinePieceImage&, CompositeOperator = CompositeSourceOver);
     void paintBoxShadow(const PaintInfo&, const LayoutRect&, const RenderStyle&, ShadowStyle, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
index 26f89d1..d14afaa 100644 (file)
@@ -902,26 +902,6 @@ void RenderElement::styleWillChange(StyleDifference diff, const RenderStyle& new
         view().frameView().updateExtendBackgroundIfNecessary();
 }
 
-void RenderElement::handleDynamicFloatPositionChange()
-{
-    // We have gone from not affecting the inline status of the parent flow to suddenly
-    // having an impact.  See if there is a mismatch between the parent flow's
-    // childrenInline() state and our state.
-    setInline(style().isDisplayInlineType());
-    if (isInline() != parent()->childrenInline()) {
-        if (!isInline())
-            downcast<RenderBoxModelObject>(*parent()).childBecameNonInline(*this);
-        else {
-            // An anonymous block must be made to wrap this inline.
-            auto newBlock = downcast<RenderBlock>(*parent()).createAnonymousBlock();
-            auto& block = *newBlock;
-            parent()->insertChildInternal(WTFMove(newBlock), this);
-            auto thisToMove = parent()->takeChildInternal(*this);
-            block.insertChildInternal(WTFMove(thisToMove), nullptr);
-        }
-    }
-}
-
 void RenderElement::removeAnonymousWrappersForInlinesIfNecessary()
 {
     // FIXME: Move to RenderBlock.
@@ -972,8 +952,14 @@ void RenderElement::styleDidChange(StyleDifference diff, const RenderStyle* oldS
     updateImage(oldStyle ? oldStyle->maskBoxImage().image() : nullptr, m_style.maskBoxImage().image());
     updateShapeImage(oldStyle ? oldStyle->shapeOutside() : nullptr, m_style.shapeOutside());
 
-    if (s_affectsParentBlock)
-        handleDynamicFloatPositionChange();
+    if (s_affectsParentBlock) {
+        // We have gone from not affecting the inline status of the parent flow to suddenly
+        // having an impact. See if there is a mismatch between the parent flow's
+        // childrenInline() state and our state.
+        setInline(style().isDisplayInlineType());
+        if (isInline() != parent()->childrenInline())
+            RenderTreeBuilder::current()->childFlowStateChangesAndAffectsParentBlock(*this);
+    }
 
     if (s_noLongerAffectsParentBlock)
         parent()->removeAnonymousWrappersForInlinesIfNecessary();
index 1a6d2d4..e7f5f8b 100644 (file)
@@ -1036,20 +1036,6 @@ void RenderInline::updateDragState(bool dragOn)
         continuation->updateDragState(dragOn);
 }
 
-void RenderInline::childBecameNonInline(RenderElement& child)
-{
-    // We have to split the parent flow.
-    auto newBox = containingBlock()->createAnonymousBlock();
-    newBox->setIsContinuation();
-    RenderBoxModelObject* oldContinuation = continuation();
-    if (oldContinuation)
-        oldContinuation->removeFromContinuationChain();
-    newBox->insertIntoContinuationChainAfter(*this);
-    RenderObject* beforeChild = child.nextSibling();
-    auto removedChild = takeChildInternal(child);
-    RenderTreeBuilder::current()->splitFlow(*this, beforeChild, WTFMove(newBox), WTFMove(removedChild), oldContinuation);
-}
-
 void RenderInline::updateHitTestResult(HitTestResult& result, const LayoutPoint& point)
 {
     if (result.innerNode())
index 7918ed9..7326c76 100644 (file)
@@ -149,8 +149,6 @@ private:
     LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const final;
     int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const final;
     
-    void childBecameNonInline(RenderElement&) final;
-
     void updateHitTestResult(HitTestResult&, const LayoutPoint&) final;
 
     void imageChanged(WrappedImagePtr, const IntRect* = 0) final;
index 0ffdfc5..97f5011 100644 (file)
@@ -300,6 +300,24 @@ RenderObject* RenderTreeBuilder::splitAnonymousBoxesAroundChild(RenderBox& paren
     return beforeChild;
 }
 
+void RenderTreeBuilder::childFlowStateChangesAndAffectsParentBlock(RenderElement& child)
+{
+    auto* parent = child.parent();
+    if (!child.isInline()) {
+        if (is<RenderBlock>(parent))
+            blockBuilder().childBecameNonInline(downcast<RenderBlock>(*parent), child);
+        else if (is<RenderInline>(*parent))
+            inlineBuilder().childBecameNonInline(downcast<RenderInline>(*parent), child);
+    } else {
+        // An anonymous block must be made to wrap this inline.
+        auto newBlock = downcast<RenderBlock>(*parent).createAnonymousBlock();
+        auto& block = *newBlock;
+        parent->insertChildInternal(WTFMove(newBlock), &child);
+        auto thisToMove = parent->takeChildInternal(child);
+        block.insertChildInternal(WTFMove(thisToMove), nullptr);
+    }
+}
+
 void RenderTreeBuilder::insertChildToRenderInline(RenderInline& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
 {
     inlineBuilder().insertChild(parent, WTFMove(child), beforeChild);
@@ -345,11 +363,6 @@ void RenderTreeBuilder::insertChildToRenderTableRow(RenderTableRow& parent, Rend
     tableBuilder().insertChild(parent, WTFMove(child), beforeChild);
 }
 
-void RenderTreeBuilder::splitFlow(RenderInline& parent, RenderObject* beforeChild, RenderPtr<RenderBlock> newBlockBox, RenderPtr<RenderObject> child, RenderBoxModelObject* oldCont)
-{
-    inlineBuilder().splitFlow(parent, beforeChild, WTFMove(newBlockBox), WTFMove(child), oldCont);
-}
-
 void RenderTreeBuilder::moveRubyChildren(RenderRubyBase& from, RenderRubyBase& to)
 {
     rubyBuilder().moveChildren(from, to);
index 2f2f8af..b036627 100644 (file)
@@ -74,8 +74,8 @@ public:
     bool childRequiresTable(const RenderElement& parent, const RenderObject& child);
     void makeChildrenNonInline(RenderBlock& parent, RenderObject* insertionPoint = nullptr);
     RenderObject* splitAnonymousBoxesAroundChild(RenderBox& parent, RenderObject* beforeChild);
-    void splitFlow(RenderInline& parent, RenderObject* beforeChild, RenderPtr<RenderBlock> newBlockBox, RenderPtr<RenderObject> child, RenderBoxModelObject* oldCont);
     void moveRubyChildren(RenderRubyBase& from, RenderRubyBase& to);
+    void childFlowStateChangesAndAffectsParentBlock(RenderElement& child);
 
 private:
     class FirstLetter;
index 0c19f78..13b7cbe 100644 (file)
@@ -197,4 +197,12 @@ void RenderTreeBuilder::Block::insertChildIgnoringContinuation(RenderBlock& pare
     // parent object may be dead here
 }
 
+void RenderTreeBuilder::Block::childBecameNonInline(RenderBlock& parent, RenderElement&)
+{
+    m_builder.makeChildrenNonInline(parent);
+    if (parent.isAnonymousBlock() && is<RenderBlock>(parent.parent()))
+        downcast<RenderBlock>(*parent.parent()).removeLeftoverAnonymousBlock(&parent);
+    // parent may be dead here
+}
+
 }
index ccdabf3..084b359 100644 (file)
@@ -36,6 +36,8 @@ public:
     void insertChild(RenderBlock& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
     void insertChildIgnoringContinuation(RenderBlock& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
 
+    void childBecameNonInline(RenderBlock& parent, RenderElement& child);
+
 private:
     void insertChildToContinuation(RenderBlock& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
 
index 72a9447..412d649 100644 (file)
@@ -379,4 +379,18 @@ bool RenderTreeBuilder::Inline::newChildIsInline(const RenderInline& parent, con
     return child.isInline() || (m_builder.tableBuilder().childRequiresTable(parent, child) && parent.style().display() == INLINE);
 }
 
+void RenderTreeBuilder::Inline::childBecameNonInline(RenderInline& parent, RenderElement& child)
+{
+    // We have to split the parent flow.
+    auto newBox = parent.containingBlock()->createAnonymousBlock();
+    newBox->setIsContinuation();
+    auto* oldContinuation = parent.continuation();
+    if (oldContinuation)
+        oldContinuation->removeFromContinuationChain();
+    newBox->insertIntoContinuationChainAfter(parent);
+    auto* beforeChild = child.nextSibling();
+    auto removedChild = parent.takeChildInternal(child);
+    splitFlow(parent, beforeChild, WTFMove(newBox), WTFMove(removedChild), oldContinuation);
+}
+
 }
index 79a2c8a..42b5c94 100644 (file)
@@ -37,12 +37,13 @@ public:
     void insertChildIgnoringContinuation(RenderInline& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
 
     // Make this private once all the mutation code is in RenderTreeBuilder.
-    void splitFlow(RenderInline& parent, RenderObject* beforeChild, RenderPtr<RenderBlock> newBlockBox, RenderPtr<RenderObject> child, RenderBoxModelObject* oldCont);
+    void childBecameNonInline(RenderInline& parent, RenderElement& child);
 
 private:
     void insertChildToContinuation(RenderInline& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
     void splitInlines(RenderInline& parent, RenderBlock* fromBlock, RenderBlock* toBlock, RenderBlock* middleBlock, RenderObject* beforeChild, RenderBoxModelObject* oldCont);
     bool newChildIsInline(const RenderInline& parent, const RenderObject& child);
+    void splitFlow(RenderInline& parent, RenderObject* beforeChild, RenderPtr<RenderBlock> newBlockBox, RenderPtr<RenderObject> child, RenderBoxModelObject* oldCont);
 
     RenderTreeBuilder& m_builder;
 };