[webkit-changes] [WebKit/WebKit] 6bdeb8: [css-grid] Margins for grid item's ascent should b...

Sammy Gill noreply at github.com
Wed Jan 10 13:01:20 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6bdeb823e16e81ec11433826136fb738e1b00981
      https://github.com/WebKit/WebKit/commit/6bdeb823e16e81ec11433826136fb738e1b00981
  Author: Sammy Gill <sammy.gill at apple.com>
  Date:   2024-01-10 (Wed, 10 Jan 2024)

  Changed paths:
    M LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-align-baseline-001-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-align-baseline-002-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-justify-baseline-002-expected.txt
    M Source/WebCore/rendering/GridBaselineAlignment.cpp
    M Source/WebCore/rendering/RenderBox.h

  Log Message:
  -----------
  [css-grid] Margins for grid item's ascent should be based off of the alignment context axis.
https://bugs.webkit.org/show_bug.cgi?id=260570
rdar://114299208

Reviewed by Matt Woodrow.

The ascent value for a grid item needs to include its margin alongside
its baseline value since grid items are aligned by their margin box.

Currently code uses isDescentBaselineForChild to determine whether it
should get its margin using marginUnderForChild or marginOverForchild.
It is not super clear why these two functions are choosing certain
margins off the grid item's margin box.

Choosing which margin to use should just be a matter of checking which
direction the alignment context is in. If the alignment context
direction is in the grid's column axis (i.e. grid items are being
aligned in the grid's block direction), then that should be the grid
item's block-start margin according to the grid's writing mode.
Similarly, if the alignment context direction is in the row axis (i.e.
grid items are being aligned in the grid's inline direction), then that
should be the grid item's inline-start margin according to the grid's
writing mode.

I also renamed the variable "margin," to "gridItemMargin," to better
reflect what it corresponds to. Instances where this value was being
added to the grid item's baseline value have also been changed to be in
the form of "gridItemMargin + gridItemBaseline" since that is generally
the order in which we depict/imagine the structure of the ascent value.

* LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-align-baseline-001-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-align-baseline-002-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-justify-baseline-002-expected.txt:
* Source/WebCore/rendering/GridBaselineAlignment.cpp:
(WebCore::GridBaselineAlignment::ascentForChild const):
(WebCore::GridBaselineAlignment::marginOverForChild const): Deleted.
(WebCore::GridBaselineAlignment::marginUnderForChild const): Deleted.
* Source/WebCore/rendering/RenderBox.h:
(WebCore::RenderBox::marginBlockStart const):
(WebCore::RenderBox::marginInlineStart const):

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




More information about the webkit-changes mailing list