Changeset 157211 in webkit


Ignore:
Timestamp:
Oct 10, 2013 1:38:57 AM (11 years ago)
Author:
svillar@igalia.com
Message:

[CSS Grid Layout] Implement support for grid-template
https://bugs.webkit.org/show_bug.cgi?id=103313

Reviewed by Dean Jackson.

Source/WebCore:

Based on Blink r153427, r155199 and r155712 by <jchaffraix@chromium.org>

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

Recognize, parse, store and return properly the value of
grid-template. It required some extra parsing code because the
specs mandates to check that the defined grid areas are indeed
rectangular. Named grid areas are still not fully supported, will
be done in a follow up patch.

As validating involves building the grid areas a new CSSValue was
added to hold the computed value. Note that we have to track the
explicit size of the named grid areas as the named grid areas
(".") are not tracked in our HashMap of grid areas.

This change also involves moving GridCoordinate and GridSpan to a
separate file in order to share the code that describes the grid
area coordinates.

  • CMakeLists.txt: Added new files to the build.
  • GNUmakefile.list.am: Ditto.
  • WebCore.vcxproj/WebCore.vcxproj: Ditto.
  • WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
  • WebCore.xcodeproj/project.pbxproj: Ditto.
  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::ComputedStyleExtractor::propertyValue):

  • css/CSSGridTemplateValue.cpp: Added.

(WebCore::CSSGridTemplateValue::CSSGridTemplateValue):
(WebCore::stringForPosition):
(WebCore::CSSGridTemplateValue::customCSSText):

  • css/CSSGridTemplateValue.h: Added.

(WebCore::CSSGridTemplateValue::create):
(WebCore::CSSGridTemplateValue::~CSSGridTemplateValue):
(WebCore::CSSGridTemplateValue::gridAreaMap):
(WebCore::CSSGridTemplateValue::rowCount):
(WebCore::CSSGridTemplateValue::columnCount):
(WebCore::toCSSGridTemplateValue):

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseGridTemplate): create the grid areas and
validate that they define rectangular sections.

  • css/CSSParser.h:
  • css/CSSPropertyNames.in: Added -webkit-grid-template.
  • css/CSSValue.cpp:

(WebCore::CSSValue::equals): add support for the new CSSGridTemplateValue.
(WebCore::CSSValue::cssText): Ditto.
(WebCore::CSSValue::destroy): Ditto.

  • css/CSSValue.h:

(WebCore::CSSValue::isGridTemplateValue):

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::applyProperty):

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::cachedGridCoordinate): Replaced RenderGrid::GridSpan by WebCore::GridSpan.
(WebCore::RenderGrid::resolveGridPositionsFromAutoPlacementPosition): Ditto.
(WebCore::RenderGrid::resolveGridPositionsFromStyle): Ditto.
(WebCore::RenderGrid::resolveGridPositionAgainstOppositePosition): Ditto.
(WebCore::RenderGrid::resolveNamedGridLinePositionAgainstOppositePosition): Ditto.
(WebCore::RenderGrid::resolveRowStartColumnStartNamedGridLinePositionAgainstOppositePosition): Ditto.
(WebCore::RenderGrid::resolveRowEndColumnEndNamedGridLinePositionAgainstOppositePosition): Ditto.

  • rendering/RenderGrid.h: Took GridSpan and GridCoordinate out.
  • rendering/style/GridCoordinate.h: Added.

(WebCore::GridSpan::create):
(WebCore::GridSpan::GridSpan):
(WebCore::GridSpan::operator==):
(WebCore::GridCoordinate::GridCoordinate):
(WebCore::GridCoordinate::operator==):
(WebCore::GridCoordinate::operator!=):

  • rendering/style/RenderStyle.h:
  • rendering/style/StyleGridData.cpp:

(WebCore::StyleGridData::StyleGridData):

  • rendering/style/StyleGridData.h:

(WebCore::StyleGridData::operator==):

LayoutTests:

From Blink r153427, r155199 and r155712 by <jchaffraix@chromium.org>

Added a test to verify that we properly recognize, parse, store
and return the value of grid-template.

  • fast/css-grid-layout/grid-template-get-set-expected.txt: Added.
  • fast/css-grid-layout/grid-template-get-set.html: Added.
Location:
trunk
Files:
5 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r157199 r157211  
     12013-10-08  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [CSS Grid Layout] Implement support for grid-template
     4        https://bugs.webkit.org/show_bug.cgi?id=103313
     5
     6        Reviewed by Dean Jackson.
     7
     8        From Blink r153427, r155199 and r155712  by <jchaffraix@chromium.org>
     9
     10        Added a test to verify that we properly recognize, parse, store
     11        and return the value of grid-template.
     12
     13        * fast/css-grid-layout/grid-template-get-set-expected.txt: Added.
     14        * fast/css-grid-layout/grid-template-get-set.html: Added.
     15
    1162013-10-09  Alexandru Chiculita  <achicu@adobe.com>
    217
  • trunk/Source/WebCore/CMakeLists.txt

    r157203 r157211  
    991991    css/CSSFunctionValue.cpp
    992992    css/CSSGradientValue.cpp
     993    css/CSSGridTemplateValue.cpp
    993994    css/CSSGroupingRule.cpp
    994995    css/CSSHostRule.cpp
  • trunk/Source/WebCore/ChangeLog

    r157210 r157211  
     12013-10-08  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [CSS Grid Layout] Implement support for grid-template
     4        https://bugs.webkit.org/show_bug.cgi?id=103313
     5
     6        Reviewed by Dean Jackson.
     7
     8        Based on Blink r153427, r155199 and r155712 by <jchaffraix@chromium.org>
     9
     10        Test: fast/css-grid-layout/grid-template-get-set.html
     11
     12        Recognize, parse, store and return properly the value of
     13        grid-template. It required some extra parsing code because the
     14        specs mandates to check that the defined grid areas are indeed
     15        rectangular. Named grid areas are still not fully supported, will
     16        be done in a follow up patch.
     17
     18        As validating involves building the grid areas a new CSSValue was
     19        added to hold the computed value. Note that we have to track the
     20        explicit size of the named grid areas as the named grid areas
     21        (".") are not tracked in our HashMap of grid areas.
     22
     23        This change also involves moving GridCoordinate and GridSpan to a
     24        separate file in order to share the code that describes the grid
     25        area coordinates.
     26
     27        * CMakeLists.txt: Added new files to the build.
     28        * GNUmakefile.list.am: Ditto.
     29        * WebCore.vcxproj/WebCore.vcxproj: Ditto.
     30        * WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
     31        * WebCore.xcodeproj/project.pbxproj: Ditto.
     32        * css/CSSComputedStyleDeclaration.cpp:
     33        (WebCore::ComputedStyleExtractor::propertyValue):
     34        * css/CSSGridTemplateValue.cpp: Added.
     35        (WebCore::CSSGridTemplateValue::CSSGridTemplateValue):
     36        (WebCore::stringForPosition):
     37        (WebCore::CSSGridTemplateValue::customCSSText):
     38        * css/CSSGridTemplateValue.h: Added.
     39        (WebCore::CSSGridTemplateValue::create):
     40        (WebCore::CSSGridTemplateValue::~CSSGridTemplateValue):
     41        (WebCore::CSSGridTemplateValue::gridAreaMap):
     42        (WebCore::CSSGridTemplateValue::rowCount):
     43        (WebCore::CSSGridTemplateValue::columnCount):
     44        (WebCore::toCSSGridTemplateValue):
     45        * css/CSSParser.cpp:
     46        (WebCore::CSSParser::parseValue):
     47        (WebCore::CSSParser::parseGridTemplate): create the grid areas and
     48        validate that they define rectangular sections.
     49        * css/CSSParser.h:
     50        * css/CSSPropertyNames.in: Added -webkit-grid-template.
     51        * css/CSSValue.cpp:
     52        (WebCore::CSSValue::equals): add support for the new CSSGridTemplateValue.
     53        (WebCore::CSSValue::cssText): Ditto.
     54        (WebCore::CSSValue::destroy): Ditto.
     55        * css/CSSValue.h:
     56        (WebCore::CSSValue::isGridTemplateValue):
     57        * css/StyleResolver.cpp:
     58        (WebCore::StyleResolver::applyProperty):
     59        * rendering/RenderGrid.cpp:
     60        (WebCore::RenderGrid::cachedGridCoordinate): Replaced RenderGrid::GridSpan by WebCore::GridSpan.
     61        (WebCore::RenderGrid::resolveGridPositionsFromAutoPlacementPosition): Ditto.
     62        (WebCore::RenderGrid::resolveGridPositionsFromStyle): Ditto.
     63        (WebCore::RenderGrid::resolveGridPositionAgainstOppositePosition): Ditto.
     64        (WebCore::RenderGrid::resolveNamedGridLinePositionAgainstOppositePosition): Ditto.
     65        (WebCore::RenderGrid::resolveRowStartColumnStartNamedGridLinePositionAgainstOppositePosition): Ditto.
     66        (WebCore::RenderGrid::resolveRowEndColumnEndNamedGridLinePositionAgainstOppositePosition): Ditto.
     67        * rendering/RenderGrid.h: Took GridSpan and GridCoordinate out.
     68        * rendering/style/GridCoordinate.h: Added.
     69        (WebCore::GridSpan::create):
     70        (WebCore::GridSpan::GridSpan):
     71        (WebCore::GridSpan::operator==):
     72        (WebCore::GridCoordinate::GridCoordinate):
     73        (WebCore::GridCoordinate::operator==):
     74        (WebCore::GridCoordinate::operator!=):
     75        * rendering/style/RenderStyle.h:
     76        * rendering/style/StyleGridData.cpp:
     77        (WebCore::StyleGridData::StyleGridData):
     78        * rendering/style/StyleGridData.h:
     79        (WebCore::StyleGridData::operator==):
     80
    1812013-10-09  Ryosuke Niwa  <rniwa@webkit.org>
    282
  • trunk/Source/WebCore/GNUmakefile.list.am

    r157203 r157211  
    25262526        Source/WebCore/css/CSSGradientValue.cpp \
    25272527        Source/WebCore/css/CSSGradientValue.h \
     2528        Source/WebCore/css/CSSGridTemplateValue.cpp \
     2529        Source/WebCore/css/CSSGridTemplateValue.h \
    25282530        Source/WebCore/css/CSSGroupingRule.cpp \
    25292531        Source/WebCore/css/CSSGroupingRule.h \
     
    45324534        Source/WebCore/rendering/style/FillLayer.cpp \
    45334535        Source/WebCore/rendering/style/FillLayer.h \
     4536        Source/WebCore/rendering/style/GridCoordinate.h \
    45344537        Source/WebCore/rendering/style/GridPosition.h \
    45354538        Source/WebCore/rendering/style/KeyframeList.cpp \
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r157203 r157211  
    86908690      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
    86918691    </ClCompile>
     8692    <ClCompile Include="..\css\CSSGridTemplateValue.cpp" />
    86928693    <ClCompile Include="..\css\CSSGroupingRule.cpp">
    86938694      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
     
    1932619327    <ClInclude Include="..\css\CSSFunctionValue.h" />
    1932719328    <ClInclude Include="..\css\CSSGradientValue.h" />
     19329    <ClInclude Include="..\css\CSSGridTemplateValue.h" />
    1932819330    <ClInclude Include="..\css\CSSGroupingRule.h" />
    1932919331    <ClInclude Include="..\css\CSSHelper.h" />
     
    1957719579    <ClInclude Include="..\rendering\style\DataRef.h" />
    1957819580    <ClInclude Include="..\rendering\style\FillLayer.h" />
     19581    <ClInclude Include="..\rendering\style\GridCoordinate.h" />
    1957919582    <ClInclude Include="..\rendering\style\GridPosition.h" />
    1958019583    <ClInclude Include="..\rendering\style\GridTrackSize.h" />
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

    r157203 r157211  
    95719571      <Filter>rendering\style</Filter>
    95729572    </ClInclude>
     9573    <ClInclude Include="..\rendering\style\GridCoordinate.h">
     9574      <Filter>rendering\style</Filter>
     9575    </ClInclude>
    95739576    <ClInclude Include="..\rendering\style\GridPosition.h">
    95749577      <Filter>rendering\style</Filter>
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r157203 r157211  
    52895289                CD3A496417A9D01B00274E42 /* SourceBufferList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD3A495B17A9D01B00274E42 /* SourceBufferList.cpp */; };
    52905290                CD3A496517A9D01B00274E42 /* SourceBufferList.h in Headers */ = {isa = PBXBuildFile; fileRef = CD3A495C17A9D01B00274E42 /* SourceBufferList.h */; };
     5291                CD3E251C18046B0600E27F56 /* GridCoordinate.h in Headers */ = {isa = PBXBuildFile; fileRef = CD3E251B18046B0600E27F56 /* GridCoordinate.h */; settings = {ATTRIBUTES = (Private, ); }; };
     5292                CD3E252318046BCD00E27F56 /* CSSGridTemplateValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD3E252118046BCD00E27F56 /* CSSGridTemplateValue.cpp */; };
     5293                CD3E252418046BCD00E27F56 /* CSSGridTemplateValue.h in Headers */ = {isa = PBXBuildFile; fileRef = CD3E252218046BCD00E27F56 /* CSSGridTemplateValue.h */; };
    52915294                CD47B3FC16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD47B3FA16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm */; };
    52925295                CD4AC52A1496AE9A0087C4EF /* Composite.wav in Copy Audio Resources */ = {isa = PBXBuildFile; fileRef = CD4AC5281496AE2F0087C4EF /* Composite.wav */; };
     
    1220312206                CD3A495C17A9D01B00274E42 /* SourceBufferList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceBufferList.h; sourceTree = "<group>"; };
    1220412207                CD3A495D17A9D01B00274E42 /* SourceBufferList.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SourceBufferList.idl; sourceTree = "<group>"; };
     12208                CD3E251B18046B0600E27F56 /* GridCoordinate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GridCoordinate.h; path = style/GridCoordinate.h; sourceTree = "<group>"; };
     12209                CD3E252118046BCD00E27F56 /* CSSGridTemplateValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSGridTemplateValue.cpp; sourceTree = "<group>"; };
     12210                CD3E252218046BCD00E27F56 /* CSSGridTemplateValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSGridTemplateValue.h; sourceTree = "<group>"; };
    1220512211                CD47B3F916CC34F800A21EC8 /* CDMPrivateAVFoundation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDMPrivateAVFoundation.h; path = Modules/encryptedmedia/CDMPrivateAVFoundation.h; sourceTree = "<group>"; };
    1220612212                CD47B3FA16CC34F800A21EC8 /* CDMPrivateAVFoundation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CDMPrivateAVFoundation.mm; path = Modules/encryptedmedia/CDMPrivateAVFoundation.mm; sourceTree = "<group>"; };
     
    1940019406                        isa = PBXGroup;
    1940119407                        children = (
     19408                                CD3E251B18046B0600E27F56 /* GridCoordinate.h */,
    1940219409                                FBD6AF8215EF21A3008B7110 /* BasicShapes.cpp */,
    1940319410                                FBD6AF8315EF21A3008B7110 /* BasicShapes.h */,
     
    2015620163                        isa = PBXGroup;
    2015720164                        children = (
     20165                                CD3E252118046BCD00E27F56 /* CSSGridTemplateValue.cpp */,
     20166                                CD3E252218046BCD00E27F56 /* CSSGridTemplateValue.h */,
    2015820167                                93CA4C9C09DF93FA00DF8677 /* maketokenizer */,
    2015920168                                FBD6AF8415EF21D4008B7110 /* BasicShapeFunctions.cpp */,
     
    2462224631                                A0CB002517DF826C0017896B /* LineWidth.h in Headers */,
    2462324632                                A06BFE2E17DFB43F008302BB /* LineInfo.h in Headers */,
     24633                                CD3E251C18046B0600E27F56 /* GridCoordinate.h in Headers */,
     24634                                CD3E252418046BCD00E27F56 /* CSSGridTemplateValue.h in Headers */,
    2462424635                        );
    2462524636                        runOnlyForDeploymentPostprocessing = 0;
     
    2768627697                                BC10D76717D8EE6E005E2626 /* RenderBlockFlow.cpp in Sources */,
    2768727698                                A0CB002417DF82660017896B /* LineWidth.cpp in Sources */,
     27699                                CD3E252318046BCD00E27F56 /* CSSGridTemplateValue.cpp in Sources */,
    2768827700                        );
    2768927701                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r157098 r157211  
    3434#include "CSSFontValue.h"
    3535#include "CSSFunctionValue.h"
     36#include "CSSGridTemplateValue.h"
    3637#include "CSSLineBoxContainValue.h"
    3738#include "CSSParser.h"
     
    21452146        case CSSPropertyWebkitGridRow:
    21462147            return getCSSPropertyValuesForGridShorthand(webkitGridRowShorthand());
     2148
     2149        case CSSPropertyWebkitGridTemplate:
     2150            if (!style->namedGridAreaRowCount()) {
     2151                ASSERT(!style->namedGridAreaColumnCount());
     2152                return cssValuePool().createIdentifierValue(CSSValueNone);
     2153            }
     2154
     2155            return CSSGridTemplateValue::create(style->namedGridArea(), style->namedGridAreaRowCount(), style->namedGridAreaColumnCount());
    21472156
    21482157        case CSSPropertyHeight:
  • trunk/Source/WebCore/css/CSSParser.cpp

    r156991 r157211  
    4141#include "CSSFunctionValue.h"
    4242#include "CSSGradientValue.h"
     43#include "CSSGridTemplateValue.h"
    4344#include "CSSImageValue.h"
    4445#include "CSSInheritedValue.h"
     
    27132714    }
    27142715
     2716    case CSSPropertyWebkitGridTemplate:
     2717        if (!cssGridLayoutEnabled())
     2718            return false;
     2719
     2720        parsedValue = parseGridTemplate();
     2721        break;
     2722
    27152723    case CSSPropertyWebkitMarginCollapse: {
    27162724        if (num == 1) {
     
    51395147
    51405148#endif /* ENABLE(DASHBOARD_SUPPORT) */
     5149
     5150PassRefPtr<CSSValue> CSSParser::parseGridTemplate()
     5151{
     5152    NamedGridAreaMap gridAreaMap;
     5153    size_t rowCount = 0;
     5154    size_t columnCount = 0;
     5155
     5156    while (CSSParserValue* currentValue = m_valueList->current()) {
     5157        if (currentValue->unit != CSSPrimitiveValue::CSS_STRING)
     5158            return 0;
     5159
     5160        String gridRowNames = currentValue->string;
     5161        if (!gridRowNames.length())
     5162            return 0;
     5163
     5164        Vector<String> columnNames;
     5165        gridRowNames.split(' ', columnNames);
     5166
     5167        if (columnCount && (columnCount != columnNames.size())) {
     5168            // The declaration is invalid if all the rows don't have the number of columns.
     5169            return 0;
     5170        }
     5171
     5172        if (!columnCount) {
     5173            columnCount = columnNames.size();
     5174            ASSERT(columnCount);
     5175        }
     5176
     5177        for (size_t currentColumn = 0; currentColumn < columnCount; ++currentColumn) {
     5178            const String& gridAreaName = columnNames[currentColumn];
     5179
     5180            // Unamed areas are always valid (we consider them to be 1x1).
     5181            if (gridAreaName == ".")
     5182                continue;
     5183
     5184            // We handle several grid areas with the same name at once to simplify the validation code.
     5185            size_t lookAheadColumn;
     5186            for (lookAheadColumn = currentColumn; lookAheadColumn < (columnCount - 1); ++lookAheadColumn) {
     5187                if (columnNames[lookAheadColumn + 1] != gridAreaName)
     5188                    break;
     5189            }
     5190
     5191            auto gridAreaIterator = gridAreaMap.find(gridAreaName);
     5192            if (gridAreaIterator == gridAreaMap.end())
     5193                gridAreaMap.add(gridAreaName, GridCoordinate(GridSpan(rowCount, rowCount), GridSpan(currentColumn, lookAheadColumn)));
     5194            else {
     5195                GridCoordinate& gridCoordinate = gridAreaIterator->value;
     5196
     5197                // The following checks test that the grid area is a single filled-in rectangle.
     5198                // 1. The new row is adjacent to the previously parsed row.
     5199                if (rowCount != gridCoordinate.rows.initialPositionIndex + 1)
     5200                    return 0;
     5201
     5202                // 2. The new area starts at the same position as the previously parsed area.
     5203                if (currentColumn != gridCoordinate.columns.initialPositionIndex)
     5204                    return 0;
     5205
     5206                // 3. The new area ends at the same position as the previously parsed area.
     5207                if (lookAheadColumn != gridCoordinate.columns.finalPositionIndex)
     5208                    return 0;
     5209
     5210                ++gridCoordinate.rows.finalPositionIndex;
     5211            }
     5212            currentColumn = lookAheadColumn;
     5213        }
     5214
     5215        ++rowCount;
     5216        m_valueList->next();
     5217    }
     5218
     5219    if (!rowCount || !columnCount)
     5220        return 0;
     5221
     5222    return CSSGridTemplateValue::create(gridAreaMap, rowCount, columnCount);
     5223}
    51415224
    51425225PassRefPtr<CSSValue> CSSParser::parseCounterContent(CSSParserValueList* args, bool counters)
  • trunk/Source/WebCore/css/CSSParser.h

    r156550 r157211  
    170170    PassRefPtr<CSSPrimitiveValue> parseGridTrackSize();
    171171    PassRefPtr<CSSPrimitiveValue> parseGridBreadth(CSSParserValue*);
     172    PassRefPtr<CSSValue> parseGridTemplate();
    172173
    173174    bool parseDashboardRegions(CSSPropertyID, bool important);
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r156814 r157211  
    315315-webkit-grid-column
    316316-webkit-grid-row
     317-webkit-grid-template
    317318-webkit-grid-auto-flow
    318319-webkit-highlight [Inherited]
  • trunk/Source/WebCore/css/CSSValue.cpp

    r157098 r157211  
    4141#include "CSSFunctionValue.h"
    4242#include "CSSGradientValue.h"
     43#include "CSSGridTemplateValue.h"
    4344#include "CSSImageGeneratorValue.h"
    4445#include "CSSImageSetValue.h"
     
    199200        case InitialClass:
    200201            return compareCSSValues<CSSInitialValue>(*this, other);
     202        case GridTemplateClass:
     203            return compareCSSValues<CSSGridTemplateValue>(*this, other);
    201204        case PrimitiveClass:
    202205            return compareCSSValues<CSSPrimitiveValue>(*this, other);
     
    301304    case InitialClass:
    302305        return toCSSInitialValue(this)->customCSSText();
     306    case GridTemplateClass:
     307        return toCSSGridTemplateValue(this)->customCSSText();
    303308    case PrimitiveClass:
    304309        return toCSSPrimitiveValue(this)->customCSSText();
     
    426431        delete toCSSInitialValue(this);
    427432        return;
     433    case GridTemplateClass:
     434        delete toCSSGridTemplateValue(this);
     435        return;
    428436    case PrimitiveClass:
    429437        delete toCSSPrimitiveValue(this);
  • trunk/Source/WebCore/css/CSSValue.h

    r157024 r157211  
    110110    bool isVariableValue() const { return m_classType == VariableClass; }
    111111#endif
     112    bool isGridTemplateValue() const { return m_classType == GridTemplateClass; }
    112113#if ENABLE(SVG)
    113114    bool isSVGColor() const { return m_classType == SVGColorClass || m_classType == SVGPaintClass; }
     
    180181        VariableClass,
    181182#endif
     183        GridTemplateClass,
    182184#if ENABLE(SVG)
    183185        SVGColorClass,
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r157121 r157211  
    4040#include "CSSFontSelector.h"
    4141#include "CSSFontValue.h"
     42#include "CSSGridTemplateValue.h"
    4243#include "CSSLineBoxContainValue.h"
    4344#include "CSSPageRule.h"
     
    27872788        return;
    27882789    }
     2790    case CSSPropertyWebkitGridTemplate: {
     2791        if (isInherit) {
     2792            state.style()->setNamedGridArea(state.parentStyle()->namedGridArea());
     2793            state.style()->setNamedGridAreaRowCount(state.parentStyle()->namedGridAreaRowCount());
     2794            state.style()->setNamedGridAreaColumnCount(state.parentStyle()->namedGridAreaColumnCount());
     2795            return;
     2796        }
     2797        if (isInitial) {
     2798            state.style()->setNamedGridArea(RenderStyle::initialNamedGridArea());
     2799            state.style()->setNamedGridAreaRowCount(RenderStyle::initialNamedGridAreaCount());
     2800            state.style()->setNamedGridAreaColumnCount(RenderStyle::initialNamedGridAreaCount());
     2801            return;
     2802        }
     2803
     2804        if (value->isPrimitiveValue()) {
     2805            ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNone);
     2806            return;
     2807        }
     2808
     2809        CSSGridTemplateValue* gridTemplateValue = toCSSGridTemplateValue(value);
     2810        state.style()->setNamedGridArea(gridTemplateValue->gridAreaMap());
     2811        state.style()->setNamedGridAreaRowCount(gridTemplateValue->rowCount());
     2812        state.style()->setNamedGridAreaColumnCount(gridTemplateValue->columnCount());
     2813        return;
     2814    }
    27892815
    27902816    // These properties are aliased and DeprecatedStyleBuilder already applied the property on the prefixed version.
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r156876 r157211  
    2727#include "RenderGrid.h"
    2828
     29#include "GridCoordinate.h"
    2930#include "LayoutRepainter.h"
    3031#include "NotImplemented.h"
     
    706707}
    707708
    708 RenderGrid::GridCoordinate RenderGrid::cachedGridCoordinate(const RenderBox* gridItem) const
     709GridCoordinate RenderGrid::cachedGridCoordinate(const RenderBox* gridItem) const
    709710{
    710711    ASSERT(m_gridItemCoordinate.contains(gridItem));
     
    712713}
    713714
    714 RenderGrid::GridSpan RenderGrid::resolveGridPositionsFromAutoPlacementPosition(const RenderBox*, TrackSizingDirection, size_t initialPosition) const
     715GridSpan RenderGrid::resolveGridPositionsFromAutoPlacementPosition(const RenderBox*, TrackSizingDirection, size_t initialPosition) const
    715716{
    716717    // FIXME: We don't support spanning with auto positions yet. Once we do, this is wrong. Also we should make
     
    719720}
    720721
    721 PassOwnPtr<RenderGrid::GridSpan> RenderGrid::resolveGridPositionsFromStyle(const RenderBox* gridItem, TrackSizingDirection direction) const
     722PassOwnPtr<GridSpan> RenderGrid::resolveGridPositionsFromStyle(const RenderBox* gridItem, TrackSizingDirection direction) const
    722723{
    723724    const GridPosition& initialPosition = (direction == ForColumns) ? gridItem->style()->gridItemColumnStart() : gridItem->style()->gridItemRowStart();
     
    830831}
    831832
    832 PassOwnPtr<RenderGrid::GridSpan> RenderGrid::resolveGridPositionAgainstOppositePosition(size_t resolvedOppositePosition, const GridPosition& position, GridPositionSide side) const
     833PassOwnPtr<GridSpan> RenderGrid::resolveGridPositionAgainstOppositePosition(size_t resolvedOppositePosition, const GridPosition& position, GridPositionSide side) const
    833834{
    834835    if (position.isAuto())
     
    854855}
    855856
    856 PassOwnPtr<RenderGrid::GridSpan> RenderGrid::resolveNamedGridLinePositionAgainstOppositePosition(size_t resolvedOppositePosition, const GridPosition& position, GridPositionSide side) const
     857PassOwnPtr<GridSpan> RenderGrid::resolveNamedGridLinePositionAgainstOppositePosition(size_t resolvedOppositePosition, const GridPosition& position, GridPositionSide side) const
    857858{
    858859    ASSERT(position.isSpan());
     
    875876}
    876877
    877 PassOwnPtr<RenderGrid::GridSpan> RenderGrid::resolveRowStartColumnStartNamedGridLinePositionAgainstOppositePosition(size_t resolvedOppositePosition, const GridPosition& position, const Vector<size_t>& gridLines) const
     878PassOwnPtr<GridSpan> RenderGrid::resolveRowStartColumnStartNamedGridLinePositionAgainstOppositePosition(size_t resolvedOppositePosition, const GridPosition& position, const Vector<size_t>& gridLines) const
    878879{
    879880    // The grid line inequality needs to be strict (which doesn't match the after / end case) because |resolvedOppositePosition|
     
    890891}
    891892
    892 PassOwnPtr<RenderGrid::GridSpan> RenderGrid::resolveRowEndColumnEndNamedGridLinePositionAgainstOppositePosition(size_t resolvedOppositePosition, const GridPosition& position, const Vector<size_t>& gridLines) const
     893PassOwnPtr<GridSpan> RenderGrid::resolveRowEndColumnEndNamedGridLinePositionAgainstOppositePosition(size_t resolvedOppositePosition, const GridPosition& position, const Vector<size_t>& gridLines) const
    893894{
    894895    // FIXME: This could be a binary search as |gridLines| is ordered.
  • trunk/Source/WebCore/rendering/RenderGrid.h

    r156155 r157211  
    3131namespace WebCore {
    3232
     33class GridCoordinate;
     34class GridSpan;
    3335class GridTrack;
    3436
     
    5961
    6062    LayoutUnit computePreferredTrackWidth(const Length&, size_t) const;
    61 
    62     struct GridSpan {
    63         static PassOwnPtr<GridSpan> create(size_t initialPosition, size_t finalPosition)
    64         {
    65             return adoptPtr(new GridSpan(initialPosition, finalPosition));
    66         }
    67 
    68         GridSpan(size_t initialPosition, size_t finalPosition)
    69             : initialPositionIndex(initialPosition)
    70             , finalPositionIndex(finalPosition)
    71         {
    72             ASSERT(initialPositionIndex <= finalPositionIndex);
    73         }
    74 
    75         size_t initialPositionIndex;
    76         size_t finalPositionIndex;
    77     };
    78 
    79     struct GridCoordinate {
    80         // HashMap requires a default constuctor.
    81         GridCoordinate()
    82             : columns(0, 0)
    83             , rows(0, 0)
    84         {
    85         }
    86 
    87         GridCoordinate(const GridSpan& r, const GridSpan& c)
    88             : columns(c)
    89             , rows(r)
    90         {
    91         }
    92 
    93         GridSpan columns;
    94         GridSpan rows;
    95     };
    9663
    9764    class GridIterator;
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r157121 r157211  
    784784    const NamedGridLinesMap& namedGridColumnLines() const { return rareNonInheritedData->m_grid->m_namedGridColumnLines; }
    785785    const NamedGridLinesMap& namedGridRowLines() const { return rareNonInheritedData->m_grid->m_namedGridRowLines; }
     786    const NamedGridAreaMap& namedGridArea() const { return rareNonInheritedData->m_grid->m_namedGridArea; }
     787    size_t namedGridAreaRowCount() const { return rareNonInheritedData->m_grid->m_namedGridAreaRowCount; }
     788    size_t namedGridAreaColumnCount() const { return rareNonInheritedData->m_grid->m_namedGridAreaColumnCount; }
    786789    GridAutoFlow gridAutoFlow() const { return rareNonInheritedData->m_grid->m_gridAutoFlow; }
    787790    const GridTrackSize& gridAutoColumns() const { return rareNonInheritedData->m_grid->m_gridAutoColumns; }
     
    13201323    void setNamedGridColumnLines(const NamedGridLinesMap& namedGridColumnLines) { SET_VAR(rareNonInheritedData.access()->m_grid, m_namedGridColumnLines, namedGridColumnLines); }
    13211324    void setNamedGridRowLines(const NamedGridLinesMap& namedGridRowLines) { SET_VAR(rareNonInheritedData.access()->m_grid, m_namedGridRowLines, namedGridRowLines); }
     1325    void setNamedGridArea(const NamedGridAreaMap& namedGridArea) { SET_VAR(rareNonInheritedData.access()->m_grid, m_namedGridArea, namedGridArea); }
     1326    void setNamedGridAreaRowCount(size_t rowCount) { SET_VAR(rareNonInheritedData.access()->m_grid, m_namedGridAreaRowCount, rowCount); }
     1327    void setNamedGridAreaColumnCount(size_t columnCount) { SET_VAR(rareNonInheritedData.access()->m_grid, m_namedGridAreaColumnCount, columnCount); }
    13221328    void setGridAutoFlow(GridAutoFlow flow) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridAutoFlow, flow); }
    13231329    void setGridItemColumnStart(const GridPosition& columnStartPosition) { SET_VAR(rareNonInheritedData.access()->m_gridItem, m_gridColumnStart, columnStartPosition); }
     
    17751781    static GridTrackSize initialGridAutoRows() { return GridTrackSize(Auto); }
    17761782
     1783    static NamedGridAreaMap initialNamedGridArea() { return NamedGridAreaMap(); }
     1784    static size_t initialNamedGridAreaCount() { return 0; }
     1785
    17771786    // 'auto' is the default.
    17781787    static GridPosition initialGridPosition() { return GridPosition(); }
  • trunk/Source/WebCore/rendering/style/StyleGridData.cpp

    r153752 r157211  
    3737    , m_gridAutoRows(RenderStyle::initialGridAutoRows())
    3838    , m_gridAutoColumns(RenderStyle::initialGridAutoColumns())
     39    , m_namedGridArea(RenderStyle::initialNamedGridArea())
     40    , m_namedGridAreaRowCount(RenderStyle::initialNamedGridAreaCount())
     41    , m_namedGridAreaColumnCount(RenderStyle::initialNamedGridAreaCount())
    3942{
    4043}
     
    4952    , m_gridAutoRows(o.m_gridAutoRows)
    5053    , m_gridAutoColumns(o.m_gridAutoColumns)
     54    , m_namedGridArea(o.m_namedGridArea)
     55    , m_namedGridAreaRowCount(o.m_namedGridAreaRowCount)
     56    , m_namedGridAreaColumnCount(o.m_namedGridAreaColumnCount)
    5157{
    5258}
  • trunk/Source/WebCore/rendering/style/StyleGridData.h

    r153752 r157211  
    2727#define StyleGridData_h
    2828
     29#include "GridCoordinate.h"
    2930#include "GridTrackSize.h"
    3031#include "RenderStyleConstants.h"
     
    4647    {
    4748        // FIXME: comparing two hashes doesn't look great for performance. Something to keep in mind going forward.
    48         return m_gridColumns == o.m_gridColumns && m_gridRows == o.m_gridRows && m_gridAutoFlow == o.m_gridAutoFlow && m_gridAutoRows == o.m_gridAutoRows && m_gridAutoColumns == o.m_gridAutoColumns && m_namedGridColumnLines == o.m_namedGridColumnLines && m_namedGridRowLines == o.m_namedGridRowLines;
     49        return m_gridColumns == o.m_gridColumns && m_gridRows == o.m_gridRows && m_gridAutoFlow == o.m_gridAutoFlow && m_gridAutoRows == o.m_gridAutoRows && m_gridAutoColumns == o.m_gridAutoColumns && m_namedGridColumnLines == o.m_namedGridColumnLines && m_namedGridRowLines == o.m_namedGridRowLines && m_namedGridArea == o.m_namedGridArea && m_namedGridArea == o.m_namedGridArea && m_namedGridAreaRowCount == o.m_namedGridAreaRowCount && m_namedGridAreaColumnCount == o.m_namedGridAreaColumnCount;
    4950    }
    5051
     
    6667    GridTrackSize m_gridAutoColumns;
    6768
     69    NamedGridAreaMap m_namedGridArea;
     70    // Because m_namedGridArea doesn't store the unnamed grid areas, we need to keep track
     71    // of the explicit grid size defined by both named and unnamed grid areas.
     72    size_t m_namedGridAreaRowCount;
     73    size_t m_namedGridAreaColumnCount;
     74
    6875private:
    6976    StyleGridData();
Note: See TracChangeset for help on using the changeset viewer.