Title: [264465] trunk
Revision
264465
Author
[email protected]
Date
2020-07-16 09:59:18 -0700 (Thu, 16 Jul 2020)

Log Message

[css-grid] Fix line name positions after implicit tracks
https://bugs.webkit.org/show_bug.cgi?id=214315

Reviewed by Manuel Rego Casasnovas.

LayoutTests/imported/w3c:

Expect the tests to pass.

* web-platform-tests/css/css-grid/parsing/grid-template-columns-computed-implicit-track-expected.txt:
* web-platform-tests/css/css-grid/parsing/grid-template-rows-computed-implicit-track-expected.txt:

Source/WebCore:

When serializing grid-template-rows/columns of a grid container, we get
the list of used track sizes, and then insert line names at the
corresponding indices.

Before this patch, these indices were simply taken from the computed
value. However, leading implicit tracks appear in the used value but not
in the computed one. Therefore, we have to offset the indices so that
the line names appear at the proper positions.

This patch is a port of https://crrev.com/777829

Tests: imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-columns-computed-implicit-track.html
       imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-rows-computed-implicit-track.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::populateGridTrackList):
(WebCore::valueForGridTrackList):
* rendering/RenderGrid.h:

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (264464 => 264465)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-07-16 16:47:31 UTC (rev 264464)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-07-16 16:59:18 UTC (rev 264465)
@@ -1,3 +1,15 @@
+2020-07-16  Oriol Brufau  <[email protected]>
+
+        [css-grid] Fix line name positions after implicit tracks
+        https://bugs.webkit.org/show_bug.cgi?id=214315
+
+        Reviewed by Manuel Rego Casasnovas.
+
+        Expect the tests to pass.
+
+        * web-platform-tests/css/css-grid/parsing/grid-template-columns-computed-implicit-track-expected.txt:
+        * web-platform-tests/css/css-grid/parsing/grid-template-rows-computed-implicit-track-expected.txt:
+
 2020-07-16  Carlos Alberto Lopez Perez  <[email protected]>
 
         Update WPT tests for css-writing-modes (follow-up fix)

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-columns-computed-implicit-track-expected.txt (264464 => 264465)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-columns-computed-implicit-track-expected.txt	2020-07-16 16:47:31 UTC (rev 264464)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-columns-computed-implicit-track-expected.txt	2020-07-16 16:59:18 UTC (rev 264465)
@@ -1,26 +1,26 @@
 
 PASS Property grid-template-columns value 'none' computes to '10px' 
 PASS Property grid-template-columns value '1px' computes to '10px 1px' 
-FAIL Property grid-template-columns value '1px [a]' computes to '10px 1px [a]' assert_equals: expected "10px 1px [a]" but got "10px [a] 1px"
-FAIL Property grid-template-columns value '1px [a] 2px' computes to '10px 1px [a] 2px' assert_equals: expected "10px 1px [a] 2px" but got "10px [a] 1px 2px"
-FAIL Property grid-template-columns value '[a] 1px' computes to '10px [a] 1px' assert_equals: expected "10px [a] 1px" but got "[a] 10px 1px"
-FAIL Property grid-template-columns value '[a] 1px [b]' computes to '10px [a] 1px [b]' assert_equals: expected "10px [a] 1px [b]" but got "[a] 10px [b] 1px"
+PASS Property grid-template-columns value '1px [a]' computes to '10px 1px [a]' 
+PASS Property grid-template-columns value '1px [a] 2px' computes to '10px 1px [a] 2px' 
+PASS Property grid-template-columns value '[a] 1px' computes to '10px [a] 1px' 
+PASS Property grid-template-columns value '[a] 1px [b]' computes to '10px [a] 1px [b]' 
 PASS Property grid-template-columns value '1px repeat(1, 2px) 3px' computes to '10px 1px 2px 3px' 
 PASS Property grid-template-columns value '1px repeat(auto-fill, 2px) 3px' computes to '10px 1px 2px 3px' 
 PASS Property grid-template-columns value '1px repeat(auto-fit, 2px) 3px' computes to '10px 1px 0px 3px' 
-FAIL Property grid-template-columns value '1px [a] repeat(1, 2px 3px) [b] 4px' computes to '10px 1px [a] 2px 3px [b] 4px' assert_equals: expected "10px 1px [a] 2px 3px [b] 4px" but got "10px [a] 1px 2px [b] 3px 4px"
-FAIL Property grid-template-columns value '1px [a] repeat(auto-fill, 2px 3px) [b] 4px' computes to '10px 1px [a] 2px 3px [b] 4px' assert_equals: expected "10px 1px [a] 2px 3px [b] 4px" but got "10px [a] 1px 2px [b] 3px 4px"
-FAIL Property grid-template-columns value '1px [a] repeat(auto-fit, 2px 3px) [b] 4px' computes to '10px 1px [a] 0px 0px [b] 4px' assert_equals: expected "10px 1px [a] 0px 0px [b] 4px" but got "10px [a] 1px 0px [b] 0px 4px"
-FAIL Property grid-template-columns value '1px [a] repeat(1, [b] 2px [c]) [d] 3px' computes to '10px 1px [a b] 2px [c d] 3px' assert_equals: expected "10px 1px [a b] 2px [c d] 3px" but got "10px [a b] 1px [c d] 2px 3px"
-FAIL Property grid-template-columns value '1px [a] repeat(auto-fill, [b] 2px [c]) [d] 3px' computes to '10px 1px [a b] 2px [c d] 3px' assert_equals: expected "10px 1px [a b] 2px [c d] 3px" but got "10px [a b] 1px [c d] 2px 3px"
-FAIL Property grid-template-columns value '1px [a] repeat(auto-fit, [b] 2px [c]) [d] 3px' computes to '10px 1px [a b] 0px [c d] 3px' assert_equals: expected "10px 1px [a b] 0px [c d] 3px" but got "10px [a b] 1px [c d] 0px 3px"
-FAIL Property grid-template-columns value '[a] 1px repeat(1, 2px [b] 3px) 4px [d]' computes to '10px [a] 1px 2px [b] 3px 4px [d]' assert_equals: expected "10px [a] 1px 2px [b] 3px 4px [d]" but got "[a] 10px 1px [b] 2px 3px [d] 4px"
-FAIL Property grid-template-columns value '[a] 1px repeat(auto-fill, 2px [b] 3px) 4px [d]' computes to '10px [a] 1px 2px [b] 3px 4px [d]' assert_equals: expected "10px [a] 1px 2px [b] 3px 4px [d]" but got "[a] 10px 1px [b] 2px 3px [d] 4px"
-FAIL Property grid-template-columns value '[a] 1px repeat(auto-fit, 2px [b] 3px) 4px [d]' computes to '10px [a] 1px 0px [b] 0px 4px [d]' assert_equals: expected "10px [a] 1px 0px [b] 0px 4px [d]" but got "[a] 10px 1px [b] 0px 0px [d] 4px"
-FAIL Property grid-template-columns value '100% [a] repeat(1, [b] 200% [c]) [d] 300%' computes to '10px 1px [a b] 2px [c d] 3px' assert_equals: expected "10px 1px [a b] 2px [c d] 3px" but got "10px [a b] 1px [c d] 2px 3px"
-FAIL Property grid-template-columns value '100% [a] repeat(auto-fill, [b] 200% [c]) [d] 300%' computes to '10px 1px [a b] 2px [c d] 3px' assert_equals: expected "10px 1px [a b] 2px [c d] 3px" but got "10px [a b] 1px [c d] 2px 3px"
-FAIL Property grid-template-columns value '100% [a] repeat(auto-fit, [b] 200% [c]) [d] 300%' computes to '10px 1px [a b] 0px [c d] 3px' assert_equals: expected "10px 1px [a b] 0px [c d] 3px" but got "10px [a b] 1px [c d] 0px 3px"
-FAIL Property grid-template-columns value '[a] 1em repeat(1, 2em [b] 3em) 4em [d]' computes to '10px [a] 1px 2px [b] 3px 4px [d]' assert_equals: expected "10px [a] 1px 2px [b] 3px 4px [d]" but got "[a] 10px 1px [b] 2px 3px [d] 4px"
-FAIL Property grid-template-columns value '[a] 1em repeat(auto-fill, 2em [b] 3em) 4em [d]' computes to '10px [a] 1px 2px [b] 3px 4px [d]' assert_equals: expected "10px [a] 1px 2px [b] 3px 4px [d]" but got "[a] 10px 1px [b] 2px 3px [d] 4px"
-FAIL Property grid-template-columns value '[a] 1em repeat(auto-fit, 2em [b] 3em) 4em [d]' computes to '10px [a] 1px 0px [b] 0px 4px [d]' assert_equals: expected "10px [a] 1px 0px [b] 0px 4px [d]" but got "[a] 10px 1px [b] 0px 0px [d] 4px"
+PASS Property grid-template-columns value '1px [a] repeat(1, 2px 3px) [b] 4px' computes to '10px 1px [a] 2px 3px [b] 4px' 
+PASS Property grid-template-columns value '1px [a] repeat(auto-fill, 2px 3px) [b] 4px' computes to '10px 1px [a] 2px 3px [b] 4px' 
+PASS Property grid-template-columns value '1px [a] repeat(auto-fit, 2px 3px) [b] 4px' computes to '10px 1px [a] 0px 0px [b] 4px' 
+PASS Property grid-template-columns value '1px [a] repeat(1, [b] 2px [c]) [d] 3px' computes to '10px 1px [a b] 2px [c d] 3px' 
+PASS Property grid-template-columns value '1px [a] repeat(auto-fill, [b] 2px [c]) [d] 3px' computes to '10px 1px [a b] 2px [c d] 3px' 
+PASS Property grid-template-columns value '1px [a] repeat(auto-fit, [b] 2px [c]) [d] 3px' computes to '10px 1px [a b] 0px [c d] 3px' 
+PASS Property grid-template-columns value '[a] 1px repeat(1, 2px [b] 3px) 4px [d]' computes to '10px [a] 1px 2px [b] 3px 4px [d]' 
+PASS Property grid-template-columns value '[a] 1px repeat(auto-fill, 2px [b] 3px) 4px [d]' computes to '10px [a] 1px 2px [b] 3px 4px [d]' 
+PASS Property grid-template-columns value '[a] 1px repeat(auto-fit, 2px [b] 3px) 4px [d]' computes to '10px [a] 1px 0px [b] 0px 4px [d]' 
+PASS Property grid-template-columns value '100% [a] repeat(1, [b] 200% [c]) [d] 300%' computes to '10px 1px [a b] 2px [c d] 3px' 
+PASS Property grid-template-columns value '100% [a] repeat(auto-fill, [b] 200% [c]) [d] 300%' computes to '10px 1px [a b] 2px [c d] 3px' 
+PASS Property grid-template-columns value '100% [a] repeat(auto-fit, [b] 200% [c]) [d] 300%' computes to '10px 1px [a b] 0px [c d] 3px' 
+PASS Property grid-template-columns value '[a] 1em repeat(1, 2em [b] 3em) 4em [d]' computes to '10px [a] 1px 2px [b] 3px 4px [d]' 
+PASS Property grid-template-columns value '[a] 1em repeat(auto-fill, 2em [b] 3em) 4em [d]' computes to '10px [a] 1px 2px [b] 3px 4px [d]' 
+PASS Property grid-template-columns value '[a] 1em repeat(auto-fit, 2em [b] 3em) 4em [d]' computes to '10px [a] 1px 0px [b] 0px 4px [d]' 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-rows-computed-implicit-track-expected.txt (264464 => 264465)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-rows-computed-implicit-track-expected.txt	2020-07-16 16:47:31 UTC (rev 264464)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-rows-computed-implicit-track-expected.txt	2020-07-16 16:59:18 UTC (rev 264465)
@@ -1,26 +1,26 @@
 
 PASS Property grid-template-rows value 'none' computes to '10px' 
 PASS Property grid-template-rows value '1px' computes to '10px 1px' 
-FAIL Property grid-template-rows value '1px [a]' computes to '10px 1px [a]' assert_equals: expected "10px 1px [a]" but got "10px [a] 1px"
-FAIL Property grid-template-rows value '1px [a] 2px' computes to '10px 1px [a] 2px' assert_equals: expected "10px 1px [a] 2px" but got "10px [a] 1px 2px"
-FAIL Property grid-template-rows value '[a] 1px' computes to '10px [a] 1px' assert_equals: expected "10px [a] 1px" but got "[a] 10px 1px"
-FAIL Property grid-template-rows value '[a] 1px [b]' computes to '10px [a] 1px [b]' assert_equals: expected "10px [a] 1px [b]" but got "[a] 10px [b] 1px"
+PASS Property grid-template-rows value '1px [a]' computes to '10px 1px [a]' 
+PASS Property grid-template-rows value '1px [a] 2px' computes to '10px 1px [a] 2px' 
+PASS Property grid-template-rows value '[a] 1px' computes to '10px [a] 1px' 
+PASS Property grid-template-rows value '[a] 1px [b]' computes to '10px [a] 1px [b]' 
 PASS Property grid-template-rows value '1px repeat(1, 2px) 3px' computes to '10px 1px 2px 3px' 
 PASS Property grid-template-rows value '1px repeat(auto-fill, 2px) 3px' computes to '10px 1px 2px 3px' 
 PASS Property grid-template-rows value '1px repeat(auto-fit, 2px) 3px' computes to '10px 1px 0px 3px' 
-FAIL Property grid-template-rows value '1px [a] repeat(1, 2px 3px) [b] 4px' computes to '10px 1px [a] 2px 3px [b] 4px' assert_equals: expected "10px 1px [a] 2px 3px [b] 4px" but got "10px [a] 1px 2px [b] 3px 4px"
-FAIL Property grid-template-rows value '1px [a] repeat(auto-fill, 2px 3px) [b] 4px' computes to '10px 1px [a] 2px 3px [b] 4px' assert_equals: expected "10px 1px [a] 2px 3px [b] 4px" but got "10px [a] 1px 2px [b] 3px 4px"
-FAIL Property grid-template-rows value '1px [a] repeat(auto-fit, 2px 3px) [b] 4px' computes to '10px 1px [a] 0px 0px [b] 4px' assert_equals: expected "10px 1px [a] 0px 0px [b] 4px" but got "10px [a] 1px 0px [b] 0px 4px"
-FAIL Property grid-template-rows value '1px [a] repeat(1, [b] 2px [c]) [d] 3px' computes to '10px 1px [a b] 2px [c d] 3px' assert_equals: expected "10px 1px [a b] 2px [c d] 3px" but got "10px [a b] 1px [c d] 2px 3px"
-FAIL Property grid-template-rows value '1px [a] repeat(auto-fill, [b] 2px [c]) [d] 3px' computes to '10px 1px [a b] 2px [c d] 3px' assert_equals: expected "10px 1px [a b] 2px [c d] 3px" but got "10px [a b] 1px [c d] 2px 3px"
-FAIL Property grid-template-rows value '1px [a] repeat(auto-fit, [b] 2px [c]) [d] 3px' computes to '10px 1px [a b] 0px [c d] 3px' assert_equals: expected "10px 1px [a b] 0px [c d] 3px" but got "10px [a b] 1px [c d] 0px 3px"
-FAIL Property grid-template-rows value '[a] 1px repeat(1, 2px [b] 3px) 4px [d]' computes to '10px [a] 1px 2px [b] 3px 4px [d]' assert_equals: expected "10px [a] 1px 2px [b] 3px 4px [d]" but got "[a] 10px 1px [b] 2px 3px [d] 4px"
-FAIL Property grid-template-rows value '[a] 1px repeat(auto-fill, 2px [b] 3px) 4px [d]' computes to '10px [a] 1px 2px [b] 3px 4px [d]' assert_equals: expected "10px [a] 1px 2px [b] 3px 4px [d]" but got "[a] 10px 1px [b] 2px 3px [d] 4px"
-FAIL Property grid-template-rows value '[a] 1px repeat(auto-fit, 2px [b] 3px) 4px [d]' computes to '10px [a] 1px 0px [b] 0px 4px [d]' assert_equals: expected "10px [a] 1px 0px [b] 0px 4px [d]" but got "[a] 10px 1px [b] 0px 0px [d] 4px"
-FAIL Property grid-template-rows value '100% [a] repeat(1, [b] 200% [c]) [d] 300%' computes to '10px 1px [a b] 2px [c d] 3px' assert_equals: expected "10px 1px [a b] 2px [c d] 3px" but got "10px [a b] 1px [c d] 2px 3px"
-FAIL Property grid-template-rows value '100% [a] repeat(auto-fill, [b] 200% [c]) [d] 300%' computes to '10px 1px [a b] 2px [c d] 3px' assert_equals: expected "10px 1px [a b] 2px [c d] 3px" but got "10px [a b] 1px [c d] 2px 3px"
-FAIL Property grid-template-rows value '100% [a] repeat(auto-fit, [b] 200% [c]) [d] 300%' computes to '10px 1px [a b] 0px [c d] 3px' assert_equals: expected "10px 1px [a b] 0px [c d] 3px" but got "10px [a b] 1px [c d] 0px 3px"
-FAIL Property grid-template-rows value '[a] 1em repeat(1, 2em [b] 3em) 4em [d]' computes to '10px [a] 1px 2px [b] 3px 4px [d]' assert_equals: expected "10px [a] 1px 2px [b] 3px 4px [d]" but got "[a] 10px 1px [b] 2px 3px [d] 4px"
-FAIL Property grid-template-rows value '[a] 1em repeat(auto-fill, 2em [b] 3em) 4em [d]' computes to '10px [a] 1px 2px [b] 3px 4px [d]' assert_equals: expected "10px [a] 1px 2px [b] 3px 4px [d]" but got "[a] 10px 1px [b] 2px 3px [d] 4px"
-FAIL Property grid-template-rows value '[a] 1em repeat(auto-fit, 2em [b] 3em) 4em [d]' computes to '10px [a] 1px 0px [b] 0px 4px [d]' assert_equals: expected "10px [a] 1px 0px [b] 0px 4px [d]" but got "[a] 10px 1px [b] 0px 0px [d] 4px"
+PASS Property grid-template-rows value '1px [a] repeat(1, 2px 3px) [b] 4px' computes to '10px 1px [a] 2px 3px [b] 4px' 
+PASS Property grid-template-rows value '1px [a] repeat(auto-fill, 2px 3px) [b] 4px' computes to '10px 1px [a] 2px 3px [b] 4px' 
+PASS Property grid-template-rows value '1px [a] repeat(auto-fit, 2px 3px) [b] 4px' computes to '10px 1px [a] 0px 0px [b] 4px' 
+PASS Property grid-template-rows value '1px [a] repeat(1, [b] 2px [c]) [d] 3px' computes to '10px 1px [a b] 2px [c d] 3px' 
+PASS Property grid-template-rows value '1px [a] repeat(auto-fill, [b] 2px [c]) [d] 3px' computes to '10px 1px [a b] 2px [c d] 3px' 
+PASS Property grid-template-rows value '1px [a] repeat(auto-fit, [b] 2px [c]) [d] 3px' computes to '10px 1px [a b] 0px [c d] 3px' 
+PASS Property grid-template-rows value '[a] 1px repeat(1, 2px [b] 3px) 4px [d]' computes to '10px [a] 1px 2px [b] 3px 4px [d]' 
+PASS Property grid-template-rows value '[a] 1px repeat(auto-fill, 2px [b] 3px) 4px [d]' computes to '10px [a] 1px 2px [b] 3px 4px [d]' 
+PASS Property grid-template-rows value '[a] 1px repeat(auto-fit, 2px [b] 3px) 4px [d]' computes to '10px [a] 1px 0px [b] 0px 4px [d]' 
+PASS Property grid-template-rows value '100% [a] repeat(1, [b] 200% [c]) [d] 300%' computes to '10px 1px [a b] 2px [c d] 3px' 
+PASS Property grid-template-rows value '100% [a] repeat(auto-fill, [b] 200% [c]) [d] 300%' computes to '10px 1px [a b] 2px [c d] 3px' 
+PASS Property grid-template-rows value '100% [a] repeat(auto-fit, [b] 200% [c]) [d] 300%' computes to '10px 1px [a b] 0px [c d] 3px' 
+PASS Property grid-template-rows value '[a] 1em repeat(1, 2em [b] 3em) 4em [d]' computes to '10px [a] 1px 2px [b] 3px 4px [d]' 
+PASS Property grid-template-rows value '[a] 1em repeat(auto-fill, 2em [b] 3em) 4em [d]' computes to '10px [a] 1px 2px [b] 3px 4px [d]' 
+PASS Property grid-template-rows value '[a] 1em repeat(auto-fit, 2em [b] 3em) 4em [d]' computes to '10px [a] 1px 0px [b] 0px 4px [d]' 
 

Modified: trunk/Source/WebCore/ChangeLog (264464 => 264465)


--- trunk/Source/WebCore/ChangeLog	2020-07-16 16:47:31 UTC (rev 264464)
+++ trunk/Source/WebCore/ChangeLog	2020-07-16 16:59:18 UTC (rev 264465)
@@ -1,3 +1,29 @@
+2020-07-16  Oriol Brufau  <[email protected]>
+
+        [css-grid] Fix line name positions after implicit tracks
+        https://bugs.webkit.org/show_bug.cgi?id=214315
+
+        Reviewed by Manuel Rego Casasnovas.
+
+        When serializing grid-template-rows/columns of a grid container, we get
+        the list of used track sizes, and then insert line names at the
+        corresponding indices.
+
+        Before this patch, these indices were simply taken from the computed
+        value. However, leading implicit tracks appear in the used value but not
+        in the computed one. Therefore, we have to offset the indices so that
+        the line names appear at the proper positions.
+
+        This patch is a port of https://crrev.com/777829
+
+        Tests: imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-columns-computed-implicit-track.html
+               imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-rows-computed-implicit-track.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::populateGridTrackList):
+        (WebCore::valueForGridTrackList):
+        * rendering/RenderGrid.h:
+
 2020-07-16  Andres Gonzalez  <[email protected]>
 
         [webAccessibilityObjectWrapper doAXAttributedStringForTextMarkerRange]needs to autorelease the return value from the main thread.

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (264464 => 264465)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2020-07-16 16:47:31 UTC (rev 264464)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2020-07-16 16:59:18 UTC (rev 264465)
@@ -868,20 +868,24 @@
 }
 
 template <typename T, typename F>
-void populateGridTrackList(CSSValueList& list, OrderedNamedLinesCollector& collector, const Vector<T>& tracks, F getTrackSize, unsigned start, unsigned end, unsigned offset = 0)
+void populateGridTrackList(CSSValueList& list, OrderedNamedLinesCollector& collector, const Vector<T>& tracks, F getTrackSize, int start, int end, int offset = 0)
 {
-    ASSERT(end <= tracks.size());
-    for (unsigned i = start; i < end; ++i) {
-        addValuesForNamedGridLinesAtIndex(collector, i + offset, list);
+    ASSERT(0 <= start);
+    ASSERT(start <= end);
+    ASSERT(static_cast<unsigned>(end) <= tracks.size());
+    for (int i = start; i < end; ++i) {
+        if (i + offset >= 0)
+            addValuesForNamedGridLinesAtIndex(collector, i + offset, list);
         list.append(getTrackSize(tracks[i]));
     }
-    addValuesForNamedGridLinesAtIndex(collector, end + offset, list);
+    if (end + offset >= 0)
+        addValuesForNamedGridLinesAtIndex(collector, end + offset, list);
 }
 
 template <typename T, typename F>
-void populateGridTrackList(CSSValueList& list, OrderedNamedLinesCollector& collector, const Vector<T>& tracks, F getTrackSize)
+void populateGridTrackList(CSSValueList& list, OrderedNamedLinesCollector& collector, const Vector<T>& tracks, F getTrackSize, int offset = 0)
 {
-    populateGridTrackList<T>(list, collector, tracks, getTrackSize, 0, tracks.size());
+    populateGridTrackList<T>(list, collector, tracks, getTrackSize, 0, tracks.size(), offset);
 }
 
 static Ref<CSSValue> valueForGridTrackList(GridTrackSizingDirection direction, RenderObject* renderer, const RenderStyle& style)
@@ -911,9 +915,12 @@
     if (isRenderGrid) {
         auto* grid = downcast<RenderGrid>(renderer);
         OrderedNamedLinesCollectorInGridLayout collector(style, isRowAxis, grid->autoRepeatCountForDirection(direction), autoRepeatTrackSizes.size());
+        // Named grid line indices are relative to the explicit grid, but we are including all tracks.
+        // So we need to subtract the number of leading implicit tracks in order to get the proper line index.
+        int offset = -grid->explicitGridStartForDirection(direction);
         populateGridTrackList(list.get(), collector, grid->trackSizesForComputedStyle(direction), [&](const LayoutUnit& v) {
             return zoomAdjustedPixelValue(v, style);
-        });
+        }, offset);
         return list;
     }
 

Modified: trunk/Source/WebCore/rendering/RenderGrid.h (264464 => 264465)


--- trunk/Source/WebCore/rendering/RenderGrid.h	2020-07-16 16:47:31 UTC (rev 264464)
+++ trunk/Source/WebCore/rendering/RenderGrid.h	2020-07-16 16:59:18 UTC (rev 264465)
@@ -68,6 +68,7 @@
     const Vector<LayoutUnit>& rowPositions() const { return m_rowPositions; }
 
     unsigned autoRepeatCountForDirection(GridTrackSizingDirection direction) const { return m_grid.autoRepeatTracks(direction); }
+    unsigned explicitGridStartForDirection(GridTrackSizingDirection direction) const { return m_grid.explicitGridStart(direction); }
 
     // Required by GridTrackSizingAlgorithm. Keep them under control.
     LayoutUnit guttersSize(const Grid&, GridTrackSizingDirection, unsigned startLine, unsigned span, Optional<LayoutUnit> availableSize) const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to