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

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

Issue 211053002: [CSS Grid Layout] Avoid mark grid as dirty always when removing a child (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing 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 | « no previous file | 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 fce09911d7c73dce2f2a867a7c8c1123b7a63e20..26330c4e13b44dd9cf3b7f21e4b348ce8788b5aa 100644
--- a/Source/core/rendering/RenderGrid.cpp
+++ b/Source/core/rendering/RenderGrid.cpp
@@ -223,8 +223,22 @@ void RenderGrid::removeChild(RenderObject* child)
return;
ASSERT(child->isBox());
- // FIXME: We could avoid dirtying the grid in some cases (e.g. if it's an explicitly positioned element).
- dirtyGrid();
+
+ if (style()->gridAutoFlow() != AutoFlowNone) {
+ // The grid needs to be recomputed as it might contain auto-placed items that will change their position.
+ dirtyGrid();
+ return;
+ }
+
+ const RenderBox* childBox = toRenderBox(child);
+ GridCoordinate coordinate = m_gridItemCoordinate.take(childBox);
+
+ for (size_t row = coordinate.rows.initialPositionIndex; row <= coordinate.rows.finalPositionIndex; ++row) {
+ for (size_t column = coordinate.columns.initialPositionIndex; column <= coordinate.columns.finalPositionIndex; ++column) {
+ GridCell& cell = m_grid[row][column];
+ cell.remove(cell.find(childBox));
+ }
+ }
}
void RenderGrid::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698