Changeset 159808 in webkit


Ignore:
Timestamp:
Nov 27, 2013 12:31:14 AM (10 years ago)
Author:
svillar@igalia.com
Message:

[CSS Grid Layout] Support grid-definition-{rows|columns} repeat() syntax
https://bugs.webkit.org/show_bug.cgi?id=103312

Reviewed by Andreas Kling.

PerformanceTests:

Use the repeat() syntax to build the huge grids used by the
performance tests.

  • Layout/auto-grid-lots-of-data.html:
  • Layout/fixed-grid-lots-of-data.html:

Source/WebCore:

Added support for the repeat() syntax inside
grid-definition-{rows|columns} by just adding the repeated values
to our list of column|row definitions.

The parsing of <track-name> was refactored in a new function as
it's used now in three different places. The <track-size> parsing
was also refactored to share it with the repeat() parsing.

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

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseGridTrackNames):
(WebCore::CSSParser::parseGridTrackList):
(WebCore::CSSParser::parseGridTrackRepeatFunction):
(WebCore::CSSParser::parseGridTrackSize):

  • css/CSSParser.h:

LayoutTests:

Based on Blink r153155 by <jchaffraix@chromium.org>. Some code was
refactored in a helper function to have a more compact test.

  • fast/css-grid-layout/grid-element-repeat-get-set-expected.txt: Added.
  • fast/css-grid-layout/grid-element-repeat-get-set.html: Added.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r159807 r159808  
     12013-11-26  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [CSS Grid Layout] Support grid-definition-{rows|columns} repeat() syntax
     4        https://bugs.webkit.org/show_bug.cgi?id=103312
     5
     6        Reviewed by Andreas Kling.
     7
     8        Based on Blink r153155 by <jchaffraix@chromium.org>. Some code was
     9        refactored in a helper function to have a more compact test.
     10
     11        * fast/css-grid-layout/grid-element-repeat-get-set-expected.txt: Added.
     12        * fast/css-grid-layout/grid-element-repeat-get-set.html: Added.
     13
    1142013-11-26  Ryosuke Niwa  <rniwa@webkit.org>
    215
  • trunk/PerformanceTests/ChangeLog

    r159805 r159808  
     12013-11-26  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [CSS Grid Layout] Support grid-definition-{rows|columns} repeat() syntax
     4        https://bugs.webkit.org/show_bug.cgi?id=103312
     5
     6        Reviewed by Andreas Kling.
     7
     8        Use the repeat() syntax to build the huge grids used by the
     9        performance tests.
     10
     11        * Layout/auto-grid-lots-of-data.html:
     12        * Layout/fixed-grid-lots-of-data.html:
     13
    1142013-11-26  Ryosuke Niwa  <rniwa@webkit.org>
    215
  • trunk/PerformanceTests/Layout/auto-grid-lots-of-data.html

    r159685 r159808  
    1414body {
    1515    display: -webkit-grid;
    16     /* FIXME: change to repeat(100, auto) when repeat() syntax becomes available. */
    17     -webkit-grid-definition-rows: auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto;
    18     -webkit-grid-definition-columns: auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto;
     16    -webkit-grid-definition-rows: repeat(100, auto);
     17    -webkit-grid-definition-columns: repeat(20, auto);
    1918}
    2019
  • trunk/PerformanceTests/Layout/fixed-grid-lots-of-data.html

    r159684 r159808  
    1313
    1414body {
    15     /* FIXME: replace by repeat() syntax when available */
    1615    display: -webkit-grid;
    17     -webkit-grid-definition-rows: 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px;
    18     -webkit-grid-definition-columns: 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px 200px;
     16    -webkit-grid-definition-rows: repeat(100, 200px);
     17    -webkit-grid-definition-columns: repeat(20, 200px);
    1918}
    2019
  • trunk/Source/WebCore/ChangeLog

    r159806 r159808  
     12013-11-26  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [CSS Grid Layout] Support grid-definition-{rows|columns} repeat() syntax
     4        https://bugs.webkit.org/show_bug.cgi?id=103312
     5
     6        Reviewed by Andreas Kling.
     7
     8        Added support for the repeat() syntax inside
     9        grid-definition-{rows|columns} by just adding the repeated values
     10        to our list of column|row definitions.
     11
     12        The parsing of <track-name> was refactored in a new function as
     13        it's used now in three different places. The <track-size> parsing
     14        was also refactored to share it with the repeat() parsing.
     15
     16        Test: fast/css-grid-layout/grid-element-repeat-get-set.html
     17
     18        * css/CSSParser.cpp:
     19        (WebCore::CSSParser::parseValue):
     20        (WebCore::CSSParser::parseGridTrackNames):
     21        (WebCore::CSSParser::parseGridTrackList):
     22        (WebCore::CSSParser::parseGridTrackRepeatFunction):
     23        (WebCore::CSSParser::parseGridTrackSize):
     24        * css/CSSParser.h:
     25
    1262013-11-26  Marcelo Lira  <marcelo.lira@openbossa.org>
    227
  • trunk/Source/WebCore/css/CSSParser.cpp

    r159591 r159808  
    26982698        if (!cssGridLayoutEnabled())
    26992699            return false;
    2700         parsedValue = parseGridTrackSize();
     2700        parsedValue = parseGridTrackSize(*m_valueList);
    27012701        break;
    27022702
     
    50315031}
    50325032
     5033void CSSParser::parseGridTrackNames(CSSParserValueList& parserValues, CSSValueList& values)
     5034{
     5035    do {
     5036        RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(parserValues.current());
     5037        values.append(name.release());
     5038        parserValues.next();
     5039    } while (parserValues.current() && parserValues.current()->unit == CSSPrimitiveValue::CSS_STRING);
     5040}
     5041
    50335042bool CSSParser::parseGridTrackList(CSSPropertyID propId, bool important)
    50345043{
     
    50445053    RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated();
    50455054    // Handle leading track names
    5046     while (m_valueList->current() && m_valueList->current()->unit == CSSPrimitiveValue::CSS_STRING) {
    5047         RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(m_valueList->current());
    5048         values->append(name.release());
    5049         m_valueList->next();
    5050     }
    5051 
    5052     bool seenTrackSize = false;
    5053     while (m_valueList->current()) {
    5054         RefPtr<CSSPrimitiveValue> primitiveValue = parseGridTrackSize();
    5055         if (!primitiveValue)
    5056             return false;
    5057 
    5058         seenTrackSize = true;
    5059         values->append(primitiveValue.release());
    5060 
    5061         while (m_valueList->current() && m_valueList->current()->unit == CSSPrimitiveValue::CSS_STRING) {
    5062             RefPtr<CSSPrimitiveValue> name = createPrimitiveStringValue(m_valueList->current());
    5063             values->append(name.release());
    5064             m_valueList->next();
    5065         }
    5066     }
    5067 
    5068     if (!seenTrackSize)
     5055    if (m_valueList->current() && m_valueList->current()->unit == CSSPrimitiveValue::CSS_STRING)
     5056        parseGridTrackNames(*m_valueList, *values);
     5057
     5058    bool seenTrackSizeOrRepeatFunction = false;
     5059    while (CSSParserValue* currentValue = m_valueList->current()) {
     5060        if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase(currentValue->function->name, "repeat(")) {
     5061            if (!parseGridTrackRepeatFunction(*values))
     5062                return false;
     5063        } else {
     5064            RefPtr<CSSPrimitiveValue> primitiveValue = parseGridTrackSize(*m_valueList);
     5065            if (!primitiveValue)
     5066                return false;
     5067            values->append(primitiveValue.release());
     5068        }
     5069        seenTrackSizeOrRepeatFunction = true;
     5070
     5071        if (m_valueList->current() && m_valueList->current()->unit == CSSPrimitiveValue::CSS_STRING)
     5072            parseGridTrackNames(*m_valueList, *values);
     5073    }
     5074
     5075    if (!seenTrackSizeOrRepeatFunction)
    50695076        return false;
    50705077
     
    50735080}
    50745081
    5075 PassRefPtr<CSSPrimitiveValue> CSSParser::parseGridTrackSize()
    5076 {
    5077     CSSParserValue* currentValue = m_valueList->current();
     5082bool CSSParser::parseGridTrackRepeatFunction(CSSValueList& list)
     5083{
     5084    CSSParserValueList* arguments = m_valueList->current()->function->args.get();
     5085    if (!arguments || arguments->size() < 3 || !validUnit(arguments->valueAt(0), FPositiveInteger) || !isComma(arguments->valueAt(1)))
     5086        return false;
     5087
     5088    ASSERT_WITH_SECURITY_IMPLICATION(arguments->valueAt(0)->fValue > 0);
     5089    size_t repetitions = arguments->valueAt(0)->fValue;
     5090    RefPtr<CSSValueList> repeatedValues = CSSValueList::createSpaceSeparated();
     5091    arguments->next(); // Skip the repetition count.
     5092    arguments->next(); // Skip the comma.
     5093
     5094    while (arguments->current()) {
     5095        if (arguments->current()->unit == CSSPrimitiveValue::CSS_STRING)
     5096            parseGridTrackNames(*arguments, *repeatedValues);
     5097
     5098        if (!arguments->current())
     5099            break;
     5100
     5101        RefPtr<CSSPrimitiveValue> trackSize = parseGridTrackSize(*arguments);
     5102        if (!trackSize)
     5103            return false;
     5104
     5105        repeatedValues->append(trackSize.release());
     5106    }
     5107
     5108    for (size_t i = 0; i < repetitions; ++i) {
     5109        for (size_t j = 0; j < repeatedValues->length(); ++j)
     5110            list.append(repeatedValues->itemWithoutBoundsCheck(j));
     5111    }
     5112
    50785113    m_valueList->next();
     5114    return true;
     5115}
     5116
     5117PassRefPtr<CSSPrimitiveValue> CSSParser::parseGridTrackSize(CSSParserValueList& inputList)
     5118{
     5119    CSSParserValue* currentValue = inputList.current();
     5120    inputList.next();
    50795121
    50805122    if (currentValue->id == CSSValueAuto)
     
    50985140    }
    50995141
    5100     if (PassRefPtr<CSSPrimitiveValue> trackBreadth = parseGridBreadth(currentValue))
    5101         return trackBreadth;
    5102 
    5103     return 0;
     5142    return parseGridBreadth(currentValue);
    51045143}
    51055144
  • trunk/Source/WebCore/css/CSSParser.h

    r159591 r159808  
    171171    bool parseSingleGridAreaLonghand(RefPtr<CSSValue>&);
    172172    bool parseGridTrackList(CSSPropertyID, bool important);
    173     PassRefPtr<CSSPrimitiveValue> parseGridTrackSize();
     173    bool parseGridTrackRepeatFunction(CSSValueList&);
     174    PassRefPtr<CSSPrimitiveValue> parseGridTrackSize(CSSParserValueList& inputList);
    174175    PassRefPtr<CSSPrimitiveValue> parseGridBreadth(CSSParserValue*);
    175176    PassRefPtr<CSSValue> parseGridTemplate();
     177    void parseGridTrackNames(CSSParserValueList& inputList, CSSValueList& values);
    176178
    177179    bool parseDashboardRegions(CSSPropertyID, bool important);
Note: See TracChangeset for help on using the changeset viewer.