[webkit-changes] [WebKit/WebKit] 74849b: Directly check values of grid-template-rows and gr...

Sammy Gill noreply at github.com
Tue Aug 22 16:01:42 PDT 2023


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

  Changed paths:
    M LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-shorthand-areas-valid-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-shorthand-valid-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-shorthand-valid.html
    M Source/WebCore/css/ShorthandSerializer.cpp
    M Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
    M Source/WebCore/css/parser/CSSPropertyParserHelpers.h

  Log Message:
  -----------
  Directly check values of grid-template-rows and grid-template-columns when serializing grid-template with grid areas
https://bugs.webkit.org/show_bug.cgi?id=260494
rdar://114224504

Reviewed by Tim Nguyen.

The grid-template shorthand has two different options for its syntax:
- [ <'grid-template-rows'> / <'grid-template-columns'> ]
- [ <line-names>? <string> <track-size>? <line-names>? ]+ [ / <explicit-track-list> ]?

In the latter version of the syntax, ShorthandSerializer would bail out
early (and not serialize any values) if grid-template-areas (the <string>
portion of the syntax) was not set by the grid-template shorthand. We
should instead check the values of grid-template-rows and grid-template-columns
directly to see if they can be expressed inside of this shorthand.

For the rows portion we build up the shorthand iteratively, so we can
just check if the value is a valid <track-size> and return an empty
string if it is not since that would mean the value could not be
expressed in the shorthand. A value being a valid <track-size> means that
it must be one of: minmax(), fit-content(), length-percentage, flex,
min-content, max-content, or auto. If it is not one of these then the
value is not a <track-size>.

For the columns portion we have to check the entire value of grid-template-columns
beforehand since we will end up appending the whole value to the end
of the shorthand. To check to see if a value is a valid <explicit-track-list>,
we need to make sure the value contains only <line-names>s and <track-size>s
with at least one <track-size> in the value.

* LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-shorthand-areas-valid-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-shorthand-valid.html:
* Source/WebCore/css/ShorthandSerializer.cpp:
(WebCore::ShorthandSerializer::commonSerializationChecks):
(WebCore::ShorthandSerializer::serializeGridTemplate const):
* Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::isGridBreadthIdent):
(WebCore::CSSPropertyParserHelpers::consumeGridBreadth):
* Source/WebCore/css/parser/CSSPropertyParserHelpers.h:

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




More information about the webkit-changes mailing list