[webkit-changes] [WebKit/WebKit] c87ee9: [margin-trim] block-start margins for grid items i...

Sammy Gill noreply at github.com
Fri Apr 14 08:27:51 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c87ee9281557b041309d82cc2a04fff613444fc9
      https://github.com/WebKit/WebKit/commit/c87ee9281557b041309d82cc2a04fff613444fc9
  Author: Sammy Gill <sammy.gill at apple.com>
  Date:   2023-04-14 (Fri, 14 Apr 2023)

  Changed paths:
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/grid-block-start-expected.txt
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/grid-block-start.html
    M Source/WebCore/css/ComputedStyleExtractor.cpp
    M Source/WebCore/rendering/RenderBox.cpp

  Log Message:
  -----------
  [margin-trim] block-start margins for grid items in horizontal writing-mode should be reflected in computed style.
https://bugs.webkit.org/show_bug.cgi?id=253716
rdar://106559103

Reviewed by Alan Baradlay.

When the block-start margins for grid items that are adjacent to the
block-start edge of the grid, We need to set the rare data bits for
the item to indicate that the margin has been trimmed. We can then check
if this bit is set within ComputedStyleExtractor to get the trimmed
value for this margin by directly querying the renderer's m_marginBox.
In a horizontal writing mode this bit would correspond to the "top,"
margin value.

For block-start margins, the trimming occurs when a renderer goes
through layout and calls RenderBox::constrainBlockMarginInAvailableSpaceOrTrim,
which is called from RenderBox::computeBlockDirectionMargins. This
function consults the layout system, which is grid in this case, via
shouldTrimChildMargin to see if it should trim its margin. If this
returns true, then the renderer will not compute the margin and will
return 0_lu. We can use this opportunity to set the rare data for the
renderer to indicate that this margin has been trimmed.

Inside of ComputedStyleExtractor, we need to update
rendererCanHaveTrimmedMargin so that this returns true for grid items.
This will allow us to do 2 things:
1.) Have isLayoutDependent return true for grid items with margin-trim
set on the grid so that layout is forced when checking the "top," margin
for grid items
2.) Allow us to call box->hasTrimmedMargin when computing the margin
value (since that call is guarded by a call to rendererCanHaveTrimmedMargin)

Similarly, there are a couple of other extra pieces of code in RenderBox
(particularly in physicalToFlowRelativeDirectionMapping and hasTrimmedMargin)
that should now be used with grid items.

* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/grid-block-start-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/grid-block-start.html: Added.
* Source/WebCore/css/ComputedStyleExtractor.cpp:
(WebCore::rendererCanHaveTrimmedMargin):
(WebCore::isLayoutDependent):
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::physicalToFlowRelativeDirectionMapping const):
(WebCore::RenderBox::hasTrimmedMargin const):
(WebCore::RenderBox::constrainBlockMarginInAvailableSpaceOrTrim const):

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




More information about the webkit-changes mailing list