| Index: Source/core/rendering/style/GridResolvedPosition.cpp
|
| diff --git a/Source/core/rendering/style/GridResolvedPosition.cpp b/Source/core/rendering/style/GridResolvedPosition.cpp
|
| index 7249b15e739b0e8d7dac18dabeae7a6dd85219bb..0cf77ffff98477596e47980f92a5c41e668fb05c 100644
|
| --- a/Source/core/rendering/style/GridResolvedPosition.cpp
|
| +++ b/Source/core/rendering/style/GridResolvedPosition.cpp
|
| @@ -80,11 +80,16 @@ size_t GridResolvedPosition::explicitGridSizeForSide(const RenderStyle& gridCont
|
| return (side == ColumnStartSide || side == ColumnEndSide) ? explicitGridColumnCount(gridContainerStyle) : explicitGridRowCount(gridContainerStyle);
|
| }
|
|
|
| +static const NamedGridLinesMap& gridLinesForSide(const RenderStyle& style, GridPositionSide side)
|
| +{
|
| + return (side == ColumnStartSide || side == ColumnEndSide) ? style.namedGridColumnLines() : style.namedGridRowLines();
|
| +}
|
| +
|
| GridResolvedPosition GridResolvedPosition::resolveNamedGridLinePositionFromStyle(const RenderStyle& gridContainerStyle, const GridPosition& position, GridPositionSide side)
|
| {
|
| ASSERT(!position.namedGridLine().isNull());
|
|
|
| - const NamedGridLinesMap& gridLinesNames = (side == ColumnStartSide || side == ColumnEndSide) ? gridContainerStyle.namedGridColumnLines() : gridContainerStyle.namedGridRowLines();
|
| + const NamedGridLinesMap& gridLinesNames = gridLinesForSide(gridContainerStyle, side);
|
| NamedGridLinesMap::const_iterator it = gridLinesNames.find(position.namedGridLine());
|
| if (it == gridLinesNames.end()) {
|
| if (position.isPositive())
|
| @@ -125,21 +130,24 @@ GridResolvedPosition GridResolvedPosition::resolveGridPositionFromStyle(const Re
|
| }
|
| case NamedGridAreaPosition:
|
| {
|
| - NamedGridAreaMap::const_iterator it = gridContainerStyle.namedGridArea().find(position.namedGridLine());
|
| - // Unknown grid area should have been computed to 'auto' by now.
|
| - ASSERT_WITH_SECURITY_IMPLICATION(it != gridContainerStyle.namedGridArea().end());
|
| - const GridCoordinate& gridAreaCoordinate = it->value;
|
| - switch (side) {
|
| - case ColumnStartSide:
|
| - return gridAreaCoordinate.columns.resolvedInitialPosition;
|
| - case ColumnEndSide:
|
| - return gridAreaCoordinate.columns.resolvedFinalPosition;
|
| - case RowStartSide:
|
| - return gridAreaCoordinate.rows.resolvedInitialPosition;
|
| - case RowEndSide:
|
| - return GridResolvedPosition(gridAreaCoordinate.rows.resolvedFinalPosition);
|
| - }
|
| - ASSERT_NOT_REACHED();
|
| + // First attempt to match the grid area’s edge to a named grid area: if there is a named line with the name
|
| + // ''<custom-ident>-start (for grid-*-start) / <custom-ident>-end'' (for grid-*-end), contributes the first such
|
| + // line to the grid item’s placement.
|
| + String namedGridLine = position.namedGridLine();
|
| + String implicitNamedGridLine = namedGridLine + ((side == ColumnStartSide || side == RowStartSide) ? "-start" : "-end");
|
| + const NamedGridLinesMap& gridLineNames = gridLinesForSide(gridContainerStyle, side);
|
| + NamedGridLinesMap::const_iterator implicitLineIter = gridLineNames.find(implicitNamedGridLine);
|
| + if (implicitLineIter != gridLineNames.end())
|
| + return adjustGridPositionForSide(implicitLineIter->value[0], side);
|
| +
|
| + // Otherwise, if there is a named line with the specified name, contributes the first such line to the grid
|
| + // item’s placement.
|
| + NamedGridLinesMap::const_iterator explicitLineIter = gridLineNames.find(namedGridLine);
|
| + if (explicitLineIter != gridLineNames.end())
|
| + return adjustGridPositionForSide(explicitLineIter->value[0], side);
|
| +
|
| + // FIXME: if none of the above works specs mandate us to treat it as auto. We cannot return auto right here
|
| + // right now because callers expect a resolved position. We need deeper changes to support this use case.
|
| return GridResolvedPosition(0);
|
| }
|
| case AutoPosition:
|
| @@ -175,7 +183,7 @@ PassOwnPtr<GridSpan> GridResolvedPosition::resolveNamedGridLinePositionAgainstOp
|
| // Negative positions are not allowed per the specification and should have been handled during parsing.
|
| ASSERT(position.spanPosition() > 0);
|
|
|
| - const NamedGridLinesMap& gridLinesNames = (side == ColumnStartSide || side == ColumnEndSide) ? gridContainerStyle.namedGridColumnLines() : gridContainerStyle.namedGridRowLines();
|
| + const NamedGridLinesMap& gridLinesNames = gridLinesForSide(gridContainerStyle, side);
|
| NamedGridLinesMap::const_iterator it = gridLinesNames.find(position.namedGridLine());
|
|
|
| // If there is no named grid line of that name, we resolve the position to 'auto' (which is equivalent to 'span 1' in this case).
|
|
|