Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0b1757694dabeeb50887ecb95dc800f36ebddf79
      
https://github.com/WebKit/WebKit/commit/0b1757694dabeeb50887ecb95dc800f36ebddf79
  Author: Alan Baradlay <[email protected]>
  Date:   2026-07-25 (Sat, 25 Jul 2026)

  Changed paths:
    M Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp
    M Source/WebCore/layout/integration/flex/FlexIntegrationUtils.cpp
    M Source/WebCore/layout/integration/flex/FlexIntegrationUtils.h
    M Source/WebCore/rendering/RenderBlock.cpp
    M Source/WebCore/rendering/RenderFlexibleBox.h

  Log Message:
  -----------
  [cleanup] Split the flex-item cross-size override and intrinsic-width flag 
into separate scopes
https://bugs.webkit.org/show_bug.cgi?id=320216

Reviewed by Antti Koivisto.

ScopedCrossAxisOverrideForFlexItem (introduced in 320206) bundled two separate 
concerns that
were applied together at every flex-item intrinsic-width measurement:

- the cross-axis size override, set on the item so its own size computation 
sees the container's
  definite cross size (and cleared when the cross size is indefinite), plus the 
optional
  preferred-width invalidation; and
- RenderFlexibleBox::m_inFlexItemIntrinsicWidthComputation, which makes the 
item's percentage
  content resolve against that definite cross size (via 
canUseFlexItemForPercentageResolution).

Bundling them made the class unnameable and forced both onto every use 
regardless of need.
Split it into two single-purpose scopes:

- FlexItemDefiniteCrossSizeScope: the override + invalidation. Touches only the 
item, so it
  needs no access to the container. It is used when measuring an item before it 
is stretched:
  when the item is going to be stretched to a definite cross size (flexbox 9.8 
rule 1), that size
  becomes its cross-axis overriding size so the measurement sees the item's 
final cross size;
  otherwise the item has no definite cross size and both of its overriding 
sizes are cleared.
- FlexItemIntrinsicWidthComputationScope: the flag. This is the only piece that 
reaches the
  container's private member, so it stays a friend of RenderFlexibleBox.

Both main-axis branches of computeMainAxisExtentForFlexItem need the definite 
cross size: the
inline (width) branch measures the item's width by laying its content out, and 
the block
(column/height) branch resolves an intrinsic height that -- for a replaced 
item, or any item with
a preferred aspect ratio -- is computed from the item's used cross size. The 
intrinsic-width flag,
on the other hand, only affects percentage resolution while the item's width is 
being measured, so
it is applied to the inline branch, the two direct 
min/maxContentLogicalWidthContribution reads,
and RenderBlock::computeChildIntrinsicLogicalWidths, but not to the block 
branch. No intended
change in behavior.

Since FlexItemDefiniteCrossSizeScope was the last user of the generic 
OverridingSizesScope that
saved, replaced and restored a box's overriding sizes, that class is folded 
into it: the flex-item
scope now saves and restores the axes it touches directly, which lets its two 
branches read as the
sizing rule they implement rather than as axis bookkeeping. The one remaining 
caller,
FlexFormattingContext::flexItemIntrinsicLogicalWidth, clears the item's 
overriding width around a
computeLogicalWidth call, and now does that save/restore by hand with a FIXME: 
computeLogicalWidth
returns the overriding width as-is for a flex item, but nothing in the layout 
pass appears to set an
overriding inline size on an orthogonal flex item at that point, so this may be 
removable.

Also fixed a stale comment: computeLogicalWidthUsing re-computes the intrinsic 
widths for content
sizes, not "always".

* Source/WebCore/layout/integration/flex/FlexIntegrationUtils.h:
* Source/WebCore/layout/integration/flex/FlexIntegrationUtils.cpp:
(WebCore::LayoutIntegration::FlexItemDefiniteCrossSizeScope::FlexItemDefiniteCrossSizeScope):
(WebCore::LayoutIntegration::FlexItemDefiniteCrossSizeScope::~FlexItemDefiniteCrossSizeScope):
(WebCore::LayoutIntegration::FlexItemIntrinsicWidthComputationScope::FlexItemIntrinsicWidthComputationScope):
(WebCore::LayoutIntegration::FlexIntegrationUtils::computeMainAxisExtentForFlexItemWithCrossAxisOverride):
(WebCore::LayoutIntegration::FlexIntegrationUtils::maxContentMainAxisContributionForFlexItem):
(WebCore::LayoutIntegration::FlexIntegrationUtils::minContentMainAxisContributionForFlexItem):
(WebCore::LayoutIntegration::OverridingSizesScope::OverridingSizesScope): 
Deleted.
(WebCore::LayoutIntegration::OverridingSizesScope::~OverridingSizesScope): 
Deleted.
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp:
(WebCore::FlexFormattingContext::flexItemIntrinsicLogicalWidth):
* Source/WebCore/rendering/RenderFlexibleBox.h:
* Source/WebCore/rendering/RenderBlock.cpp:
(WebCore::RenderBlock::computeChildIntrinsicLogicalWidths):

Canonical link: https://commits.webkit.org/317921@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to