Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: f2b020b83d749e6e5f4de95cedcfca2d29335b6f
https://github.com/WebKit/WebKit/commit/f2b020b83d749e6e5f4de95cedcfca2d29335b6f
Author: Alan Baradlay <[email protected]>
Date: 2026-07-26 (Sun, 26 Jul 2026)
Changed paths:
M Source/WebCore/Headers.cmake
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
A Source/WebCore/layout/formattingContexts/flex/FlexItemContentCache.h
M Source/WebCore/layout/integration/flex/FlexIntegrationUtils.cpp
M Source/WebCore/layout/integration/flex/FlexIntegrationUtils.h
M Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp
M Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.h
M Source/WebCore/rendering/RenderBox.cpp
M Source/WebCore/rendering/RenderFlexibleBox.cpp
M Source/WebCore/rendering/RenderFlexibleBox.h
M Source/WebCore/rendering/RenderListBox.cpp
M Source/WebCore/rendering/RenderTable.cpp
M Source/WebCore/rendering/RenderTableCell.cpp
M Source/WebCore/rendering/RenderTextControl.cpp
Log Message:
-----------
[cleanup] Move the flex-item measurement caches off RenderFlexibleBox into a
FlexItemContentCache
https://bugs.webkit.org/show_bug.cgi?id=320287
Reviewed by Antti Koivisto.
RenderFlexibleBox owned the two per-flex-item measurement caches --
m_blockAxisSize (an item's inner
main size when the main axis is its block axis) and m_contentLogicalHeights (an
item's cross-axis
content height, captured before min/max or a stretch override constrains it) --
along with all the
logic around them, even though the flex formatting context is what produces and
consumes those
values.
Introduce FlexItemContentCache, a small header-only class holding both maps
behind a named API,
modelled on the inline formatting context's InlineContentCache.
FlexIntegrationUtils holds one and
takes over the cache logic: flexItemContentLogicalHeight,
setFlexItemContentLogicalHeightFromLayout,
restoreFlexItemContentLogicalHeight, computeBlockAxisContentSizeForFlexItem,
invalidateBlockAxisSizeForFlexItem and flexItemWillBeRemoved.
The two setters are renamed while moving:
setFlexItemContentLogicalHeightIfNeeded ->
setFlexItemContentLogicalHeightFromLayout (the render side depositing the
height during the item's own
layout, skipped when the container has already set an overriding height) and
cacheFlexItemContentLogicalHeightIfAllowed ->
restoreFlexItemContentLogicalHeight (the stretch path
putting back the height it saved before stretching, which must bypass that
override check). The old
IfNeeded/IfAllowed suffixes did not say which was which.
Lifetime is unchanged: FlexIntegrationUtils is a member of
LayoutIntegration::FlexLayout, which is a
member of RenderFlexibleBox, so cached entries survive across layouts exactly
as before.
RenderFlexibleBox keeps four one-line forwarders because the render side
reaches the caches with only
a flex container in hand: RenderBox, RenderTable, RenderTableCell,
RenderTextControl and RenderListBox
deposit an item's content height mid-layout, RelayoutScopeForScrollbarChange
invalidates the
block-axis size, and RenderBox and RenderTreeBuilder drop an item's entries
when it goes away. Those
forward through FlexLayout, which exposes them for the integration.
FlexItemContentCache.h includes RenderBox.h rather than forward-declaring it:
the HashMap keyed on
SingleThreadWeakRef<const RenderBox> instantiates WeakRef::ptr(), which
static_asserts on the type
being complete. Unified builds get that from a neighbouring translation unit,
so it only shows up in
non-unified builds. The class is annotated the way InlineContentCache is --
WTF_MAKE_TZONE_ALLOCATED
in the header with the _IMPL in a cpp -- since the _INLINE form would need an
Inlines.h include,
which is not allowed in a non-Inlines.h header.
No change in behavior.
* Source/WebCore/Headers.cmake:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/layout/formattingContexts/flex/FlexItemContentCache.h: Added.
(WebCore::FlexItemContentCache::blockAxisSize const):
(WebCore::FlexItemContentCache::setBlockAxisSize):
(WebCore::FlexItemContentCache::clearBlockAxisSize):
(WebCore::FlexItemContentCache::contentLogicalHeight const):
(WebCore::FlexItemContentCache::setContentLogicalHeight):
(WebCore::FlexItemContentCache::remove):
* Source/WebCore/layout/integration/flex/FlexIntegrationUtils.h:
* Source/WebCore/layout/integration/flex/FlexIntegrationUtils.cpp:
(WebCore::LayoutIntegration::canSetFlexItemContentLogicalHeight):
(WebCore::LayoutIntegration::FlexIntegrationUtils::applyStretchedLogicalHeightToFlexItem):
(WebCore::LayoutIntegration::FlexIntegrationUtils::flexItemContentLogicalHeight):
(WebCore::LayoutIntegration::FlexIntegrationUtils::setFlexItemContentLogicalHeightFromLayout):
(WebCore::LayoutIntegration::FlexIntegrationUtils::restoreFlexItemContentLogicalHeight):
(WebCore::LayoutIntegration::FlexIntegrationUtils::computeBlockAxisContentSizeForFlexItem):
(WebCore::LayoutIntegration::FlexIntegrationUtils::invalidateBlockAxisSizeForFlexItem):
(WebCore::LayoutIntegration::FlexIntegrationUtils::flexItemWillBeRemoved):
(WebCore::LayoutIntegration::FlexIntegrationUtils::flexItemContentLogicalHeight
const):
(WebCore::LayoutIntegration::FlexIntegrationUtils::FlexIntegrationUtils):
* Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.h:
* Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp:
(WebCore::LayoutIntegration::FlexLayout::flexItemContentLogicalHeight):
(WebCore::LayoutIntegration::FlexLayout::setFlexItemContentLogicalHeightFromLayout):
(WebCore::LayoutIntegration::FlexLayout::invalidateBlockAxisSizeForFlexItem):
(WebCore::LayoutIntegration::FlexLayout::flexItemWillBeRemoved):
(WebCore::LayoutIntegration::FlexLayout::flexItemContentLogicalHeight const):
(WebCore::LayoutIntegration::FlexLayout::FlexLayout):
* Source/WebCore/rendering/RenderFlexibleBox.h:
(WebCore::RenderFlexibleBox::setBlockAxisSizeForFlexItem): Deleted.
(WebCore::RenderFlexibleBox::blockAxisSizeForFlexItem const): Deleted.
* Source/WebCore/rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::invalidateBlockAxisSizeForFlexItem):
(WebCore::RenderFlexibleBox::flexItemWillBeRemoved):
(WebCore::RenderFlexibleBox::flexItemContentLogicalHeight):
(WebCore::RenderFlexibleBox::setFlexItemContentLogicalHeightFromLayout):
(WebCore::RenderFlexibleBox::setFlexItemContentLogicalHeightIfNeeded): Deleted.
(WebCore::canSetFlexItemContentLogicalHeight): Deleted.
(WebCore::RenderFlexibleBox::cacheFlexItemContentLogicalHeightIfAllowed):
Deleted.
(WebCore::RenderFlexibleBox::computeBlockAxisContentSizeForFlexItem): Deleted.
(WebCore::RenderFlexibleBox::flexItemContentLogicalHeight const):
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::updateLogicalHeight):
* Source/WebCore/rendering/RenderTable.cpp:
(WebCore::RenderTable::layout):
* Source/WebCore/rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::layout):
* Source/WebCore/rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::computeLogicalHeight const):
* Source/WebCore/rendering/RenderListBox.cpp:
(WebCore::RenderListBox::computeLogicalHeight const):
Canonical link: https://commits.webkit.org/317939@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications