Ignore:
Timestamp:
Oct 10, 2013, 1:38:57 AM (12 years ago)
Author:
[email protected]
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 <[email protected]>

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 <[email protected]>

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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.
Note: See TracChangeset for help on using the changeset viewer.