Changeset 108855 in webkit


Ignore:
Timestamp:
Feb 24, 2012 3:24:46 PM (12 years ago)
Author:
jchaffraix@webkit.org
Message:

Implement limited parsing of -webkit-grid-column and -webkit-grid-row
https://bugs.webkit.org/show_bug.cgi?id=79151

Reviewed by Ojan Vafai.

Source/WebCore:

Test: fast/css-grid-layout/grid-item-column-row-get-set.html

This change implements a subset of the grammar:

-webkit-grid-{row|column} := <integer> | 'auto'

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • Target.pri:
  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:

Added the new files to our build systems.

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::valueForGridPosition): Check that we have the right translated grammar
(this function will be more useful once we implement more of the grammar).
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):

  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::applyProperty):
Added handling for the new properties.

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseValue):
Allow only 'auto' or <integer>.

  • css/CSSProperty.cpp:

(WebCore::CSSProperty::isInheritedProperty):
grid-colum and grid-row are not inherited.

  • css/CSSPropertyNames.in:

Added the 2 new properties.

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::RenderStyle):
(WebCore::RenderStyle::diff):

  • rendering/style/RenderStyle.h:
  • rendering/style/StyleGridItemData.cpp: Added.

(WebCore::StyleGridItemData::StyleGridItemData):

  • rendering/style/StyleGridItemData.h: Added.

(StyleGridItemData):
(WebCore::StyleGridItemData::create):
(WebCore::StyleGridItemData::copy):
(WebCore::StyleGridItemData::operator==):
(WebCore::StyleGridItemData::operator!=):
Implemented the minimum working class.

  • rendering/style/StyleRareNonInheritedData.cpp:

(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
(WebCore::StyleRareNonInheritedData::operator==):

  • rendering/style/StyleRareNonInheritedData.h:

(StyleRareNonInheritedData):
Added StyleGridItemData to the class StyleRareNonInheritedData.

LayoutTests:

  • fast/css-grid-layout/grid-item-column-row-get-set-expected.txt: Added.
  • fast/css-grid-layout/grid-item-column-row-get-set.html: Added.
Location:
trunk
Files:
4 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r108854 r108855  
     12012-02-24  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        Implement limited parsing of -webkit-grid-column and -webkit-grid-row
     4        https://bugs.webkit.org/show_bug.cgi?id=79151
     5
     6        Reviewed by Ojan Vafai.
     7
     8        * fast/css-grid-layout/grid-item-column-row-get-set-expected.txt: Added.
     9        * fast/css-grid-layout/grid-item-column-row-get-set.html: Added.
     10
    1112012-02-24  Adrienne Walker  <enne@google.com>
    212
  • trunk/Source/WebCore/CMakeLists.txt

    r108787 r108855  
    13701370    rendering/style/StyleGeneratedImage.cpp
    13711371    rendering/style/StyleGridData.cpp
     1372    rendering/style/StyleGridItemData.cpp
    13721373    rendering/style/StyleInheritedData.cpp
    13731374    rendering/style/StyleMarqueeData.cpp
  • trunk/Source/WebCore/ChangeLog

    r108852 r108855  
     12012-02-24  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        Implement limited parsing of -webkit-grid-column and -webkit-grid-row
     4        https://bugs.webkit.org/show_bug.cgi?id=79151
     5
     6        Reviewed by Ojan Vafai.
     7
     8        Test: fast/css-grid-layout/grid-item-column-row-get-set.html
     9
     10        This change implements a subset of the grammar:
     11
     12        -webkit-grid-{row|column} := <integer> | 'auto'
     13
     14        * CMakeLists.txt:
     15        * GNUmakefile.list.am:
     16        * Target.pri:
     17        * WebCore.gypi:
     18        * WebCore.vcproj/WebCore.vcproj:
     19        * WebCore.xcodeproj/project.pbxproj:
     20        Added the new files to our build systems.
     21
     22        * css/CSSComputedStyleDeclaration.cpp:
     23        (WebCore::valueForGridPosition): Check that we have the right translated grammar
     24        (this function will be more useful once we implement more of the grammar).
     25        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
     26        * css/CSSStyleSelector.cpp:
     27        (WebCore::CSSStyleSelector::applyProperty):
     28        Added handling for the new properties.
     29
     30        * css/CSSParser.cpp:
     31        (WebCore::CSSParser::parseValue):
     32        Allow only 'auto' or <integer>.
     33
     34        * css/CSSProperty.cpp:
     35        (WebCore::CSSProperty::isInheritedProperty):
     36        grid-colum and grid-row are not inherited.
     37
     38        * css/CSSPropertyNames.in:
     39        Added the 2 new properties.
     40
     41        * rendering/style/RenderStyle.cpp:
     42        (WebCore::RenderStyle::RenderStyle):
     43        (WebCore::RenderStyle::diff):
     44        * rendering/style/RenderStyle.h:
     45        * rendering/style/StyleGridItemData.cpp: Added.
     46        (WebCore::StyleGridItemData::StyleGridItemData):
     47        * rendering/style/StyleGridItemData.h: Added.
     48        (StyleGridItemData):
     49        (WebCore::StyleGridItemData::create):
     50        (WebCore::StyleGridItemData::copy):
     51        (WebCore::StyleGridItemData::operator==):
     52        (WebCore::StyleGridItemData::operator!=):
     53        Implemented the minimum working class.
     54
     55        * rendering/style/StyleRareNonInheritedData.cpp:
     56        (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
     57        (WebCore::StyleRareNonInheritedData::operator==):
     58        * rendering/style/StyleRareNonInheritedData.h:
     59        (StyleRareNonInheritedData):
     60        Added StyleGridItemData to the class StyleRareNonInheritedData.
     61
    1622012-02-24  Joshua Bell  <jsbell@chromium.org>
    263
  • trunk/Source/WebCore/GNUmakefile.list.am

    r108849 r108855  
    36893689        Source/WebCore/rendering/style/StyleGridData.cpp \
    36903690        Source/WebCore/rendering/style/StyleGridData.h \
     3691        Source/WebCore/rendering/style/StyleGridItemData.cpp \
     3692        Source/WebCore/rendering/style/StyleGridItemData.h \
    36913693        Source/WebCore/rendering/style/StyleImage.h \
    36923694        Source/WebCore/rendering/style/StyleInheritedData.cpp \
  • trunk/Source/WebCore/Target.pri

    r108792 r108855  
    12911291    rendering/style/StyleGeneratedImage.cpp \
    12921292    rendering/style/StyleGridData.cpp \
     1293    rendering/style/StyleGridItemData.cpp \
    12931294    rendering/style/StyleInheritedData.cpp \
    12941295    rendering/style/StyleMarqueeData.cpp \
  • trunk/Source/WebCore/WebCore.gypi

    r108849 r108855  
    539539            'rendering/style/StyleGeneratedImage.h',
    540540            'rendering/style/StyleGridData.h',
     541            'rendering/style/StyleGridItemData.h',
    541542            'rendering/style/StyleImage.h',
    542543            'rendering/style/StyleInheritedData.h',
     
    45474548            'rendering/style/StyleGeneratedImage.cpp',
    45484549            'rendering/style/StyleGridData.cpp',
     4550            'rendering/style/StyleGridItemData.cpp',
    45494551            'rendering/style/StyleInheritedData.cpp',
    45504552            'rendering/style/StyleMarqueeData.cpp',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r108785 r108855  
    4350843508                                </File>
    4350943509                                <File
     43510                                        RelativePath="..\rendering\style\StyleGridItemData.cpp"
     43511                                        >
     43512                                        <FileConfiguration
     43513                                                Name="Debug|Win32"
     43514                                                ExcludedFromBuild="true"
     43515                                                >
     43516                                                <Tool
     43517                                                        Name="VCCLCompilerTool"
     43518                                                />
     43519                                        </FileConfiguration>
     43520                                        <FileConfiguration
     43521                                                Name="Release|Win32"
     43522                                                ExcludedFromBuild="true"
     43523                                                >
     43524                                                <Tool
     43525                                                        Name="VCCLCompilerTool"
     43526                                                />
     43527                                        </FileConfiguration>
     43528                                        <FileConfiguration
     43529                                                Name="Debug_Cairo_CFLite|Win32"
     43530                                                ExcludedFromBuild="true"
     43531                                                >
     43532                                                <Tool
     43533                                                        Name="VCCLCompilerTool"
     43534                                                />
     43535                                        </FileConfiguration>
     43536                                        <FileConfiguration
     43537                                                Name="Release_Cairo_CFLite|Win32"
     43538                                                ExcludedFromBuild="true"
     43539                                                >
     43540                                                <Tool
     43541                                                        Name="VCCLCompilerTool"
     43542                                                />
     43543                                        </FileConfiguration>
     43544                                        <FileConfiguration
     43545                                                Name="Debug_All|Win32"
     43546                                                ExcludedFromBuild="true"
     43547                                                >
     43548                                                <Tool
     43549                                                        Name="VCCLCompilerTool"
     43550                                                />
     43551                                        </FileConfiguration>
     43552                                        <FileConfiguration
     43553                                                Name="Production|Win32"
     43554                                                ExcludedFromBuild="true"
     43555                                                >
     43556                                                <Tool
     43557                                                        Name="VCCLCompilerTool"
     43558                                                />
     43559                                        </FileConfiguration>
     43560                                </File>
     43561                                <File
     43562                                        RelativePath="..\rendering\style\StyleGridItemData.h"
     43563                                        >
     43564                                </File>
     43565                                <File
    4351043566                                        RelativePath="..\rendering\style\StyleImage.h"
    4351143567                                        >
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r108826 r108855  
    35283528                A10DC76A14747BAB005E2471 /* StyleGridData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A10DC76814747BAB005E2471 /* StyleGridData.cpp */; };
    35293529                A10DC76B14747BAB005E2471 /* StyleGridData.h in Headers */ = {isa = PBXBuildFile; fileRef = A10DC76914747BAB005E2471 /* StyleGridData.h */; settings = {ATTRIBUTES = (Private, ); }; };
     3530                A110DB9D14F5DF8700A03B93 /* StyleGridItemData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A110DB9C14F5DF8700A03B93 /* StyleGridItemData.cpp */; };
     3531                A110DB9B14F5DF7700A03B93 /* StyleGridItemData.h in Headers */ = {isa = PBXBuildFile; fileRef = A110DB9A14F5DF7700A03B93 /* StyleGridItemData.h */; settings = {ATTRIBUTES = (Private, ); }; };
    35303532                A120ACA413F998CA00FE4AC7 /* LayoutRepainter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A120ACA113F9984600FE4AC7 /* LayoutRepainter.cpp */; };
    35313533                A12538D413F9B60A00024754 /* LayoutRepainter.h in Headers */ = {isa = PBXBuildFile; fileRef = A120ACA013F9983700FE4AC7 /* LayoutRepainter.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    1041710419                A10DC76814747BAB005E2471 /* StyleGridData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StyleGridData.cpp; path = style/StyleGridData.cpp; sourceTree = "<group>"; };
    1041810420                A10DC76914747BAB005E2471 /* StyleGridData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StyleGridData.h; path = style/StyleGridData.h; sourceTree = "<group>"; };
     10421                A110DB9A14F5DF7700A03B93 /* StyleGridItemData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StyleGridItemData.h; path = style/StyleGridItemData.h; sourceTree = "<group>"; };
     10422                A110DB9C14F5DF8700A03B93 /* StyleGridItemData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StyleGridItemData.cpp; path = style/StyleGridItemData.cpp; sourceTree = "<group>"; };
    1041910423                A120ACA013F9983700FE4AC7 /* LayoutRepainter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutRepainter.h; sourceTree = "<group>"; };
    1042010424                A120ACA113F9984600FE4AC7 /* LayoutRepainter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutRepainter.cpp; sourceTree = "<group>"; };
     
    1959119595                                A10DC76814747BAB005E2471 /* StyleGridData.cpp */,
    1959219596                                A10DC76914747BAB005E2471 /* StyleGridData.h */,
     19597                                A110DB9C14F5DF8700A03B93 /* StyleGridItemData.cpp */,
     19598                                A110DB9A14F5DF7700A03B93 /* StyleGridItemData.h */,
    1959319599                                BCEF43CE0E673DA1001C1287 /* StyleImage.h */,
    1959419600                                BC2273010E82F1E600E7F975 /* StyleInheritedData.cpp */,
     
    2384123847                                BCEF444A0E6745E0001C1287 /* StyleGeneratedImage.h in Headers */,
    2384223848                                A10DC76B14747BAB005E2471 /* StyleGridData.h in Headers */,
     23849                                A110DB9B14F5DF7700A03B93 /* StyleGridItemData.h in Headers */,
    2384323850                                BCEF43CF0E673DA1001C1287 /* StyleImage.h in Headers */,
    2384423851                                BC2273040E82F1E600E7F975 /* StyleInheritedData.h in Headers */,
     
    2690626913                                BCEF447D0E674806001C1287 /* StyleGeneratedImage.cpp in Sources */,
    2690726914                                A10DC76A14747BAB005E2471 /* StyleGridData.cpp in Sources */,
     26915                                A110DB9D14F5DF8700A03B93 /* StyleGridItemData.cpp in Sources */,
    2690826916                                BC2273030E82F1E600E7F975 /* StyleInheritedData.cpp in Sources */,
    2690926917                                BC5EB7290E81DE8100B25965 /* StyleMarqueeData.cpp in Sources */,
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r108133 r108855  
    233233    CSSPropertyWebkitGridColumns,
    234234    CSSPropertyWebkitGridRows,
     235
     236    CSSPropertyWebkitGridColumn,
     237    CSSPropertyWebkitGridRow,
    235238#endif
    236239    CSSPropertyWebkitHighlight,
     
    914917    return list.release();
    915918}
     919
     920static PassRefPtr<CSSValue> valueForGridPosition(const Length& position, CSSValuePool* cssValuePool)
     921{
     922    if (position.isAuto())
     923        return cssValuePool->createIdentifierValue(CSSValueAuto);
     924
     925    ASSERT(position.isFixed());
     926    return cssValuePool->createValue(position.value(), CSSPrimitiveValue::CSS_NUMBER);
     927}
    916928#endif
    917929
     
    16491661            return valueForGridTrackList(style->gridRows(), style.get(), cssValuePool);
    16501662        }
     1663
     1664        case CSSPropertyWebkitGridColumn:
     1665            return valueForGridPosition(style->gridItemColumn(), cssValuePool);
     1666        case CSSPropertyWebkitGridRow:
     1667            return valueForGridPosition(style->gridItemRow(), cssValuePool);
    16511668#endif
    16521669        case CSSPropertyHeight:
  • trunk/Source/WebCore/css/CSSParser.cpp

    r108784 r108855  
    18831883    case CSSPropertyWebkitGridRows:
    18841884        return parseGridTrackList(propId, important);
     1885
     1886    case CSSPropertyWebkitGridColumn:
     1887    case CSSPropertyWebkitGridRow:
     1888        validPrimitive = id == CSSValueAuto || validUnit(value, FInteger, m_strict);
     1889        break;
    18851890#endif
    18861891    case CSSPropertyWebkitMarginCollapse: {
  • trunk/Source/WebCore/css/CSSProperty.cpp

    r108133 r108855  
    574574    case CSSPropertyWebkitGridColumns:
    575575    case CSSPropertyWebkitGridRows:
     576
     577    case CSSPropertyWebkitGridColumn:
     578    case CSSPropertyWebkitGridRow:
    576579#endif
    577580    case CSSPropertyWebkitLineClamp:
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r108133 r108855  
    377377-webkit-grid-columns
    378378-webkit-grid-rows
     379-webkit-grid-column
     380-webkit-grid-row
    379381#endif
    380382#if defined(ENABLE_DASHBOARD_SUPPORT) && ENABLE_DASHBOARD_SUPPORT
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r108555 r108855  
    29532953    return false;
    29542954}
     2955
     2956
     2957static bool createGridPosition(CSSValue* value, Length& position)
     2958{
     2959    // For now, we only accept: <integer> | 'auto'
     2960    if (!value->isPrimitiveValue())
     2961        return false;
     2962
     2963    CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
     2964    if (primitiveValue->getIdent() == CSSValueAuto)
     2965        return true;
     2966
     2967    ASSERT(primitiveValue->isNumber());
     2968    position.setValue(primitiveValue->getIntValue());
     2969    return true;
     2970}
    29552971#endif
    29562972
     
    38033819            return;
    38043820        m_style->setGridRows(lengths);
     3821        return;
     3822    }
     3823
     3824    case CSSPropertyWebkitGridColumn: {
     3825        Length column;
     3826        if (!createGridPosition(value, column))
     3827            return;
     3828        m_style->setGridItemColumn(column);
     3829        return;
     3830    }
     3831    case CSSPropertyWebkitGridRow: {
     3832        Length row;
     3833        if (!createGridPosition(value, row))
     3834            return;
     3835        m_style->setGridItemRow(row);
    38053836        return;
    38063837    }
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r108133 r108855  
    136136#if ENABLE(CSS_GRID_LAYOUT)
    137137    rareNonInheritedData.access()->m_grid.init();
     138    rareNonInheritedData.access()->m_gridItem.init();
    138139#endif
    139140    rareInheritedData.init();
     
    425426#endif
    426427#if ENABLE(CSS_GRID_LAYOUT)
    427         if (rareNonInheritedData->m_grid.get() != other->rareNonInheritedData->m_grid.get())
     428        if (rareNonInheritedData->m_grid.get() != other->rareNonInheritedData->m_grid.get()
     429            && rareNonInheritedData->m_gridItem.get() != other->rareNonInheritedData->m_gridItem.get())
    428430            return StyleDifferenceLayout;
    429431#endif
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r108555 r108855  
    7878#if ENABLE(CSS_GRID_LAYOUT)
    7979#include "StyleGridData.h"
     80#include "StyleGridItemData.h"
    8081#endif
    8182
     
    815816    const Vector<Length>& gridColumns() const { return rareNonInheritedData->m_grid->m_gridColumns; }
    816817    const Vector<Length>& gridRows() const { return rareNonInheritedData->m_grid->m_gridRows; }
     818
     819    const Length& gridItemColumn() const { return rareNonInheritedData->m_gridItem->m_gridColumn; }
     820    const Length& gridItemRow() const { return rareNonInheritedData->m_gridItem->m_gridRow; }
    817821#endif
    818822
     
    12411245    void setGridColumns(const Vector<Length>& lengths) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridColumns, lengths); }
    12421246    void setGridRows(const Vector<Length>& lengths) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridRows, lengths); }
     1247
     1248    void setGridItemColumn(const Length& columnPosition) { SET_VAR(rareNonInheritedData.access()->m_gridItem, m_gridColumn, columnPosition); }
     1249    void setGridItemRow(const Length& rowPosition) { SET_VAR(rareNonInheritedData.access()->m_gridItem, m_gridRow, rowPosition); }
    12431250#endif
    12441251
     
    16371644    static Vector<Length> initialGridColumns() { return initialGridTrackValue(); }
    16381645    static Vector<Length> initialGridRows() { return initialGridTrackValue(); }
     1646
     1647    // 'auto' is the default.
     1648    static Length initialGridItemColumn() { return Length(); }
     1649    static Length initialGridItemRow() { return Length(); }
    16391650#endif
    16401651
  • trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp

    r103192 r108855  
    9999#if ENABLE(CSS_GRID_LAYOUT)
    100100    , m_grid(o.m_grid)
     101    , m_gridItem(o.m_gridItem)
    101102#endif
    102103    , m_content(o.m_content ? o.m_content->clone() : nullptr)
     
    166167#if ENABLE(CSS_GRID_LAYOUT)
    167168        && m_grid == o.m_grid
     169        && m_gridItem == o.m_gridItem
    168170#endif
    169171        && contentDataEquivalent(o)
  • trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h

    r101288 r108855  
    4949#if ENABLE(CSS_GRID_LAYOUT)
    5050class StyleGridData;
     51class StyleGridItemData;
    5152#endif
    5253class StyleMarqueeData;
     
    120121#if ENABLE(CSS_GRID_LAYOUT)
    121122    DataRef<StyleGridData> m_grid;
     123    DataRef<StyleGridItemData> m_gridItem;
    122124#endif
    123125
Note: See TracChangeset for help on using the changeset viewer.