static GridSpan resolveGridPositionAgainstOppositePosition(const RenderStyle& gridContainerStyle, int oppositeLine, const GridPosition& position, GridPositionSide side, unsigned autoRepeatTracksCount) { if (position.isAuto()) { if (isStartSide(side)) return GridSpan::untranslatedDefiniteGridSpan(oppositeLine - 1, oppositeLine); return GridSpan::untranslatedDefiniteGridSpan(oppositeLine, oppositeLine + 1); } ASSERT(position.isSpan()); ASSERT(position.spanPosition() > 0); if (!position.namedGridLine().isNull()) { // span 2 'c' -> we need to find the appropriate grid line before / after our opposite position. return resolveNamedGridLinePositionAgainstOppositePosition(gridContainerStyle, oppositeLine, position, side, autoRepeatTracksCount); } // '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(); if (isStartSide(side)) return GridSpan::untranslatedDefiniteGridSpan(oppositeLine - positionOffset, oppositeLine); return GridSpan::untranslatedDefiniteGridSpan(oppositeLine, oppositeLine + positionOffset); }
std::unique_ptr<GridSpan> GridResolvedPosition::resolveGridPositionAgainstOppositePosition(const RenderStyle& gridContainerStyle, const GridResolvedPosition& resolvedOppositePosition, const GridPosition& position, GridPositionSide side) { if (position.isAuto()) return std::make_unique<GridSpan>(resolvedOppositePosition, resolvedOppositePosition); ASSERT(position.isSpan()); ASSERT(position.spanPosition() > 0); if (!position.namedGridLine().isNull()) { // span 2 'c' -> we need to find the appropriate grid line before / after our opposite position. return resolveNamedGridLinePositionAgainstOppositePosition(gridContainerStyle, resolvedOppositePosition, position, 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 (isStartSide(side)) { size_t initialResolvedPosition = std::max<int>(0, resolvedOppositePosition.toInt() - positionOffset); return std::make_unique<GridSpan>(initialResolvedPosition, resolvedOppositePosition); } return std::make_unique<GridSpan>(resolvedOppositePosition, resolvedOppositePosition.toInt() + positionOffset); }
static const String implicitNamedGridLineForSide(const String& lineName, GridPositionSide side) { return lineName + (isStartSide(side) ? "-start" : "-end"); }