[webkit-changes] [WebKit/WebKit] 364adc: [css-grid] Add LayoutRequirement to indicate when ...

Sammy Gill noreply at github.com
Thu Jul 18 08:17:17 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 364adc3b7d9e55c7947b770c1a95f435d002b988
      https://github.com/WebKit/WebKit/commit/364adc3b7d9e55c7947b770c1a95f435d002b988
  Author: Sammy Gill <sammy.gill at apple.com>
  Date:   2024-07-18 (Thu, 18 Jul 2024)

  Changed paths:
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    A Source/WebCore/rendering/GridLayoutState.h
    M Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp
    M Source/WebCore/rendering/GridTrackSizingAlgorithm.h
    M Source/WebCore/rendering/RenderGrid.cpp
    M Source/WebCore/rendering/RenderGrid.h

  Log Message:
  -----------
  [css-grid] Add LayoutRequirement to indicate when a grid item needs stretching in column axis.
https://bugs.webkit.org/show_bug.cgi?id=276609
rdar://problem/131751762

Reviewed by Alan Baradlay.

Currently grid will invalidate an item before stretching its block
size in one of the following scenarios

1.) Its current block size is not the stretched size
2.) It has percent height descendants

Let's try to limit 2 when we stretch in the column axis. This is done
by adding a new bit via LayoutRequirements to indicate when this should
be done.

There are two different scenarios in which we will currently set this
bit.

The first opportunity to set this bit is by checking damaged grid items
before we perform grid layout. If we find a damaged grid item,
then we will check if it needs to be stretched in the column axis by
checking its style.

The second time we may need to set this bit is during the grid track
sizing algorithm in GridTrackSizingAlgorithmStrategy::logicalHeightForChild.
Here we may clear any overriding sizes, mark the renderer as dirty, and
perform layout on it. If an item was previously stretched here then we
will lose its stretched size after this. If this is the case then we
will attempt to set the new bit if the item's style requires stretching.

Later on when we get to the stretch alignment logic, then we will check
to see if this bit is set when stretching an item in the column axis and
its block axis is in the same direction. In other cases we will fall
back to the original logic.

In order to accomplish this I added GridLayoutState, which is a new
helper class that should help keep track of extra layout related
information as we perform grid layout. This is a stack based class so
it will be created at the beginning of layout and destroyed at the end.

* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/rendering/GridLayoutState.h: Added.
(WebCore::GridLayoutState::itemsLayoutRequirements):
* Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp:
(WebCore::GridTrackSizingAlgorithmStrategy::logicalHeightForChild const):
(WebCore::GridTrackSizingAlgorithm::setup):
* Source/WebCore/rendering/GridTrackSizingAlgorithm.h:
* Source/WebCore/rendering/RenderGrid.cpp:
(WebCore::RenderGrid::computeTrackSizesForDefiniteSize):
(WebCore::RenderGrid::repeatTracksSizingIfNeeded):
(WebCore::RenderGrid::canSetColumnAxisStretchRequirementForItem const):
(WebCore::RenderGrid::computeLayoutRequirementsForItemsBeforeLayout const):
(WebCore::RenderGrid::layoutGrid):
(WebCore::RenderGrid::layoutMasonry):
(WebCore::RenderGrid::computeIntrinsicLogicalWidths const):
(WebCore::RenderGrid::computeTrackSizesForIndefiniteSize const):
(WebCore::RenderGrid::updateGridAreaForAspectRatioItems):
(WebCore::RenderGrid::layoutGridItems):
(WebCore::RenderGrid::layoutMasonryItems):
(WebCore::RenderGrid::applyStretchAlignmentToChildIfNeeded):
* Source/WebCore/rendering/RenderGrid.h:

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



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


More information about the webkit-changes mailing list