⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 245798 in webkit


Ignore:
Timestamp:
May 27, 2019, 2:27:15 PM (7 years ago)
Author:
Oriol Brufau
Message:

[css-grid] Preserve repeat() notation when serializing declared values
​https://bugs.webkit.org/show_bug.cgi?id=197840

Reviewed by Manuel Rego Casasnovas.

LayoutTests/imported/w3c:

Import WPT test.

  • web-platform-tests/css/css-grid/grid-definition/grid-support-repeat-002-expected.txt: Added.
  • web-platform-tests/css/css-grid/grid-definition/grid-support-repeat-002.html: Added.
  • web-platform-tests/css/css-grid/grid-definition/w3c-import.log:

Source/WebCore:

Tests: fast/css-grid-layout/grid-element-auto-repeat-get-set.html

fast/css-grid-layout/grid-repeat-calc.html
fast/css-grid-layout/named-grid-line-get-set.html
imported/w3c/web-platform-tests/css/css-grid/grid-definition/grid-support-repeat-002.html

Before this change, a repeat() notation with an integral number of
repetitions was expanded at parse time. This was observable when reading
declared values using JS APIs.

This patch makes the parser preserve that notation, like it was already
happening when the number of repetitions was automatic and not integral.

The resolved value in getComputedStyle() will still be expanded, though,
as required by the spec.

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • css/CSSGridIntegerRepeatValue.cpp: Added.

(WebCore::CSSGridIntegerRepeatValue::customCSSText const):
(WebCore::CSSGridIntegerRepeatValue::equals const):

  • css/CSSGridIntegerRepeatValue.h: Added.
  • css/CSSValue.cpp:

(WebCore::CSSValue::equals const):
(WebCore::CSSValue::cssText const):
(WebCore::CSSValue::destroy):

  • css/CSSValue.h:

(WebCore::CSSValue::isGridIntegerRepeatValue const):

  • css/StyleBuilderConverter.h:

(WebCore::StyleBuilderConverter::createGridTrackList):
(WebCore::StyleBuilderConverter::convertGridTrackSizeList):

  • css/parser/CSSPropertyParser.cpp:

(WebCore::consumeGridTrackRepeatFunction):

Tools:

Adapt CSSPropertyParserTest to CSSGridIntegerRepeatValue.

  • TestWebKitAPI/Tests/WebCore/CSSParser.cpp:

(TestWebKitAPI::computeNumberOfTracks):

LayoutTests:

Update test expectations.

  • fast/css-grid-layout/grid-element-auto-repeat-get-set-expected.txt:
  • fast/css-grid-layout/grid-element-auto-repeat-get-set.html:
  • fast/css-grid-layout/grid-repeat-calc-expected.txt:
  • fast/css-grid-layout/grid-repeat-calc.html:
  • fast/css-grid-layout/named-grid-line-get-set-expected.txt:
  • fast/css-grid-layout/named-grid-line-get-set.html:
Location:
trunk
Files:
4 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r245788 r245798  
     12019-05-27  Oriol Brufau  <obrufau@igalia.com>
     2
     3        [css-grid] Preserve repeat() notation when serializing declared values
     4        https://bugs.webkit.org/show_bug.cgi?id=197840
     5
     6        Reviewed by Manuel Rego Casasnovas.
     7
     8        Update test expectations.
     9
     10        * fast/css-grid-layout/grid-element-auto-repeat-get-set-expected.txt:
     11        * fast/css-grid-layout/grid-element-auto-repeat-get-set.html:
     12        * fast/css-grid-layout/grid-repeat-calc-expected.txt:
     13        * fast/css-grid-layout/grid-repeat-calc.html:
     14        * fast/css-grid-layout/named-grid-line-get-set-expected.txt:
     15        * fast/css-grid-layout/named-grid-line-get-set.html:
     16
    1172019-05-27  Carlos Garcia Campos  <cgarcia@igalia.com>
    218
  • trunk/LayoutTests/fast/css-grid-layout/grid-element-auto-repeat-get-set-expected.txt

    r213831 r245798  
    1414PASS element.style.gridTemplateRows is "repeat(auto-fill, [foo] minmax(175px, max-content) [bar])"
    1515PASS getComputedStyle(element, '').getPropertyValue('grid-template-columns') is "100px 100px 100px 250px 250px"
    16 PASS element.style.gridTemplateColumns is "repeat(auto-fill, minmax(50px, 100px)) 250px 250px"
     16PASS element.style.gridTemplateColumns is "repeat(auto-fill, minmax(50px, 100px)) repeat(2, 250px)"
    1717PASS getComputedStyle(element, '').getPropertyValue('grid-template-rows') is "450px 50px [bar] 50px [bar foo] 10px [foo] 10px"
    18 PASS element.style.gridTemplateRows is "450px repeat(auto-fill, minmax(max-content, 5em) [bar]) [foo] 1em [foo] 1em"
     18PASS element.style.gridTemplateRows is "repeat(1, 450px) repeat(auto-fill, minmax(max-content, 5em) [bar]) repeat(2, [foo] 1em)"
    1919PASS getComputedStyle(element, '').getPropertyValue('grid-template-columns') is "[start] 80px [foo bar] 200px [foo bar] 200px [foo bar] 200px [end]"
    2020PASS element.style.gridTemplateColumns is "[start] 10% repeat(auto-fill, [foo bar] 200px) [end]"
    … …  
    3434PASS element.style.gridTemplateRows is "repeat(auto-fit, [foo] minmax(20em, max-content) [bar])"
    3535PASS getComputedStyle(element, '').getPropertyValue('grid-template-columns') is "0px 0px 20px 20px"
    36 PASS element.style.gridTemplateColumns is "repeat(auto-fit, minmax(300px, min-content)) 20px 20px"
     36PASS element.style.gridTemplateColumns is "repeat(auto-fit, minmax(300px, min-content)) repeat(2, 20px)"
    3737PASS getComputedStyle(element, '').getPropertyValue('grid-template-rows') is "60px 0px [bar foo] 10px [foo] 10px"
    38 PASS element.style.gridTemplateRows is "10% repeat(auto-fit, minmax(30em, max-content) [bar]) [foo] 1em [foo] 1em"
     38PASS element.style.gridTemplateRows is "repeat(1, 10%) repeat(auto-fit, minmax(30em, max-content) [bar]) repeat(2, [foo] 1em)"
    3939PASS getComputedStyle(element, '').getPropertyValue('grid-template-columns') is "[a z] 0px [y z] 0px [y z] 0px [y z] 0px [y z] 0px [y z] 0px [y z] 0px [y b] 30px [c d] 20px [e]"
    4040PASS element.style.gridTemplateColumns is "[a] repeat(auto-fit, [z] 100px [y]) [b] 30px [c d] 20px [e]"
    … …  
    4242PASS element.style.gridTemplateRows is "repeat(auto-fit, [z] 100px [y]) [a b] 30px [c d] 20px [e]"
    4343PASS getComputedStyle(element, '').getPropertyValue('grid-template-columns') is "[a z] 0px [y z] 0px [y z] 0px [y z] 0px [y z] 0px [y z] 0px [y z] 0px [y b] 30px [c] 20px [e]"
    44 PASS element.style.gridTemplateColumns is "[a] repeat(auto-fit, [z] 100px [y]) [b] 30px [c] 20px [e]"
     44PASS element.style.gridTemplateColumns is "[a] repeat(auto-fit, [z] 100px [y]) repeat(1, [b] 30px [c]) 20px [e]"
    4545PASS getComputedStyle(element, '').getPropertyValue('grid-template-rows') is "[a b] 30px [c d] 20px [e z] 0px [y z] 0px [y z] 0px [y z] 0px [y z] 0px [y]"
    4646PASS element.style.gridTemplateRows is "[a b] 30px [c d] 20px [e] repeat(auto-fit, [z] 100px [y])"
  • trunk/LayoutTests/fast/css-grid-layout/grid-element-auto-repeat-get-set.html

    r213831 r245798  
    1414    testGridTemplatesSetJSValues("repeat(auto-fill, [foo bar] 200px)", "repeat(auto-fill, 20em [foo bar])", "[foo bar] 200px [foo bar] 200px [foo bar] 200px [foo bar] 200px", "200px [foo bar] 200px [foo bar] 200px [foo bar]");
    1515    testGridTemplatesSetJSValues("repeat(auto-fill, [foo bar] minmax(300px, 1fr))", "repeat(auto-fill, [foo] minmax(175px, max-content) [bar])", "[foo bar] 400px [foo bar] 400px", "[foo] 175px [bar foo] 175px [bar foo] 175px [bar]");
    16     testGridTemplatesSetJSValues("repeat(auto-fill, minmax(50px, 100px)) repeat(2, 250px)", "repeat(1, 450px) repeat(auto-fill, minmax(max-content, 5em) [bar]) repeat(2, [foo] 1em)", "100px 100px 100px 250px 250px", "450px 50px [bar] 50px [bar foo] 10px [foo] 10px", "repeat(auto-fill, minmax(50px, 100px)) 250px 250px", "450px repeat(auto-fill, minmax(max-content, 5em) [bar]) [foo] 1em [foo] 1em");
     16    testGridTemplatesSetJSValues("repeat(auto-fill, minmax(50px, 100px)) repeat(2, 250px)", "repeat(1, 450px) repeat(auto-fill, minmax(max-content, 5em) [bar]) repeat(2, [foo] 1em)", "100px 100px 100px 250px 250px", "450px 50px [bar] 50px [bar foo] 10px [foo] 10px", "repeat(auto-fill, minmax(50px, 100px)) repeat(2, 250px)", "repeat(1, 450px) repeat(auto-fill, minmax(max-content, 5em) [bar]) repeat(2, [foo] 1em)");
    1717    testGridTemplatesSetJSValues("[start] 10% repeat(auto-fill, [foo bar] 200px) [end]", "75px [prev] repeat(auto-fill, 20em [foo bar]) [next] 15em [last end]", "[start] 80px [foo bar] 200px [foo bar] 200px [foo bar] 200px [end]", "75px [prev] 200px [foo bar next] 150px [last end]");
    1818    testGridTemplatesSetJSValues("repeat(auto-fit, [foo bar] 150px)", "repeat(auto-fit, 24em [foo bar])", "[foo bar] 0px [foo bar] 0px [foo bar] 0px [foo bar] 0px [foo bar] 0px", "0px [foo bar] 0px [foo bar]");
    1919    testGridTemplatesSetJSValues("repeat(auto-fill, [start] 200px 100px [end])", "100px [foo] repeat(auto-fill, [a] 2em [b] 10% [c]) [bar] 3em", "[start] 200px 100px [end start] 200px 100px [end]", "100px [foo a] 20px [b] 60px [c a] 20px [b] 60px [c a] 20px [b] 60px [c a] 20px [b] 60px [c a] 20px [b] 60px [c bar] 30px");
    2020    testGridTemplatesSetJSValues("repeat(auto-fit, [foo bar] minmax(270px, 1fr))", "repeat(auto-fit, [foo] minmax(20em, max-content) [bar])", "[foo bar] 0px [foo bar] 0px", "[foo] 0px [bar foo] 0px [bar foo] 0px [bar]");
    21     testGridTemplatesSetJSValues("repeat(auto-fit, minmax(300px, min-content)) repeat(2, 20px)", "repeat(1, 10%) repeat(auto-fit, minmax(30em, max-content) [bar]) repeat(2, [foo] 1em)", "0px 0px 20px 20px", "60px 0px [bar foo] 10px [foo] 10px", "repeat(auto-fit, minmax(300px, min-content)) 20px 20px", "10% repeat(auto-fit, minmax(30em, max-content) [bar]) [foo] 1em [foo] 1em");
     21    testGridTemplatesSetJSValues("repeat(auto-fit, minmax(300px, min-content)) repeat(2, 20px)", "repeat(1, 10%) repeat(auto-fit, minmax(30em, max-content) [bar]) repeat(2, [foo] 1em)", "0px 0px 20px 20px", "60px 0px [bar foo] 10px [foo] 10px", "repeat(auto-fit, minmax(300px, min-content)) repeat(2, 20px)", "repeat(1, 10%) repeat(auto-fit, minmax(30em, max-content) [bar]) repeat(2, [foo] 1em)");
    2222    testGridTemplatesSetJSValues("[a] repeat(auto-fit, [z] 100px [y]) [b] 30px [c d] 20px [e]", "repeat(auto-fit, [z] 100px [y]) [a b] 30px [c d] 20px [e]", "[a z] 0px [y z] 0px [y z] 0px [y z] 0px [y z] 0px [y z] 0px [y z] 0px [y b] 30px [c d] 20px [e]", "[z] 0px [y z] 0px [y z] 0px [y z] 0px [y z] 0px [y a b] 30px [c d] 20px [e]");
    23     testGridTemplatesSetJSValues("[a] repeat(auto-fit, [z] 100px [y]) repeat(1, [b] 30px [c]) 20px [e]", "[a b] 30px [c d] 20px [e] repeat(auto-fit, [z] 100px [y])", "[a z] 0px [y z] 0px [y z] 0px [y z] 0px [y z] 0px [y z] 0px [y z] 0px [y b] 30px [c] 20px [e]", "[a b] 30px [c d] 20px [e z] 0px [y z] 0px [y z] 0px [y z] 0px [y z] 0px [y]", "[a] repeat(auto-fit, [z] 100px [y]) [b] 30px [c] 20px [e]");
     23    testGridTemplatesSetJSValues("[a] repeat(auto-fit, [z] 100px [y]) repeat(1, [b] 30px [c]) 20px [e]", "[a b] 30px [c d] 20px [e] repeat(auto-fit, [z] 100px [y])", "[a z] 0px [y z] 0px [y z] 0px [y z] 0px [y z] 0px [y z] 0px [y z] 0px [y b] 30px [c] 20px [e]", "[a b] 30px [c d] 20px [e z] 0px [y z] 0px [y z] 0px [y z] 0px [y z] 0px [y]", "[a] repeat(auto-fit, [z] 100px [y]) repeat(1, [b] 30px [c]) 20px [e]");
    2424    testGridTemplatesSetJSValues("repeat(auto-fit, [start] 200px 100px [end])", "100px [foo] repeat(auto-fit, [a] 2em [b] 10% [c]) [bar] 3em", "[start] 0px 0px [end start] 0px 0px [end]", "100px [foo a] 0px [b] 0px [c a] 0px [b] 0px [c a] 0px [b] 0px [c a] 0px [b] 0px [c a] 0px [b] 0px [c bar] 30px");
    2525
  • trunk/LayoutTests/fast/css-grid-layout/grid-repeat-calc-expected.txt

    r200510 r245798  
    66PASS testDiv.style['grid-template-rows'] is ""
    77testDiv.style['grid-template-rows'] = 'repeat(calc(1 + 1), 18px)'
    8 PASS testDiv.style['grid-template-rows'] is "18px 18px"
     8PASS testDiv.style['grid-template-rows'] is "repeat(2, 18px)"
    99PASS window.getComputedStyle(testDiv).getPropertyValue('grid-template-rows') is "18px 18px"
    1010PASS successfullyParsed is true
  • trunk/LayoutTests/fast/css-grid-layout/grid-repeat-calc.html

    r200510 r245798  
    1111shouldBeEmptyString("testDiv.style['grid-template-rows']");
    1212evalAndLog("testDiv.style['grid-template-rows'] = 'repeat(calc(1 + 1), 18px)'");
    13 shouldBeEqualToString("testDiv.style['grid-template-rows']", "18px 18px");
     13shouldBeEqualToString("testDiv.style['grid-template-rows']", "repeat(2, 18px)");
    1414shouldBeEqualToString("window.getComputedStyle(testDiv).getPropertyValue('grid-template-rows')", "18px 18px");
    1515
  • trunk/LayoutTests/fast/css-grid-layout/named-grid-line-get-set-expected.txt

    r234687 r245798  
    7878PASS element.style.gridTemplateRows is "[foo bar] auto [foo] auto [bar]"
    7979PASS getComputedStyle(element, '').getPropertyValue('grid-template-columns') is "[first] 0px [foo bar] 20px [foo bar] 20px"
    80 PASS element.style.gridTemplateColumns is "[first] auto [foo bar] 20px [foo bar] 20px"
     80PASS element.style.gridTemplateColumns is "[first] auto repeat(2, [foo bar] 20px)"
    8181PASS getComputedStyle(element, '').getPropertyValue('grid-template-rows') is "220px [foo] 300px [baz]"
    82 PASS element.style.gridTemplateRows is "220px [foo] 50% [baz]"
     82PASS element.style.gridTemplateRows is "220px [foo] repeat(1, 50% [baz])"
    8383
    8484Test getting invalid grid-template-columns and grid-template-rows set through CSS
  • trunk/LayoutTests/fast/css-grid-layout/named-grid-line-get-set.html

    r234687 r245798  
    125125    testGridTemplatesSetJSValues("[first nav] minmax(min-content, max-content) [nav] auto [last]", "[first nav2] minmax(max-content, min-content) [nav2] minmax(10px, 15px) [last]", "[first nav] 0px [nav] 0px [last]", "[first nav2] 0px [nav2] 15px [last]", "[first nav] minmax(min-content, max-content) [nav] auto [last]", "[first nav2] minmax(max-content, min-content) [nav2] minmax(10px, 15px) [last]");
    126126    testGridTemplatesSetJSValues("[foo bar] auto [foo] auto [bar]", "[foo bar] auto [foo] auto [bar]", "[foo bar] 0px [foo] 0px [bar]", "[foo bar] 0px [foo] 0px [bar]", "[foo bar] auto [foo] auto [bar]", "[foo bar] auto [foo] auto [bar]");
    127     testGridTemplatesSetJSValues("[first] auto repeat(2, [foo bar] 20px)", "220px [foo] repeat(1, 50% [baz])", "[first] 0px [foo bar] 20px [foo bar] 20px", "220px [foo] 300px [baz]", "[first] auto [foo bar] 20px [foo bar] 20px", "220px [foo] 50% [baz]");
     127    testGridTemplatesSetJSValues("[first] auto repeat(2, [foo bar] 20px)", "220px [foo] repeat(1, 50% [baz]", "[first] 0px [foo bar] 20px [foo bar] 20px", "220px [foo] 300px [baz]", "[first] auto repeat(2, [foo bar] 20px)", "220px [foo] repeat(1, 50% [baz])");
    128128
    129129    debug("");
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r245768 r245798  
     12019-05-27  Oriol Brufau  <obrufau@igalia.com>
     2
     3        [css-grid] Preserve repeat() notation when serializing declared values
     4        https://bugs.webkit.org/show_bug.cgi?id=197840
     5
     6        Reviewed by Manuel Rego Casasnovas.
     7
     8        Import WPT test.
     9
     10        * web-platform-tests/css/css-grid/grid-definition/grid-support-repeat-002-expected.txt: Added.
     11        * web-platform-tests/css/css-grid/grid-definition/grid-support-repeat-002.html: Added.
     12        * web-platform-tests/css/css-grid/grid-definition/w3c-import.log:
     13
    1142019-05-24  Joonghun Park  <jh718.park@samsung.com>
    215
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-definition/w3c-import.log

    r245295 r245798  
    4747/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-definition/grid-support-named-grid-lines-001.html
    4848/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-definition/grid-support-repeat-001.html
     49/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-definition/grid-support-repeat-002.html
    4950/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-definition/grid-template-columns-fit-content-001-expected.html
    5051/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-definition/grid-template-columns-fit-content-001.html
  • trunk/Source/WebCore/ChangeLog

    r245796 r245798  
     12019-05-27  Oriol Brufau  <obrufau@igalia.com>
     2
     3        [css-grid] Preserve repeat() notation when serializing declared values
     4        https://bugs.webkit.org/show_bug.cgi?id=197840
     5
     6        Reviewed by Manuel Rego Casasnovas.
     7
     8        Tests: fast/css-grid-layout/grid-element-auto-repeat-get-set.html
     9               fast/css-grid-layout/grid-repeat-calc.html
     10               fast/css-grid-layout/named-grid-line-get-set.html
     11               imported/w3c/web-platform-tests/css/css-grid/grid-definition/grid-support-repeat-002.html
     12
     13        Before this change, a repeat() notation with an integral number of
     14        repetitions was expanded at parse time. This was observable when reading
     15        declared values using JS APIs.
     16
     17        This patch makes the parser preserve that notation, like it was already
     18        happening when the number of repetitions was automatic and not integral.
     19
     20        The resolved value in getComputedStyle() will still be expanded, though,
     21        as required by the spec.
     22
     23        * Sources.txt:
     24        * WebCore.xcodeproj/project.pbxproj:
     25        * css/CSSGridIntegerRepeatValue.cpp: Added.
     26        (WebCore::CSSGridIntegerRepeatValue::customCSSText const):
     27        (WebCore::CSSGridIntegerRepeatValue::equals const):
     28        * css/CSSGridIntegerRepeatValue.h: Added.
     29        * css/CSSValue.cpp:
     30        (WebCore::CSSValue::equals const):
     31        (WebCore::CSSValue::cssText const):
     32        (WebCore::CSSValue::destroy):
     33        * css/CSSValue.h:
     34        (WebCore::CSSValue::isGridIntegerRepeatValue const):
     35        * css/StyleBuilderConverter.h:
     36        (WebCore::StyleBuilderConverter::createGridTrackList):
     37        (WebCore::StyleBuilderConverter::convertGridTrackSizeList):
     38        * css/parser/CSSPropertyParser.cpp:
     39        (WebCore::consumeGridTrackRepeatFunction):
     40
    1412019-05-27  Chris Dumez  <cdumez@apple.com>
    242
  • trunk/Source/WebCore/Headers.cmake

    r245796 r245798  
    289289    css/CSSFontFaceRule.h
    290290    css/CSSFontFamily.h
     291    css/CSSGridIntegerRepeatValue.h
    291292    css/CSSGroupingRule.h
    292293    css/CSSImportRule.h
  • trunk/Source/WebCore/Sources.txt

    r245787 r245798  
    673673css/CSSGradientValue.cpp
    674674css/CSSGridAutoRepeatValue.cpp
     675css/CSSGridIntegerRepeatValue.cpp
    675676css/CSSGridLineNamesValue.cpp
    676677css/CSSGridTemplateAreasValue.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r245796 r245798  
    984984                33503CA410179AD7003B47E1 /* JSNotification.h in Headers */ = {isa = PBXBuildFile; fileRef = 33503CA010179AD7003B47E1 /* JSNotification.h */; settings = {ATTRIBUTES = (Private, ); }; };
    985985                33D0212D131DB37B004091A8 /* CookieStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = E13F01EA1270E10D00DFBA71 /* CookieStorage.h */; settings = {ATTRIBUTES = (Private, ); }; };
     986                35C74FDB228A1EF6000C21A0 /* CSSGridIntegerRepeatValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 35C74FD7228A19A6000C21A0 /* CSSGridIntegerRepeatValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
    986987                3717D7E817ECC591003C276D /* extract-localizable-strings.pl in Copy Scripts */ = {isa = PBXBuildFile; fileRef = 3717D7E517ECC3A6003C276D /* extract-localizable-strings.pl */; };
    987988                371E65CC13661EDC00BEEDB0 /* PageSerializer.h in Headers */ = {isa = PBXBuildFile; fileRef = 371E65CB13661EDC00BEEDB0 /* PageSerializer.h */; };
    … …  
    71017102                33503CA010179AD7003B47E1 /* JSNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSNotification.h; sourceTree = "<group>"; };
    71027103                33503CC61017A1B1003B47E1 /* Notification.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Notification.cpp; sourceTree = "<group>"; };
     7104                35C74FD3228A1912000C21A0 /* CSSGridIntegerRepeatValue.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CSSGridIntegerRepeatValue.cpp; sourceTree = "<group>"; };
     7105                35C74FD7228A19A6000C21A0 /* CSSGridIntegerRepeatValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSGridIntegerRepeatValue.h; sourceTree = "<group>"; };
    71037106                3662F984047CEDBE5DDDAFAA /* RenderMathMLMenclose.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMathMLMenclose.cpp; sourceTree = "<group>"; };
    71047107                37119A7920CCB610002C6DC9 /* WebKitTargetConditionals.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = WebKitTargetConditionals.xcconfig; sourceTree = "<group>"; };
    … …  
    2659226595                                E110032E1C9AC3DE00412DD0 /* CSSGridAutoRepeatValue.cpp */,
    2659326596                                E110032F1C9AC3DE00412DD0 /* CSSGridAutoRepeatValue.h */,
     26597                                35C74FD3228A1912000C21A0 /* CSSGridIntegerRepeatValue.cpp */,
     26598                                35C74FD7228A19A6000C21A0 /* CSSGridIntegerRepeatValue.h */,
    2659426599                                CD7DBB2618CA11FF00C11066 /* CSSGridLineNamesValue.cpp */,
    2659526600                                CD7DBB2718CA11FF00C11066 /* CSSGridLineNamesValue.h */,
    … …  
    2865728662                                BC53C6920DA591140021EB5D /* CSSGradientValue.h in Headers */,
    2865828663                                E11003311C9AC3DE00412DD0 /* CSSGridAutoRepeatValue.h in Headers */,
     28664                                35C74FDB228A1EF6000C21A0 /* CSSGridIntegerRepeatValue.h in Headers */,
    2865928665                                CD7DBB2918CA19C600C11066 /* CSSGridLineNamesValue.h in Headers */,
    2866028666                                CD3E252418046BCD00E27F56 /* CSSGridTemplateAreasValue.h in Headers */,
  • trunk/Source/WebCore/css/CSSValue.cpp

    r237243 r245798  
    6666
    6767#include "CSSGridAutoRepeatValue.h"
     68#include "CSSGridIntegerRepeatValue.h"
    6869#include "CSSGridLineNamesValue.h"
    6970#include "CSSGridTemplateAreasValue.h"
    … …  
    189190        case GridAutoRepeatClass:
    190191            return compareCSSValues<CSSGridAutoRepeatValue>(*this, other);
     192        case GridIntegerRepeatClass:
     193            return compareCSSValues<CSSGridIntegerRepeatValue>(*this, other);
    191194        case GridLineNamesClass:
    192195            return compareCSSValues<CSSGridLineNamesValue>(*this, other);
    … …  
    289292    case GridAutoRepeatClass:
    290293        return downcast<CSSGridAutoRepeatValue>(*this).customCSSText();
     294    case GridIntegerRepeatClass:
     295        return downcast<CSSGridIntegerRepeatValue>(*this).customCSSText();
    291296    case GridLineNamesClass:
    292297        return downcast<CSSGridLineNamesValue>(*this).customCSSText();
    … …  
    400405        delete downcast<CSSGridAutoRepeatValue>(this);
    401406        return;
     407    case GridIntegerRepeatClass:
     408        delete downcast<CSSGridIntegerRepeatValue>(this);
     409        return;
    402410    case GridLineNamesClass:
    403411        delete downcast<CSSGridLineNamesValue>(this);
  • trunk/Source/WebCore/css/CSSValue.h

    r238771 r245798  
    112112    bool isContentDistributionValue() const { return m_classType == CSSContentDistributionClass; }
    113113    bool isGridAutoRepeatValue() const { return m_classType == GridAutoRepeatClass; }
     114    bool isGridIntegerRepeatValue() const { return m_classType == GridIntegerRepeatClass; }
    114115    bool isGridTemplateAreasValue() const { return m_classType == GridTemplateAreasClass; }
    115116    bool isGridLineNamesValue() const { return m_classType == GridLineNamesClass; }
    … …  
    201202        GridLineNamesClass,
    202203        GridAutoRepeatClass,
     204        GridIntegerRepeatClass,
    203205        // Do not append non-list class types here.
    204206    };
  • trunk/Source/WebCore/css/StyleBuilderConverter.h

    r245276 r245798  
    3535#include "CSSFunctionValue.h"
    3636#include "CSSGridAutoRepeatValue.h"
     37#include "CSSGridIntegerRepeatValue.h"
    3738#include "CSSGridLineNamesValue.h"
    3839#include "CSSImageGeneratorValue.h"
    … …  
    990991
    991992    unsigned currentNamedGridLine = 0;
     993    auto handleLineNameOrTrackSize = [&](const CSSValue& currentValue) {
     994        if (is<CSSGridLineNamesValue>(currentValue))
     995            createGridLineNamesList(currentValue, currentNamedGridLine, tracksData.m_namedGridLines, tracksData.m_orderedNamedGridLines);
     996        else {
     997            ++currentNamedGridLine;
     998            tracksData.m_trackSizes.append(createGridTrackSize(currentValue, styleResolver));
     999        }
     1000    };
     1001
    9921002    for (auto& currentValue : downcast<CSSValueList>(value)) {
    993         if (is<CSSGridLineNamesValue>(currentValue)) {
    994             createGridLineNamesList(currentValue.get(), currentNamedGridLine, tracksData.m_namedGridLines, tracksData.m_orderedNamedGridLines);
    995             continue;
    996         }
    997 
    9981003        if (is<CSSGridAutoRepeatValue>(currentValue)) {
    9991004            ASSERT(tracksData.m_autoRepeatTrackSizes.isEmpty());
    … …  
    10141019        }
    10151020
    1016         ++currentNamedGridLine;
    1017         tracksData.m_trackSizes.append(createGridTrackSize(currentValue, styleResolver));
     1021        if (is<CSSGridIntegerRepeatValue>(currentValue)) {
     1022            size_t repetitions = downcast<CSSGridIntegerRepeatValue>(currentValue.get()).repetitions();
     1023            for (size_t i = 0; i < repetitions; ++i) {
     1024                for (auto& integerRepeatValue : downcast<CSSValueList>(currentValue.get()))
     1025                    handleLineNameOrTrackSize(integerRepeatValue);
     1026            }
     1027            continue;
     1028        }
     1029
     1030        handleLineNameOrTrackSize(currentValue);
    10181031    }
    10191032
    … …  
    11001113        ASSERT(!currValue->isGridLineNamesValue());
    11011114        ASSERT(!currValue->isGridAutoRepeatValue());
     1115        ASSERT(!currValue->isGridIntegerRepeatValue());
    11021116        trackSizes.uncheckedAppend(convertGridTrackSize(styleResolver, currValue));
    11031117    }
  • trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp

    r245276 r245798  
    4848#include "CSSFunctionValue.h"
    4949#include "CSSGridAutoRepeatValue.h"
     50#include "CSSGridIntegerRepeatValue.h"
    5051#include "CSSGridLineNamesValue.h"
    5152#include "CSSGridTemplateAreasValue.h"
    … …  
    34053406        // We clamp the repetitions to a multiple of the repeat() track list's size, while staying below the max grid size.
    34063407        repetitions = std::min(repetitions, GridPosition::max() / numberOfTracks);
    3407         for (size_t i = 0; i < repetitions; ++i) {
    3408             for (size_t j = 0; j < repeatedValues->length(); ++j)
    3409                 list.append(*repeatedValues->itemWithoutBoundsCheck(j));
    3410         }
     3408        RefPtr<CSSValueList> integerRepeatedValues = CSSGridIntegerRepeatValue::create(repetitions);
     3409        for (size_t i = 0; i < repeatedValues->length(); ++i)
     3410            integerRepeatedValues->append(*repeatedValues->itemWithoutBoundsCheck(i));
     3411        list.append(integerRepeatedValues.releaseNonNull());
    34113412    }
    34123413    return true;
  • trunk/Tools/ChangeLog

    r245778 r245798  
     12019-05-27  Oriol Brufau  <obrufau@igalia.com>
     2
     3        [css-grid] Preserve repeat() notation when serializing declared values
     4        https://bugs.webkit.org/show_bug.cgi?id=197840
     5
     6        Reviewed by Manuel Rego Casasnovas.
     7
     8        Adapt CSSPropertyParserTest to CSSGridIntegerRepeatValue.
     9
     10        * TestWebKitAPI/Tests/WebCore/CSSParser.cpp:
     11        (TestWebKitAPI::computeNumberOfTracks):
     12
    1132019-05-26  Wenson Hsieh  <wenson_hsieh@apple.com>
    214
  • trunk/Tools/TestWebKitAPI/Tests/WebCore/CSSParser.cpp

    r212629 r245798  
    2626#include "config.h"
    2727
     28#include <WebCore/CSSGridIntegerRepeatValue.h>
    2829#include <WebCore/CSSParser.h>
    2930#include <WebCore/CSSValueList.h>
    … …  
    4041        if (value->isGridLineNamesValue())
    4142            continue;
     43        if (is<CSSGridIntegerRepeatValue>(value)) {
     44            auto& repeatValue = downcast<CSSGridIntegerRepeatValue>(value.get());
     45            numberOfTracks += repeatValue.repetitions() * computeNumberOfTracks(repeatValue);
     46            continue;
     47        }
    4248        ++numberOfTracks;
    4349    }
Note: See TracChangeset for help on using the changeset viewer.