[webkit-changes] [WebKit/WebKit] ac15c3: Check implicitly assigned line names in NamedLineC...

Sammy Gill noreply at github.com
Fri Aug 25 09:06:28 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ac15c399013cbb04e8ebea7e35ad09abf2483b4d
      https://github.com/WebKit/WebKit/commit/ac15c399013cbb04e8ebea7e35ad09abf2483b4d
  Author: Sammy Gill <sammy.gill at apple.com>
  Date:   2023-08-25 (Fri, 25 Aug 2023)

  Changed paths:
    M LayoutTests/TestExpectations
    M Source/WebCore/rendering/style/GridPositionsResolver.cpp
    M Source/WebCore/rendering/style/GridPositionsResolver.h

  Log Message:
  -----------
  Check implicitly assigned line names in NamedLineCollectionBase::contains.
https://bugs.webkit.org/show_bug.cgi?id=260526
rdar://114271506

Reviewed by Matt Woodrow.

NamedLineCollection::contains does 3 main things:
1.) Check to see if the line we are looking for is beyond the bounds
of the grid and return false if it is. This can happen when we are
checking to see if a parent grid's line is within a subgrid.
2.) Checks to see if the line is within the collection of the grid's
implicitly assigned lines and return true if it is.
3.) Call into NamedLineCollectionBase::contains

Since we already do 1 in NamedLineCollectionBase::contains, the only
difference between the methods is 2. It seems like this contains method
should be checking this anyways since we check to see if the line is
within the collection of other types of grid lines (m_namedLinesIndices
and m_autoRepeatNamedLinesIndices). By moving this logic to the method
in the base class we no longer need to have the version in the subclass.

THis helped fix a bug where items in a subgrid were not being placed
correctly using *-start and *-end line names that were implicitly
created from a grid area in the parent grid.

In the following example the <x> element would get placed into the 8th
grid column when it should be placed inth the 7th.

<style>
i {
      grid-row: 1;
      counter-increment: i;
    }
i::before { content: counter(i, decimal); }
</style>

<div style="display:grid; grid-template-areas: '. . . . . . a a a ';">
  <i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i>
  <div style="display:grid; grid:auto/subgrid; grid-column:5 / 9;">
    <x style="grid-column: a-start / a-end">x</x>
  </div>
</div>

When we create a NamedLineCollectionBase for the parent grid we will
look and see if any of those lines are within our grid (the subgrid).
However since this uses the base class the parent class was nothing
checking against the implicitly created lines. Now these lines should
be detected and added into the local line collection that subgrid
creates.

* LayoutTests/TestExpectations:
* Source/WebCore/rendering/style/GridPositionsResolver.cpp:
(WebCore::NamedLineCollectionBase::contains const):
(WebCore::NamedLineCollection::NamedLineCollection):
(WebCore::NamedLineCollectionBase::hasExplicitNamedLines const):
(WebCore::NamedLineCollectionBase::hasNamedLines const):
(WebCore::NamedLineCollection::hasExplicitNamedLines const): Deleted.
(WebCore::NamedLineCollection::hasNamedLines const): Deleted.
(WebCore::NamedLineCollection::contains const): Deleted.
* Source/WebCore/rendering/style/GridPositionsResolver.h:

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




More information about the webkit-changes mailing list