[webkit-changes] [WebKit/WebKit] 423f79: Block level boxes with block-step-size other than ...

Sammy Gill noreply at github.com
Thu Mar 2 06:51:38 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 423f7933224ac4609944bf6e5a18932f2c337b37
      https://github.com/WebKit/WebKit/commit/423f7933224ac4609944bf6e5a18932f2c337b37
  Author: Sammy Gill <sammy.gill at apple.com>
  Date:   2023-03-02 (Thu, 02 Mar 2023)

  Changed paths:
    A LayoutTests/imported/w3c/web-platform-tests/css/css-rhythm/block-step-size-establishes-block-formatting-context-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-rhythm/block-step-size-establishes-block-formatting-context-list-item-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-rhythm/block-step-size-establishes-block-formatting-context-list-item.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-rhythm/block-step-size-establishes-block-formatting-context.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-rhythm/block-step-size-none-does-not-establish-block-formatting-context-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-rhythm/block-step-size-none-does-not-establish-block-formatting-context.html
    M Source/WebCore/rendering/RenderBox.cpp
    M Source/WebCore/rendering/RenderElement.cpp

  Log Message:
  -----------
  Block level boxes with block-step-size other than none should establish an independent formatting context.
https://bugs.webkit.org/show_bug.cgi?id=252358
rdar://105519556

Reviewed by Tim Nguyen.

In order to determine whether this property would apply to a box we
first need to check its display type. According to the table from
css-display-3 (https://www.w3.org/TR/css-display-3/#the-display-properties),
block level boxes are generated from the following display types:
block, flow-root, list-item, flex, grid, block ruby, and table. Of these,
flow-root, flex, grid, and table already establish an independent
formatting context. So we need to make sure that a new block formatting
context is generated for the remaining, which is what the tests cover.

Inside RenderBox::establishesBlockFormattingContext and
RenderElement::establishesIndependentFormattingContext we will call
into RenderElement::isBlockLevelElementWithBlockStepSizing which will
return true if the box has a block level display type and if it has
a valid value for block-step-sizing (other than none).

div {
    width: 50px;
    height: 100px;
    background-color: green;
}
.floating {
    float: left;
}
.block-step-size {
    block-step-size: 1px;
}
</style>
<div class="floating"></div>
<div class="block-step-size"></div>

Since both of the conditions hold for the second div it will establish a
new block formatting context and will become aware of the float so that
it does not get positioned over it.

Spec reference: https://drafts.csswg.org/css-rhythm/#block-step-size

* LayoutTests/imported/w3c/web-platform-tests/css/css-rhythm/block-step-size-establishes-independent-formatting-context-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-rhythm/block-step-size-establishes-independent-formatting-context-list-item-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-rhythm/block-step-size-establishes-independent-formatting-context-list-item.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-rhythm/block-step-size-establishes-independent-formatting-context.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-rhythm/block-step-size-none-does-not-establish-indepdendent-formatting-context-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-rhythm/block-step-size-none-does-not-establish-indepdendent-formatting-context.html: Added.
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::establishesBlockFormattingContext const):
* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::establishesIndependentFormattingContext const):
(WebCore::RenderElement::isBlockLevelElementWithBlockStepSizing const):
* Source/WebCore/rendering/RenderElement.h:

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




More information about the webkit-changes mailing list