Index: Source/core/rendering/RenderGrid.cpp |
diff --git a/Source/core/rendering/RenderGrid.cpp b/Source/core/rendering/RenderGrid.cpp |
index 351881084b582f24de06651ade28f7fd5595239d..96f1dde74f08210cebf0afbf4bb3bf694d5c36eb 100644 |
--- a/Source/core/rendering/RenderGrid.cpp |
+++ b/Source/core/rendering/RenderGrid.cpp |
@@ -191,20 +191,28 @@ void RenderGrid::addChild(RenderObject* newChild, RenderObject* beforeChild) |
return; |
} |
+ if (style()->gridAutoFlow() != AutoFlowNone) { |
+ // The grid needs to be recomputed as it might contain auto-placed items that will change their position. |
+ dirtyGrid(); |
+ return; |
+ } |
+ |
RenderBox* newChildBox = toRenderBox(newChild); |
OwnPtr<GridSpan> rowPositions = resolveGridPositionsFromStyle(newChildBox, ForRows); |
OwnPtr<GridSpan> columnPositions = resolveGridPositionsFromStyle(newChildBox, ForColumns); |
if (!rowPositions || !columnPositions) { |
// 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) { |
- // FIXME: We could just insert the new child provided we had a primitive to arbitrarily grow the grid. |
- dirtyGrid(); |
- } else { |
- insertItemIntoGrid(newChildBox, GridCoordinate(*rowPositions, *columnPositions)); |
- } |
+ return; |
Julien - ping for review
2014/03/21 04:10:35
Not sure what the return brings us here as it real
|
} |
+ |
+ // Grow grid if required. |
+ for (size_t i = gridRowCount(); i <= rowPositions->finalPositionIndex; i++) |
+ growGrid(ForRows); |
+ for (size_t i = gridColumnCount(); i <= columnPositions->finalPositionIndex; i++) |
+ growGrid(ForColumns); |
Julien - ping for review
2014/03/21 04:10:35
I have been thinking that we need a way to grow th
|
+ |
+ insertItemIntoGrid(newChildBox, GridCoordinate(*rowPositions, *columnPositions)); |
} |
void RenderGrid::removeChild(RenderObject* child) |