No subject


Tue May 3 15:05:30 PDT 2016


data structure representing the grid whereas the newly added numTracks() will always return
the actual size of the grid.

This is the first required step of the process of isolating the data used by the grid track
sizing algorithm from the actual internal state of the LayoutGrid object.

No new tests as this is just a code refactoring.

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::gridColumnCount): Always return the number of columns of the internal
data structure to represent the grid.
(WebCore::RenderGrid::layoutBlock):
(WebCore::RenderGrid::computeIntrinsicLogicalWidths): Use the actual size of the grid to
create the GridSizingData structure.
(WebCore::RenderGrid::placeItemsOnGrid): Use the actual size of the grid to create the
GridSizingData structure.
(WebCore::RenderGrid::offsetAndBreadthForPositionedChild):
(WebCore::RenderGrid::numTracks): New method which returns the actual size of the grid.
* rendering/RenderGrid.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderGridcpp">trunk/Source/WebCore/rendering/RenderGrid.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderGridh">trunk/Source/WebCore/rendering/RenderGrid.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208961 => 208962)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog	2016-11-22 11:14:44 UTC (rev 208961)
+++ trunk/Source/WebCore/ChangeLog	2016-11-22 14:34:55 UTC (rev 208962)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2016-11-21  Sergio Villar Senin  &lt;svillar at igalia.com&gt;
+
+        [css-grid] Isolate size of internal representation from actual grid size
+        https://bugs.webkit.org/show_bug.cgi?id=165006
+
+        Reviewed by Manuel Rego Casasnovas.
+
+        RenderGrid has an internal representation of a grid used to place grid items, compute grid
+        positions, run the track sizing algorithm etc. That data structure normally has exactly the
+        same size as the actual grid specified using the grid-template-xxx properties (or any other
+        shorthand). But in some cases, like for example when the grid is empty, the internal data
+        structure does not really match the actual grid. In the particular case of empty grids no
+        memory allocations are done to create a grid representation as it is not needed.
+
+        From now on both gridColumnCount() and gridRowCount() will always return the size of the
+        data structure representing the grid whereas the newly added numTracks() will always return
+        the actual size of the grid.
+
+        This is the first required step of the process of isolating the data used by the grid track
+        sizing algorithm from the actual internal state of the LayoutGrid object.
+
+        No new tests as this is just a code refactoring.
+
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::gridColumnCount): Always return the number of columns of the internal
+        data structure to represent the grid.
+        (WebCore::RenderGrid::layoutBlock):
+        (WebCore::RenderGrid::computeIntrinsicLogicalWidths): Use the actual size of the grid to
+        create the GridSizingData structure.
+        (WebCore::RenderGrid::placeItemsOnGrid): Use the actual size of the grid to create the
+        GridSizingData structure.
+        (WebCore::RenderGrid::offsetAndBreadthForPositionedChild):
+        (WebCore::RenderGrid::numTracks): New method which returns the actual size of the grid.
+        * rendering/RenderGrid.h:
+
</ins><span class="cx"> 2016-11-21  Konstantin Tokarev  &lt;annulen at yandex.ru&gt;
</span><span class="cx"> 
</span><span class="cx">         Disable #line markers in bison output on Windows
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderGridcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (208961 => 208962)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderGrid.cpp	2016-11-22 11:14:44 UTC (rev 208961)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp	2016-11-22 14:34:55 UTC (rev 208962)
</span><span class="lines">@@ -387,12 +387,7 @@
</span><span class="cx"> unsigned RenderGrid::gridColumnCount() const
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!m_gridIsDirty);
</span><del>-    // Due to limitations in our internal representation, we cannot know the number of columns from
-    // m_grid *if* there is no row (because m_grid would be empty). That's why in that case we need
-    // to get it from the style. Note that we know for sure that there are't any implicit tracks,
-    // because not having rows implies that there are no &quot;normal&quot; children (out-of-flow children are
-    // not stored in m_grid).
-    return m_grid.size() ? m_grid[0].size() : GridPositionsResolver::explicitGridColumnCount(style(), m_autoRepeatColumns);
</del><ins>+    return m_grid.size() ? m_grid[0].size() : 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> unsigned RenderGrid::gridRowCount() const
</span><span class="lines">@@ -488,7 +483,7 @@
</span><span class="cx"> 
</span><span class="cx">     placeItemsOnGrid(TrackSizing);
</span><span class="cx"> 
</span><del>-    GridSizingData sizingData(gridColumnCount(), gridRowCount());
</del><ins>+    GridSizingData sizingData(numTracks(ForColumns), numTracks(ForRows));
</ins><span class="cx"> 
</span><span class="cx">     // At this point the logical width is always definite as the above call to updateLogicalWidth()
</span><span class="cx">     // properly resolves intrinsic sizes. We cannot do the same for heights though because many code
</span><span class="lines">@@ -638,7 +633,7 @@
</span><span class="cx">     if (!wasPopulated)
</span><span class="cx">         const_cast&lt;RenderGrid*&gt;(this)-&gt;placeItemsOnGrid(IntrinsicSizeComputation);
</span><span class="cx"> 
</span><del>-    GridSizingData sizingData(gridColumnCount(), gridRowCount());
</del><ins>+    GridSizingData sizingData(numTracks(ForColumns), numTracks(ForRows));
</ins><span class="cx">     sizingData.setAvailableSpace(Nullopt);
</span><span class="cx">     sizingData.setFreeSpace(ForColumns, Nullopt);
</span><span class="cx">     sizingData.sizingOperation = IntrinsicSizeComputation;
</span><span class="lines">@@ -1687,8 +1682,12 @@
</span><span class="cx">         insertItemIntoGrid(*child, GridArea(area.rows, area.columns));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ASSERT(gridRowCount() &gt;= GridPositionsResolver::explicitGridRowCount(style(), m_autoRepeatRows));
-    ASSERT(gridColumnCount() &gt;= GridPositionsResolver::explicitGridColumnCount(style(), m_autoRepeatColumns));
</del><ins>+#if ENABLE(ASSERT)
+    if (!m_gridItemArea.isEmpty()) {
+        ASSERT(gridRowCount() &gt;= GridPositionsResolver::explicitGridRowCount(style(), m_autoRepeatRows));
+        ASSERT(gridColumnCount() &gt;= GridPositionsResolver::explicitGridColumnCount(style(), m_autoRepeatColumns));
+    }
+#endif
</ins><span class="cx"> 
</span><span class="cx">     placeSpecifiedMajorAxisItemsOnGrid(specifiedMajorAxisAutoGridItems);
</span><span class="cx">     placeAutoMajorAxisItemsOnGrid(autoMajorAxisAutoGridItems);
</span><span class="lines">@@ -2057,7 +2056,7 @@
</span><span class="cx"> 
</span><span class="cx">     GridPosition startPosition = isRowAxis ? child.style().gridItemColumnStart() : child.style().gridItemRowStart();
</span><span class="cx">     GridPosition endPosition = isRowAxis ? child.style().gridItemColumnEnd() : child.style().gridItemRowEnd();
</span><del>-    int lastLine = isRowAxis ? gridColumnCount() : gridRowCount();
</del><ins>+    int lastLine = numTracks(direction);
</ins><span class="cx"> 
</span><span class="cx">     bool startIsAuto = startPosition.isAuto()
</span><span class="cx">         || (startPosition.isNamedGridArea() &amp;&amp; !NamedLineCollection::isValidNamedLineOrArea(startPosition.namedGridLine(), style(), (direction == ForColumns) ? ColumnStartSide : RowStartSide))
</span><span class="lines">@@ -2711,6 +2710,19 @@
</span><span class="cx">     return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLocation;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+unsigned RenderGrid::numTracks(GridTrackSizingDirection direction) const
+{
+    // Due to limitations in our internal representation, we cannot know the number of columns from
+    // m_grid *if* there is no row (because m_grid would be empty). That's why in that case we need
+    // to get it from the style. Note that we know for sure that there are't any implicit tracks,
+    // because not having rows implies that there are no &quot;normal&quot; children (out-of-flow children are
+    // not stored in m_grid).
+    if (direction == ForRows)
+        return m_grid.size();
+
+    return m_grid.size() ? m_grid[0].size() : GridPositionsResolver::explicitGridColumnCount(style(), m_autoRepeatColumns);
+}
+
</ins><span class="cx"> void RenderGrid::paintChildren(PaintInfo&amp; paintInfo, const LayoutPoint&amp; paintOffset, PaintInfo&amp; forChild, bool usePrintRect)
</span><span class="cx"> {
</span><span class="cx">     for (RenderBox* child = m_orderIterator.first(); child; child = m_orderIterator.next())
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderGridh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderGrid.h (208961 => 208962)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderGrid.h	2016-11-22 11:14:44 UTC (rev 208961)
+++ trunk/Source/WebCore/rendering/RenderGrid.h	2016-11-22 14:34:55 UTC (rev 208962)
</span><span class="lines">@@ -190,8 +190,10 @@
</span><span class="cx"> 
</span><span class="cx">     bool spanningItemCrossesFlexibleSizedTracks(const GridSpan&amp;, GridTrackSizingDirection, SizingOperation) const;
</span><span class="cx"> 
</span><ins>+    // FIXME: Look for better names once the refactoring is complete.
</ins><span class="cx">     unsigned gridColumnCount() const;
</span><span class="cx">     unsigned gridRowCount() const;
</span><ins>+    unsigned numTracks(GridTrackSizingDirection) const;
</ins><span class="cx"> 
</span><span class="cx">     LayoutUnit translateRTLCoordinate(LayoutUnit) const;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>


More information about the webkit-changes mailing list