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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 RenderBlock::addChild(newChild, beforeChild); 184 RenderBlock::addChild(newChild, beforeChild);
185 185
186 if (gridIsDirty()) 186 if (gridIsDirty())
187 return; 187 return;
188 188
189 if (!newChild->isBox()) { 189 if (!newChild->isBox()) {
190 dirtyGrid(); 190 dirtyGrid();
191 return; 191 return;
192 } 192 }
193 193
194 if (style()->gridAutoFlow() != AutoFlowNone) {
195 // The grid needs to be recomputed as it might contain auto-placed items that will change their position.
196 dirtyGrid();
197 return;
198 }
199
194 RenderBox* newChildBox = toRenderBox(newChild); 200 RenderBox* newChildBox = toRenderBox(newChild);
195 OwnPtr<GridSpan> rowPositions = resolveGridPositionsFromStyle(newChildBox, F orRows); 201 OwnPtr<GridSpan> rowPositions = resolveGridPositionsFromStyle(newChildBox, F orRows);
196 OwnPtr<GridSpan> columnPositions = resolveGridPositionsFromStyle(newChildBox , ForColumns); 202 OwnPtr<GridSpan> columnPositions = resolveGridPositionsFromStyle(newChildBox , ForColumns);
197 if (!rowPositions || !columnPositions) { 203 if (!rowPositions || !columnPositions) {
198 // The new child requires the auto-placement algorithm to run so we need to recompute the grid fully. 204 // The new child requires the auto-placement algorithm to run so we need to recompute the grid fully.
199 dirtyGrid(); 205 dirtyGrid();
200 } else { 206 return;
Julien - ping for review 2014/03/21 04:10:35 Not sure what the return brings us here as it real
201 if (gridRowCount() <= rowPositions->finalPositionIndex || gridColumnCoun t() <= columnPositions->finalPositionIndex) {
202 // FIXME: We could just insert the new child provided we had a primi tive to arbitrarily grow the grid.
203 dirtyGrid();
204 } else {
205 insertItemIntoGrid(newChildBox, GridCoordinate(*rowPositions, *colum nPositions));
206 }
207 } 207 }
208
209 // Grow grid if required.
210 for (size_t i = gridRowCount(); i <= rowPositions->finalPositionIndex; i++)
211 growGrid(ForRows);
212 for (size_t i = gridColumnCount(); i <= columnPositions->finalPositionIndex; i++)
213 growGrid(ForColumns);
Julien - ping for review 2014/03/21 04:10:35 I have been thinking that we need a way to grow th
214
215 insertItemIntoGrid(newChildBox, GridCoordinate(*rowPositions, *columnPositio ns));
208 } 216 }
209 217
210 void RenderGrid::removeChild(RenderObject* child) 218 void RenderGrid::removeChild(RenderObject* child)
211 { 219 {
212 RenderBlock::removeChild(child); 220 RenderBlock::removeChild(child);
213 221
214 if (gridIsDirty()) 222 if (gridIsDirty())
215 return; 223 return;
216 224
217 ASSERT(child->isBox()); 225 ASSERT(child->isBox());
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 if (isOutOfFlowPositioned()) 1390 if (isOutOfFlowPositioned())
1383 return "RenderGrid (positioned)"; 1391 return "RenderGrid (positioned)";
1384 if (isAnonymous()) 1392 if (isAnonymous())
1385 return "RenderGrid (generated)"; 1393 return "RenderGrid (generated)";
1386 if (isRelPositioned()) 1394 if (isRelPositioned())
1387 return "RenderGrid (relative positioned)"; 1395 return "RenderGrid (relative positioned)";
1388 return "RenderGrid"; 1396 return "RenderGrid";
1389 } 1397 }
1390 1398
1391 } // namespace WebCore 1399 } // namespace WebCore
OLDNEW
« 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