Title: [259334] trunk
Revision
259334
Author
[email protected]
Date
2020-03-31 19:32:49 -0700 (Tue, 31 Mar 2020)

Log Message

[MultiColumn] Call RenderTreeBuilder::multiColumnDescendantInserted only when the enclosing fragmented flow has changed
https://bugs.webkit.org/show_bug.cgi?id=209816
<rdar://problem/60742191>

Reviewed by Antti Koivisto.

Source/WebCore:

Just because an element goes from out-of-flow to in-flow, it does not necessarily mean that the enclosing flow is going to change.
This patch ensure that we only call RenderTreeBuilder::multiColumnDescendantInserted when the flow actually gains new content.

Test: fast/multicol/absolute-to-static-change-same-enclosing-flow.html

* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::childFlowStateChangesAndAffectsParentBlock):

LayoutTests:

* fast/multicol/absolute-to-static-change-same-enclosing-flow-expected.txt: Added.
* fast/multicol/absolute-to-static-change-same-enclosing-flow.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (259333 => 259334)


--- trunk/LayoutTests/ChangeLog	2020-04-01 02:29:56 UTC (rev 259333)
+++ trunk/LayoutTests/ChangeLog	2020-04-01 02:32:49 UTC (rev 259334)
@@ -1,3 +1,14 @@
+2020-03-31  Zalan Bujtas  <[email protected]>
+
+        [MultiColumn] Call RenderTreeBuilder::multiColumnDescendantInserted only when the enclosing fragmented flow has changed
+        https://bugs.webkit.org/show_bug.cgi?id=209816
+        <rdar://problem/60742191>
+
+        Reviewed by Antti Koivisto.
+
+        * fast/multicol/absolute-to-static-change-same-enclosing-flow-expected.txt: Added.
+        * fast/multicol/absolute-to-static-change-same-enclosing-flow.html: Added.
+
 2020-03-31  Wenson Hsieh  <[email protected]>
 
         Datalist option's label not used

Added: trunk/LayoutTests/fast/multicol/absolute-to-static-change-same-enclosing-flow-expected.txt (0 => 259334)


--- trunk/LayoutTests/fast/multicol/absolute-to-static-change-same-enclosing-flow-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/multicol/absolute-to-static-change-same-enclosing-flow-expected.txt	2020-04-01 02:32:49 UTC (rev 259334)
@@ -0,0 +1,2 @@
+Pass if no crash or assert when the absolute positioned element becomes static and it still part of the same column fragment.
+

Added: trunk/LayoutTests/fast/multicol/absolute-to-static-change-same-enclosing-flow.html (0 => 259334)


--- trunk/LayoutTests/fast/multicol/absolute-to-static-change-same-enclosing-flow.html	                        (rev 0)
+++ trunk/LayoutTests/fast/multicol/absolute-to-static-change-same-enclosing-flow.html	2020-04-01 02:32:49 UTC (rev 259334)
@@ -0,0 +1,18 @@
+<style>
+summary {
+  column-span: all;
+}
+#details { 
+  column-count: 2; 
+  position: absolute;
+}
+html {
+  column-count: 2;
+}
+</style>Pass if no crash or assert when the absolute positioned element becomes static and it still part of the same column fragment.<details id="details"><summary></detail><script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+document.body.offsetHeight;
+details.style.columnCount = "1";
+details.style.position = "static";
+</script>

Modified: trunk/Source/WebCore/ChangeLog (259333 => 259334)


--- trunk/Source/WebCore/ChangeLog	2020-04-01 02:29:56 UTC (rev 259333)
+++ trunk/Source/WebCore/ChangeLog	2020-04-01 02:32:49 UTC (rev 259334)
@@ -1,3 +1,19 @@
+2020-03-31  Zalan Bujtas  <[email protected]>
+
+        [MultiColumn] Call RenderTreeBuilder::multiColumnDescendantInserted only when the enclosing fragmented flow has changed
+        https://bugs.webkit.org/show_bug.cgi?id=209816
+        <rdar://problem/60742191>
+
+        Reviewed by Antti Koivisto.
+
+        Just because an element goes from out-of-flow to in-flow, it does not necessarily mean that the enclosing flow is going to change.
+        This patch ensure that we only call RenderTreeBuilder::multiColumnDescendantInserted when the flow actually gains new content.
+
+        Test: fast/multicol/absolute-to-static-change-same-enclosing-flow.html
+
+        * rendering/updating/RenderTreeBuilder.cpp:
+        (WebCore::RenderTreeBuilder::childFlowStateChangesAndAffectsParentBlock):
+
 2020-03-31  Simon Fraser  <[email protected]>
 
         Add type traits for ScrollableArea, and other cleanup

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp (259333 => 259334)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2020-04-01 02:29:56 UTC (rev 259333)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2020-04-01 02:32:49 UTC (rev 259334)
@@ -686,27 +686,29 @@
 
 void RenderTreeBuilder::childFlowStateChangesAndAffectsParentBlock(RenderElement& child)
 {
-    auto* parent = child.parent();
     if (!child.isInline()) {
-        if (is<RenderBlock>(parent))
+        auto* currentEnclosingFragment = child.enclosingFragmentedFlow();
+        auto parent = makeWeakPtr(child.parent());
+        if (is<RenderBlock>(*parent))
             blockBuilder().childBecameNonInline(downcast<RenderBlock>(*parent), child);
         else if (is<RenderInline>(*parent))
             inlineBuilder().childBecameNonInline(downcast<RenderInline>(*parent), child);
+        // WARNING: original parent might be deleted at this point.
 
-        // childBecameNonInline might have re-parented us.
         if (auto* newParent = child.parent()) {
-            // We need to re-run the grid items placement if it had gained a new item.
-            if (newParent != parent && is<RenderGrid>(*newParent))
+            // childBecameNonInline might have re-parented us.
+            if (newParent != parent && is<RenderGrid>(*newParent)) {
+                // We need to re-run the grid items placement if it had gained a new item.
                 downcast<RenderGrid>(*newParent).dirtyGrid();
-            else if (auto* enclosingFragmentedFlow = newParent->enclosingFragmentedFlow()) {
-                if (is<RenderMultiColumnFlow>(*enclosingFragmentedFlow)) {
-                    // Let the fragmented flow know that it has a new in-flow descendant.
-                    multiColumnBuilder().multiColumnDescendantInserted(downcast<RenderMultiColumnFlow>(*enclosingFragmentedFlow), child);
-                }
             }
+            if (auto* newEnclosingFragmentedFlow = newParent->enclosingFragmentedFlow(); is<RenderMultiColumnFlow>(newEnclosingFragmentedFlow) && currentEnclosingFragment != newEnclosingFragmentedFlow) {
+                // Let the fragmented flow know that it has a new in-flow descendant.
+                multiColumnBuilder().multiColumnDescendantInserted(downcast<RenderMultiColumnFlow>(*newEnclosingFragmentedFlow), child);
+            }
         }
     } else {
         // An anonymous block must be made to wrap this inline.
+        auto* parent = child.parent();
         auto newBlock = downcast<RenderBlock>(*parent).createAnonymousBlock();
         auto& block = *newBlock;
         attachToRenderElementInternal(*parent, WTFMove(newBlock), &child);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to