[webkit-changes] [WebKit/WebKit] e44bd7: [margin-trim][block layout] Trimmed block-end marg...

Sammy Gill noreply at github.com
Tue Apr 25 20:08:40 PDT 2023


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

  Changed paths:
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end-expected.txt
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end-nested-child-expected.txt
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end-nested-child.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end-with-self-collapsing-children-expected.txt
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end-with-self-collapsing-children.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end.html
    M Source/WebCore/css/ComputedStyleExtractor.cpp
    M Source/WebCore/rendering/RenderBlockFlow.cpp
    M Source/WebCore/rendering/RenderBox.cpp
    M Source/WebCore/rendering/RenderBox.h

  Log Message:
  -----------
  [margin-trim][block layout] Trimmed block-end margins should be reflected in computed style in a horizontal writing-mode BFC.
https://bugs.webkit.org/show_bug.cgi?id=253610
rdar://106454992

Reviewed by Alan Baradlay.

We currently perform margin trimming by doing some backtracking after a
block container with block-end margin trim has completed layout (261750 at main).
In order to make sure that these margins are properly shown in their
computed style value, we need a way for ComputedStyleExtractor to know
that the block-end margin for the renderer has been trimmed. This can be
done by setting the margin-trim rare data bit for that renderer.

Whenever we trim a margin in RenderBlockFlow::trimBlockEndChildrenMargins,
we can replace the calls to setMarginAfterForChild with setTrimmedMarginForChild
which will both trim the margin and set the rare data bit for the renderer.

Later on when ComputedStyleExtractor tries to determine the value of
a bottom margin for a renderer it can first use hasTrimmedMargin on the
renderer in order to determine if that specific margin is trimmed.

While creating this patch and testing the logic, I found that certain
margins are not being trimmed correctly. It seems like particularly that
self collapsing children that has other nested self collapsing content
do not have the nested content trimmed properly. Whenever we have a
self collapsing child, we need to also go inside and trim the margins
of any other children (and perhaps perform this logic for any other
children that are nested inside that). For example

<container>
    <item style="margin-bottom: 10px"></item>
    <item style="margin-bottom: 10px; height: 0px;">
        <item style="margin-bottom: 10px; height: 0px;">
            <item style="margin-bottom: 10px; height: 0px;">
                <item style="margin-bottom: 10px; height: 0px;"></item>
                <item style="margin-bottom: 10px; height: 0px;"></item>
            </item>
        </item>
    </item>
</container>

In this scenario the content itself looks fine as if margin-trimming
occurred correctly, however when looking at the computed margin-bottom
values of the nested self collapsing children we can see that their
margins were not trimmed. Currently we fail the tests in these scenarios
that are introduced in this patch because of this. I plan on addressing
this in a separate patch following this one.

* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end-nested-child-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end-nested-child.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end-with-self-collapsing-children-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end-with-self-collapsing-children.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end.html: Added.
* Source/WebCore/css/ComputedStyleExtractor.cpp:
(WebCore::rendererCanHaveTrimmedMargin):
* Source/WebCore/rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::trimBlockEndChildrenMargins):
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::physicalToFlowRelativeDirectionMapping const):
(WebCore::RenderBox::hasTrimmedMargin const):
(WebCore::RenderBox::hasTrimmedMargin const):
* Source/WebCore/rendering/RenderBox.h:
(WebCore::RenderBox::isBlockLevelBox const):

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




More information about the webkit-changes mailing list