Diff
Modified: trunk/Source/WebCore/ChangeLog (195807 => 195808)
--- trunk/Source/WebCore/ChangeLog 2016-01-29 08:38:25 UTC (rev 195807)
+++ trunk/Source/WebCore/ChangeLog 2016-01-29 09:22:28 UTC (rev 195808)
@@ -1,3 +1,73 @@
+2016-01-29 Manuel Rego Casasnovas <[email protected]>
+
+ [css-grid] Store lines instead of tracks in GridResolvedPosition
+ https://bugs.webkit.org/show_bug.cgi?id=153592
+
+ Reviewed by Sergio Villar Senin.
+
+ Due to the new feature that allows to create implicit tracks before the
+ explicit ones, we will need to use lines instead of tracks in the
+ code to be able to implement it properly.
+
+ This is just a first simple patch using lines instead of tracks in
+ GridResolvedPosition. It modifies the code that was using it, as it was
+ considering that the resolvedFinalPosition was a track index and
+ not a line index.
+
+ So if we've an item positioned like:
+ grid-column: 2 / 5;
+ grid-row: 1 / span 2;
+
+ Before we were storing this information on the GridSpan:
+ * columns:
+ * resolvedInitialPosition: 1
+ * resolvedFinalPosition: 3
+ * rows:
+ * resolvedInitialPosition: 0
+ * resolvedFinalPosition: 1
+
+ And now we're storing:
+ * columns:
+ * resolvedInitialPosition: 1
+ * resolvedFinalPosition: 4
+ * rows:
+ * resolvedInitialPosition: 0
+ * resolvedFinalPosition: 2
+
+ No new tests, no change of behavior.
+
+ * css/CSSGridTemplateAreasValue.cpp:
+ (WebCore::stringForPosition):
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::parseGridTemplateAreasRow):
+ * css/StyleBuilderConverter.h:
+ (WebCore::StyleBuilderConverter::createImplicitNamedGridLinesFromGridArea):
+ * rendering/RenderGrid.cpp:
+ (WebCore::RenderGrid::GridIterator::nextEmptyGridArea):
+ (WebCore::RenderGrid::computeUsedBreadthOfGridTracks):
+ (WebCore::RenderGrid::ensureGridSize):
+ (WebCore::RenderGrid::populateExplicitGridAndOrderIterator):
+ (WebCore::RenderGrid::placeAutoMajorAxisItemOnGrid):
+ (WebCore::RenderGrid::offsetAndBreadthForPositionedChild):
+ (WebCore::RenderGrid::gridAreaBreadthForChildIncludingAlignmentOffsets):
+ (WebCore::RenderGrid::columnAxisOffsetForChild):
+ (WebCore::RenderGrid::rowAxisOffsetForChild):
+ * rendering/RenderGrid.h:
+ * rendering/style/GridCoordinate.h:
+ (WebCore::GridSpan::GridSpan):
+ (WebCore::GridSpan::integerSpan):
+ (WebCore::GridSpan::end):
+ (WebCore::GridCoordinate::GridCoordinate):
+ * rendering/style/GridResolvedPosition.cpp:
+ (WebCore::resolveRowStartColumnStartNamedGridLinePositionAgainstOppositePosition):
+ (WebCore::resolveRowEndColumnEndNamedGridLinePositionAgainstOppositePosition):
+ (WebCore::resolveNamedGridLinePositionAgainstOppositePosition):
+ (WebCore::resolveGridPositionAgainstOppositePosition):
+ (WebCore::GridResolvedPosition::resolveGridPositionsFromAutoPlacementPosition):
+ (WebCore::GridResolvedPosition::resolveGridPositionsFromStyle):
+ (WebCore::resolveNamedGridLinePositionFromStyle): Deleted.
+ * rendering/style/GridResolvedPosition.h:
+
2016-01-28 Brady Eidson <[email protected]>
Modern IDB: SQLite backend mismanages key generator values.
Modified: trunk/Source/WebCore/css/CSSGridTemplateAreasValue.cpp (195807 => 195808)
--- trunk/Source/WebCore/css/CSSGridTemplateAreasValue.cpp 2016-01-29 08:38:25 UTC (rev 195807)
+++ trunk/Source/WebCore/css/CSSGridTemplateAreasValue.cpp 2016-01-29 09:22:28 UTC (rev 195808)
@@ -55,13 +55,13 @@
for (const auto& it : gridAreaMap) {
const GridCoordinate& coordinate = it.value;
- if (row >= coordinate.rows.resolvedInitialPosition.toInt() && row <= coordinate.rows.resolvedFinalPosition.toInt())
+ if (row >= coordinate.rows.resolvedInitialPosition.toInt() && row < coordinate.rows.resolvedFinalPosition.toInt())
candidates.append(it.key);
}
for (const auto& it : gridAreaMap) {
const GridCoordinate& coordinate = it.value;
- if (column >= coordinate.columns.resolvedInitialPosition.toInt() && column <= coordinate.columns.resolvedFinalPosition.toInt() && candidates.contains(it.key))
+ if (column >= coordinate.columns.resolvedInitialPosition.toInt() && column < coordinate.columns.resolvedFinalPosition.toInt() && candidates.contains(it.key))
return it.key;
}
Modified: trunk/Source/WebCore/css/CSSParser.cpp (195807 => 195808)
--- trunk/Source/WebCore/css/CSSParser.cpp 2016-01-29 08:38:25 UTC (rev 195807)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2016-01-29 09:22:28 UTC (rev 195808)
@@ -6195,20 +6195,20 @@
// We handle several grid areas with the same name at once to simplify the validation code.
unsigned lookAheadColumn;
- for (lookAheadColumn = currentColumn; lookAheadColumn < columnCount - 1; ++lookAheadColumn) {
- if (columnNames[lookAheadColumn + 1] != gridAreaName)
+ for (lookAheadColumn = currentColumn + 1; lookAheadColumn < columnCount; ++lookAheadColumn) {
+ if (columnNames[lookAheadColumn] != gridAreaName)
break;
}
auto gridAreaIterator = gridAreaMap.find(gridAreaName);
if (gridAreaIterator == gridAreaMap.end())
- gridAreaMap.add(gridAreaName, GridCoordinate(GridSpan(rowCount, rowCount), GridSpan(currentColumn, lookAheadColumn)));
+ gridAreaMap.add(gridAreaName, GridCoordinate(GridSpan(rowCount, rowCount + 1), GridSpan(currentColumn, lookAheadColumn)));
else {
GridCoordinate& gridCoordinate = gridAreaIterator->value;
// The following checks test that the grid area is a single filled-in rectangle.
// 1. The new row is adjacent to the previously parsed row.
- if (rowCount != gridCoordinate.rows.resolvedFinalPosition.next().toInt())
+ if (rowCount != gridCoordinate.rows.resolvedFinalPosition.toInt())
return false;
// 2. The new area starts at the same position as the previously parsed area.
@@ -6221,7 +6221,7 @@
++gridCoordinate.rows.resolvedFinalPosition;
}
- currentColumn = lookAheadColumn;
+ currentColumn = lookAheadColumn - 1;
}
m_valueList->next();
Modified: trunk/Source/WebCore/css/StyleBuilderConverter.h (195807 => 195808)
--- trunk/Source/WebCore/css/StyleBuilderConverter.h 2016-01-29 08:38:25 UTC (rev 195807)
+++ trunk/Source/WebCore/css/StyleBuilderConverter.h 2016-01-29 09:22:28 UTC (rev 195808)
@@ -880,7 +880,7 @@
}
{
auto& endVector = namedGridLines.add(area.key + "-end", Vector<unsigned>()).iterator->value;
- endVector.append(areaSpan.resolvedFinalPosition.next().toInt());
+ endVector.append(areaSpan.resolvedFinalPosition.toInt());
std::sort(endVector.begin(), endVector.end());
}
}
Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (195807 => 195808)
--- trunk/Source/WebCore/rendering/RenderGrid.cpp 2016-01-29 08:38:25 UTC (rev 195807)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp 2016-01-29 09:22:28 UTC (rev 195808)
@@ -190,7 +190,7 @@
const unsigned endOfVaryingTrackIndex = (m_direction == ForColumns) ? m_grid.size() : m_grid[0].size();
for (; varyingTrackIndex < endOfVaryingTrackIndex; ++varyingTrackIndex) {
if (isEmptyAreaEnough(rowSpan, columnSpan)) {
- std::unique_ptr<GridCoordinate> result = std::make_unique<GridCoordinate>(GridSpan(m_rowIndex, m_rowIndex + rowSpan - 1), GridSpan(m_columnIndex, m_columnIndex + columnSpan - 1));
+ std::unique_ptr<GridCoordinate> result = std::make_unique<GridCoordinate>(GridSpan(m_rowIndex, m_rowIndex + rowSpan), GridSpan(m_columnIndex, m_columnIndex + columnSpan));
// Advance the iterator to avoid an infinite loop where we would return the same grid area over and over.
++varyingTrackIndex;
return result;
@@ -566,7 +566,7 @@
// 4. Grow all Grid tracks having a fraction as the MaxTrackSizingFunction.
double flexFraction = 0;
if (hasDefiniteFreeSpace)
- flexFraction = findFlexFactorUnitSize(tracks, GridSpan(0, tracks.size() - 1), direction, initialFreeSpace.value());
+ flexFraction = findFlexFactorUnitSize(tracks, GridSpan(0, tracks.size()), direction, initialFreeSpace.value());
else {
for (const auto& trackIndex : flexibleSizedTracksIndex)
flexFraction = std::max(flexFraction, normalizedFlexFraction(tracks[trackIndex], gridTrackSize(direction, trackIndex).maxTrackBreadth().flex()));
@@ -1121,18 +1121,18 @@
}
#endif
-void RenderGrid::ensureGridSize(unsigned maximumRowIndex, unsigned maximumColumnIndex)
+void RenderGrid::ensureGridSize(unsigned maximumRowSize, unsigned maximumColumnSize)
{
const unsigned oldRowCount = gridRowCount();
- if (maximumRowIndex >= oldRowCount) {
- m_grid.grow(maximumRowIndex + 1);
+ if (maximumRowSize > oldRowCount) {
+ m_grid.grow(maximumRowSize);
for (unsigned row = oldRowCount; row < gridRowCount(); ++row)
m_grid[row].grow(gridColumnCount());
}
- if (maximumColumnIndex >= gridColumnCount()) {
+ if (maximumColumnSize > gridColumnCount()) {
for (unsigned row = 0; row < gridRowCount(); ++row)
- m_grid[row].grow(maximumColumnIndex + 1);
+ m_grid[row].grow(maximumColumnSize);
}
}
@@ -1200,21 +1200,21 @@
auto unresolvedRowPositions = GridResolvedPosition::unresolvedSpanFromStyle(style(), *child, ForRows);
if (!unresolvedRowPositions.requiresAutoPlacement()) {
GridSpan rowPositions = GridResolvedPosition::resolveGridPositionsFromStyle(unresolvedRowPositions, style());
- maximumRowIndex = std::max(maximumRowIndex, rowPositions.resolvedFinalPosition.next().toInt());
+ maximumRowIndex = std::max(maximumRowIndex, rowPositions.resolvedFinalPosition.toInt());
} else {
// Grow the grid for items with a definite row span, getting the largest such span.
GridSpan positions = GridResolvedPosition::resolveGridPositionsFromAutoPlacementPosition(style(), *child, ForRows, GridResolvedPosition(0));
- maximumRowIndex = std::max(maximumRowIndex, positions.resolvedFinalPosition.next().toInt());
+ maximumRowIndex = std::max(maximumRowIndex, positions.resolvedFinalPosition.toInt());
}
auto unresolvedColumnPositions = GridResolvedPosition::unresolvedSpanFromStyle(style(), *child, ForColumns);
if (!unresolvedColumnPositions.requiresAutoPlacement()) {
GridSpan columnPositions = GridResolvedPosition::resolveGridPositionsFromStyle(unresolvedColumnPositions, style());
- maximumColumnIndex = std::max(maximumColumnIndex, columnPositions.resolvedFinalPosition.next().toInt());
+ maximumColumnIndex = std::max(maximumColumnIndex, columnPositions.resolvedFinalPosition.toInt());
} else {
// Grow the grid for items with a definite column span, getting the largest such span.
GridSpan positions = GridResolvedPosition::resolveGridPositionsFromAutoPlacementPosition(style(), *child, ForColumns, GridResolvedPosition(0));
- maximumColumnIndex = std::max(maximumColumnIndex, positions.resolvedFinalPosition.next().toInt());
+ maximumColumnIndex = std::max(maximumColumnIndex, positions.resolvedFinalPosition.toInt());
}
}
@@ -1310,7 +1310,7 @@
// Check that it fits in the minor axis direction, as we shouldn't grow in that direction here (it was already managed in populateExplicitGridAndOrderIterator()).
GridResolvedPosition minorAxisFinalPositionIndex = autoPlacementMinorAxisDirection() == ForColumns ? emptyGridArea->columns.resolvedFinalPosition : emptyGridArea->rows.resolvedFinalPosition;
const unsigned endOfMinorAxis = autoPlacementMinorAxisDirection() == ForColumns ? gridColumnCount() : gridRowCount();
- if (minorAxisFinalPositionIndex.toInt() < endOfMinorAxis)
+ if (minorAxisFinalPositionIndex.toInt() <= endOfMinorAxis)
break;
// Discard empty grid area as it does not fit in the minor axis direction.
@@ -1477,12 +1477,12 @@
|| (positions.resolvedInitialPosition.toInt() > lastTrackIndex);
bool endIsAuto = endPosition.isAuto()
|| (endPosition.isNamedGridArea() && GridResolvedPosition::isNonExistentNamedLineOrArea(endPosition.namedGridLine(), style(), (direction == ForColumns) ? ColumnEndSide : RowEndSide))
- || (positions.resolvedFinalPosition.toInt() > lastTrackIndex);
+ || (positions.resolvedFinalPosition.prev().toInt() > lastTrackIndex);
GridResolvedPosition firstPosition = GridResolvedPosition(0);
GridResolvedPosition initialPosition = startIsAuto ? firstPosition : positions.resolvedInitialPosition;
GridResolvedPosition lastPosition = GridResolvedPosition(lastTrackIndex);
- GridResolvedPosition finalPosition = endIsAuto ? lastPosition : positions.resolvedFinalPosition;
+ GridResolvedPosition finalPosition = endIsAuto ? lastPosition : positions.resolvedFinalPosition.prev();
// Positioned children do not grow the grid, so we need to clamp the positions to avoid ending up outside of it.
initialPosition = std::min<GridResolvedPosition>(initialPosition, lastPosition);
@@ -1543,10 +1543,10 @@
const auto& linePositions = (direction == ForColumns) ? m_columnPositions : m_rowPositions;
LayoutUnit initialTrackPosition = linePositions[span.resolvedInitialPosition.toInt()];
- LayoutUnit finalTrackPosition = linePositions[span.resolvedFinalPosition.toInt()];
+ LayoutUnit finalTrackPosition = linePositions[span.resolvedFinalPosition.prev().toInt()];
// Track Positions vector stores the 'start' grid line of each track, so we have to add last track's baseSize.
- return finalTrackPosition - initialTrackPosition + tracks[span.resolvedFinalPosition.toInt()].baseSize();
+ return finalTrackPosition - initialTrackPosition + tracks[span.resolvedFinalPosition.prev().toInt()].baseSize();
}
void RenderGrid::populateGridPositions(GridSizingData& sizingData)
@@ -1836,7 +1836,7 @@
return startPosition;
case GridAxisEnd:
case GridAxisCenter: {
- unsigned childEndLine = rowsSpan.resolvedFinalPosition.next().toInt();
+ unsigned childEndLine = rowsSpan.resolvedFinalPosition.toInt();
LayoutUnit endOfRow = m_rowPositions[childEndLine];
// m_rowPositions include gutters so we need to substract them to get the actual end position for a given
// row (this does not have to be done for the last track as there are no more m_rowPositions after it)
@@ -1870,7 +1870,7 @@
return startPosition;
case GridAxisEnd:
case GridAxisCenter: {
- unsigned childEndLine = columnsSpan.resolvedFinalPosition.next().toInt();
+ unsigned childEndLine = columnsSpan.resolvedFinalPosition.toInt();
LayoutUnit endOfColumn = m_columnPositions[childEndLine];
// m_columnPositions include gutters so we need to substract them to get the actual end position for a given
// column (this does not have to be done for the last track as there are no more m_columnPositions after it)
Modified: trunk/Source/WebCore/rendering/RenderGrid.h (195807 => 195808)
--- trunk/Source/WebCore/rendering/RenderGrid.h 2016-01-29 08:38:25 UTC (rev 195807)
+++ trunk/Source/WebCore/rendering/RenderGrid.h 2016-01-29 09:22:28 UTC (rev 195808)
@@ -76,7 +76,7 @@
LayoutUnit computeUsedBreadthOfMaxLength(const GridLength&, LayoutUnit usedBreadth, LayoutUnit maxSize) const;
void resolveContentBasedTrackSizingFunctions(GridTrackSizingDirection, GridSizingData&);
- void ensureGridSize(unsigned maximumRowIndex, unsigned maximumColumnIndex);
+ void ensureGridSize(unsigned maximumRowSize, unsigned maximumColumnSize);
void insertItemIntoGrid(RenderBox&, const GridCoordinate&);
void placeItemsOnGrid();
void populateExplicitGridAndOrderIterator();
Modified: trunk/Source/WebCore/rendering/style/GridCoordinate.h (195807 => 195808)
--- trunk/Source/WebCore/rendering/style/GridCoordinate.h 2016-01-29 08:38:25 UTC (rev 195807)
+++ trunk/Source/WebCore/rendering/style/GridCoordinate.h 2016-01-29 09:22:28 UTC (rev 195808)
@@ -44,15 +44,15 @@
const unsigned kGridMaxTracks = 1000000;
// A span in a single direction (either rows or columns). Note that |resolvedInitialPosition|
-// and |resolvedFinalPosition| are grid areas' indexes, NOT grid lines'. Iterating over the
-// span should include both |resolvedInitialPosition| and |resolvedFinalPosition| to be correct.
+// and |resolvedFinalPosition| are grid lines' indexes.
+// Iterating over the span shouldn't include |resolvedFinalPosition| to be correct.
class GridSpan {
public:
GridSpan(const GridResolvedPosition& resolvedInitialPosition, const GridResolvedPosition& resolvedFinalPosition)
: resolvedInitialPosition(std::min(resolvedInitialPosition.toInt(), kGridMaxTracks - 1))
, resolvedFinalPosition(std::min(resolvedFinalPosition.toInt(), kGridMaxTracks))
{
- ASSERT(resolvedInitialPosition <= resolvedFinalPosition);
+ ASSERT(resolvedInitialPosition < resolvedFinalPosition);
}
bool operator==(const GridSpan& o) const
@@ -62,7 +62,7 @@
unsigned integerSpan() const
{
- return resolvedFinalPosition.toInt() - resolvedInitialPosition.toInt() + 1;
+ return resolvedFinalPosition.toInt() - resolvedInitialPosition.toInt();
}
GridResolvedPosition resolvedInitialPosition;
@@ -77,7 +77,7 @@
iterator end() const
{
- return resolvedFinalPosition.next();
+ return resolvedFinalPosition;
}
};
@@ -86,8 +86,8 @@
public:
// HashMap requires a default constuctor.
GridCoordinate()
- : columns(0, 0)
- , rows(0, 0)
+ : columns(0, 1)
+ , rows(0, 1)
{
}
Modified: trunk/Source/WebCore/rendering/style/GridResolvedPosition.cpp (195807 => 195808)
--- trunk/Source/WebCore/rendering/style/GridResolvedPosition.cpp 2016-01-29 08:38:25 UTC (rev 195807)
+++ trunk/Source/WebCore/rendering/style/GridResolvedPosition.cpp 2016-01-29 09:22:28 UTC (rev 195808)
@@ -109,11 +109,6 @@
return isColumnSide(side) ? GridResolvedPosition::explicitGridColumnCount(gridContainerStyle) : GridResolvedPosition::explicitGridRowCount(gridContainerStyle);
}
-static GridResolvedPosition adjustGridPositionForRowEndColumnEndSide(unsigned resolvedPosition)
-{
- return resolvedPosition ? GridResolvedPosition(resolvedPosition - 1) : GridResolvedPosition(0);
-}
-
static GridResolvedPosition resolveNamedGridLinePositionFromStyle(const RenderStyle& gridContainerStyle, const GridPosition& position, GridPositionSide side)
{
ASSERT(!position.namedGridLine().isNull());
@@ -135,26 +130,21 @@
return it->value[namedGridLineIndex];
}
-static inline unsigned firstNamedGridLineBeforePosition(unsigned position, const Vector<unsigned>& gridLines)
+static GridSpan resolveRowStartColumnStartNamedGridLinePositionAgainstOppositePosition(const GridResolvedPosition& resolvedOppositePosition, const GridPosition& position, const Vector<unsigned>& gridLines)
{
- // The grid line inequality needs to be strict (which doesn't match the after / end case) because |position| is
- // already converted to an index in our grid representation (ie one was removed from the grid line to account for
- // the side).
+ if (!resolvedOppositePosition.toInt())
+ return GridSpan(resolvedOppositePosition, resolvedOppositePosition.next());
+
unsigned firstLineBeforePositionIndex = 0;
- auto firstLineBeforePosition = std::lower_bound(gridLines.begin(), gridLines.end(), position);
- if (firstLineBeforePosition != gridLines.end()) {
- if (*firstLineBeforePosition > position && firstLineBeforePosition != gridLines.begin())
- --firstLineBeforePosition;
-
+ auto firstLineBeforePosition = std::lower_bound(gridLines.begin(), gridLines.end(), resolvedOppositePosition.toInt());
+ if (firstLineBeforePosition != gridLines.end())
firstLineBeforePositionIndex = firstLineBeforePosition - gridLines.begin();
- }
- return firstLineBeforePositionIndex;
-}
-static GridSpan resolveRowStartColumnStartNamedGridLinePositionAgainstOppositePosition(const GridResolvedPosition& resolvedOppositePosition, const GridPosition& position, const Vector<unsigned>& gridLines)
-{
- unsigned gridLineIndex = std::max<int>(0, firstNamedGridLineBeforePosition(resolvedOppositePosition.toInt(), gridLines) - position.spanPosition() + 1);
+ unsigned gridLineIndex = std::max<int>(0, firstLineBeforePositionIndex - position.spanPosition());
+
GridResolvedPosition resolvedGridLinePosition = GridResolvedPosition(gridLines[gridLineIndex]);
+ if (resolvedGridLinePosition >= resolvedOppositePosition)
+ resolvedGridLinePosition = resolvedOppositePosition.prev();
return GridSpan(std::min<GridResolvedPosition>(resolvedGridLinePosition, resolvedOppositePosition), resolvedOppositePosition);
}
@@ -167,9 +157,9 @@
firstLineAfterOppositePositionIndex = firstLineAfterOppositePosition - gridLines.begin();
unsigned gridLineIndex = std::min<unsigned>(gridLines.size() - 1, firstLineAfterOppositePositionIndex + position.spanPosition() - 1);
- GridResolvedPosition resolvedGridLinePosition = adjustGridPositionForRowEndColumnEndSide(gridLines[gridLineIndex]);
- if (resolvedGridLinePosition < resolvedOppositePosition)
- resolvedGridLinePosition = resolvedOppositePosition;
+ GridResolvedPosition resolvedGridLinePosition = gridLines[gridLineIndex];
+ if (resolvedGridLinePosition <= resolvedOppositePosition)
+ resolvedGridLinePosition = resolvedOppositePosition.next();
return GridSpan(resolvedOppositePosition, resolvedGridLinePosition);
}
@@ -185,8 +175,11 @@
// If there is no named grid line of that name, we resolve the position to 'auto' (which is equivalent to 'span 1' in this case).
// See http://lists.w3.org/Archives/Public/www-style/2013Jun/0394.html.
- if (it == gridLinesNames.end())
- return GridSpan(resolvedOppositePosition, resolvedOppositePosition);
+ if (it == gridLinesNames.end()) {
+ if (isStartSide(side) && resolvedOppositePosition.toInt())
+ return GridSpan(resolvedOppositePosition.prev(), resolvedOppositePosition);
+ return GridSpan(resolvedOppositePosition, resolvedOppositePosition.next());
+ }
if (side == RowStartSide || side == ColumnStartSide)
return resolveRowStartColumnStartNamedGridLinePositionAgainstOppositePosition(resolvedOppositePosition, position, it->value);
@@ -196,8 +189,11 @@
static GridSpan resolveGridPositionAgainstOppositePosition(const RenderStyle& gridContainerStyle, const GridResolvedPosition& resolvedOppositePosition, const GridPosition& position, GridPositionSide side)
{
- if (position.isAuto())
- return GridSpan(resolvedOppositePosition, resolvedOppositePosition);
+ if (position.isAuto()) {
+ if (isStartSide(side) && resolvedOppositePosition.toInt())
+ return GridSpan(resolvedOppositePosition.prev(), resolvedOppositePosition);
+ return GridSpan(resolvedOppositePosition, resolvedOppositePosition.next());
+ }
ASSERT(position.isSpan());
ASSERT(position.spanPosition() > 0);
@@ -209,8 +205,11 @@
// 'span 1' is contained inside a single grid track regardless of the direction.
// That's why the CSS span value is one more than the offset we apply.
- unsigned positionOffset = position.spanPosition() - 1;
+ unsigned positionOffset = position.spanPosition();
if (isStartSide(side)) {
+ if (!resolvedOppositePosition.toInt())
+ return GridSpan(resolvedOppositePosition, resolvedOppositePosition.next());
+
unsigned initialResolvedPosition = std::max<int>(0, resolvedOppositePosition.toInt() - positionOffset);
return GridSpan(initialResolvedPosition, resolvedOppositePosition);
}
@@ -225,7 +224,7 @@
// This method will only be used when both positions need to be resolved against the opposite one.
ASSERT(unresolvedSpan.requiresAutoPlacement());
- GridResolvedPosition resolvedFinalPosition = resolvedInitialPosition;
+ GridResolvedPosition resolvedFinalPosition = resolvedInitialPosition.next();
if (unresolvedSpan.initialPosition().isSpan())
return resolveGridPositionAgainstOppositePosition(gridContainerStyle, resolvedInitialPosition, unresolvedSpan.initialPosition(), unresolvedSpan.finalPositionSide());
@@ -315,7 +314,7 @@
if (unresolvedSpan.initialPosition().shouldBeResolvedAgainstOppositePosition()) {
// Infer the position from the final position ('auto / 1' or 'span 2 / 3' case).
auto finalResolvedPosition = resolveGridPositionFromStyle(gridContainerStyle, unresolvedSpan.finalPosition(), unresolvedSpan.finalPositionSide());
- return resolveGridPositionAgainstOppositePosition(gridContainerStyle, finalResolvedPosition.prev(), unresolvedSpan.initialPosition(), unresolvedSpan.initialPositionSide());
+ return resolveGridPositionAgainstOppositePosition(gridContainerStyle, finalResolvedPosition, unresolvedSpan.initialPosition(), unresolvedSpan.initialPositionSide());
}
if (unresolvedSpan.finalPosition().shouldBeResolvedAgainstOppositePosition()) {
@@ -329,8 +328,10 @@
if (resolvedInitialPosition > resolvedFinalPosition)
std::swap(resolvedInitialPosition, resolvedFinalPosition);
+ else if (resolvedInitialPosition == resolvedFinalPosition)
+ resolvedFinalPosition = resolvedInitialPosition.next();
- return GridSpan(resolvedInitialPosition, std::max(resolvedInitialPosition, resolvedFinalPosition.prev()));
+ return GridSpan(resolvedInitialPosition, std::max(resolvedInitialPosition, resolvedFinalPosition));
}
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/style/GridResolvedPosition.h (195807 => 195808)
--- trunk/Source/WebCore/rendering/style/GridResolvedPosition.h 2016-01-29 08:38:25 UTC (rev 195807)
+++ trunk/Source/WebCore/rendering/style/GridResolvedPosition.h 2016-01-29 09:22:28 UTC (rev 195808)
@@ -71,7 +71,7 @@
GridPositionSide m_finalPositionSide;
};
-// This class represents an index into one of the dimensions of the grid array.
+// This class represents a line index into one of the dimensions of the grid array.
// Wraps an unsigned integer just for the purpose of knowing what we manipulate in the grid code.
class GridResolvedPosition {
public: