Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 541a1c2870a0a9e4a59cafb8adfe87b0827e6923
https://github.com/WebKit/WebKit/commit/541a1c2870a0a9e4a59cafb8adfe87b0827e6923
Author: Yulun Wu <[email protected]>
Date: 2026-03-28 (Sat, 28 Mar 2026)
Changed paths:
M Source/WebCore/rendering/RenderBlockFlow.cpp
Log Message:
-----------
Forced layouts are slower when all siblings create their own formatting
context.
https://bugs.webkit.org/show_bug.cgi?id=308946
rdar://171545381
Reviewed by Alan Baradlay.
This PR optimizes RenderBlockFlow::collapseMargins() by returning early when
margin
collapse with a child does not move the parent renderer.
The sibling walk looking for intruding floats in
addIntrudingFloatsFromPreviousBlocks
is only needed when the parent renderer is moved. Intruding floats should
already
be handled in `rebuildFloatingObjectSetFromIntrudingFloats`
addIntrudingFloatsFromPreviousBlocks skips siblings that create their own
formatting contexts,
creating an edge case where all siblings have their own formatting context (e.g
contain:layout).
This causes us to keep skipping previous siblings, causing collapseMargins() to
have
O(N^2) runtime for N siblings.
The fix is to return early from collapseMargins() when the logical top does not
decrease
after collapsing margins as the sibling walk is not relevant in this case and
can
be skipped entirely.
* Source/WebCore/rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::collapseMargins):
Canonical link: https://commits.webkit.org/310173@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications