Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5355)

Unified Diff: Source/core/rendering/RenderGrid.cpp

Issue 198703004: [CSS Grid Layout] Fix issues adding new items to grid (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@enable-css-grid-layout
Patch Set: Simplify code of addChild() Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/css-grid-layout/grid-item-addition-auto-placement-update-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « LayoutTests/fast/css-grid-layout/grid-item-addition-auto-placement-update-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698