Changeset 173615 in webkit


Ignore:
Timestamp:
Sep 15, 2014 2:12:18 AM (10 years ago)
Author:
svillar@igalia.com
Message:

[CSS Grid Layout] Crash at CSSParser::parseGridTemplateRowsAndAreas
https://bugs.webkit.org/show_bug.cgi?id=136778

Reviewed by Darin Adler.

Source/WebCore:

An empty list of grid line names (represented by "()") does not
add anything to the list of parsed values. That's why trying to
concatenate an adjacent list of grid line names was failing,
because we were trying to concatenate a list with the last parsed
CSSValue which was not the expected grid line names list.

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseGridTemplateRowsAndAreas):
(WebCore::CSSParser::parseGridLineNames):

  • css/CSSParser.h:

LayoutTests:

Added some new test cases to verify that we properly handle empty
lists of grid line names.

  • 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

    r173596 r173615  
     12014-09-12  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [CSS Grid Layout] Crash at CSSParser::parseGridTemplateRowsAndAreas
     4        https://bugs.webkit.org/show_bug.cgi?id=136778
     5
     6        Reviewed by Darin Adler.
     7
     8        Added some new test cases to verify that we properly handle empty
     9        lists of grid line names.
     10
     11        * fast/css-grid-layout/grid-template-shorthand-get-set-expected.txt:
     12        * fast/css-grid-layout/grid-template-shorthand-get-set.html:
     13
    1142014-09-10  Jon Honeycutt  <jhoneycutt@apple.com>
    215
  • trunk/LayoutTests/fast/css-grid-layout/grid-template-shorthand-get-set-expected.txt

    r167799 r173615  
    4141PASS window.getComputedStyle(gridTemplateComplexFormOnlyAreas, '').getPropertyValue('-webkit-grid-template-rows') is "0px"
    4242PASS window.getComputedStyle(gridTemplateComplexFormOnlyAreas, '').getPropertyValue('-webkit-grid-template-areas') is "\"a\""
     43PASS window.getComputedStyle(gridTemplateNoColumnsRowWithEmptyTrailingLineNames, '').getPropertyValue('-webkit-grid-template-columns') is "none"
     44PASS window.getComputedStyle(gridTemplateNoColumnsRowWithEmptyTrailingLineNames, '').getPropertyValue('-webkit-grid-template-rows') is "(first) 0px"
     45PASS window.getComputedStyle(gridTemplateNoColumnsRowWithEmptyTrailingLineNames, '').getPropertyValue('-webkit-grid-template-areas') is "\"a\""
    4346
    4447Test getting wrong values for grid-template shorthand through CSS (they should resolve to the default: 'none')
     
    103106PASS window.getComputedStyle(gridTemplateComplexFormWithNoneColumns, '').getPropertyValue('-webkit-grid-template-rows') is "none"
    104107PASS window.getComputedStyle(gridTemplateComplexFormWithNoneColumns, '').getPropertyValue('-webkit-grid-template-areas') is "none"
     108PASS window.getComputedStyle(gridTemplateNoColumnsRowWithTwoEmptyTrailingLineNames, '').getPropertyValue('-webkit-grid-template-columns') is "none"
     109PASS window.getComputedStyle(gridTemplateNoColumnsRowWithTwoEmptyTrailingLineNames, '').getPropertyValue('-webkit-grid-template-rows') is "none"
     110PASS window.getComputedStyle(gridTemplateNoColumnsRowWithTwoEmptyTrailingLineNames, '').getPropertyValue('-webkit-grid-template-areas') is "none"
     111PASS window.getComputedStyle(gridTemplateNoColumnsRowWithEmptyTrailingLineNamesAndNonEmptyLeadingLineNames, '').getPropertyValue('-webkit-grid-template-columns') is "none"
     112PASS window.getComputedStyle(gridTemplateNoColumnsRowWithEmptyTrailingLineNamesAndNonEmptyLeadingLineNames, '').getPropertyValue('-webkit-grid-template-rows') is "none"
     113PASS window.getComputedStyle(gridTemplateNoColumnsRowWithEmptyTrailingLineNamesAndNonEmptyLeadingLineNames, '').getPropertyValue('-webkit-grid-template-areas') is "none"
    105114
    106115Test the initial value
  • trunk/LayoutTests/fast/css-grid-layout/grid-template-shorthand-get-set.html

    r168416 r173615  
    4343    -webkit-grid-template: "a";
    4444}
     45#gridTemplateNoColumnsRowWithEmptyTrailingLineNames {
     46    -webkit-grid-template: (first) "a" auto ();
     47}
    4548
    4649/* Bad values. */
     
    105108#gridTemplateComplexFormWithNoneColumns {
    106109    -webkit-grid-template: none / "a" (name) 10px;
     110}
     111#gridTemplateNoColumnsRowWithTwoEmptyTrailingLineNames {
     112    -webkit-grid-template: (first) "a" auto () ();
     113}
     114#gridTemplateNoColumnsRowWithEmptyTrailingLineNamesAndNonEmptyLeadingLineNames {
     115    -webkit-grid-template: (first) "a" auto () (tail);
    107116}
    108117
     
    123132<div class="grid" id="gridTemplateComplexFormWithAuto"></div>
    124133<div class="grid" id="gridTemplateComplexFormOnlyAreas"></div>
     134<div class="grid" id="gridTemplateNoColumnsRowWithEmptyTrailingLineNames"></div>
     135<div class="grid" id="gridTemplateNoColumnsRowWithEmptyTrailingLineNamesAndNonEmptyLeadingLineNames"></div>
     136<div class="grid" id="gridTemplateNoColumnsRowWithNonEmptyLeadingLineNamesAndEmptyTrailingLineNames"></div>
    125137<div class="grid" id="gridTemplateMultipleSlash"></div>
    126138<div class="grid" id="gridTemplateSimpleFormJustColumns"></div>
     
    143155<div class="grid" id="gridTemplateComplexFormColumnsNotParsing2"></div>
    144156<div class="grid" id="gridTemplateComplexFormWithNoneColumns"></div>
     157<div class="grid" id="gridTemplateNoColumnsRowWithTwoEmptyTrailingLineNames"></div>
    145158<script src="resources/grid-template-shorthand-parsing-utils.js"></script>
    146159<script>
     
    160173    testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormWithAuto"), "10px", "0px", '"a"');
    161174    testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormOnlyAreas"), "none", "0px", '"a"');
     175    testGridDefinitionsValues(document.getElementById("gridTemplateNoColumnsRowWithEmptyTrailingLineNames"), "none", "(first) 0px", '"a"');
    162176
    163177    debug("");
     
    183197    testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormColumnsNotParsing2"), "none", "none", "none");
    184198    testGridDefinitionsValues(document.getElementById("gridTemplateComplexFormWithNoneColumns"), "none", "none", "none");
     199    testGridDefinitionsValues(document.getElementById("gridTemplateNoColumnsRowWithTwoEmptyTrailingLineNames"), "none", "none", "none");
     200    testGridDefinitionsValues(document.getElementById("gridTemplateNoColumnsRowWithEmptyTrailingLineNamesAndNonEmptyLeadingLineNames"), "none", "none", "none");
    185201
    186202    debug("");
  • trunk/Source/WebCore/ChangeLog

    r173614 r173615  
     12014-09-12  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [CSS Grid Layout] Crash at CSSParser::parseGridTemplateRowsAndAreas
     4        https://bugs.webkit.org/show_bug.cgi?id=136778
     5
     6        Reviewed by Darin Adler.
     7
     8        An empty list of grid line names (represented by "()") does not
     9        add anything to the list of parsed values. That's why trying to
     10        concatenate an adjacent list of grid line names was failing,
     11        because we were trying to concatenate a list with the last parsed
     12        CSSValue which was not the expected grid line names list.
     13
     14        * css/CSSParser.cpp:
     15        (WebCore::CSSParser::parseGridTemplateRowsAndAreas):
     16        (WebCore::CSSParser::parseGridLineNames):
     17        * css/CSSParser.h:
     18
    1192014-09-15  Andres Gomez  <agomez@igalia.com>
    220
  • trunk/Source/WebCore/css/CSSParser.cpp

    r173579 r173615  
    50165016        // This will handle the trailing/leading <custom-ident>* in the grammar.
    50175017        trailingIdentWasAdded = false;
    5018         if (m_valueList->current() && m_valueList->current()->unit == CSSParserValue::ValueList) {
    5019             parseGridLineNames(*m_valueList, *templateRows);
    5020             trailingIdentWasAdded = true;
    5021         }
     5018        if (m_valueList->current() && m_valueList->current()->unit == CSSParserValue::ValueList)
     5019            trailingIdentWasAdded = parseGridLineNames(*m_valueList, *templateRows);
    50225020    } while (m_valueList->current());
    50235021
     
    51955193}
    51965194
    5197 void CSSParser::parseGridLineNames(CSSParserValueList& inputList, CSSValueList& valueList, CSSGridLineNamesValue* previousNamedAreaTrailingLineNames)
     5195bool CSSParser::parseGridLineNames(CSSParserValueList& inputList, CSSValueList& valueList, CSSGridLineNamesValue* previousNamedAreaTrailingLineNames)
    51985196{
    51995197    ASSERT(inputList.current() && inputList.current()->unit == CSSParserValue::ValueList);
     
    52025200    if (!identList->size()) {
    52035201        inputList.next();
    5204         return;
     5202        return false;
    52055203    }
    52065204
     
    52185216
    52195217    inputList.next();
     5218    return true;
    52205219}
    52215220
  • trunk/Source/WebCore/css/CSSParser.h

    r173268 r173615  
    172172    bool parseGridTemplateAreasRow(NamedGridAreaMap&, const unsigned, unsigned&);
    173173    PassRefPtr<CSSValue> parseGridTemplateAreas();
    174     void parseGridLineNames(CSSParserValueList&, CSSValueList&, CSSGridLineNamesValue* = nullptr);
     174    bool parseGridLineNames(CSSParserValueList&, CSSValueList&, CSSGridLineNamesValue* = nullptr);
    175175    PassRefPtr<CSSValue> parseGridAutoFlow(CSSParserValueList&);
    176176#endif
Note: See TracChangeset for help on using the changeset viewer.