Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: Source/core/rendering/style/GridCoordinate.h

Issue 113943003: [CSS Grid] Introduce an explicit type for resolved grid positions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@to-land-zero
Patch Set: Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/RenderGrid.cpp ('k') | Source/core/rendering/style/GridPosition.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/style/GridCoordinate.h
diff --git a/Source/core/rendering/style/GridCoordinate.h b/Source/core/rendering/style/GridCoordinate.h
index 937d3f08b9b2c73688b0ada58ccf780c3d81b9c1..6c665c1fc3e8f309bfa509ef78c046f9c2b71292 100644
--- a/Source/core/rendering/style/GridCoordinate.h
+++ b/Source/core/rendering/style/GridCoordinate.h
@@ -31,7 +31,7 @@
#ifndef GridCoordinate_h
#define GridCoordinate_h
-#include "core/rendering/style/GridPosition.h"
+#include "core/rendering/style/GridResolvedPosition.h"
#include "wtf/HashMap.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/text/WTFString.h"
@@ -42,25 +42,25 @@ namespace WebCore {
// and |finalPositionIndex| are grid areas' indexes, NOT grid lines'. Iterating over the
// span should include both |initialPositionIndex| and |finalPositionIndex| to be correct.
struct GridSpan {
- static PassOwnPtr<GridSpan> create(size_t initialPosition, size_t finalPosition)
+ static PassOwnPtr<GridSpan> create(const GridResolvedPosition& initialPosition, const GridResolvedPosition& finalPosition)
{
return adoptPtr(new GridSpan(initialPosition, finalPosition));
}
- static PassOwnPtr<GridSpan> createWithSpanAgainstOpposite(size_t resolvedOppositePosition, const GridPosition& position, GridPositionSide side)
+ static PassOwnPtr<GridSpan> createWithSpanAgainstOpposite(const GridResolvedPosition& resolvedOppositePosition, const GridPosition& position, GridPositionSide side)
{
// '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.
size_t positionOffset = position.spanPosition() - 1;
if (side == ColumnStartSide || side == RowStartSide) {
- size_t initialResolvedPosition = std::max<int>(0, resolvedOppositePosition - positionOffset);
+ GridResolvedPosition initialResolvedPosition = GridResolvedPosition(std::max<int>(0, resolvedOppositePosition.integerPosition() - positionOffset));
return GridSpan::create(initialResolvedPosition, resolvedOppositePosition);
}
- return GridSpan::create(resolvedOppositePosition, resolvedOppositePosition + positionOffset);
+ return GridSpan::create(resolvedOppositePosition, GridResolvedPosition(resolvedOppositePosition.integerPosition() + positionOffset));
}
- static PassOwnPtr<GridSpan> createWithNamedSpanAgainstOpposite(size_t resolvedOppositePosition, const GridPosition& position, GridPositionSide side, const Vector<size_t>& gridLines)
+ static PassOwnPtr<GridSpan> createWithNamedSpanAgainstOpposite(const GridResolvedPosition& resolvedOppositePosition, const GridPosition& position, GridPositionSide side, const Vector<size_t>& gridLines)
{
if (side == RowStartSide || side == ColumnStartSide)
return createWithInitialNamedSpanAgainstOpposite(resolvedOppositePosition, position, gridLines);
@@ -68,37 +68,38 @@ struct GridSpan {
return createWithFinalNamedSpanAgainstOpposite(resolvedOppositePosition, position, gridLines);
}
- static PassOwnPtr<GridSpan> createWithInitialNamedSpanAgainstOpposite(size_t resolvedOppositePosition, const GridPosition& position, const Vector<size_t>& gridLines)
+ static PassOwnPtr<GridSpan> createWithInitialNamedSpanAgainstOpposite(const GridResolvedPosition& resolvedOppositePosition, const GridPosition& position, const Vector<size_t>& gridLines)
{
// The grid line inequality needs to be strict (which doesn't match the after / end case) because |resolvedOppositePosition|
// is already converted to an index in our grid representation (ie one was removed from the grid line to account for the side).
size_t firstLineBeforeOppositePositionIndex = 0;
- const size_t* firstLineBeforeOppositePosition = std::lower_bound(gridLines.begin(), gridLines.end(), resolvedOppositePosition);
+ const size_t* firstLineBeforeOppositePosition = std::lower_bound(gridLines.begin(), gridLines.end(), resolvedOppositePosition.integerPosition());
if (firstLineBeforeOppositePosition != gridLines.end())
firstLineBeforeOppositePositionIndex = firstLineBeforeOppositePosition - gridLines.begin();
size_t gridLineIndex = std::max<int>(0, firstLineBeforeOppositePositionIndex - position.spanPosition() + 1);
size_t resolvedGridLinePosition = gridLines[gridLineIndex];
- if (resolvedGridLinePosition > resolvedOppositePosition)
- resolvedGridLinePosition = resolvedOppositePosition;
- return GridSpan::create(resolvedGridLinePosition, resolvedOppositePosition);
+ if (resolvedGridLinePosition > resolvedOppositePosition.integerPosition())
+ resolvedGridLinePosition = resolvedOppositePosition.integerPosition();
+ return GridSpan::create(GridResolvedPosition(resolvedGridLinePosition), resolvedOppositePosition);
}
- static PassOwnPtr<GridSpan> createWithFinalNamedSpanAgainstOpposite(size_t resolvedOppositePosition, const GridPosition& position, const Vector<size_t>& gridLines)
+ static PassOwnPtr<GridSpan> createWithFinalNamedSpanAgainstOpposite(const GridResolvedPosition& resolvedOppositePosition, const GridPosition& position, const Vector<size_t>& gridLines)
{
size_t firstLineAfterOppositePositionIndex = gridLines.size() - 1;
- const size_t* firstLineAfterOppositePosition = std::upper_bound(gridLines.begin(), gridLines.end(), resolvedOppositePosition);
+ const size_t* firstLineAfterOppositePosition = std::upper_bound(gridLines.begin(), gridLines.end(), resolvedOppositePosition.integerPosition());
if (firstLineAfterOppositePosition != gridLines.end())
firstLineAfterOppositePositionIndex = firstLineAfterOppositePosition - gridLines.begin();
size_t gridLineIndex = std::min(gridLines.size() - 1, firstLineAfterOppositePositionIndex + position.spanPosition() - 1);
- size_t resolvedGridLinePosition = GridPosition::adjustGridPositionForAfterEndSide(gridLines[gridLineIndex]);
+ size_t resolvedGridLinePositionInteger = GridResolvedPosition::adjustGridPositionForAfterEndSide(gridLines[gridLineIndex]);
+ GridResolvedPosition resolvedGridLinePosition = GridResolvedPosition(resolvedGridLinePositionInteger);
if (resolvedGridLinePosition < resolvedOppositePosition)
- resolvedGridLinePosition = resolvedOppositePosition;
+ resolvedGridLinePosition.setIntegerPosition(resolvedOppositePosition.integerPosition());
return GridSpan::create(resolvedOppositePosition, resolvedGridLinePosition);
}
- GridSpan(size_t initialPosition, size_t finalPosition)
+ GridSpan(const GridResolvedPosition& initialPosition, const GridResolvedPosition& finalPosition)
: initialPositionIndex(initialPosition)
, finalPositionIndex(finalPosition)
{
@@ -110,8 +111,8 @@ struct GridSpan {
return initialPositionIndex == o.initialPositionIndex && finalPositionIndex == o.finalPositionIndex;
}
- size_t initialPositionIndex;
- size_t finalPositionIndex;
+ GridResolvedPosition initialPositionIndex;
+ GridResolvedPosition finalPositionIndex;
};
// This represents a grid area that spans in both rows' and columns' direction.
« no previous file with comments | « Source/core/rendering/RenderGrid.cpp ('k') | Source/core/rendering/style/GridPosition.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698