[webkit-changes] [WebKit/WebKit] 7957e0: Implement lastLineBaseline for flex containers.

Sammy Gill noreply at github.com
Sat Oct 15 01:51:10 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7957e0705174b2517ea83858a019b4ed32ba5cfc
      https://github.com/WebKit/WebKit/commit/7957e0705174b2517ea83858a019b4ed32ba5cfc
  Author: Sammy Gill <sammy.gill at apple.com>
  Date:   2022-10-15 (Sat, 15 Oct 2022)

  Changed paths:
    M LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/alignment/flex-align-baseline-flex-003-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/alignment/flex-align-baseline-flex-004-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-align-baseline-flex-003-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-align-baseline-flex-004-expected.txt
    R LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-flexbox/alignment/flex-align-baseline-table-001-expected.txt
    R LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-flexbox/alignment/flex-align-baseline-table-002-expected.txt
    R LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-flexbox/alignment/flex-align-baseline-table-003-expected.txt
    R LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-align-baseline-table-001-expected.txt
    R LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-align-baseline-table-002-expected.txt
    R LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-align-baseline-table-003-expected.txt
    M Source/WebCore/rendering/OrderIterator.cpp
    M Source/WebCore/rendering/OrderIterator.h
    M Source/WebCore/rendering/RenderFlexibleBox.cpp
    M Source/WebCore/rendering/RenderFlexibleBox.h

  Log Message:
  -----------
  Implement lastLineBaseline for flex containers.
https://bugs.webkit.org/show_bug.cgi?id=246201
rdar://100882674

Reviewed by Alan Bujtas.

CSS Flexible Box Layout Module Level 1 defines the last baseline for
flex containers so that they may participate in last baseline alignment.

The spec provides steps to take when the inline axis of the container is
the same as the main axis as well as when it matches the cross axis.

RenderFlexibleBox::getBaselineChild was created to refactor the code so
that the pieces that are used by both firstLineBaseline and
lastLineBaseline could be shared. The behavior changes slightly based
on the alignment being used, so we need to pass that in as well.

The OrderIterator, which is used to iterate over flex items in the order
specified by the "order" property (if it is set), also needed to be
slightly modified so that it could be used in last baseline alignment.
This is because for last baseline alignment we need to first look at
the endmost item on the last line and work our way towards the beginning
of the line. To simplify this, OrderIterator was modified to provide a
reverse method that iterates both the OrderValues from the CSS Property
(so that the item in order last goes first) and also starts iterating
from the last child of the flex container.

Spec reference: https://www.w3.org/TR/css-flexbox-1/#flex-baselines

* LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/alignment/flex-align-baseline-flex-003-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/alignment/flex-align-baseline-flex-004-expected.txt:
* Source/WebCore/rendering/OrderIterator.cpp:
(WebCore::OrderIterator::next):
(WebCore::OrderIterator::reverse):
* Source/WebCore/rendering/OrderIterator.h:
* Source/WebCore/rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::firstLineBaseline const):
(WebCore::RenderFlexibleBox::lastLineBaseline const):
(WebCore::RenderFlexibleBox::getBaselineChild const):
(WebCore::RenderFlexibleBox::layoutBlock):
(WebCore::RenderFlexibleBox::layoutAndPlaceChildren):
* Source/WebCore/rendering/RenderFlexibleBox.h:
m_numberOfInFlowChildrenOnFirstLine and
m_numberOfInFlowChildrenOnLastLine have both been changed to
std::optional<size_t>. Instead of being -1 before the items have been
placed on the line, they will now be empty optionals. However, the
overall behavior remains the same and all the references to the
variables have been change to reflect the new type.

* LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-flexbox/alignment/flex-align-baseline-table-001-expected.txt: Removed.
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-flexbox/alignment/flex-align-baseline-table-002-expected.txt: Removed.
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-flexbox/alignment/flex-align-baseline-table-003-expected.txt: Removed.
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-align-baseline-table-001-expected.txt: Removed.
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-align-baseline-table-002-expected.txt: Removed.
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-align-baseline-table-003-expected.txt: Removed.
These are no longer needed since the behavior matches what is expected
in the root TestExpectations now.

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




More information about the webkit-changes mailing list