Skip to content

Commit

Permalink
Allow grid shorthands to set masonry to rows and columns.
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=249108
rdar://103231154

Reviewed by Matt Woodrow.

CSS grid has the "grid" and "grid-template" properties that can be used
to set the longhands of "grid-template-rows" and
"grid-template-columns." These shorthands should be able to set both
longhand properties to masonry if specified.

This can be done by modifiny consumeGridTrackList to check if the passed
in values are "masonry." Since createGridTrackList already checks for
the scenario where masonry is specified, the rest of the logic should
be able to remain the same.

* LayoutTests/imported/w3c/web-platform-tests/css/css-grid/masonry/tentative/parsing/masonry-parsing-expected.txt:
* Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::consumeGridTrackList):

Canonical link: https://commits.webkit.org/257713@main
  • Loading branch information
sammygill committed Dec 12, 2022
1 parent 0b2a814 commit 4a5c7a9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
Expand Up @@ -23,32 +23,32 @@ PASS e.style['grid-template-rows'] = "masonry subgrid" should not set the proper
PASS e.style['grid-template-rows'] = "masonry repeat(1, [])" should not set the property value
PASS e.style['grid-template-rows'] = "masonry repeat(auto-fill, [])" should not set the property value
PASS e.style['grid-template-rows'] = "masonry / none" should not set the property value
FAIL e.style['grid-template'] = "masonry / masonry" should set grid-template-areas assert_equals: grid-template-areas should be canonical expected "none" but got ""
FAIL e.style['grid-template'] = "masonry / masonry" should set grid-template-columns assert_equals: grid-template-columns should be canonical expected "masonry" but got ""
FAIL e.style['grid-template'] = "masonry / masonry" should set grid-template-rows assert_equals: grid-template-rows should be canonical expected "masonry" but got ""
FAIL e.style['grid-template'] = "masonry / masonry" should not set unrelated longhands assert_true: expected true got false
FAIL e.style['grid-template'] = "masonry / subgrid [foo]" should set grid-template-areas assert_equals: grid-template-areas should be canonical expected "none" but got ""
FAIL e.style['grid-template'] = "masonry / subgrid [foo]" should set grid-template-columns assert_equals: grid-template-columns should be canonical expected "subgrid [foo]" but got ""
FAIL e.style['grid-template'] = "masonry / subgrid [foo]" should set grid-template-rows assert_equals: grid-template-rows should be canonical expected "masonry" but got ""
FAIL e.style['grid-template'] = "masonry / subgrid [foo]" should not set unrelated longhands assert_true: expected true got false
PASS e.style['grid-template'] = "masonry / masonry" should set grid-template-areas
PASS e.style['grid-template'] = "masonry / masonry" should set grid-template-columns
PASS e.style['grid-template'] = "masonry / masonry" should set grid-template-rows
PASS e.style['grid-template'] = "masonry / masonry" should not set unrelated longhands
PASS e.style['grid-template'] = "masonry / subgrid [foo]" should set grid-template-areas
PASS e.style['grid-template'] = "masonry / subgrid [foo]" should set grid-template-columns
PASS e.style['grid-template'] = "masonry / subgrid [foo]" should set grid-template-rows
PASS e.style['grid-template'] = "masonry / subgrid [foo]" should not set unrelated longhands
PASS e.style['grid-template'] = "10px / masonry" should set grid-template-areas
PASS e.style['grid-template'] = "10px / masonry" should set grid-template-columns
PASS e.style['grid-template'] = "10px / masonry" should set grid-template-rows
PASS e.style['grid-template'] = "10px / masonry" should not set unrelated longhands
FAIL e.style['grid'] = "masonry / masonry" should set grid-auto-columns assert_equals: grid-auto-columns should be canonical expected "auto" but got ""
FAIL e.style['grid'] = "masonry / masonry" should set grid-auto-flow assert_equals: grid-auto-flow should be canonical expected "row" but got ""
FAIL e.style['grid'] = "masonry / masonry" should set grid-auto-rows assert_equals: grid-auto-rows should be canonical expected "auto" but got ""
FAIL e.style['grid'] = "masonry / masonry" should set grid-template-areas assert_equals: grid-template-areas should be canonical expected "none" but got ""
FAIL e.style['grid'] = "masonry / masonry" should set grid-template-columns assert_equals: grid-template-columns should be canonical expected "masonry" but got ""
FAIL e.style['grid'] = "masonry / masonry" should set grid-template-rows assert_equals: grid-template-rows should be canonical expected "masonry" but got ""
FAIL e.style['grid'] = "masonry / masonry" should not set unrelated longhands assert_true: expected true got false
FAIL e.style['grid'] = "masonry / subgrid [foo]" should set grid-auto-columns assert_equals: grid-auto-columns should be canonical expected "auto" but got ""
FAIL e.style['grid'] = "masonry / subgrid [foo]" should set grid-auto-flow assert_equals: grid-auto-flow should be canonical expected "row" but got ""
FAIL e.style['grid'] = "masonry / subgrid [foo]" should set grid-auto-rows assert_equals: grid-auto-rows should be canonical expected "auto" but got ""
FAIL e.style['grid'] = "masonry / subgrid [foo]" should set grid-template-areas assert_equals: grid-template-areas should be canonical expected "none" but got ""
FAIL e.style['grid'] = "masonry / subgrid [foo]" should set grid-template-columns assert_equals: grid-template-columns should be canonical expected "subgrid [foo]" but got ""
FAIL e.style['grid'] = "masonry / subgrid [foo]" should set grid-template-rows assert_equals: grid-template-rows should be canonical expected "masonry" but got ""
FAIL e.style['grid'] = "masonry / subgrid [foo]" should not set unrelated longhands assert_true: expected true got false
PASS e.style['grid'] = "masonry / masonry" should set grid-auto-columns
PASS e.style['grid'] = "masonry / masonry" should set grid-auto-flow
PASS e.style['grid'] = "masonry / masonry" should set grid-auto-rows
PASS e.style['grid'] = "masonry / masonry" should set grid-template-areas
PASS e.style['grid'] = "masonry / masonry" should set grid-template-columns
PASS e.style['grid'] = "masonry / masonry" should set grid-template-rows
PASS e.style['grid'] = "masonry / masonry" should not set unrelated longhands
PASS e.style['grid'] = "masonry / subgrid [foo]" should set grid-auto-columns
PASS e.style['grid'] = "masonry / subgrid [foo]" should set grid-auto-flow
PASS e.style['grid'] = "masonry / subgrid [foo]" should set grid-auto-rows
PASS e.style['grid'] = "masonry / subgrid [foo]" should set grid-template-areas
PASS e.style['grid'] = "masonry / subgrid [foo]" should set grid-template-columns
PASS e.style['grid'] = "masonry / subgrid [foo]" should set grid-template-rows
PASS e.style['grid'] = "masonry / subgrid [foo]" should not set unrelated longhands
PASS e.style['grid'] = "10px / masonry" should set grid-auto-columns
PASS e.style['grid'] = "10px / masonry" should set grid-auto-flow
PASS e.style['grid'] = "10px / masonry" should set grid-auto-rows
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
Expand Up @@ -7871,6 +7871,8 @@ static bool consumeSubgridNameRepeatFunction(CSSParserTokenRange& range, CSSValu

RefPtr<CSSValue> consumeGridTrackList(CSSParserTokenRange& range, const CSSParserContext& context, TrackListType trackListType)
{
if (range.peek().id() == CSSValueMasonry)
return consumeIdent(range);
bool seenAutoRepeat = false;
if (trackListType == GridTemplate && context.subgridEnabled && range.peek().id() == CSSValueSubgrid) {
consumeIdent(range);
Expand Down

0 comments on commit 4a5c7a9

Please sign in to comment.