本文整理汇总了C++中GridPosition::type方法的典型用法代码示例。如果您正苦于以下问题:C++ GridPosition::type方法的具体用法?C++ GridPosition::type怎么用?C++ GridPosition::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridPosition
的用法示例。
在下文中一共展示了GridPosition::type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resolveGridPositionFromStyle
static int resolveGridPositionFromStyle(const RenderStyle& gridContainerStyle, const GridPosition& position, GridPositionSide side, unsigned autoRepeatTracksCount)
{
switch (position.type()) {
case ExplicitPosition: {
ASSERT(position.integerPosition());
if (!position.namedGridLine().isNull())
return resolveNamedGridLinePositionFromStyle(gridContainerStyle, position, side, autoRepeatTracksCount);
// Handle <integer> explicit position.
if (position.isPositive())
return position.integerPosition() - 1;
unsigned resolvedPosition = std::abs(position.integerPosition()) - 1;
const unsigned endOfTrack = explicitGridSizeForSide(gridContainerStyle, side, autoRepeatTracksCount);
return endOfTrack - resolvedPosition;
}
case NamedGridAreaPosition:
{
// First attempt to match the grid area's edge to a named grid area: if there is a named line with the name
// ''<custom-ident>-start (for grid-*-start) / <custom-ident>-end'' (for grid-*-end), contributes the first such
// line to the grid item's placement.
String namedGridLine = position.namedGridLine();
ASSERT(!position.namedGridLine().isNull());
unsigned lastLine = explicitGridSizeForSide(gridContainerStyle, side, autoRepeatTracksCount);
NamedLineCollection implicitLines(gridContainerStyle, implicitNamedGridLineForSide(namedGridLine, side), directionFromSide(side), lastLine, autoRepeatTracksCount);
if (implicitLines.hasNamedLines())
return implicitLines.firstPosition();
// Otherwise, if there is a named line with the specified name, contributes the first such line to the grid
// item's placement.
NamedLineCollection explicitLines(gridContainerStyle, namedGridLine, directionFromSide(side), lastLine, autoRepeatTracksCount);
if (explicitLines.hasNamedLines())
return explicitLines.firstPosition();
ASSERT(!NamedLineCollection::isValidNamedLineOrArea(namedGridLine, gridContainerStyle, side));
// If none of the above works specs mandate to assume that all the lines in the implicit grid have this name.
return lastLine + 1;
}
case AutoPosition:
case SpanPosition:
// 'auto' and span depend on the opposite position for resolution (e.g. grid-row: auto / 1 or grid-column: span 3 / "myHeader").
ASSERT_NOT_REACHED();
return 0;
}
ASSERT_NOT_REACHED();
return 0;
}
示例2: resolveGridPositionFromStyle
GridResolvedPosition GridResolvedPosition::resolveGridPositionFromStyle(const RenderStyle& gridContainerStyle, const GridPosition& position, GridPositionSide side)
{
switch (position.type()) {
case ExplicitPosition: {
ASSERT(position.integerPosition());
if (!position.namedGridLine().isNull())
return resolveNamedGridLinePositionFromStyle(gridContainerStyle, position, side);
// Handle <integer> explicit position.
if (position.isPositive())
return adjustGridPositionForSide(position.integerPosition() - 1, side);
size_t resolvedPosition = abs(position.integerPosition()) - 1;
const size_t endOfTrack = explicitGridSizeForSide(gridContainerStyle, side);
// Per http://lists.w3.org/Archives/Public/www-style/2013Mar/0589.html, we clamp negative value to the first line.
if (endOfTrack < resolvedPosition)
return GridResolvedPosition(0);
return adjustGridPositionForSide(endOfTrack - resolvedPosition, side);
}
case NamedGridAreaPosition:
{
NamedGridAreaMap::const_iterator it = gridContainerStyle.namedGridArea().find(position.namedGridLine());
// Unknown grid area should have been computed to 'auto' by now.
ASSERT_WITH_SECURITY_IMPLICATION(it != gridContainerStyle.namedGridArea().end());
const GridCoordinate& gridAreaCoordinate = it->value;
switch (side) {
case ColumnStartSide:
return gridAreaCoordinate.columns.resolvedInitialPosition;
case ColumnEndSide:
return gridAreaCoordinate.columns.resolvedFinalPosition;
case RowStartSide:
return gridAreaCoordinate.rows.resolvedInitialPosition;
case RowEndSide:
return GridResolvedPosition(gridAreaCoordinate.rows.resolvedFinalPosition);
}
ASSERT_NOT_REACHED();
return GridResolvedPosition(0);
}
case AutoPosition:
case SpanPosition:
// 'auto' and span depend on the opposite position for resolution (e.g. grid-row: auto / 1 or grid-column: span 3 / "myHeader").
ASSERT_NOT_REACHED();
return GridResolvedPosition(0);
}
ASSERT_NOT_REACHED();
return GridResolvedPosition(0);
}