- Revision
- 264403
- Author
- obru...@igalia.com
- Date
- 2020-07-15 10:26:41 -0700 (Wed, 15 Jul 2020)
Log Message
[css-grid] Rename SmallestTrackStart to ExplicitGridStart
https://bugs.webkit.org/show_bug.cgi?id=214347
Reviewed by Manuel Rego Casasnovas.
The SmallestTrackStart method used to return a signed int which was
never positive, representing the smallest untranslated start among all
grid items, clamped by 0 as a maximum.
In practice, though, what we usually want is the index of the first
explicit track/line among all tracks/lines, or equivalently, the number
of leading implicit tracks/lines.
That number is precisely minus the return value of SmallestTrackStart.
Thus, in grid layout there were various std::abs() to invert the value.
But it's a bit confusing to have an API which returns a non-positive
integer, which then needs to be made non-negative. Therefore, this patch
renames SmallestTrackStart to ExplicitGridStart, and makes it return
the unsigned which is usually desired.
This patch should have no effect in practice.
This patch is a port of https://crrev.com/777768
* rendering/Grid.cpp:
(WebCore::Grid::setExplicitGridStart):
(WebCore::Grid::explicitGridStart const):
(WebCore::Grid::setNeedsItemsPlacement):
* rendering/Grid.h:
* rendering/GridTrackSizingAlgorithm.cpp:
(WebCore::GridTrackSizingAlgorithm::rawGridTrackSize const):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::computeEmptyTracksForAutoRepeat const):
(WebCore::RenderGrid::placeItemsOnGrid const):
(WebCore::RenderGrid::populateExplicitGridAndOrderIterator const):
(WebCore::RenderGrid::gridAreaBreadthForOutOfFlowChild):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (264402 => 264403)
--- trunk/Source/WebCore/ChangeLog 2020-07-15 17:09:25 UTC (rev 264402)
+++ trunk/Source/WebCore/ChangeLog 2020-07-15 17:26:41 UTC (rev 264403)
@@ -1,3 +1,43 @@
+2020-07-15 Oriol Brufau <obru...@igalia.com>
+
+ [css-grid] Rename SmallestTrackStart to ExplicitGridStart
+ https://bugs.webkit.org/show_bug.cgi?id=214347
+
+ Reviewed by Manuel Rego Casasnovas.
+
+ The SmallestTrackStart method used to return a signed int which was
+ never positive, representing the smallest untranslated start among all
+ grid items, clamped by 0 as a maximum.
+
+ In practice, though, what we usually want is the index of the first
+ explicit track/line among all tracks/lines, or equivalently, the number
+ of leading implicit tracks/lines.
+
+ That number is precisely minus the return value of SmallestTrackStart.
+ Thus, in grid layout there were various std::abs() to invert the value.
+
+ But it's a bit confusing to have an API which returns a non-positive
+ integer, which then needs to be made non-negative. Therefore, this patch
+ renames SmallestTrackStart to ExplicitGridStart, and makes it return
+ the unsigned which is usually desired.
+
+ This patch should have no effect in practice.
+
+ This patch is a port of https://crrev.com/777768
+
+ * rendering/Grid.cpp:
+ (WebCore::Grid::setExplicitGridStart):
+ (WebCore::Grid::explicitGridStart const):
+ (WebCore::Grid::setNeedsItemsPlacement):
+ * rendering/Grid.h:
+ * rendering/GridTrackSizingAlgorithm.cpp:
+ (WebCore::GridTrackSizingAlgorithm::rawGridTrackSize const):
+ * rendering/RenderGrid.cpp:
+ (WebCore::RenderGrid::computeEmptyTracksForAutoRepeat const):
+ (WebCore::RenderGrid::placeItemsOnGrid const):
+ (WebCore::RenderGrid::populateExplicitGridAndOrderIterator const):
+ (WebCore::RenderGrid::gridAreaBreadthForOutOfFlowChild):
+
2020-07-15 Chris Dumez <cdu...@apple.com>
Unreviewed atttempt to fix build after r264389.
Modified: trunk/Source/WebCore/rendering/Grid.cpp (264402 => 264403)
--- trunk/Source/WebCore/rendering/Grid.cpp 2020-07-15 17:09:25 UTC (rev 264402)
+++ trunk/Source/WebCore/rendering/Grid.cpp 2020-07-15 17:26:41 UTC (rev 264403)
@@ -74,17 +74,15 @@
setGridItemArea(child, area);
}
-void Grid::setSmallestTracksStart(int rowStart, int columnStart)
+void Grid::setExplicitGridStart(unsigned rowStart, unsigned columnStart)
{
- ASSERT(rowStart > GridPosition::min() && rowStart < GridPosition::max() - 1);
- ASSERT(columnStart > GridPosition::min() && columnStart < GridPosition::max() - 1);
- m_smallestRowStart = rowStart;
- m_smallestColumnStart = columnStart;
+ m_explicitRowStart = rowStart;
+ m_explicitColumnStart = columnStart;
}
-int Grid::smallestTrackStart(GridTrackSizingDirection direction) const
+unsigned Grid::explicitGridStart(GridTrackSizingDirection direction) const
{
- return direction == ForRows ? m_smallestRowStart : m_smallestColumnStart;
+ return direction == ForRows ? m_explicitRowStart : m_explicitColumnStart;
}
GridArea Grid::gridItemArea(const RenderBox& item) const
@@ -157,8 +155,8 @@
m_grid.shrink(0);
m_gridItemArea.clear();
- m_smallestRowStart = 0;
- m_smallestColumnStart = 0;
+ m_explicitRowStart = 0;
+ m_explicitColumnStart = 0;
m_autoRepeatEmptyColumns = nullptr;
m_autoRepeatEmptyRows = nullptr;
m_autoRepeatColumns = 0;
Modified: trunk/Source/WebCore/rendering/Grid.h (264402 => 264403)
--- trunk/Source/WebCore/rendering/Grid.h 2020-07-15 17:09:25 UTC (rev 264402)
+++ trunk/Source/WebCore/rendering/Grid.h 2020-07-15 17:26:41 UTC (rev 264403)
@@ -61,8 +61,8 @@
const GridCell& cell(unsigned row, unsigned column) const { return m_grid[row][column]; }
- int smallestTrackStart(GridTrackSizingDirection) const;
- void setSmallestTracksStart(int rowStart, int columnStart);
+ unsigned explicitGridStart(GridTrackSizingDirection) const;
+ void setExplicitGridStart(unsigned rowStart, unsigned columnStart);
unsigned autoRepeatTracks(GridTrackSizingDirection) const;
void setAutoRepeatTracks(unsigned autoRepeatRows, unsigned autoRepeatColumns);
@@ -86,8 +86,8 @@
OrderIterator m_orderIterator;
- int m_smallestColumnStart { 0 };
- int m_smallestRowStart { 0 };
+ unsigned m_explicitColumnStart { 0 };
+ unsigned m_explicitRowStart { 0 };
unsigned m_autoRepeatColumns { 0 };
unsigned m_autoRepeatRows { 0 };
Modified: trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp (264402 => 264403)
--- trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp 2020-07-15 17:09:25 UTC (rev 264402)
+++ trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp 2020-07-15 17:26:41 UTC (rev 264403)
@@ -176,7 +176,7 @@
// grid-template-areas is specified for example).
unsigned explicitTracksCount = trackStyles.size() + autoRepeatTracksCount;
- int untranslatedIndexAsInt = translatedIndex + m_grid.smallestTrackStart(direction);
+ int untranslatedIndexAsInt = translatedIndex - m_grid.explicitGridStart(direction);
unsigned autoTrackStylesSize = autoTrackStyles.size();
if (untranslatedIndexAsInt < 0) {
int index = untranslatedIndexAsInt % static_cast<int>(autoTrackStylesSize);
Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (264402 => 264403)
--- trunk/Source/WebCore/rendering/RenderGrid.cpp 2020-07-15 17:09:25 UTC (rev 264402)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp 2020-07-15 17:26:41 UTC (rev 264403)
@@ -540,7 +540,7 @@
std::unique_ptr<OrderedTrackIndexSet> emptyTrackIndexes;
unsigned insertionPoint = isRowAxis ? style().gridAutoRepeatColumnsInsertionPoint() : style().gridAutoRepeatRowsInsertionPoint();
- unsigned firstAutoRepeatTrack = insertionPoint + std::abs(grid.smallestTrackStart(direction));
+ unsigned firstAutoRepeatTrack = insertionPoint + grid.explicitGridStart(direction);
unsigned lastAutoRepeatTrack = firstAutoRepeatTrack + grid.autoRepeatTracks(direction);
if (!grid.hasGridItems()) {
@@ -616,9 +616,9 @@
GridArea area = grid.gridItemArea(*child);
if (!area.rows.isIndefinite())
- area.rows.translate(std::abs(grid.smallestTrackStart(ForRows)));
+ area.rows.translate(grid.explicitGridStart(ForRows));
if (!area.columns.isIndefinite())
- area.columns.translate(std::abs(grid.smallestTrackStart(ForColumns)));
+ area.columns.translate(grid.explicitGridStart(ForColumns));
if (area.rows.isIndefinite() || area.columns.isIndefinite()) {
grid.setGridItemArea(*child, area);
@@ -688,8 +688,8 @@
void RenderGrid::populateExplicitGridAndOrderIterator(Grid& grid) const
{
OrderIteratorPopulator populator(grid.orderIterator());
- int smallestRowStart = 0;
- int smallestColumnStart = 0;
+ unsigned explicitRowStart = 0;
+ unsigned explicitColumnStart = 0;
unsigned autoRepeatRows = grid.autoRepeatTracks(ForRows);
unsigned autoRepeatColumns = grid.autoRepeatTracks(ForColumns);
unsigned maximumRowIndex = GridPositionsResolver::explicitGridRowCount(style(), autoRepeatRows);
@@ -701,7 +701,7 @@
GridSpan rowPositions = GridPositionsResolver::resolveGridPositionsFromStyle(style(), *child, ForRows, autoRepeatRows);
if (!rowPositions.isIndefinite()) {
- smallestRowStart = std::min(smallestRowStart, rowPositions.untranslatedStartLine());
+ explicitRowStart = std::max<int>(explicitRowStart, -rowPositions.untranslatedStartLine());
maximumRowIndex = std::max<int>(maximumRowIndex, rowPositions.untranslatedEndLine());
} else {
// Grow the grid for items with a definite row span, getting the largest such span.
@@ -711,7 +711,7 @@
GridSpan columnPositions = GridPositionsResolver::resolveGridPositionsFromStyle(style(), *child, ForColumns, autoRepeatColumns);
if (!columnPositions.isIndefinite()) {
- smallestColumnStart = std::min(smallestColumnStart, columnPositions.untranslatedStartLine());
+ explicitColumnStart = std::max<int>(explicitColumnStart, -columnPositions.untranslatedStartLine());
maximumColumnIndex = std::max<int>(maximumColumnIndex, columnPositions.untranslatedEndLine());
} else {
// Grow the grid for items with a definite column span, getting the largest such span.
@@ -722,8 +722,8 @@
grid.setGridItemArea(*child, { rowPositions, columnPositions });
}
- grid.setSmallestTracksStart(smallestRowStart, smallestColumnStart);
- grid.ensureGridSize(maximumRowIndex + std::abs(smallestRowStart), maximumColumnIndex + std::abs(smallestColumnStart));
+ grid.setExplicitGridStart(explicitRowStart, explicitColumnStart);
+ grid.ensureGridSize(maximumRowIndex + explicitRowStart, maximumColumnIndex + explicitColumnStart);
}
std::unique_ptr<GridArea> RenderGrid::createEmptyGridAreaAtSpecifiedPositionsOutsideGrid(Grid& grid, const RenderBox& gridItem, GridTrackSizingDirection specifiedDirection, const GridSpan& specifiedPositions) const
@@ -1529,9 +1529,9 @@
if (span.isIndefinite())
return isRowAxis ? clientLogicalWidth() : clientLogicalHeight();
- int smallestStart = abs(m_grid.smallestTrackStart(direction));
- int startLine = span.untranslatedStartLine() + smallestStart;
- int endLine = span.untranslatedEndLine() + smallestStart;
+ unsigned explicitStart = m_grid.explicitGridStart(direction);
+ int startLine = span.untranslatedStartLine() + explicitStart;
+ int endLine = span.untranslatedEndLine() + explicitStart;
int lastLine = numTracks(direction, m_grid);
GridPosition startPosition = direction == ForColumns ? child.style().gridItemColumnStart() : child.style().gridItemRowStart();
GridPosition endPosition = direction == ForColumns ? child.style().gridItemColumnEnd() : child.style().gridItemRowEnd();