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

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

Issue 358673003: [CSS Grid Layout] Avoid inserting grid items twice in the grid (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing Created 6 years, 5 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-before-anonymous-child-crash-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 a1de68202177f4dafa8c7e86d0569ead6c56f4df..1714fcc4a2846d7870b0a9755d8c2207cc881de9 100644
--- a/Source/core/rendering/RenderGrid.cpp
+++ b/Source/core/rendering/RenderGrid.cpp
@@ -202,6 +202,14 @@ RenderGrid::~RenderGrid()
void RenderGrid::addChild(RenderObject* newChild, RenderObject* beforeChild)
{
+ // If the new requested beforeChild is not one of our children is because it's wrapped by an anonymous container. If
+ // we do not special case this situation we could end up calling addChild() twice for the newChild, one with the
+ // initial beforeChild and another one with its parent.
+ if (beforeChild && beforeChild->parent() != this) {
+ ASSERT(beforeChild->parent()->isAnonymous());
+ beforeChild = splitAnonymousBoxesAroundChild(beforeChild);
+ }
+
RenderBlock::addChild(newChild, beforeChild);
if (gridIsDirty())
@@ -776,6 +784,7 @@ void RenderGrid::insertItemIntoGrid(RenderBox* child, const GridCoordinate& coor
m_grid[row.toInt()][column.toInt()].append(child);
}
+ RELEASE_ASSERT(!m_gridItemCoordinate.contains(child));
m_gridItemCoordinate.set(child, coordinate);
}
« no previous file with comments | « LayoutTests/fast/css-grid-layout/grid-item-before-anonymous-child-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698