Title: [279996] trunk/Source/WebCore
Revision
279996
Author
za...@apple.com
Date
2021-07-16 13:34:06 -0700 (Fri, 16 Jul 2021)

Log Message

[RenderTreeBuilder] Update the fragmented status of the renderer when it becomes in-flow
https://bugs.webkit.org/show_bug.cgi?id=228025
<rdar://80458138>

Reviewed by Antti Koivisto.

This patch ensures that we update fragmented status of the renderer when it becomes in-flow and not just when the containing block's childrenInline status needs updating.
(e.g. the block renderer goes from out-of-flow to in-flow, and the containing block already has block level children, we don't call childFlowStateChangesAndAffectsParentBlock)

* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::normalizeTreeAfterStyleChange): Move the update logic out from childFlowStateChangesAndAffectsParentBlock to here and run it unconditionally.
(WebCore::RenderTreeBuilder::childFlowStateChangesAndAffectsParentBlock):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (279995 => 279996)


--- trunk/Source/WebCore/ChangeLog	2021-07-16 20:25:58 UTC (rev 279995)
+++ trunk/Source/WebCore/ChangeLog	2021-07-16 20:34:06 UTC (rev 279996)
@@ -1,3 +1,18 @@
+2021-07-16  Alan Bujtas  <za...@apple.com>
+
+        [RenderTreeBuilder] Update the fragmented status of the renderer when it becomes in-flow
+        https://bugs.webkit.org/show_bug.cgi?id=228025
+        <rdar://80458138>
+
+        Reviewed by Antti Koivisto.
+
+        This patch ensures that we update fragmented status of the renderer when it becomes in-flow and not just when the containing block's childrenInline status needs updating.
+        (e.g. the block renderer goes from out-of-flow to in-flow, and the containing block already has block level children, we don't call childFlowStateChangesAndAffectsParentBlock)
+
+        * rendering/updating/RenderTreeBuilder.cpp:
+        (WebCore::RenderTreeBuilder::normalizeTreeAfterStyleChange): Move the update logic out from childFlowStateChangesAndAffectsParentBlock to here and run it unconditionally.
+        (WebCore::RenderTreeBuilder::childFlowStateChangesAndAffectsParentBlock):
+
 2021-07-16  Fujii Hironori  <hironori.fu...@sony.com>
 
         [curl] Use curl_multi_poll and curl_multi_wakeup instead of select

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp (279995 => 279996)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2021-07-16 20:25:58 UTC (rev 279995)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2021-07-16 20:34:06 UTC (rev 279996)
@@ -583,8 +583,29 @@
         // 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.
+        auto* currentEnclosingFragment = renderer.enclosingFragmentedFlow();
         if (renderer.isInline() != renderer.parent()->childrenInline())
             childFlowStateChangesAndAffectsParentBlock(renderer);
+        // WARNING: original parent might be deleted at this point.
+        if (auto* newParent = renderer.parent()) {
+            // FIXME: Merge this with the multicolumn code below webkit.org/b/228024
+            auto newMultiColumnForRenderer = [&]() -> RenderMultiColumnFlow* {
+                // Update the state when the renderer has moved from one multi-column flow to another.
+                auto* newEnclosingFragmentedFlow = newParent->enclosingFragmentedFlow();
+                if (newParent->isMultiColumnBlockFlow()) {
+                    // This renderer is a spanner so it is not in the subtree of the multicolumn renderer. It is parented directly under the block flow so
+                    // enclosingFragmentedFlow() returns the parent enclosing flow.
+                    ASSERT(is<RenderBox>(renderer) && downcast<RenderBlockFlow>(*newParent).multiColumnFlow()->spannerMap().contains(&downcast<RenderBox>(renderer)));
+                    newEnclosingFragmentedFlow = downcast<RenderBlockFlow>(*newParent).multiColumnFlow();
+                }
+                return newEnclosingFragmentedFlow != currentEnclosingFragment && is<RenderMultiColumnFlow>(newEnclosingFragmentedFlow) ? downcast<RenderMultiColumnFlow>(newEnclosingFragmentedFlow) : nullptr;
+            };
+            if (auto* newEnclosingMultiColumn = newMultiColumnForRenderer()) {
+                // Let the fragmented flow know that it has a new in-flow descendant.
+                renderer.initializeFragmentedFlowStateOnInsertion();
+                multiColumnBuilder().multiColumnDescendantInserted(*newEnclosingMultiColumn, renderer);
+            }
+        }
         return;
     }
 
@@ -710,7 +731,6 @@
 void RenderTreeBuilder::childFlowStateChangesAndAffectsParentBlock(RenderElement& child)
 {
     if (!child.isInline()) {
-        auto* currentEnclosingFragment = child.enclosingFragmentedFlow();
         auto parent = makeWeakPtr(child.parent());
         if (is<RenderBlock>(*parent))
             blockBuilder().childBecameNonInline(downcast<RenderBlock>(*parent), child);
@@ -717,40 +737,19 @@
         else if (is<RenderInline>(*parent))
             inlineBuilder().childBecameNonInline(downcast<RenderInline>(*parent), child);
         // WARNING: original parent might be deleted at this point.
-
-        if (auto* newParent = child.parent()) {
-            // 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();
-            }
-
-            auto newMultiColumnForChildRenderer = [&]() -> RenderMultiColumnFlow* {
-                // Update the state when the child has moved from one multi-column flow to another.
-                auto* newEnclosingFragmentedFlow = newParent->enclosingFragmentedFlow();
-                if (newParent->isMultiColumnBlockFlow()) {
-                    // This child is a spanner so it is not in the subtree of the multicolumn renderer. It is parented directly under the block flow so
-                    // enclosingFragmentedFlow() returns the parent enclosing flow.
-                    ASSERT(is<RenderBox>(child) && downcast<RenderBlockFlow>(*newParent).multiColumnFlow()->spannerMap().contains(&downcast<RenderBox>(child)));
-                    newEnclosingFragmentedFlow = downcast<RenderBlockFlow>(*newParent).multiColumnFlow();
-                }
-                return newEnclosingFragmentedFlow != currentEnclosingFragment && is<RenderMultiColumnFlow>(newEnclosingFragmentedFlow) ? downcast<RenderMultiColumnFlow>(newEnclosingFragmentedFlow) : nullptr;
-            };
-            if (auto* newEnclosingMultiColumn = newMultiColumnForChildRenderer()) {
-                // Let the fragmented flow know that it has a new in-flow descendant.
-                child.initializeFragmentedFlowStateOnInsertion();
-                multiColumnBuilder().multiColumnDescendantInserted(*newEnclosingMultiColumn, child);
-            }
+        if (auto* newParent = child.parent(); 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 {
-        // 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);
-        auto thisToMove = detachFromRenderElement(*parent, child);
-        attachToRenderElementInternal(block, WTFMove(thisToMove));
+        return;
     }
+    // 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);
+    auto thisToMove = detachFromRenderElement(*parent, child);
+    attachToRenderElementInternal(block, WTFMove(thisToMove));
 }
 
 void RenderTreeBuilder::removeAnonymousWrappersForInlineChildrenIfNeeded(RenderElement& parent)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to