Changeset 202972 in webkit


Ignore:
Timestamp:
Jul 8, 2016 1:57:50 AM (8 years ago)
Author:
Manuel Rego Casasnovas
Message:

[css-grid] Disallow repeat() in grid-template shorthand
https://bugs.webkit.org/show_bug.cgi?id=159200

Reviewed by Sergio Villar Senin.

Source/WebCore:

As discussed on www-style, "repeat()" notation shouldn't be allowed
in the ASCII branch of the grid-template shorthand.
https://lists.w3.org/Archives/Public/www-style/2016May/0193.html

The patch uses an enum to invalidate "repeat()" when parsing
the grid-template shorthand.

Test: fast/css-grid-layout/grid-template-shorthand-get-set.html

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseGridTemplateColumns): Add enum.
(WebCore::CSSParser::parseGridTemplateRowsAndAreasAndColumns): Pass "DisallowRepeat"
when calling parseGridTemplateColumns().
(WebCore::CSSParser::parseGridTrackList): Use enum to allow/disallow repeat.

  • css/CSSParser.h: Define the new enum and modify method signatures to use it,

setting it to "AllowRepeat" by default.

LayoutTests:

Modified test to follow the new behavior including new cases.

  • fast/css-grid-layout/grid-template-shorthand-get-set-expected.txt:
  • fast/css-grid-layout/grid-template-shorthand-get-set.html:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202970 r202972  
     12016-07-08  Manuel Rego Casasnovas  <rego@igalia.com>
     2
     3        [css-grid] Disallow repeat() in grid-template shorthand
     4        https://bugs.webkit.org/show_bug.cgi?id=159200
     5
     6        Reviewed by Sergio Villar Senin.
     7
     8        Modified test to follow the new behavior including new cases.
     9
     10        * fast/css-grid-layout/grid-template-shorthand-get-set-expected.txt:
     11        * fast/css-grid-layout/grid-template-shorthand-get-set.html:
     12
    1132016-07-08  Frederic Wang  <fwang@igalia.com>
    214
  • trunk/LayoutTests/fast/css-grid-layout/grid-template-shorthand-get-set-expected.txt

    r201919 r202972  
    4141PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesMultipleRowsWithoutRowsSizes, '').getPropertyValue('grid-template-rows') is "[head1] 0px [tail1 head2] 0px [tail2]"
    4242PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesMultipleRowsWithoutRowsSizes, '').getPropertyValue('grid-template-areas') is "\"a\" \"b\""
    43 PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesMultipleRowsAndColumns, '').getPropertyValue('grid-template-columns') is "[first] 10px [nav nav2] 15px [nav nav2] 15px"
     43PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesMultipleRowsAndColumns, '').getPropertyValue('grid-template-columns') is "[first] 10px [nav nav2] 15px [nav] 15px [last]"
    4444PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesMultipleRowsAndColumns, '').getPropertyValue('grid-template-rows') is "100px [nav nav2] 25px [nav nav2] 25px [last]"
    4545PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesMultipleRowsAndColumns, '').getPropertyValue('grid-template-areas') is "\"a b c\" \"d e f\" \"g h i\""
    46 PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesMultipleRowsAndColumnsWithoutRowsSizes, '').getPropertyValue('grid-template-columns') is "[first] 10px [nav nav2] 15px [nav nav2] 15px"
     46PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesMultipleRowsAndColumnsWithoutRowsSizes, '').getPropertyValue('grid-template-columns') is "[first] 10px [nav nav2] 15px [nav] 15px [last]"
    4747PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesMultipleRowsAndColumnsWithoutRowsSizes, '').getPropertyValue('grid-template-rows') is "0px [nav nav2] 0px [nav nav2] 0px [last]"
    4848PASS window.getComputedStyle(gridTemplateComplexFormWithLineNamesMultipleRowsAndColumnsWithoutRowsSizes, '').getPropertyValue('grid-template-areas') is "\"a b c\" \"d e f\" \"g h i\""
     
    130130PASS window.getComputedStyle(gridTemplateNoColumnsRowWithEmptyTrailingLineNamesAndNonEmptyLeadingLineNames, '').getPropertyValue('grid-template-rows') is "none"
    131131PASS window.getComputedStyle(gridTemplateNoColumnsRowWithEmptyTrailingLineNamesAndNonEmptyLeadingLineNames, '').getPropertyValue('grid-template-areas') is "none"
     132PASS window.getComputedStyle(gridTemplateRepeat, '').getPropertyValue('grid-template-columns') is "none"
     133PASS window.getComputedStyle(gridTemplateRepeat, '').getPropertyValue('grid-template-rows') is "none"
     134PASS window.getComputedStyle(gridTemplateRepeat, '').getPropertyValue('grid-template-areas') is "none"
     135PASS window.getComputedStyle(gridTemplateRepeatAutoFill, '').getPropertyValue('grid-template-columns') is "none"
     136PASS window.getComputedStyle(gridTemplateRepeatAutoFill, '').getPropertyValue('grid-template-rows') is "none"
     137PASS window.getComputedStyle(gridTemplateRepeatAutoFill, '').getPropertyValue('grid-template-areas') is "none"
     138PASS window.getComputedStyle(gridTemplateRepeatAutoFit, '').getPropertyValue('grid-template-columns') is "none"
     139PASS window.getComputedStyle(gridTemplateRepeatAutoFit, '').getPropertyValue('grid-template-rows') is "none"
     140PASS window.getComputedStyle(gridTemplateRepeatAutoFit, '').getPropertyValue('grid-template-areas') is "none"
    132141
    133142Test the initial value
     
    198207PASS window.getComputedStyle(element, '').getPropertyValue('grid-template-rows') is "none"
    199208PASS window.getComputedStyle(element, '').getPropertyValue('grid-template-areas') is "none"
     209PASS window.getComputedStyle(element, '').getPropertyValue('grid-template-columns') is "none"
     210PASS window.getComputedStyle(element, '').getPropertyValue('grid-template-rows') is "none"
     211PASS window.getComputedStyle(element, '').getPropertyValue('grid-template-areas') is "none"
     212PASS window.getComputedStyle(element, '').getPropertyValue('grid-template-columns') is "none"
     213PASS window.getComputedStyle(element, '').getPropertyValue('grid-template-rows') is "none"
     214PASS window.getComputedStyle(element, '').getPropertyValue('grid-template-areas') is "none"
     215PASS window.getComputedStyle(element, '').getPropertyValue('grid-template-columns') is "none"
     216PASS window.getComputedStyle(element, '').getPropertyValue('grid-template-rows') is "none"
     217PASS window.getComputedStyle(element, '').getPropertyValue('grid-template-areas') is "none"
    200218PASS successfullyParsed is true
    201219
  • trunk/LayoutTests/fast/css-grid-layout/grid-template-shorthand-get-set.html

    r201919 r202972  
    4646    grid-template:        "a b c" 100px [nav]
    4747                           [nav2] "d e f" 25px  [nav]
    48                            [nav2] "g h i" 25px  [last] / [first] 10px repeat(2, [nav nav2] 15px);
     48                           [nav2] "g h i" 25px  [last] / [first] 10px [nav nav2] 15px [nav] 15px [last];
    4949}
    5050#gridTemplateComplexFormWithLineNamesMultipleRowsAndColumnsWithoutRowsSizes {
    5151    grid-template:        "a b c" [nav]
    5252                           [nav2] "d e f" [nav]
    53                            [nav2] "g h i" [last] / [first] 10px repeat(2, [nav nav2] 15px);
     53                           [nav2] "g h i" [last] / [first] 10px [nav nav2] 15px [nav] 15px [last];
    5454}
    5555#gridTemplateComplexFormWithAuto {
     
    137137#gridTemplateNoColumnsRowWithEmptyTrailingLineNamesAndNonEmptyLeadingLineNames {
    138138    grid-template: [first] "a" auto [] [tail];
     139}
     140#gridTemplateRepeat {
     141    grid-template: "a" / repeat(1, 100px);
     142}
     143#gridTemplateRepeatAutoFill {
     144    grid-template: "a" / repeat(auto-fill, 100px);
     145}
     146#gridTemplateRepeatAutoFit {
     147    grid-template: "a" / repeat(auto-fit, 100px);
    139148}
    140149
     
    185194<div class="grid" id="gridTemplateComplexFormWithNoneColumns"></div>
    186195<div class="grid" id="gridTemplateNoColumnsRowWithTwoEmptyTrailingLineNames"></div>
     196<div class="grid" id="gridTemplateRepeat"></div>
     197<div class="grid" id="gridTemplateRepeatAutoFill"></div>
     198<div class="grid" id="gridTemplateRepeatAutoFit"></div>
    187199<script src="resources/grid-template-shorthand-parsing-utils.js"></script>
    188200<script>
     
    202214    testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormWithLineNamesMultipleRows"), "10px", "[head1] 15px [tail1 head2] 20px [tail2]", '"a" "b"');
    203215    testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormWithLineNamesMultipleRowsWithoutRowsSizes"), "10px", "[head1] 0px [tail1 head2] 0px [tail2]", '"a" "b"');
    204     testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormWithLineNamesMultipleRowsAndColumns"), "[first] 10px [nav nav2] 15px [nav nav2] 15px", "100px [nav nav2] 25px [nav nav2] 25px [last]", '"a b c" "d e f" "g h i"');
    205     testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormWithLineNamesMultipleRowsAndColumnsWithoutRowsSizes"), "[first] 10px [nav nav2] 15px [nav nav2] 15px", "0px [nav nav2] 0px [nav nav2] 0px [last]", '"a b c" "d e f" "g h i"');
     216    testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormWithLineNamesMultipleRowsAndColumns"), "[first] 10px [nav nav2] 15px [nav] 15px [last]", "100px [nav nav2] 25px [nav nav2] 25px [last]", '"a b c" "d e f" "g h i"');
     217    testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormWithLineNamesMultipleRowsAndColumnsWithoutRowsSizes"), "[first] 10px [nav nav2] 15px [nav] 15px [last]", "0px [nav nav2] 0px [nav nav2] 0px [last]", '"a b c" "d e f" "g h i"');
    206218    testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormWithAuto"), "10px", "0px", '"a"');
    207219    testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormOnlyAreas"), "0px", "0px", '"a"');
     
    234246    testGridDefinitionsValues(document.getElementById("gridTemplateNoColumnsRowWithTwoEmptyTrailingLineNames"), "none", "none", "none");
    235247    testGridDefinitionsValues(document.getElementById("gridTemplateNoColumnsRowWithEmptyTrailingLineNamesAndNonEmptyLeadingLineNames"), "none", "none", "none");
     248    testGridDefinitionsValues(document.getElementById("gridTemplateRepeat"), "none", "none", "none");
     249    testGridDefinitionsValues(document.getElementById("gridTemplateRepeatAutoFill"), "none", "none", "none");
     250    testGridDefinitionsValues(document.getElementById("gridTemplateRepeatAutoFit"), "none", "none", "none");
    236251
    237252    debug("");
     
    264279    testGridDefinitionsSetBadJSValues("20px none / 15px");
    265280    testGridDefinitionsSetBadJSValues("10px 'a' / 25px");
     281    testGridDefinitionsSetBadJSValues("'a b' / 100px repeat(1, 200px)");
     282    testGridDefinitionsSetBadJSValues("'a b c' / repeat(2, 200px) 100px");
     283    testGridDefinitionsSetBadJSValues("'a b c d' / 100px repeat(auto-fill, 200px) 100px");
    266284
    267285</script>
  • trunk/Source/WebCore/ChangeLog

    r202970 r202972  
     12016-07-08  Manuel Rego Casasnovas  <rego@igalia.com>
     2
     3        [css-grid] Disallow repeat() in grid-template shorthand
     4        https://bugs.webkit.org/show_bug.cgi?id=159200
     5
     6        Reviewed by Sergio Villar Senin.
     7
     8        As discussed on www-style, "repeat()" notation shouldn't be allowed
     9        in the ASCII branch of the grid-template shorthand.
     10        https://lists.w3.org/Archives/Public/www-style/2016May/0193.html
     11
     12        The patch uses an enum to invalidate "repeat()" when parsing
     13        the grid-template shorthand.
     14
     15        Test: fast/css-grid-layout/grid-template-shorthand-get-set.html
     16
     17        * css/CSSParser.cpp:
     18        (WebCore::CSSParser::parseGridTemplateColumns): Add enum.
     19        (WebCore::CSSParser::parseGridTemplateRowsAndAreasAndColumns): Pass "DisallowRepeat"
     20        when calling parseGridTemplateColumns().
     21        (WebCore::CSSParser::parseGridTrackList): Use enum to allow/disallow repeat.
     22        * css/CSSParser.h: Define the new enum and modify method signatures to use it,
     23        setting it to "AllowRepeat" by default.
     24
    1252016-07-08  Frederic Wang  <fwang@igalia.com>
    226
  • trunk/Source/WebCore/css/CSSParser.cpp

    r202950 r202972  
    56325632}
    56335633
    5634 RefPtr<CSSValue> CSSParser::parseGridTemplateColumns()
     5634RefPtr<CSSValue> CSSParser::parseGridTemplateColumns(TrackListType trackListType)
    56355635{
    56365636    ASSERT(isCSSGridLayoutEnabled());
     
    56385638    if (!(m_valueList->current() && isForwardSlashOperator(*m_valueList->current()) && m_valueList->next()))
    56395639        return nullptr;
    5640     if (auto columnsValue = parseGridTrackList()) {
     5640    if (auto columnsValue = parseGridTrackList(trackListType)) {
    56415641        if (m_valueList->current())
    56425642            return nullptr;
     
    56915691    }
    56925692
    5693     // [<track-list> /]?
     5693    // [/ <explicit-track-list> ]?
    56945694    RefPtr<CSSValue> templateColumns;
    56955695    if (m_valueList->current()) {
    56965696        ASSERT(isForwardSlashOperator(*m_valueList->current()));
    5697         templateColumns = parseGridTemplateColumns();
     5697        templateColumns = parseGridTemplateColumns(DisallowRepeat);
    56985698        if (!templateColumns)
    56995699            return false;
     
    59315931}
    59325932
    5933 RefPtr<CSSValue> CSSParser::parseGridTrackList()
     5933RefPtr<CSSValue> CSSParser::parseGridTrackList(TrackListType trackListType)
    59345934{
    59355935    ASSERT(isCSSGridLayoutEnabled());
     
    59545954            break;
    59555955        if (currentValue->unit == CSSParserValue::Function && equalLettersIgnoringASCIICase(currentValue->function->name, "repeat(")) {
     5956            if (trackListType == DisallowRepeat)
     5957                return nullptr;
    59565958            bool isAutoRepeat;
    59575959            if (!parseGridTrackRepeatFunction(values, isAutoRepeat, allTracksAreFixedSized))
  • trunk/Source/WebCore/css/CSSParser.h

    r202950 r202972  
    236236    RefPtr<CSSValue> parseGridPosition();
    237237    bool parseGridItemPositionShorthand(CSSPropertyID, bool important);
    238     RefPtr<CSSValue> parseGridTemplateColumns();
     238    enum TrackListType { AllowRepeat, DisallowRepeat };
     239    RefPtr<CSSValue> parseGridTemplateColumns(TrackListType = AllowRepeat);
    239240    bool parseGridTemplateRowsAndAreasAndColumns(bool important);
    240241    bool parseGridTemplateShorthand(bool important);
     
    243244    bool parseGridGapShorthand(bool important);
    244245    bool parseSingleGridAreaLonghand(RefPtr<CSSValue>&);
    245     RefPtr<CSSValue> parseGridTrackList();
     246    RefPtr<CSSValue> parseGridTrackList(TrackListType = AllowRepeat);
    246247    bool parseGridTrackRepeatFunction(CSSValueList&, bool& isAutoRepeat, bool& allTracksAreFixedSized);
    247248    RefPtr<CSSValue> parseGridTrackSize(CSSParserValueList& inputList);
Note: See TracChangeset for help on using the changeset viewer.