[webkit-changes] [WebKit/WebKit] f67976: Implement margin-trim for floats in block containe...

Sammy Gill noreply at github.com
Wed Feb 15 10:29:10 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f679766e27a17ddcbdd8a562f6f1581fab68d053
      https://github.com/WebKit/WebKit/commit/f679766e27a17ddcbdd8a562f6f1581fab68d053
  Author: Sammy Gill <sammy.gill at apple.com>
  Date:   2023-02-15 (Wed, 15 Feb 2023)

  Changed paths:
    M LayoutTests/TestExpectations
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-end-deeply-nested-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-end-deeply-nested.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-end-up-to-content-block-layout-different-containers-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-end-up-to-content-block-layout-different-containers-vert-lr-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-end-up-to-content-block-layout-different-containers-vert-lr.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-end-up-to-content-block-layout-different-containers.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-end-up-to-content-block-layout-same-container-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-end-up-to-content-block-layout-same-container.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-start-block-layout-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-start-block-layout.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-start-relative-positioned-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-start-relative-positioned.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-start-with-transforms-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-start-with-transforms.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-fit-content-block-layout-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-fit-content-block-layout.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-inline-end-block-layout-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-inline-end-block-layout.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-inline-start-block-layout-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-inline-start-block-layout.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-left-trimmed-margin-allows-float-to-fit-block-layout-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-left-trimmed-margin-allows-float-to-fit-block-layout-vert-lr-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-left-trimmed-margin-allows-float-to-fit-block-layout-vert-lr.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-left-trimmed-margin-allows-float-to-fit-block-layout.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-min-content-with-block-content-block-layout-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-min-content-with-block-content-block-layout.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-right-trimmed-margin-allows-float-to-fit-block-layout-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-right-trimmed-margin-allows-float-to-fit-block-layout.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-overflowing-float-margins-tirmmed-at-final-position-block-layout-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-overflowing-float-margins-tirmmed-at-final-position-block-layout.html
    M Source/WebCore/rendering/FloatingObjects.cpp
    M Source/WebCore/rendering/FloatingObjects.h
    M Source/WebCore/rendering/RenderBlock.cpp
    M Source/WebCore/rendering/RenderBlock.h
    M Source/WebCore/rendering/RenderBlockFlow.cpp
    M Source/WebCore/rendering/RenderBlockFlow.h
    M Source/WebCore/rendering/RenderBox.cpp
    M Source/WebCore/rendering/RenderBox.h

  Log Message:
  -----------
  Implement margin-trim for floats in block containers that contain only block boxes.
https://bugs.webkit.org/show_bug.cgi?id=249207
rdar://103285803

Reviewed by Alan Baradlay.

Another patch will be added to provide support for block containers that
contain only inline level boxes.

There are 3 different pieces that we need to implement:

1.) Trimming the block start, inline start, and inline end margins
2.) Trimming the block-end margin, which is slightly different from
the others
3.) Making sure the trimmed margins do not contribute to the inrinsic
sizing of the container

When a candidate position for a float is determined in the float
positioning code, we can determine whether it is possible to trim its
margins. For each candidate position, we can determine whether any edges
of the margin box would touch the container and then trim that edge if
it is specified in margin-trim. This can be done for the inline-start,
inline-end, and block-start edges of the container.

Trimming the block-end margin is slightly different because it is not
in the context of the containing block like the other margins but of the
block formatting context. This means that we can only trim these margins
after its block formatting context is done with layout. In
RnderBlockFlow we can check to see if it establishes a block formatting
context and then proceed to trim the block-end margins of its floats
where needed. As we iterate over each float, we check to see if its block
end location is lower than the lowest piece of content in the BFC. If
so, we trim it up to the necesssary amount where it will not extend the
height of the BFC.

Finally, to make sure that the trimmed inline margins do not contribute
to the intrinsic sizing of its containing block, all we need to do
is check to see if the item is a float and if any of the inline margins
are specified to be trimmed. If so, we do not include those in its
contribution.

* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-end-deeply-nested-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-end-deeply-nested.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-end-up-to-content-block-layout-different-containers-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-end-up-to-content-block-layout-different-containers-vert-lr-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-end-up-to-content-block-layout-different-containers-vert-lr.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-end-up-to-content-block-layout-different-containers.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-end-up-to-content-block-layout-same-container-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-end-up-to-content-block-layout-same-container.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-start-block-layout-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-start-block-layout.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-start-relative-positioned-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-start-relative-positioned.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-start-with-transforms-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-block-start-with-transforms.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-fit-content-block-layout-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-fit-content-block-layout.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-inline-end-block-layout-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-inline-end-block-layout.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-inline-start-block-layout-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-inline-start-block-layout.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-left-trimmed-margin-allows-float-to-fit-block-layout-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-left-trimmed-margin-allows-float-to-fit-block-layout-vert-lr-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-left-trimmed-margin-allows-float-to-fit-block-layout-vert-lr.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-left-trimmed-margin-allows-float-to-fit-block-layout.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-min-content-with-block-content-block-layout-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-min-content-with-block-content-block-layout.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-right-trimmed-margin-allows-float-to-fit-block-layout-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-float-right-trimmed-margin-allows-float-to-fit-block-layout.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-overflowing-float-margins-tirmmed-at-final-position-block-layout-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/block-container-overflowing-float-margins-tirmmed-at-final-position-block-layout.html: Added.
* Source/WebCore/rendering/FloatingObjects.cpp:
(WebCore::FloatingObject::isLowestPlacedFloatBottomInBlockFormattingContext const):
* Source/WebCore/rendering/FloatingObjects.h:
(WebCore::FloatingObject::setHeight):
* Source/WebCore/rendering/RenderBlock.cpp:
(WebCore::RenderBlock::computeBlockPreferredLogicalWidths const):
* Source/WebCore/rendering/RenderBlock.h:
(WebCore::RenderBlock::logicalMarginBoxHeightForChild const):
(WebCore::RenderBlock::logicalMarginBoxTopForChild const):
* Source/WebCore/rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutBlock):
(WebCore::RenderBlockFlow::trimFloatBlockEndMargins):
(WebCore::RenderBlockFlow::shouldChildInlineMarginContributeToContainerIntrinsicSize const):
(WebCore::RenderBlockFlow::insertFloatingObject):
(WebCore::RenderBlockFlow::trimMarginForFloat):
(WebCore::RenderBlockFlow::computeLogicalLocationForFloat):
(WebCore::RenderBlockFlow::blockFormattingContextInFlowBlockLevelContentHeight const):
* Source/WebCore/rendering/RenderBlockFlow.h:
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::establishesBlockFormattingContext const):
(WebCore::RenderBox::blockFormattingContextRoot const):
* Source/WebCore/rendering/RenderBox.h:

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




More information about the webkit-changes mailing list