Title: [205114] trunk
Revision
205114
Author
svil...@igalia.com
Date
2016-08-29 01:50:13 -0700 (Mon, 29 Aug 2016)

Log Message

[css-grid] Do not recursively call layout during auto repeat computation
https://bugs.webkit.org/show_bug.cgi?id=161234

Reviewed by Manuel Rego Casasnovas.

Source/WebCore:

The computation of auto repeat tracks was incorrectly recursively triggering
a layout in order to compute the available size. That was happening whenever
the width was indefinite. In such cases we should treat the width always as
indefinite without having to run any extra code. During the layout phase
we'll have the actual width available.

This fix also unveiled a few errors in one of the imported mozilla tests which were
incorrectly passing when they should not.

Test: fast/css-grid-layout/grid-indefinite-size-auto-repeat-crash.html

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::layoutBlock):
(WebCore::RenderGrid::computeIntrinsicLogicalWidths):
(WebCore::RenderGrid::computeAutoRepeatTracksCount):
(WebCore::RenderGrid::placeItemsOnGrid):
* rendering/RenderGrid.h:

LayoutTests:

Added a new test case and fixed a few tests inside the imported
grid-repeat-auto-fill-fit-001.html which were wrong due to a bug in Firefox. The intrinsic
size computation was not considering the existence of definite minimum sizes for some of the
grids so the outcome was narrower than expected.

* fast/css-grid-layout/grid-indefinite-size-auto-repeat-crash-expected.txt: Added.
* fast/css-grid-layout/grid-indefinite-size-auto-repeat-crash.html: Added.
* fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-001-expected.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (205113 => 205114)


--- trunk/LayoutTests/ChangeLog	2016-08-29 08:06:28 UTC (rev 205113)
+++ trunk/LayoutTests/ChangeLog	2016-08-29 08:50:13 UTC (rev 205114)
@@ -1,3 +1,19 @@
+2016-08-26  Sergio Villar Senin  <svil...@igalia.com>
+
+        [css-grid] Do not recursively call layout during auto repeat computation
+        https://bugs.webkit.org/show_bug.cgi?id=161234
+
+        Reviewed by Manuel Rego Casasnovas.
+
+        Added a new test case and fixed a few tests inside the imported
+        grid-repeat-auto-fill-fit-001.html which were wrong due to a bug in Firefox. The intrinsic
+        size computation was not considering the existence of definite minimum sizes for some of the
+        grids so the outcome was narrower than expected.
+
+        * fast/css-grid-layout/grid-indefinite-size-auto-repeat-crash-expected.txt: Added.
+        * fast/css-grid-layout/grid-indefinite-size-auto-repeat-crash.html: Added.
+        * fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-001-expected.html:
+
 2016-08-25  Frederic Wang  <fw...@igalia.com>
 
         Add support for non-BMP operators U+1EEF0 and U+1EEF1

Added: trunk/LayoutTests/fast/css-grid-layout/grid-indefinite-size-auto-repeat-crash-expected.txt (0 => 205114)


--- trunk/LayoutTests/fast/css-grid-layout/grid-indefinite-size-auto-repeat-crash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-indefinite-size-auto-repeat-crash-expected.txt	2016-08-29 08:50:13 UTC (rev 205114)
@@ -0,0 +1,13 @@
+item
+item
+item
+item
+item
+item
+item
+item
+item
+item
+This test checks that the computation of auto repeat tracks works when the grid container width is indefinite.
+
+This test has PASSED if it didn't CRASH.
Property changes on: trunk/LayoutTests/fast/css-grid-layout/grid-indefinite-size-auto-repeat-crash-expected.txt
___________________________________________________________________

Added: svn:eol-style

+LF \ No newline at end of property

Added: trunk/LayoutTests/fast/css-grid-layout/grid-indefinite-size-auto-repeat-crash.html (0 => 205114)


--- trunk/LayoutTests/fast/css-grid-layout/grid-indefinite-size-auto-repeat-crash.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/grid-indefinite-size-auto-repeat-crash.html	2016-08-29 08:50:13 UTC (rev 205114)
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML>
+<link href="" rel="stylesheet">
+<link href="" rel=stylesheet>
+<link href="" rel=stylesheet>
+<style>
+.autoFill { grid: repeat(auto-fill, 100px) / repeat(auto-fill, 100px); }
+.autoFit { grid: repeat(auto-fit, 100px) / repeat(auto-fit, 100px); }
+</style>
+
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+</script>
+
+<div class="grid autoFill"></div>
+<div class="grid autoFit"></div>
+
+<div class="grid autoFill min-content"></div>
+<div class="grid autoFit min-content"></div>
+
+<div class="grid autoFill max-content"></div>
+<div class="grid autoFit max-content"></div>
+
+<div class="grid autoFill min-width-min-content min-height-min-content"></div>
+<div class="grid autoFit min-width-min-content min-height-min-content"></div>
+
+<div class="grid autoFill min-width-max-content min-height-max-content"></div>
+<div class="grid autoFit min-width-max-content min-height-max-content"></div>
+
+<div class="grid autoFill">item</div>
+<div class="grid autoFit">item</div>
+
+<div class="grid autoFill min-content">item</div>
+<div class="grid autoFit min-content">item</div>
+
+<div class="grid autoFill max-content">item</div>
+<div class="grid autoFit max-content">item</div>
+
+<div class="grid autoFill min-width-min-content min-height-min-content">item</div>
+<div class="grid autoFit min-width-min-content min-height-min-content">item</div>
+
+<div class="grid autoFill min-width-max-content min-height-max-content">item</div>
+<div class="grid autoFit min-width-max-content min-height-max-content">item</div>
+
+<p>This test checks that the computation of auto repeat tracks works when the grid container width is indefinite.</p>
+<p>This test has PASSED if it didn't CRASH.</p>
Property changes on: trunk/LayoutTests/fast/css-grid-layout/grid-indefinite-size-auto-repeat-crash.html
___________________________________________________________________

Added: svn:eol-style

+LF \ No newline at end of property

Added: svn:mime-type

+text/html \ No newline at end of property

Modified: trunk/LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-001-expected.html (205113 => 205114)


--- trunk/LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-001-expected.html	2016-08-29 08:06:28 UTC (rev 205113)
+++ trunk/LayoutTests/fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-001-expected.html	2016-08-29 08:50:13 UTC (rev 205114)
@@ -101,8 +101,8 @@
 <div class="grid r1 xw80"><x></x><x></x><a></a><b></b><x></x></div>
 <div class="grid r1 xw50 c2"><x></x><x></x><a></a><b></b><x></x></div>
 <div class="grid r1 w100 xw80"><x></x><x></x><a></a><b></b><x></x></div>
-<div class="grid r1 mw50 float c2"><x></x><x></x><a></a><b></b><x></x></div>
-<div class="grid r1 mw80 float"><x></x><x></x><a></a><b></b><x></x></div>
+<div class="grid r1 mw50 float"><x></x><x></x><a></a><b></b><x></x></div>
+<div class="grid r1 mw80 float c4"><x></x><x></x><a></a><b></b><x></x></div>
 <div class="grid r1 w100 mw50 float c4"><x></x><x></x><a></a><b></b><x></x></div>
 <div class="grid r1 mw100 w50 float c4"><x></x><x></x><a></a><b></b><x></x></div>
 
@@ -118,7 +118,7 @@
 <div class="grid r2 xw50 c1"><x></x><x></x><a></a><b></b><x></x></div>
 <div class="grid r2 w100 xw80 c2"><x></x><x></x><a></a><b></b><x></x></div>
 <div class="grid r2 mw50 float c1"><x></x><x></x><a></a><b></b><x></x></div>
-<div class="grid r2 mw80 float c2"><x></x><x></x><a></a><b></b><x></x></div>
+<div class="grid r2 mw80 float"><x></x><x></x><a></a><b></b><x></x></div>
 <div class="grid r2 w100 mw50 float"><x></x><x></x><a></a><b></b><x></x></div>
 <div class="grid r2 mw100 w50 float"><x></x><x></x><a></a><b></b><x></x></div>
 
@@ -150,7 +150,7 @@
 <div class="grid r1 xw80"><x></x><x></x><a></a><b></b><x></x></div>
 <div class="grid r1 xw50 c2"><x></x><x></x><a></a><b></b><x></x></div>
 <div class="grid r1 w100 xw80"><x></x><x></x><a></a><b></b><x></x></div>
-<div class="grid r1 mw50 float c2"><x></x><x></x><a></a><b></b><x></x></div>
+<div class="grid r1 mw50 float"><x></x><x></x><a></a><b></b><x></x></div>
 <div class="grid r1 mw80 float"><x></x><x></x><a></a><b></b><x></x></div>
 <div class="grid r1 w100 mw50 float"><x></x><x></x><a></a><b></b><x></x></div>
 <div class="grid r1 mw100 w50 float"><x></x><x></x><a></a><b></b><x></x></div>
@@ -167,7 +167,7 @@
 <div class="grid r2 xw50 c1"><x></x><x></x><a></a><b></b><x></x></div>
 <div class="grid r2 w100 xw80 c2"><x></x><x></x><a></a><b></b><x></x></div>
 <div class="grid r2 mw50 float c1"><x></x><x></x><a></a><b></b><x></x></div>
-<div class="grid r2 mw80 float c2"><x></x><x></x><a></a><b></b><x></x></div>
+<div class="grid r2 mw80 float"><x></x><x></x><a></a><b></b><x></x></div>
 <div class="grid r2 w100 mw50 float"><x></x><x></x><a></a><b></b><x></x></div>
 <div class="grid r2 mw100 w50 float"><x></x><x></x><a></a><b></b><x></x></div>
 

Modified: trunk/Source/WebCore/ChangeLog (205113 => 205114)


--- trunk/Source/WebCore/ChangeLog	2016-08-29 08:06:28 UTC (rev 205113)
+++ trunk/Source/WebCore/ChangeLog	2016-08-29 08:50:13 UTC (rev 205114)
@@ -1,3 +1,28 @@
+2016-08-26  Sergio Villar Senin  <svil...@igalia.com>
+
+        [css-grid] Do not recursively call layout during auto repeat computation
+        https://bugs.webkit.org/show_bug.cgi?id=161234
+
+        Reviewed by Manuel Rego Casasnovas.
+
+        The computation of auto repeat tracks was incorrectly recursively triggering
+        a layout in order to compute the available size. That was happening whenever
+        the width was indefinite. In such cases we should treat the width always as
+        indefinite without having to run any extra code. During the layout phase
+        we'll have the actual width available.
+
+        This fix also unveiled a few errors in one of the imported mozilla tests which were
+        incorrectly passing when they should not.
+
+        Test: fast/css-grid-layout/grid-indefinite-size-auto-repeat-crash.html
+
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::layoutBlock):
+        (WebCore::RenderGrid::computeIntrinsicLogicalWidths):
+        (WebCore::RenderGrid::computeAutoRepeatTracksCount):
+        (WebCore::RenderGrid::placeItemsOnGrid):
+        * rendering/RenderGrid.h:
+
 2016-08-29  Youenn Fablet  <you...@apple.com>
 
         data:// URL behavior of XHR does not match spec

Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (205113 => 205114)


--- trunk/Source/WebCore/rendering/RenderGrid.cpp	2016-08-29 08:06:28 UTC (rev 205113)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp	2016-08-29 08:50:13 UTC (rev 205114)
@@ -440,7 +440,7 @@
     updateLogicalWidth();
     bool logicalHeightWasIndefinite = !computeContentLogicalHeight(MainOrPreferredSize, style().logicalHeight(), Nullopt);
 
-    placeItemsOnGrid();
+    placeItemsOnGrid(TrackSizing);
 
     GridSizingData sizingData(gridColumnCount(), gridRowCount());
 
@@ -581,7 +581,7 @@
 {
     bool wasPopulated = !m_gridIsDirty;
     if (!wasPopulated)
-        const_cast<RenderGrid*>(this)->placeItemsOnGrid();
+        const_cast<RenderGrid*>(this)->placeItemsOnGrid(IntrinsicSizeComputation);
 
     GridSizingData sizingData(gridColumnCount(), gridRowCount());
     sizingData.setFreeSpaceForDirection(ForColumns, Nullopt);
@@ -1412,7 +1412,7 @@
     }
 }
 
-unsigned RenderGrid::computeAutoRepeatTracksCount(GridTrackSizingDirection direction) const
+unsigned RenderGrid::computeAutoRepeatTracksCount(GridTrackSizingDirection direction, SizingOperation sizingOperation) const
 {
     bool isRowAxis = direction == ForColumns;
     const auto& autoRepeatTracks = isRowAxis ? style().gridAutoRepeatColumns() : style().gridAutoRepeatRows();
@@ -1421,19 +1421,18 @@
     if (!autoRepeatTrackListLength)
         return 0;
 
-    Optional<LayoutUnit> availableSize = isRowAxis ? availableLogicalWidth() : computeContentLogicalHeight(MainOrPreferredSize, style().logicalHeight(), Nullopt);
-    if (!isRowAxis || containingBlock()) {
+    Optional<LayoutUnit> availableSize;
+    if (isRowAxis) {
+        if (sizingOperation != IntrinsicSizeComputation)
+            availableSize =  availableLogicalWidth();
+    } else {
+        availableSize = computeContentLogicalHeight(MainOrPreferredSize, style().logicalHeight(), LayoutUnit(-1));
         if (!availableSize) {
-            const Length& maxLength = isRowAxis ? style().logicalMaxWidth() : style().logicalMaxHeight();
-            if (!maxLength.isUndefined()) {
-                availableSize = isRowAxis
-                    ? computeLogicalWidthInRegionUsing(MaxSize, maxLength, containingBlockLogicalWidthForContent(), *containingBlock(), nullptr)
-                    : computeContentLogicalHeight(MaxSize, maxLength, Nullopt);
-            }
+            const Length& maxLength = style().logicalMaxHeight();
+            if (!maxLength.isUndefined())
+                availableSize = computeContentLogicalHeight(MaxSize, maxLength, LayoutUnit(-1));
         } else {
-            availableSize = isRowAxis
-                ? constrainLogicalWidthInRegionByMinMax(availableSize.value(), availableLogicalWidth(), *containingBlock())
-                : constrainLogicalHeightByMinMax(availableSize.value(), Nullopt);
+            availableSize = constrainLogicalHeightByMinMax(availableSize.value(), LayoutUnit(-1));
         }
     }
 
@@ -1520,13 +1519,13 @@
     return emptyTrackIndexes;
 }
 
-void RenderGrid::placeItemsOnGrid()
+void RenderGrid::placeItemsOnGrid(SizingOperation sizingOperation)
 {
     ASSERT(m_gridIsDirty);
     ASSERT(m_gridItemArea.isEmpty());
 
-    m_autoRepeatColumns = computeAutoRepeatTracksCount(ForColumns);
-    m_autoRepeatRows = computeAutoRepeatTracksCount(ForRows);
+    m_autoRepeatColumns = computeAutoRepeatTracksCount(ForColumns, sizingOperation);
+    m_autoRepeatRows = computeAutoRepeatTracksCount(ForRows, sizingOperation);
 
     populateExplicitGridAndOrderIterator();
     m_gridIsDirty = false;

Modified: trunk/Source/WebCore/rendering/RenderGrid.h (205113 => 205114)


--- trunk/Source/WebCore/rendering/RenderGrid.h	2016-08-29 08:06:28 UTC (rev 205113)
+++ trunk/Source/WebCore/rendering/RenderGrid.h	2016-08-29 08:50:13 UTC (rev 205114)
@@ -82,7 +82,7 @@
     void ensureGridSize(unsigned maximumRowSize, unsigned maximumColumnSize);
     void insertItemIntoGrid(RenderBox&, const GridArea&);
 
-    unsigned computeAutoRepeatTracksCount(GridTrackSizingDirection) const;
+    unsigned computeAutoRepeatTracksCount(GridTrackSizingDirection, SizingOperation) const;
 
     typedef ListHashSet<size_t> OrderedTrackIndexSet;
     std::unique_ptr<OrderedTrackIndexSet> computeEmptyTracksForAutoRepeat(GridTrackSizingDirection) const;
@@ -90,7 +90,7 @@
     bool hasAutoRepeatEmptyTracks(GridTrackSizingDirection) const;
     bool isEmptyAutoRepeatTrack(GridTrackSizingDirection, unsigned track) const;
 
-    void placeItemsOnGrid();
+    void placeItemsOnGrid(SizingOperation);
     void populateExplicitGridAndOrderIterator();
     std::unique_ptr<GridArea> createEmptyGridAreaAtSpecifiedPositionsOutsideGrid(const RenderBox&, GridTrackSizingDirection, const GridSpan&) const;
     void placeSpecifiedMajorAxisItemsOnGrid(const Vector<RenderBox*>&);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to