Title: [228327] trunk/Source/WebCore
Revision
228327
Author
za...@apple.com
Date
2018-02-09 10:31:29 -0800 (Fri, 09 Feb 2018)

Log Message

[RenderTreeBuilder] Move multicolumn descendant/sibling removal logic to RenderTreeBuilder
https://bugs.webkit.org/show_bug.cgi?id=182628
<rdar://problem/37369528>

Reviewed by Antti Koivisto.

No change in functionality

* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::takeChild):
* rendering/RenderFragmentedFlow.h:
* rendering/RenderMultiColumnFlow.cpp:
(WebCore::RenderMultiColumnFlow::handleSpannerRemoval): Deleted.
(WebCore::RenderMultiColumnFlow::fragmentedFlowRelativeWillBeRemoved): Deleted.
* rendering/RenderMultiColumnFlow.h:
* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::multiColumnRelativeWillBeRemoved):
* rendering/updating/RenderTreeBuilder.h:
* rendering/updating/RenderTreeBuilderMultiColumn.cpp:
(WebCore::RenderTreeBuilder::MultiColumn::handleSpannerRemoval):
(WebCore::RenderTreeBuilder::MultiColumn::multiColumnRelativeWillBeRemoved):
* rendering/updating/RenderTreeBuilderMultiColumn.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (228326 => 228327)


--- trunk/Source/WebCore/ChangeLog	2018-02-09 18:27:13 UTC (rev 228326)
+++ trunk/Source/WebCore/ChangeLog	2018-02-09 18:31:29 UTC (rev 228327)
@@ -1,3 +1,28 @@
+2018-02-09  Zalan Bujtas  <za...@apple.com>
+
+        [RenderTreeBuilder] Move multicolumn descendant/sibling removal logic to RenderTreeBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=182628
+        <rdar://problem/37369528>
+
+        Reviewed by Antti Koivisto.
+
+        No change in functionality
+
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::takeChild):
+        * rendering/RenderFragmentedFlow.h:
+        * rendering/RenderMultiColumnFlow.cpp:
+        (WebCore::RenderMultiColumnFlow::handleSpannerRemoval): Deleted.
+        (WebCore::RenderMultiColumnFlow::fragmentedFlowRelativeWillBeRemoved): Deleted.
+        * rendering/RenderMultiColumnFlow.h:
+        * rendering/updating/RenderTreeBuilder.cpp:
+        (WebCore::RenderTreeBuilder::multiColumnRelativeWillBeRemoved):
+        * rendering/updating/RenderTreeBuilder.h:
+        * rendering/updating/RenderTreeBuilderMultiColumn.cpp:
+        (WebCore::RenderTreeBuilder::MultiColumn::handleSpannerRemoval):
+        (WebCore::RenderTreeBuilder::MultiColumn::multiColumnRelativeWillBeRemoved):
+        * rendering/updating/RenderTreeBuilderMultiColumn.h:
+
 2018-02-09  Youenn Fablet  <you...@apple.com>
 
         Add support for cache storage of blob response

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (228326 => 228327)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2018-02-09 18:27:13 UTC (rev 228326)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2018-02-09 18:31:29 UTC (rev 228327)
@@ -3852,9 +3852,9 @@
 RenderPtr<RenderObject> RenderBlockFlow::takeChild(RenderTreeBuilder& builder, RenderObject& oldChild)
 {
     if (!renderTreeBeingDestroyed()) {
-        RenderFragmentedFlow* fragmentedFlow = multiColumnFlow();
+        auto* fragmentedFlow = multiColumnFlow();
         if (fragmentedFlow && fragmentedFlow != &oldChild)
-            fragmentedFlow->fragmentedFlowRelativeWillBeRemoved(oldChild);
+            builder.multiColumnRelativeWillBeRemoved(*fragmentedFlow, oldChild);
     }
     return RenderBlock::takeChild(builder, oldChild);
 }

Modified: trunk/Source/WebCore/rendering/RenderFragmentedFlow.h (228326 => 228327)


--- trunk/Source/WebCore/rendering/RenderFragmentedFlow.h	2018-02-09 18:27:13 UTC (rev 228326)
+++ trunk/Source/WebCore/rendering/RenderFragmentedFlow.h	2018-02-09 18:31:29 UTC (rev 228327)
@@ -86,8 +86,6 @@
 
     virtual bool singleFragmentHasUniformLogicalHeight() const { return true; }
     
-    // Called when a sibling or descendant of the flow thread is about to be removed.
-    virtual void fragmentedFlowRelativeWillBeRemoved(RenderObject&) { }
     // Called when a descendant box's layout is finished and it has been positioned within its container.
     virtual void fragmentedFlowDescendantBoxLaidOut(RenderBox*) { }
 

Modified: trunk/Source/WebCore/rendering/RenderMultiColumnFlow.cpp (228326 => 228327)


--- trunk/Source/WebCore/rendering/RenderMultiColumnFlow.cpp	2018-02-09 18:27:13 UTC (rev 228326)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnFlow.cpp	2018-02-09 18:31:29 UTC (rev 228327)
@@ -165,45 +165,6 @@
     return createRenderer<RenderMultiColumnSet>(*this, WTFMove(style));
 }
 
-void RenderMultiColumnFlow::handleSpannerRemoval(RenderObject& spanner)
-{
-    // The placeholder may already have been removed, but if it hasn't, do so now.
-    if (auto placeholder = spannerMap().take(&downcast<RenderBox>(spanner)))
-        placeholder->removeFromParentAndDestroy();
-
-    if (RenderObject* next = spanner.nextSibling()) {
-        if (RenderObject* previous = spanner.previousSibling()) {
-            if (previous->isRenderMultiColumnSet() && next->isRenderMultiColumnSet()) {
-                // Merge two sets that no longer will be separated by a spanner.
-                next->removeFromParentAndDestroy();
-                previous->setNeedsLayout();
-            }
-        }
-    }
-}
-
-void RenderMultiColumnFlow::fragmentedFlowRelativeWillBeRemoved(RenderObject& relative)
-{
-    invalidateFragments();
-    if (is<RenderMultiColumnSpannerPlaceholder>(relative)) {
-        // Remove the map entry for this spanner, but leave the actual spanner renderer alone. Also
-        // keep the reference to the spanner, since the placeholder may be about to be re-inserted
-        // in the tree.
-        ASSERT(relative.isDescendantOf(this));
-        spannerMap().remove(downcast<RenderMultiColumnSpannerPlaceholder>(relative).spanner());
-        return;
-    }
-    if (relative.style().columnSpan() == ColumnSpanAll) {
-        if (relative.parent() != parent())
-            return; // not a valid spanner.
-        
-        handleSpannerRemoval(relative);
-    }
-    // Note that we might end up with empty column sets if all column content is removed. That's no
-    // big deal though (and locating them would be expensive), and they will be found and re-used if
-    // content is added again later.
-}
-
 void RenderMultiColumnFlow::fragmentedFlowDescendantBoxLaidOut(RenderBox* descendant)
 {
     if (!is<RenderMultiColumnSpannerPlaceholder>(*descendant))

Modified: trunk/Source/WebCore/rendering/RenderMultiColumnFlow.h (228326 => 228327)


--- trunk/Source/WebCore/rendering/RenderMultiColumnFlow.h	2018-02-09 18:27:13 UTC (rev 228326)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnFlow.h	2018-02-09 18:31:29 UTC (rev 228327)
@@ -107,7 +107,6 @@
     const char* renderName() const override;
     void addFragmentToThread(RenderFragmentContainer*) override;
     void willBeRemovedFromTree() override;
-    void fragmentedFlowRelativeWillBeRemoved(RenderObject&) override;
     void fragmentedFlowDescendantBoxLaidOut(RenderBox*) override;
     LogicalExtentComputedValues computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop) const override;
     LayoutUnit initialLogicalWidth() const override;
@@ -118,8 +117,6 @@
     bool addForcedFragmentBreak(const RenderBlock*, LayoutUnit, RenderBox* breakChild, bool isBefore, LayoutUnit* offsetBreakAdjustment = 0) override;
     bool isPageLogicalHeightKnown() const override;
 
-    void handleSpannerRemoval(RenderObject& spanner);
-
 private:
     std::unique_ptr<SpannerMap> m_spannerMap;
 

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp (228326 => 228327)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2018-02-09 18:27:13 UTC (rev 228326)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2018-02-09 18:31:29 UTC (rev 228327)
@@ -405,6 +405,10 @@
         removeFromParentAndDestroyCleaningUpAnonymousWrappers(destroyRootParent);
     // WARNING: child is deleted here.
 }
+void RenderTreeBuilder::multiColumnRelativeWillBeRemoved(RenderMultiColumnFlow& flow, RenderObject& relative)
+{
+    multiColumnBuilder().multiColumnRelativeWillBeRemoved(flow, relative);
+}
 
 void RenderTreeBuilder::insertChildToRenderInline(RenderInline& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
 {

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h (228326 => 228327)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h	2018-02-09 18:27:13 UTC (rev 228326)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h	2018-02-09 18:31:29 UTC (rev 228327)
@@ -80,6 +80,7 @@
     RenderObject* resolveMovedChildForMultiColumnFlow(RenderFragmentedFlow& enclosingFragmentedFlow, RenderObject* beforeChild);
     void removeFromParentAndDestroyCleaningUpAnonymousWrappers(RenderObject& child);
     void multiColumnDescendantInserted(RenderMultiColumnFlow&, RenderObject& newDescendant);
+    void multiColumnRelativeWillBeRemoved(RenderMultiColumnFlow&, RenderObject& relative);
 
 private:
     class FirstLetter;

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderMultiColumn.cpp (228326 => 228327)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderMultiColumn.cpp	2018-02-09 18:27:13 UTC (rev 228326)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderMultiColumn.cpp	2018-02-09 18:31:29 UTC (rev 228327)
@@ -367,4 +367,43 @@
     return nextDescendant;
 }
 
+void RenderTreeBuilder::MultiColumn::handleSpannerRemoval(RenderMultiColumnFlow& flow, RenderObject& spanner)
+{
+    // The placeholder may already have been removed, but if it hasn't, do so now.
+    if (auto placeholder = flow.spannerMap().take(&downcast<RenderBox>(spanner)))
+        placeholder->removeFromParentAndDestroy();
+
+    if (auto* next = spanner.nextSibling()) {
+        if (auto* previous = spanner.previousSibling()) {
+            if (previous->isRenderMultiColumnSet() && next->isRenderMultiColumnSet()) {
+                // Merge two sets that no longer will be separated by a spanner.
+                next->removeFromParentAndDestroy();
+                previous->setNeedsLayout();
+            }
+        }
+    }
 }
+
+void RenderTreeBuilder::MultiColumn::multiColumnRelativeWillBeRemoved(RenderMultiColumnFlow& flow, RenderObject& relative)
+{
+    flow.invalidateFragments();
+    if (is<RenderMultiColumnSpannerPlaceholder>(relative)) {
+        // Remove the map entry for this spanner, but leave the actual spanner renderer alone. Also
+        // keep the reference to the spanner, since the placeholder may be about to be re-inserted
+        // in the tree.
+        ASSERT(relative.isDescendantOf(&flow));
+        flow.spannerMap().remove(downcast<RenderMultiColumnSpannerPlaceholder>(relative).spanner());
+        return;
+    }
+    if (relative.style().columnSpan() == ColumnSpanAll) {
+        if (relative.parent() != flow.parent())
+            return; // not a valid spanner.
+
+        handleSpannerRemoval(flow, relative);
+    }
+    // Note that we might end up with empty column sets if all column content is removed. That's no
+    // big deal though (and locating them would be expensive), and they will be found and re-used if
+    // content is added again later.
+}
+
+}

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderMultiColumn.h (228326 => 228327)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderMultiColumn.h	2018-02-09 18:27:13 UTC (rev 228326)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderMultiColumn.h	2018-02-09 18:31:29 UTC (rev 228327)
@@ -41,11 +41,13 @@
     // location in the tree.
     RenderObject* resolveMovedChild(RenderFragmentedFlow& enclosingFragmentedFlow, RenderObject* beforeChild);
     void multiColumnDescendantInserted(RenderMultiColumnFlow&, RenderObject& newDescendant);
+    void multiColumnRelativeWillBeRemoved(RenderMultiColumnFlow&, RenderObject& relative);
 
 private:
     void createFragmentedFlow(RenderBlockFlow&);
     void destroyFragmentedFlow(RenderBlockFlow&);
     RenderObject* processPossibleSpannerDescendant(RenderMultiColumnFlow&, RenderObject*& subtreeRoot, RenderObject& descendant);
+    void handleSpannerRemoval(RenderMultiColumnFlow&, RenderObject& spanner);
 
     RenderTreeBuilder& m_builder;
 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to