Title: [293895] trunk/Source/WebCore
- Revision
- 293895
- Author
- [email protected]
- Date
- 2022-05-06 09:26:46 -0700 (Fri, 06 May 2022)
Log Message
Add lambda for fragmented flow state change handling
https://bugs.webkit.org/show_bug.cgi?id=240165
Patch by Rob Buis <[email protected]> on 2022-05-06
Reviewed by Alan Bujtas.
Add lambda for fragmented flow state change handling
and call it in the case where the parent is affected.
* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::normalizeTreeAfterStyleChange):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (293894 => 293895)
--- trunk/Source/WebCore/ChangeLog 2022-05-06 16:09:09 UTC (rev 293894)
+++ trunk/Source/WebCore/ChangeLog 2022-05-06 16:26:46 UTC (rev 293895)
@@ -1,3 +1,16 @@
+2022-05-06 Rob Buis <[email protected]>
+
+ Add lambda for fragmented flow state change handling
+ https://bugs.webkit.org/show_bug.cgi?id=240165
+
+ Reviewed by Alan Bujtas.
+
+ Add lambda for fragmented flow state change handling
+ and call it in the case where the parent is affected.
+
+ * rendering/updating/RenderTreeBuilder.cpp:
+ (WebCore::RenderTreeBuilder::normalizeTreeAfterStyleChange):
+
2022-05-06 Jer Noble <[email protected]>
[iOS] Infinite recursion at -[WKFullScreenWindowController _exitFullscreenImmediately]
Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp (293894 => 293895)
--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp 2022-05-06 16:09:09 UTC (rev 293894)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp 2022-05-06 16:26:46 UTC (rev 293895)
@@ -599,7 +599,50 @@
bool isOutOfFlowPositioned = renderer.style().hasOutOfFlowPosition();
bool startsAffectingParent = false;
bool noLongerAffectsParent = false;
+ auto handleFragmentedFlowStateChange = [&] {
+ if (!renderer.parent())
+ return;
+ // Out of flow children of RenderMultiColumnFlow are not really part of the multicolumn flow. We need to ensure that changes in positioning like this
+ // trigger insertions into the multicolumn flow.
+ if (auto* enclosingFragmentedFlow = parent.enclosingFragmentedFlow(); is<RenderMultiColumnFlow>(enclosingFragmentedFlow)) {
+ auto movingIntoMulticolumn = [&] {
+ if (wasOutOfFlowPositioned && !isOutOfFlowPositioned)
+ return true;
+ if (auto* containingBlock = renderer.containingBlock(); containingBlock && isOutOfFlowPositioned) {
+ // Sometimes the flow state could change even when the renderer stays out-of-flow (e.g when going from fixed to absolute and
+ // the containing block is inside a multi-column flow).
+ return containingBlock->fragmentedFlowState() == RenderObject::InsideInFragmentedFlow
+ && renderer.fragmentedFlowState() == RenderObject::NotInsideFragmentedFlow;
+ }
+ return false;
+ }();
+ if (movingIntoMulticolumn) {
+ renderer.initializeFragmentedFlowStateOnInsertion();
+ multiColumnBuilder().multiColumnDescendantInserted(downcast<RenderMultiColumnFlow>(*enclosingFragmentedFlow), renderer);
+ return;
+ }
+ auto movingOutOfMulticolumn = !wasOutOfFlowPositioned && isOutOfFlowPositioned;
+ if (movingOutOfMulticolumn) {
+ multiColumnBuilder().restoreColumnSpannersForContainer(renderer, downcast<RenderMultiColumnFlow>(*enclosingFragmentedFlow));
+ return;
+ }
+ // Style change may have moved some subtree out of the fragmented flow. Their flow states have already been updated (see adjustFragmentedFlowStateOnContainingBlockChangeIfNeeded)
+ // and here is where we take care of the remaining, spanner tree mutation.
+ WeakHashSet<RenderElement> spannerContainingBlockSet;
+ for (auto& descendant : descendantsOfType<RenderMultiColumnSpannerPlaceholder>(renderer)) {
+ if (auto* containingBlock = descendant.containingBlock(); containingBlock && containingBlock->enclosingFragmentedFlow() != enclosingFragmentedFlow)
+ spannerContainingBlockSet.add(*containingBlock);
+ }
+ auto oldEnclosingFragmentedFlow = WeakPtr { *enclosingFragmentedFlow };
+ for (auto& containingBlock : spannerContainingBlockSet) {
+ if (!oldEnclosingFragmentedFlow)
+ break;
+ multiColumnBuilder().restoreColumnSpannersForContainer(containingBlock, downcast<RenderMultiColumnFlow>(*oldEnclosingFragmentedFlow));
+ }
+ }
+ };
+
if (is<RenderBlock>(parent))
noLongerAffectsParent = (!wasFloating && isFloating) || (!wasOutOfFlowPositioned && isOutOfFlowPositioned);
@@ -612,29 +655,10 @@
// 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 ? dynamicDowncast<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);
- }
- }
+ handleFragmentedFlowStateChange();
return;
}
@@ -657,45 +681,7 @@
}
}
- // Out of flow children of RenderMultiColumnFlow are not really part of the multicolumn flow. We need to ensure that changes in positioning like this
- // trigger insertions into the multicolumn flow.
- if (auto* enclosingFragmentedFlow = parent.enclosingFragmentedFlow(); is<RenderMultiColumnFlow>(enclosingFragmentedFlow)) {
- auto movingIntoMulticolumn = [&] {
- if (wasOutOfFlowPositioned && !isOutOfFlowPositioned)
- return true;
- if (auto* containingBlock = renderer.containingBlock(); containingBlock && isOutOfFlowPositioned) {
- // Sometimes the flow state could change even when the renderer stays out-of-flow (e.g when going from fixed to absolute and
- // the containing block is inside a multi-column flow).
- return containingBlock->fragmentedFlowState() == RenderObject::InsideInFragmentedFlow
- && renderer.fragmentedFlowState() == RenderObject::NotInsideFragmentedFlow;
- }
- return false;
- }();
- if (movingIntoMulticolumn) {
- renderer.initializeFragmentedFlowStateOnInsertion();
- multiColumnBuilder().multiColumnDescendantInserted(downcast<RenderMultiColumnFlow>(*enclosingFragmentedFlow), renderer);
- return;
- }
- auto movingOutOfMulticolumn = !wasOutOfFlowPositioned && isOutOfFlowPositioned;
- if (movingOutOfMulticolumn) {
- multiColumnBuilder().restoreColumnSpannersForContainer(renderer, downcast<RenderMultiColumnFlow>(*enclosingFragmentedFlow));
- return;
- }
-
- // Style change may have moved some subtree out of the fragmented flow. Their flow states have already been updated (see adjustFragmentedFlowStateOnContainingBlockChangeIfNeeded)
- // and here is where we take care of the remaining, spanner tree mutation.
- WeakHashSet<RenderElement> spannerContainingBlockSet;
- for (auto& descendant : descendantsOfType<RenderMultiColumnSpannerPlaceholder>(renderer)) {
- if (auto* containingBlock = descendant.containingBlock(); containingBlock && containingBlock->enclosingFragmentedFlow() != enclosingFragmentedFlow)
- spannerContainingBlockSet.add(*containingBlock);
- }
- auto oldEnclosingFragmentedFlow = WeakPtr { *enclosingFragmentedFlow };
- for (auto& containingBlock : spannerContainingBlockSet) {
- if (!oldEnclosingFragmentedFlow)
- break;
- multiColumnBuilder().restoreColumnSpannersForContainer(containingBlock, downcast<RenderMultiColumnFlow>(*oldEnclosingFragmentedFlow));
- }
- }
+ handleFragmentedFlowStateChange();
}
void RenderTreeBuilder::makeChildrenNonInline(RenderBlock& parent, RenderObject* insertionPoint)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes