ASSERTION FAILED: !gridWasPopulated() in WebCore::RenderGrid::placeItemsOnGrid
authorrego@igalia.com <rego@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Oct 2014 12:11:29 +0000 (12:11 +0000)
committerrego@igalia.com <rego@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Oct 2014 12:11:29 +0000 (12:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=136939

Reviewed by Darin Adler.

Source/WebCore:

In some particular situations computeIntrinsicLogicalWidths() is called
in the middle of layoutGridItems(). In these cases we do not need to
populate the grid again, so we should avoid calling placeItemsOnGrid().
In addition, we do not need to clean the grid either, as that will be
done later by layoutGridItems().

Test: fast/css-grid-layout/grid-was-populated-assert.html

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::computeIntrinsicLogicalWidths): Avoid calls to
placeItemsOnGrid() and clearGrid() if the grid was already populated.
* rendering/RenderGrid.h: Move gridWasPopulated() header out of the
debug ifdefs.

LayoutTests:

Added a test case to reproduce the crash in debug mode.

* fast/css-grid-layout/grid-was-populated-assert-expected.txt: Added.
* fast/css-grid-layout/grid-was-populated-assert.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174946 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/css-grid-layout/grid-was-populated-assert-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-was-populated-assert.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderGrid.cpp
Source/WebCore/rendering/RenderGrid.h

index 6126485..740008b 100644 (file)
@@ -1,3 +1,15 @@
+2014-10-21  Manuel Rego Casasnovas  <rego@igalia.com>
+
+        ASSERTION FAILED: !gridWasPopulated() in WebCore::RenderGrid::placeItemsOnGrid
+        https://bugs.webkit.org/show_bug.cgi?id=136939
+
+        Reviewed by Darin Adler.
+
+        Added a test case to reproduce the crash in debug mode.
+
+        * fast/css-grid-layout/grid-was-populated-assert-expected.txt: Added.
+        * fast/css-grid-layout/grid-was-populated-assert.html: Added.
+
 2014-10-17  Jeffrey Pfau  <jpfau@apple.com>
 
         Ensure attached frame count doesn't exceed the maximum allowed frames
diff --git a/LayoutTests/fast/css-grid-layout/grid-was-populated-assert-expected.txt b/LayoutTests/fast/css-grid-layout/grid-was-populated-assert-expected.txt
new file mode 100644 (file)
index 0000000..6daff1f
--- /dev/null
@@ -0,0 +1,4 @@
+This test passes if it does not crash in debug mode.
+
+
+
diff --git a/LayoutTests/fast/css-grid-layout/grid-was-populated-assert.html b/LayoutTests/fast/css-grid-layout/grid-was-populated-assert.html
new file mode 100644 (file)
index 0000000..8906ed6
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script>
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+    }
+    </script>
+    <style>
+    details {
+        display: -webkit-grid;
+        -webkit-columns: 5;
+    }
+    div {
+        display: -webkit-grid;
+    }
+    input {
+        -webkit-columns: 5;
+    }
+    </style>
+</head>
+<body>
+    <p>This test passes if it does not crash in debug mode.</p>
+    <details open>
+        <button>
+            <div>
+                <input placeholder="testing" />
+            </div>
+        </button>
+    </details>
+</body>
+</html>
index 516548e..276a54b 100644 (file)
@@ -1,3 +1,24 @@
+2014-10-21  Manuel Rego Casasnovas  <rego@igalia.com>
+
+        ASSERTION FAILED: !gridWasPopulated() in WebCore::RenderGrid::placeItemsOnGrid
+        https://bugs.webkit.org/show_bug.cgi?id=136939
+
+        Reviewed by Darin Adler.
+
+        In some particular situations computeIntrinsicLogicalWidths() is called
+        in the middle of layoutGridItems(). In these cases we do not need to
+        populate the grid again, so we should avoid calling placeItemsOnGrid().
+        In addition, we do not need to clean the grid either, as that will be
+        done later by layoutGridItems().
+
+        Test: fast/css-grid-layout/grid-was-populated-assert.html
+
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::computeIntrinsicLogicalWidths): Avoid calls to
+        placeItemsOnGrid() and clearGrid() if the grid was already populated.
+        * rendering/RenderGrid.h: Move gridWasPopulated() header out of the
+        debug ifdefs.
+
 2014-10-21  Zan Dobersek  <zdobersek@igalia.com>
 
         [Cairo] Make dashPattern, dotPattern in GraphicsContext::setPlatformStrokeStyle() const
index 30bb54f..49bfc3e 100644 (file)
@@ -242,7 +242,9 @@ void RenderGrid::layoutBlock(bool relayoutChildren, LayoutUnit)
 
 void RenderGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
 {
-    const_cast<RenderGrid*>(this)->placeItemsOnGrid();
+    bool wasPopulated = gridWasPopulated();
+    if (!wasPopulated)
+        const_cast<RenderGrid*>(this)->placeItemsOnGrid();
 
     GridSizingData sizingData(gridColumnCount(), gridRowCount());
     LayoutUnit availableLogicalSpace = 0;
@@ -259,7 +261,8 @@ void RenderGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo
         // FIXME: This should add in the scrollbarWidth (e.g. see RenderFlexibleBox).
     }
 
-    const_cast<RenderGrid*>(this)->clearGrid();
+    if (!wasPopulated)
+        const_cast<RenderGrid*>(this)->clearGrid();
 }
 
 void RenderGrid::computePreferredLogicalWidths()
index 75de9b8..cf1c730 100644 (file)
@@ -110,9 +110,10 @@ private:
 
 #ifndef NDEBUG
     bool tracksAreWiderThanMinTrackBreadth(GridTrackSizingDirection, const Vector<GridTrack>&);
-    bool gridWasPopulated() const { return !m_grid.isEmpty() && !m_grid[0].isEmpty(); }
 #endif
 
+    bool gridWasPopulated() const { return !m_grid.isEmpty() && !m_grid[0].isEmpty(); }
+
     size_t gridColumnCount() const
     {
         ASSERT(gridWasPopulated());