Index: Source/core/rendering/RenderGrid.cpp |
diff --git a/Source/core/rendering/RenderGrid.cpp b/Source/core/rendering/RenderGrid.cpp |
index 43f3a7013874d2c8cf75cbc9a28ab06503d80c9d..33a32181a69a10335356b5a3bd52cd009bc34856 100644 |
--- a/Source/core/rendering/RenderGrid.cpp |
+++ b/Source/core/rendering/RenderGrid.cpp |
@@ -197,7 +197,7 @@ void RenderGrid::addChild(RenderObject* newChild, RenderObject* beforeChild) |
// The new child requires the auto-placement algorithm to run so we need to recompute the grid fully. |
dirtyGrid(); |
} else { |
- if (gridRowCount() <= rowPositions->finalPositionIndex || gridColumnCount() <= columnPositions->finalPositionIndex) { |
+ if (gridRowCount() <= rowPositions->finalPositionIndex.integerPosition() || gridColumnCount() <= columnPositions->finalPositionIndex.integerPosition()) { |
// FIXME: We could just insert the new child provided we had a primitive to arbitrarily grow the grid. |
dirtyGrid(); |
} else { |
@@ -680,8 +680,8 @@ void RenderGrid::growGrid(GridTrackSizingDirection direction) |
void RenderGrid::insertItemIntoGrid(RenderBox* child, const GridCoordinate& coordinate) |
{ |
- for (size_t row = coordinate.rows.initialPositionIndex; row <= coordinate.rows.finalPositionIndex; ++row) { |
- for (size_t column = coordinate.columns.initialPositionIndex; column <= coordinate.columns.finalPositionIndex; ++column) |
+ for (size_t row = coordinate.rows.initialPositionIndex; row <= coordinate.rows.finalPositionIndex.integerPosition(); ++row) { |
+ for (size_t column = coordinate.columns.initialPositionIndex; column <= coordinate.columns.finalPositionIndex.integerPosition(); ++column) |
m_grid[row][column].append(child); |
} |
@@ -760,9 +760,9 @@ void RenderGrid::populateExplicitGridAndOrderIterator() |
// |positions| is 0 if we need to run the auto-placement algorithm. Our estimation ignores |
// this case as the auto-placement algorithm will grow the grid as needed. |
if (rowPositions) |
- maximumRowIndex = std::max(maximumRowIndex, rowPositions->finalPositionIndex + 1); |
+ maximumRowIndex = std::max(maximumRowIndex, rowPositions->finalPositionIndex.integerPosition() + 1); |
if (columnPositions) |
- maximumColumnIndex = std::max(maximumColumnIndex, columnPositions->finalPositionIndex + 1); |
+ maximumColumnIndex = std::max(maximumColumnIndex, columnPositions->finalPositionIndex.integerPosition() + 1); |
} |
m_grid.grow(maximumRowIndex); |
@@ -933,27 +933,27 @@ PassOwnPtr<GridSpan> RenderGrid::resolveGridPositionsFromStyle(const RenderBox* |
if (initialPosition.shouldBeResolvedAgainstOppositePosition()) { |
// Infer the position from the final position ('auto / 1' or 'span 2 / 3' case). |
- const size_t finalResolvedPosition = resolveGridPositionFromStyle(finalPosition, finalPositionSide); |
+ GridResolvedPosition finalResolvedPosition = resolveGridPositionFromStyle(finalPosition, finalPositionSide); |
return resolveGridPositionAgainstOppositePosition(finalResolvedPosition, initialPosition, initialPositionSide); |
} |
if (finalPosition.shouldBeResolvedAgainstOppositePosition()) { |
// Infer our position from the initial position ('1 / auto' or '3 / span 2' case). |
- const size_t initialResolvedPosition = resolveGridPositionFromStyle(initialPosition, initialPositionSide); |
+ GridResolvedPosition initialResolvedPosition = resolveGridPositionFromStyle(initialPosition, initialPositionSide); |
return resolveGridPositionAgainstOppositePosition(initialResolvedPosition, finalPosition, finalPositionSide); |
} |
- size_t resolvedInitialPosition = resolveGridPositionFromStyle(initialPosition, initialPositionSide); |
- size_t resolvedFinalPosition = resolveGridPositionFromStyle(finalPosition, finalPositionSide); |
+ GridResolvedPosition resolvedInitialPosition = resolveGridPositionFromStyle(initialPosition, initialPositionSide); |
+ GridResolvedPosition resolvedFinalPosition = resolveGridPositionFromStyle(finalPosition, finalPositionSide); |
// If 'grid-after' specifies a line at or before that specified by 'grid-before', it computes to 'span 1'. |
if (resolvedFinalPosition < resolvedInitialPosition) |
- resolvedFinalPosition = resolvedInitialPosition; |
+ resolvedFinalPosition.setIntegerPosition(resolvedInitialPosition.integerPosition()); |
- return adoptPtr(new GridSpan(resolvedInitialPosition, resolvedFinalPosition)); |
+ return adoptPtr(new GridSpan(resolvedInitialPosition.integerPosition(), resolvedFinalPosition.integerPosition())); |
} |
-size_t RenderGrid::resolveNamedGridLinePositionFromStyle(const GridPosition& position, GridPositionSide side) const |
+GridResolvedPosition RenderGrid::resolveNamedGridLinePositionFromStyle(const GridPosition& position, GridPositionSide side) const |
{ |
ASSERT(!position.namedGridLine().isNull()); |
@@ -961,9 +961,9 @@ size_t RenderGrid::resolveNamedGridLinePositionFromStyle(const GridPosition& pos |
NamedGridLinesMap::const_iterator it = gridLinesNames.find(position.namedGridLine()); |
if (it == gridLinesNames.end()) { |
if (position.isPositive()) |
- return 0; |
+ return GridResolvedPosition(); |
const size_t lastLine = explicitGridSizeForSide(side); |
- return GridPosition::adjustGridPositionForSide(lastLine, side); |
+ return GridResolvedPosition::adjustGridPositionForSide(lastLine, side); |
} |
size_t namedGridLineIndex; |
@@ -971,10 +971,10 @@ size_t RenderGrid::resolveNamedGridLinePositionFromStyle(const GridPosition& pos |
namedGridLineIndex = std::min<size_t>(position.integerPosition(), it->value.size()) - 1; |
else |
namedGridLineIndex = std::max<int>(it->value.size() - abs(position.integerPosition()), 0); |
- return GridPosition::adjustGridPositionForSide(it->value[namedGridLineIndex], side); |
+ return GridResolvedPosition::adjustGridPositionForSide(it->value[namedGridLineIndex], side); |
} |
-size_t RenderGrid::resolveGridPositionFromStyle(const GridPosition& position, GridPositionSide side) const |
+GridResolvedPosition RenderGrid::resolveGridPositionFromStyle(const GridPosition& position, GridPositionSide side) const |
{ |
switch (position.type()) { |
case ExplicitPosition: { |
@@ -985,16 +985,16 @@ size_t RenderGrid::resolveGridPositionFromStyle(const GridPosition& position, Gr |
// Handle <integer> explicit position. |
if (position.isPositive()) |
- return GridPosition::adjustGridPositionForSide(position.integerPosition() - 1, side); |
+ return GridResolvedPosition::adjustGridPositionForSide(position.integerPosition() - 1, side); |
size_t resolvedPosition = abs(position.integerPosition()) - 1; |
const size_t endOfTrack = explicitGridSizeForSide(side); |
// Per http://lists.w3.org/Archives/Public/www-style/2013Mar/0589.html, we clamp negative value to the first line. |
if (endOfTrack < resolvedPosition) |
- return 0; |
+ return GridResolvedPosition(); |
- return GridPosition::adjustGridPositionForSide(endOfTrack - resolvedPosition, side); |
+ return GridResolvedPosition::adjustGridPositionForSide(endOfTrack - resolvedPosition, side); |
} |
case NamedGridAreaPosition: |
{ |
@@ -1004,28 +1004,28 @@ size_t RenderGrid::resolveGridPositionFromStyle(const GridPosition& position, Gr |
const GridCoordinate& gridAreaCoordinate = it->value; |
switch (side) { |
case ColumnStartSide: |
- return gridAreaCoordinate.columns.initialPositionIndex; |
+ return GridResolvedPosition(gridAreaCoordinate.columns.initialPositionIndex); |
case ColumnEndSide: |
- return gridAreaCoordinate.columns.finalPositionIndex; |
+ return GridResolvedPosition(gridAreaCoordinate.columns.finalPositionIndex); |
case RowStartSide: |
- return gridAreaCoordinate.rows.initialPositionIndex; |
+ return GridResolvedPosition(gridAreaCoordinate.rows.initialPositionIndex); |
case RowEndSide: |
- return gridAreaCoordinate.rows.finalPositionIndex; |
+ return GridResolvedPosition(gridAreaCoordinate.rows.finalPositionIndex); |
} |
ASSERT_NOT_REACHED(); |
- return 0; |
+ return GridResolvedPosition(); |
} |
case AutoPosition: |
case SpanPosition: |
// 'auto' and span depend on the opposite position for resolution (e.g. grid-row: auto / 1 or grid-column: span 3 / "myHeader"). |
ASSERT_NOT_REACHED(); |
- return 0; |
+ return GridResolvedPosition(); |
} |
ASSERT_NOT_REACHED(); |
- return 0; |
+ return GridResolvedPosition(); |
} |
-PassOwnPtr<GridSpan> RenderGrid::resolveGridPositionAgainstOppositePosition(size_t resolvedOppositePosition, const GridPosition& position, GridPositionSide side) const |
+PassOwnPtr<GridSpan> RenderGrid::resolveGridPositionAgainstOppositePosition(const GridResolvedPosition& resolvedOppositePosition, const GridPosition& position, GridPositionSide side) const |
{ |
if (position.isAuto()) |
return GridSpan::create(resolvedOppositePosition, resolvedOppositePosition); |
@@ -1041,7 +1041,7 @@ PassOwnPtr<GridSpan> RenderGrid::resolveGridPositionAgainstOppositePosition(size |
return GridSpan::createWithSpanAgainstOpposite(resolvedOppositePosition, position, side); |
} |
-PassOwnPtr<GridSpan> RenderGrid::resolveNamedGridLinePositionAgainstOppositePosition(size_t resolvedOppositePosition, const GridPosition& position, GridPositionSide side) const |
+PassOwnPtr<GridSpan> RenderGrid::resolveNamedGridLinePositionAgainstOppositePosition(const GridResolvedPosition& resolvedOppositePosition, const GridPosition& position, GridPositionSide side) const |
{ |
ASSERT(position.isSpan()); |
ASSERT(!position.namedGridLine().isNull()); |
@@ -1064,7 +1064,7 @@ LayoutUnit RenderGrid::gridAreaBreadthForChild(const RenderBox* child, GridTrack |
const GridCoordinate& coordinate = cachedGridCoordinate(child); |
const GridSpan& span = (direction == ForColumns) ? coordinate.columns : coordinate.rows; |
LayoutUnit gridAreaBreadth = 0; |
- for (size_t trackIndex = span.initialPositionIndex; trackIndex <= span.finalPositionIndex; ++trackIndex) |
+ for (size_t trackIndex = span.initialPositionIndex; trackIndex <= span.finalPositionIndex.integerPosition(); ++trackIndex) |
gridAreaBreadth += tracks[trackIndex].m_usedBreadth; |
return gridAreaBreadth; |
} |
@@ -1130,8 +1130,8 @@ void RenderGrid::paintChildren(PaintInfo& paintInfo, const LayoutPoint& paintOff |
{ |
OrderIteratorPopulator populator(paintIterator); |
- for (size_t row = dirtiedRows.initialPositionIndex; row < dirtiedRows.finalPositionIndex; ++row) { |
- for (size_t column = dirtiedColumns.initialPositionIndex; column < dirtiedColumns.finalPositionIndex; ++column) { |
+ for (size_t row = dirtiedRows.initialPositionIndex; row < dirtiedRows.finalPositionIndex.integerPosition(); ++row) { |
+ for (size_t column = dirtiedColumns.initialPositionIndex; column < dirtiedColumns.finalPositionIndex.integerPosition(); ++column) { |
const Vector<RenderBox*, 1>& children = m_grid[row][column]; |
// FIXME: If we start adding spanning children in all grid areas they span, this |
// would make us paint them several times, which is wrong! |