[webkit-changes] [WebKit/WebKit] 53332e: [margin-trim] Trimmed inline-start margins for gri...

Sammy Gill noreply at github.com
Sat Apr 15 21:04:51 PDT 2023


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

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

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

Reviewed by Alan Baradlay.

When a grid has inline-start specified for margin trim, it will trim the
inline-start margins of any items that are placed in the first column
of the grid. These trimmed margins should be reflected when querying the
computed style for the item. In order for this to happen,
ComputedStyleExtractor must be able to identify when the inline-start/left
margins of a grid item are trimmed. We can accomplish this by setting
the rare data bits for the renderer as this margin is trimmed during
layout. Then, ComputedStyleExtractor will be able to check to see if
this bit is set.

The inline-start margins for grid items are trimmed inside of
RenderBox::computeOrTrimInlineMargin as the renderer is going through
layout. This function is called as the renderer is trying to determine
its inline margin values as part of RenderBox::computeLogicalWidthInFragment.
The renderer of the grid item will consult with the grid via
shouldTrimChildMargin to determine if it should return a trimmed margin
value. At this time the renderer can also call into markMarginAsTrimmed
to set the rare data bit for the margin.

Once layout is finished, ComputedStyleExtractor can use
RenderBox::hasTrimmedMargin to check if the "left," margin is trimmed.
This function will return true only if the rare data bit is set for that
specified margin.

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

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




More information about the webkit-changes mailing list