Changeset 169349 in webkit


Ignore:
Timestamp:
May 26, 2014 9:25:25 AM (10 years ago)
Author:
commit-queue@webkit.org
Message:

[CSS Grid Layout] Implementation of the "grid" shorthand.
https://bugs.webkit.org/show_bug.cgi?id=132122

Patch by Javier Fernandez <jfernandez@igalia.com> on 2014-05-26
Reviewed by Darin Adler.

Source/WebCore:
The grid property is a shorthand that sets all of the explicit
grid properties (grid-template-rows, grid-template-columns, and
grid-template-areas) as well as all the implicit grid properties
(grid-auto-rows, grid-auto-columns, and grid-auto-flow) in a
single declaration

Notice that either explicit or implicit grid can be specified,
assigning the initial values to the omitted properties.

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

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::ComputedStyleExtractor::propertyValue):

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseGridShorthand):

  • css/CSSParser.h:
  • css/CSSPropertyNames.in:
  • css/StylePropertyShorthand.cpp:

(WebCore::webkitGridShorthand):

  • css/StylePropertyShorthand.h:

LayoutTests:
Layout Test for the basic functionality of the 'grid' shorthand. It was
also added a new javascript file with some utility functions.

  • fast/css-grid-layout/grid-shorthand-get-set-expected.txt: Added.
  • fast/css-grid-layout/grid-shorthand-get-set.html: Added.
  • fast/css-grid-layout/resources/grid-shorthand-parsing-utils.js: Added.

(testGridDefinitionsValues):
(testGridDefinitionsSetJSValues):
(testNonGridDefinitionsSetJSValues):
(checkGridDefinitionsSetJSValues):
(testGridDefinitionsSetBadJSValues):

Location:
trunk
Files:
3 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r169345 r169349  
     12014-05-26  Javier Fernandez  <jfernandez@igalia.com>
     2
     3        [CSS Grid Layout] Implementation of the "grid" shorthand.
     4        https://bugs.webkit.org/show_bug.cgi?id=132122
     5
     6        Reviewed by Darin Adler.
     7
     8        Layout Test for the basic functionality of the 'grid' shorthand. It was
     9        also added a new javascript file with some utility functions.
     10
     11        * fast/css-grid-layout/grid-shorthand-get-set-expected.txt: Added.
     12        * fast/css-grid-layout/grid-shorthand-get-set.html: Added.
     13        * fast/css-grid-layout/resources/grid-shorthand-parsing-utils.js: Added.
     14        (testGridDefinitionsValues):
     15        (testGridDefinitionsSetJSValues):
     16        (testNonGridDefinitionsSetJSValues):
     17        (checkGridDefinitionsSetJSValues):
     18        (testGridDefinitionsSetBadJSValues):
     19
    1202014-05-26  Michał Pakuła vel Rutka  <m.pakula@samsung.com>
    221
  • trunk/Source/WebCore/ChangeLog

    r169346 r169349  
     12014-05-26  Javier Fernandez  <jfernandez@igalia.com>
     2
     3        [CSS Grid Layout] Implementation of the "grid" shorthand.
     4        https://bugs.webkit.org/show_bug.cgi?id=132122
     5
     6        Reviewed by Darin Adler.
     7
     8        The grid property is a shorthand that sets all of the explicit
     9        grid properties (grid-template-rows, grid-template-columns, and
     10        grid-template-areas) as well as all the implicit grid properties
     11        (grid-auto-rows, grid-auto-columns, and grid-auto-flow) in a
     12        single declaration
     13
     14        Notice that either explicit or implicit grid can be specified,
     15        assigning the initial values to the omitted properties.
     16
     17        Test: fast/css-grid-layout/grid-shorthand-get-set.html
     18
     19        * css/CSSComputedStyleDeclaration.cpp:
     20        (WebCore::ComputedStyleExtractor::propertyValue):
     21        * css/CSSParser.cpp:
     22        (WebCore::CSSParser::parseValue):
     23        (WebCore::CSSParser::parseGridShorthand):
     24        * css/CSSParser.h:
     25        * css/CSSPropertyNames.in:
     26        * css/StylePropertyShorthand.cpp:
     27        (WebCore::webkitGridShorthand):
     28        * css/StylePropertyShorthand.h:
     29
    1302014-05-26  Zalan Bujtas  <zalan@apple.com>
    231
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r167935 r169349  
    20852085        case CSSPropertyWebkitGridTemplate:
    20862086            return getCSSPropertyValuesForGridShorthand(webkitGridTemplateShorthand());
     2087        case CSSPropertyWebkitGrid:
     2088            return getCSSPropertyValuesForGridShorthand(webkitGridShorthand());
    20872089        case CSSPropertyWebkitGridColumn:
    20882090            return getCSSPropertyValuesForGridShorthand(webkitGridColumnShorthand());
  • trunk/Source/WebCore/css/CSSParser.cpp

    r168873 r169349  
    25862586        return parseGridTemplateShorthand(important);
    25872587
     2588    case CSSPropertyWebkitGrid:
     2589        return parseGridShorthand(important);
     2590
    25882591    case CSSPropertyWebkitGridArea:
    25892592        return parseGridAreaShorthand(important);
     
    48864889    m_valueList->setCurrentIndex(index);
    48874890    return parseGridTemplateRowsAndAreas(columnsValue, important);
     4891}
     4892
     4893bool CSSParser::parseGridShorthand(bool important)
     4894{
     4895    ShorthandScope scope(this, CSSPropertyWebkitGrid);
     4896    ASSERT(shorthandForProperty(CSSPropertyWebkitGrid).length() == 6);
     4897
     4898    // 1- <grid-template>
     4899    if (parseGridTemplateShorthand(important)) {
     4900        // It can only be specified the explicit or the implicit grid properties in a single grid declaration.
     4901        // The sub-properties not specified are set to their initial value, as normal for shorthands.
     4902        addProperty(CSSPropertyWebkitGridAutoFlow, cssValuePool().createImplicitInitialValue(), important);
     4903        addProperty(CSSPropertyWebkitGridAutoColumns, cssValuePool().createImplicitInitialValue(), important);
     4904        addProperty(CSSPropertyWebkitGridAutoRows, cssValuePool().createImplicitInitialValue(), important);
     4905        return true;
     4906    }
     4907
     4908    // Need to rewind parsing to explore the alternative syntax of this shorthand.
     4909    m_valueList->setCurrentIndex(0);
     4910
     4911    // 2- <grid-auto-flow> [ <grid-auto-columns> [ / <grid-auto-rows> ]? ]
     4912    CSSValueID id = m_valueList->current()->id;
     4913    if (id != CSSValueRow && id != CSSValueColumn && id != CSSValueNone)
     4914        return false;
     4915
     4916    RefPtr<CSSValue> autoFlowValue = cssValuePool().createIdentifierValue(id);
     4917    RefPtr<CSSValue> autoColumnsValue;
     4918    RefPtr<CSSValue> autoRowsValue;
     4919
     4920    if (m_valueList->next()) {
     4921        autoColumnsValue = parseGridTrackSize(*m_valueList);
     4922        if (!autoColumnsValue)
     4923            return false;
     4924        if (m_valueList->current()) {
     4925            if (!isForwardSlashOperator(m_valueList->current()) || !m_valueList->next())
     4926                return false;
     4927            autoRowsValue = parseGridTrackSize(*m_valueList);
     4928            if (!autoRowsValue)
     4929                return false;
     4930        }
     4931        if (m_valueList->current())
     4932            return false;
     4933    } else {
     4934        // Other omitted values are set to their initial values.
     4935        autoColumnsValue = cssValuePool().createImplicitInitialValue();
     4936        autoRowsValue = cssValuePool().createImplicitInitialValue();
     4937    }
     4938
     4939    // if <grid-auto-rows> value is omitted, it is set to the value specified for grid-auto-columns.
     4940    if (!autoRowsValue)
     4941        autoRowsValue = autoColumnsValue;
     4942
     4943    addProperty(CSSPropertyWebkitGridAutoFlow, autoFlowValue.release(), important);
     4944    addProperty(CSSPropertyWebkitGridAutoColumns, autoColumnsValue.release(), important);
     4945    addProperty(CSSPropertyWebkitGridAutoRows, autoRowsValue.release(), important);
     4946
     4947    // It can only be specified the explicit or the implicit grid properties in a single grid declaration.
     4948    // The sub-properties not specified are set to their initial value, as normal for shorthands.
     4949    addProperty(CSSPropertyWebkitGridTemplateColumns, cssValuePool().createImplicitInitialValue(), important);
     4950    addProperty(CSSPropertyWebkitGridTemplateRows, cssValuePool().createImplicitInitialValue(), important);
     4951    addProperty(CSSPropertyWebkitGridTemplateAreas, cssValuePool().createImplicitInitialValue(), important);
     4952
     4953    return true;
    48884954}
    48894955
  • trunk/Source/WebCore/css/CSSParser.h

    r168416 r169349  
    163163    bool parseGridTemplateRowsAndAreas(PassRefPtr<CSSValue>, bool important);
    164164    bool parseGridTemplateShorthand(bool important);
     165    bool parseGridShorthand(bool important);
    165166    bool parseGridAreaShorthand(bool important);
    166167    bool parseSingleGridAreaLonghand(RefPtr<CSSValue>&);
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r167799 r169349  
    306306-webkit-font-size-delta
    307307#if defined(ENABLE_CSS_GRID_LAYOUT) && ENABLE_CSS_GRID_LAYOUT
     308-webkit-grid
    308309-webkit-grid-area
    309310-webkit-grid-auto-columns
  • trunk/Source/WebCore/css/StyleProperties.cpp

    r167967 r169349  
    163163    case CSSPropertyWebkitGridTemplate:
    164164        return getShorthandValue(webkitGridTemplateShorthand());
     165    case CSSPropertyWebkitGrid:
     166        return getShorthandValue(webkitGridShorthand());
    165167    case CSSPropertyWebkitGridColumn:
    166168        return getShorthandValue(webkitGridColumnShorthand());
  • trunk/Source/WebCore/css/StylePropertyShorthand.cpp

    r167821 r169349  
    353353
    354354#if ENABLE(CSS_GRID_LAYOUT)
     355StylePropertyShorthand webkitGridShorthand()
     356{
     357    static const CSSPropertyID webkitGridProperties[] = {
     358        CSSPropertyWebkitGridTemplateColumns,
     359        CSSPropertyWebkitGridTemplateRows,
     360        CSSPropertyWebkitGridTemplateAreas,
     361        CSSPropertyWebkitGridAutoFlow,
     362        CSSPropertyWebkitGridAutoColumns,
     363        CSSPropertyWebkitGridAutoRows
     364    };
     365    return StylePropertyShorthand(CSSPropertyWebkitGrid, webkitGridProperties, WTF_ARRAY_LENGTH(webkitGridProperties));
     366}
     367
    355368StylePropertyShorthand webkitGridTemplateShorthand()
    356369{
     
    570583    case CSSPropertyWebkitGridTemplate:
    571584        return webkitGridTemplateShorthand();
     585    case CSSPropertyWebkitGrid:
     586        return webkitGridShorthand();
    572587    case CSSPropertyWebkitGridColumn:
    573588        return webkitGridColumnShorthand();
     
    773788    case CSSPropertyWebkitGridTemplateRows:
    774789    case CSSPropertyWebkitGridTemplateAreas:
    775         return makeVector(webkitGridTemplateShorthand());
     790        return makeVector(webkitGridTemplateShorthand(), webkitGridShorthand());
     791    case CSSPropertyWebkitGridAutoFlow:
     792    case CSSPropertyWebkitGridAutoColumns:
     793    case CSSPropertyWebkitGridAutoRows:
     794        return makeVector(webkitGridShorthand());
    776795#endif
    777796    case CSSPropertyWebkitMarginBeforeCollapse:
  • trunk/Source/WebCore/css/StylePropertyShorthand.h

    r167799 r169349  
    100100StylePropertyShorthand webkitFlexFlowShorthand();
    101101StylePropertyShorthand webkitFlexShorthand();
     102StylePropertyShorthand webkitGridShorthand();
    102103StylePropertyShorthand webkitGridTemplateShorthand();
    103104StylePropertyShorthand webkitGridAreaShorthand();
Note: See TracChangeset for help on using the changeset viewer.