Modified: trunk/Source/WebCore/ChangeLog (208961 => 208962)
--- 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)
@@ -1,3 +1,38 @@
+2016-11-21 Sergio Villar Senin <[email protected]>
+
+ [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:
+
2016-11-21 Konstantin Tokarev <[email protected]>
Disable #line markers in bison output on Windows
Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (208961 => 208962)
--- 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)
@@ -387,12 +387,7 @@
unsigned RenderGrid::gridColumnCount() const
{
ASSERT(!m_gridIsDirty);
- // 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 "normal" children (out-of-flow children are
- // not stored in m_grid).
- return m_grid.size() ? m_grid[0].size() : GridPositionsResolver::explicitGridColumnCount(style(), m_autoRepeatColumns);
+ return m_grid.size() ? m_grid[0].size() : 0;
}
unsigned RenderGrid::gridRowCount() const
@@ -488,7 +483,7 @@
placeItemsOnGrid(TrackSizing);
- GridSizingData sizingData(gridColumnCount(), gridRowCount());
+ GridSizingData sizingData(numTracks(ForColumns), numTracks(ForRows));
// At this point the logical width is always definite as the above call to updateLogicalWidth()
// properly resolves intrinsic sizes. We cannot do the same for heights though because many code
@@ -638,7 +633,7 @@
if (!wasPopulated)
const_cast<RenderGrid*>(this)->placeItemsOnGrid(IntrinsicSizeComputation);
- GridSizingData sizingData(gridColumnCount(), gridRowCount());
+ GridSizingData sizingData(numTracks(ForColumns), numTracks(ForRows));
sizingData.setAvailableSpace(Nullopt);
sizingData.setFreeSpace(ForColumns, Nullopt);
sizingData.sizingOperation = IntrinsicSizeComputation;
@@ -1687,8 +1682,12 @@
insertItemIntoGrid(*child, GridArea(area.rows, area.columns));
}
- ASSERT(gridRowCount() >= GridPositionsResolver::explicitGridRowCount(style(), m_autoRepeatRows));
- ASSERT(gridColumnCount() >= GridPositionsResolver::explicitGridColumnCount(style(), m_autoRepeatColumns));
+#if ENABLE(ASSERT)
+ if (!m_gridItemArea.isEmpty()) {
+ ASSERT(gridRowCount() >= GridPositionsResolver::explicitGridRowCount(style(), m_autoRepeatRows));
+ ASSERT(gridColumnCount() >= GridPositionsResolver::explicitGridColumnCount(style(), m_autoRepeatColumns));
+ }
+#endif
placeSpecifiedMajorAxisItemsOnGrid(specifiedMajorAxisAutoGridItems);
placeAutoMajorAxisItemsOnGrid(autoMajorAxisAutoGridItems);
@@ -2057,7 +2056,7 @@
GridPosition startPosition = isRowAxis ? child.style().gridItemColumnStart() : child.style().gridItemRowStart();
GridPosition endPosition = isRowAxis ? child.style().gridItemColumnEnd() : child.style().gridItemRowEnd();
- int lastLine = isRowAxis ? gridColumnCount() : gridRowCount();
+ int lastLine = numTracks(direction);
bool startIsAuto = startPosition.isAuto()
|| (startPosition.isNamedGridArea() && !NamedLineCollection::isValidNamedLineOrArea(startPosition.namedGridLine(), style(), (direction == ForColumns) ? ColumnStartSide : RowStartSide))
@@ -2711,6 +2710,19 @@
return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLocation;
}
+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 "normal" 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);
+}
+
void RenderGrid::paintChildren(PaintInfo& paintInfo, const LayoutPoint& paintOffset, PaintInfo& forChild, bool usePrintRect)
{
for (RenderBox* child = m_orderIterator.first(); child; child = m_orderIterator.next())
Modified: trunk/Source/WebCore/rendering/RenderGrid.h (208961 => 208962)
--- 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)
@@ -190,8 +190,10 @@
bool spanningItemCrossesFlexibleSizedTracks(const GridSpan&, GridTrackSizingDirection, SizingOperation) const;
+ // FIXME: Look for better names once the refactoring is complete.
unsigned gridColumnCount() const;
unsigned gridRowCount() const;
+ unsigned numTracks(GridTrackSizingDirection) const;
LayoutUnit translateRTLCoordinate(LayoutUnit) const;