| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/style/GridResolvedPosition.h" | 5 #include "core/style/GridResolvedPosition.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutBox.h" | 7 #include "core/layout/LayoutBox.h" |
| 8 #include "core/style/GridCoordinate.h" | 8 #include "core/style/GridCoordinate.h" |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 static void initialAndFinalPositionsFromStyle(const ComputedStyle& gridContainer
Style, const LayoutBox& gridItem, GridTrackSizingDirection direction, GridPositi
on& initialPosition, GridPosition& finalPosition) | 40 static void initialAndFinalPositionsFromStyle(const ComputedStyle& gridContainer
Style, const LayoutBox& gridItem, GridTrackSizingDirection direction, GridPositi
on& initialPosition, GridPosition& finalPosition) |
| 41 { | 41 { |
| 42 initialPosition = (direction == ForColumns) ? gridItem.style()->gridColumnSt
art() : gridItem.style()->gridRowStart(); | 42 initialPosition = (direction == ForColumns) ? gridItem.style()->gridColumnSt
art() : gridItem.style()->gridRowStart(); |
| 43 finalPosition = (direction == ForColumns) ? gridItem.style()->gridColumnEnd(
) : gridItem.style()->gridRowEnd(); | 43 finalPosition = (direction == ForColumns) ? gridItem.style()->gridColumnEnd(
) : gridItem.style()->gridRowEnd(); |
| 44 | 44 |
| 45 // We must handle the placement error handling code here instead of in the S
tyleAdjuster because we don't want to | 45 // We must handle the placement error handling code here instead of in the S
tyleAdjuster because we don't want to |
| 46 // overwrite the specified values. | 46 // overwrite the specified values. |
| 47 if (initialPosition.isSpan() && finalPosition.isSpan()) | 47 if (initialPosition.isSpan() && finalPosition.isSpan()) |
| 48 finalPosition.setAutoPosition(); | 48 finalPosition.setAutoPosition(); |
| 49 | 49 |
| 50 // Try to early detect the case of non existing named grid lines. This way w
e could assume later that | 50 if (gridItem.isOutOfFlowPositioned()) { |
| 51 // GridResolvedPosition::resolveGrisPositionFromStyle() always return a vali
d resolved position. | 51 // Early detect the case of non existing named grid lines for positioned
items. |
| 52 if (initialPosition.isNamedGridArea() && !GridResolvedPosition::isValidNamed
LineOrArea(initialPosition.namedGridLine(), gridContainerStyle, GridResolvedPosi
tion::initialPositionSide(direction))) | 52 if (initialPosition.isNamedGridArea() && !GridResolvedPosition::isValidN
amedLineOrArea(initialPosition.namedGridLine(), gridContainerStyle, GridResolved
Position::initialPositionSide(direction))) |
| 53 initialPosition.setAutoPosition(); | 53 initialPosition.setAutoPosition(); |
| 54 | 54 |
| 55 if (finalPosition.isNamedGridArea() && !GridResolvedPosition::isValidNamedLi
neOrArea(finalPosition.namedGridLine(), gridContainerStyle, GridResolvedPosition
::finalPositionSide(direction))) | 55 if (finalPosition.isNamedGridArea() && !GridResolvedPosition::isValidNam
edLineOrArea(finalPosition.namedGridLine(), gridContainerStyle, GridResolvedPosi
tion::finalPositionSide(direction))) |
| 56 finalPosition.setAutoPosition(); | 56 finalPosition.setAutoPosition(); |
| 57 } |
| 57 | 58 |
| 58 // If the grid item has an automatic position and a grid span for a named li
ne in a given dimension, instead treat the grid span as one. | 59 // If the grid item has an automatic position and a grid span for a named li
ne in a given dimension, instead treat the grid span as one. |
| 59 if (initialPosition.isAuto() && finalPosition.isSpan() && !finalPosition.nam
edGridLine().isNull()) | 60 if (initialPosition.isAuto() && finalPosition.isSpan() && !finalPosition.nam
edGridLine().isNull()) |
| 60 finalPosition.setSpanPosition(1, String()); | 61 finalPosition.setSpanPosition(1, String()); |
| 61 if (finalPosition.isAuto() && initialPosition.isSpan() && !initialPosition.n
amedGridLine().isNull()) | 62 if (finalPosition.isAuto() && initialPosition.isSpan() && !initialPosition.n
amedGridLine().isNull()) |
| 62 initialPosition.setSpanPosition(1, String()); | 63 initialPosition.setSpanPosition(1, String()); |
| 63 } | 64 } |
| 64 | 65 |
| 65 static GridSpan definiteGridSpanWithInitialNamedSpanAgainstOpposite(size_t resol
vedOppositePosition, const GridPosition& position, const Vector<size_t>& gridLin
es) | 66 static size_t lookAheadForNamedGridLine(int start, size_t numberOfLines, const V
ector<size_t>* namedGridLinesIndexes, size_t gridLastLine) |
| 66 { | 67 { |
| 67 if (resolvedOppositePosition == 0) | 68 ASSERT(numberOfLines); |
| 68 return GridSpan::untranslatedDefiniteGridSpan(resolvedOppositePosition,
resolvedOppositePosition + 1); | |
| 69 | 69 |
| 70 size_t firstLineBeforeOppositePositionIndex = 0; | 70 // Only implicit lines on the search direction are assumed to have the given
name, so we can start to look from first line. |
| 71 const size_t* firstLineBeforeOppositePosition = std::lower_bound(gridLines.b
egin(), gridLines.end(), resolvedOppositePosition); | 71 // See: https://drafts.csswg.org/css-grid/#grid-placement-span-int |
| 72 if (firstLineBeforeOppositePosition != gridLines.end()) | 72 size_t end = std::max(start, 0); |
| 73 firstLineBeforeOppositePositionIndex = firstLineBeforeOppositePosition -
gridLines.begin(); | 73 |
| 74 size_t gridLineIndex = std::max<int>(0, firstLineBeforeOppositePositionIndex
- position.spanPosition()); | 74 if (!namedGridLinesIndexes) { |
| 75 size_t resolvedGridLinePosition = gridLines[gridLineIndex]; | 75 end = std::max(end, gridLastLine + 1); |
| 76 if (resolvedGridLinePosition >= resolvedOppositePosition) | 76 return end + numberOfLines - 1; |
| 77 resolvedGridLinePosition = resolvedOppositePosition - 1; | 77 } |
| 78 return GridSpan::untranslatedDefiniteGridSpan(resolvedGridLinePosition, reso
lvedOppositePosition); | 78 |
| 79 for (; numberOfLines; ++end) { |
| 80 if (end > gridLastLine || namedGridLinesIndexes->contains(end)) |
| 81 numberOfLines--; |
| 82 } |
| 83 |
| 84 ASSERT(end); |
| 85 return end - 1; |
| 79 } | 86 } |
| 80 | 87 |
| 81 static GridSpan definiteGridSpanWithFinalNamedSpanAgainstOpposite(size_t resolve
dOppositePosition, const GridPosition& position, const Vector<size_t>& gridLines
) | 88 static int lookBackForNamedGridLine(int end, size_t numberOfLines, const Vector<
size_t>* namedGridLinesIndexes, int gridLastLine) |
| 82 { | 89 { |
| 83 ASSERT(gridLines.size()); | 90 ASSERT(numberOfLines); |
| 84 size_t firstLineAfterOppositePositionIndex = gridLines.size() - 1; | |
| 85 const size_t* firstLineAfterOppositePosition = std::upper_bound(gridLines.be
gin(), gridLines.end(), resolvedOppositePosition); | |
| 86 if (firstLineAfterOppositePosition != gridLines.end()) | |
| 87 firstLineAfterOppositePositionIndex = firstLineAfterOppositePosition - g
ridLines.begin(); | |
| 88 size_t gridLineIndex = std::min(gridLines.size() - 1, firstLineAfterOpposite
PositionIndex + position.spanPosition() - 1); | |
| 89 size_t resolvedGridLinePosition = gridLines[gridLineIndex]; | |
| 90 if (resolvedGridLinePosition <= resolvedOppositePosition) | |
| 91 resolvedGridLinePosition = resolvedOppositePosition + 1; | |
| 92 | 91 |
| 93 return GridSpan::untranslatedDefiniteGridSpan(resolvedOppositePosition, reso
lvedGridLinePosition); | 92 // Only implicit lines on the search direction are assumed to have the given
name, so we can start to look from last line. |
| 93 // See: https://drafts.csswg.org/css-grid/#grid-placement-span-int |
| 94 int start = std::min(end, gridLastLine); |
| 95 |
| 96 if (!namedGridLinesIndexes) { |
| 97 start = std::min(start, -1); |
| 98 return start - numberOfLines + 1; |
| 99 } |
| 100 |
| 101 for (; numberOfLines; --start) { |
| 102 if (start < 0 || namedGridLinesIndexes->contains(static_cast<size_t>(sta
rt))) |
| 103 numberOfLines--; |
| 104 } |
| 105 |
| 106 return start + 1; |
| 94 } | 107 } |
| 95 | 108 |
| 96 static GridSpan definiteGridSpanWithNamedSpanAgainstOpposite(size_t resolvedOppo
sitePosition, const GridPosition& position, GridPositionSide side, const Vector<
size_t>& gridLines) | 109 static GridSpan definiteGridSpanWithNamedSpanAgainstOpposite(int resolvedOpposit
ePosition, const GridPosition& position, GridPositionSide side, const Vector<siz
e_t>* gridLines, int lastLine) |
| 97 { | 110 { |
| 98 if (side == RowStartSide || side == ColumnStartSide) | 111 int start, end; |
| 99 return definiteGridSpanWithInitialNamedSpanAgainstOpposite(resolvedOppos
itePosition, position, gridLines); | |
| 100 | 112 |
| 101 return definiteGridSpanWithFinalNamedSpanAgainstOpposite(resolvedOppositePos
ition, position, gridLines); | 113 if (side == RowStartSide || side == ColumnStartSide) { |
| 114 start = lookBackForNamedGridLine(resolvedOppositePosition - 1, position.
spanPosition(), gridLines, lastLine); |
| 115 end = resolvedOppositePosition; |
| 116 } else { |
| 117 start = resolvedOppositePosition; |
| 118 end = lookAheadForNamedGridLine(resolvedOppositePosition + 1, position.s
panPosition(), gridLines, lastLine); |
| 119 } |
| 120 |
| 121 return GridSpan::untranslatedDefiniteGridSpan(start, end); |
| 102 } | 122 } |
| 103 | 123 |
| 104 static GridSpan resolveNamedGridLinePositionAgainstOppositePosition(const Comput
edStyle& gridContainerStyle, size_t resolvedOppositePosition, const GridPosition
& position, GridPositionSide side) | 124 size_t GridResolvedPosition::explicitGridColumnCount(const ComputedStyle& gridCo
ntainerStyle) |
| 125 { |
| 126 return std::min<size_t>(gridContainerStyle.gridTemplateColumns().size(), kGr
idMaxTracks); |
| 127 } |
| 128 |
| 129 size_t GridResolvedPosition::explicitGridRowCount(const ComputedStyle& gridConta
inerStyle) |
| 130 { |
| 131 return std::min<size_t>(gridContainerStyle.gridTemplateRows().size(), kGridM
axTracks); |
| 132 } |
| 133 |
| 134 static size_t explicitGridSizeForSide(const ComputedStyle& gridContainerStyle, G
ridPositionSide side) |
| 135 { |
| 136 return (side == ColumnStartSide || side == ColumnEndSide) ? GridResolvedPosi
tion::explicitGridColumnCount(gridContainerStyle) : GridResolvedPosition::explic
itGridRowCount(gridContainerStyle); |
| 137 } |
| 138 |
| 139 static GridSpan resolveNamedGridLinePositionAgainstOppositePosition(const Comput
edStyle& gridContainerStyle, int resolvedOppositePosition, const GridPosition& p
osition, GridPositionSide side) |
| 105 { | 140 { |
| 106 ASSERT(position.isSpan()); | 141 ASSERT(position.isSpan()); |
| 107 ASSERT(!position.namedGridLine().isNull()); | 142 ASSERT(!position.namedGridLine().isNull()); |
| 108 // Negative positions are not allowed per the specification and should have
been handled during parsing. | 143 // Negative positions are not allowed per the specification and should have
been handled during parsing. |
| 109 ASSERT(position.spanPosition() > 0); | 144 ASSERT(position.spanPosition() > 0); |
| 110 | 145 |
| 111 const NamedGridLinesMap& gridLinesNames = gridLinesForSide(gridContainerStyl
e, side); | 146 const NamedGridLinesMap& gridLinesNames = gridLinesForSide(gridContainerStyl
e, side); |
| 112 NamedGridLinesMap::const_iterator it = gridLinesNames.find(position.namedGri
dLine()); | 147 NamedGridLinesMap::const_iterator it = gridLinesNames.find(position.namedGri
dLine()); |
| 113 | 148 const Vector<size_t>* gridLines = it == gridLinesNames.end() ? nullptr : &it
->value; |
| 114 // 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). | 149 size_t lastLine = explicitGridSizeForSide(gridContainerStyle, side); |
| 115 // See http://lists.w3.org/Archives/Public/www-style/2013Jun/0394.html. | 150 return definiteGridSpanWithNamedSpanAgainstOpposite(resolvedOppositePosition
, position, side, gridLines, lastLine); |
| 116 if (it == gridLinesNames.end()) { | |
| 117 if ((side == ColumnStartSide || side == RowStartSide) && resolvedOpposit
ePosition) | |
| 118 return GridSpan::untranslatedDefiniteGridSpan(resolvedOppositePositi
on - 1, resolvedOppositePosition); | |
| 119 return GridSpan::untranslatedDefiniteGridSpan(resolvedOppositePosition,
resolvedOppositePosition + 1); | |
| 120 } | |
| 121 | |
| 122 return definiteGridSpanWithNamedSpanAgainstOpposite(resolvedOppositePosition
, position, side, it->value); | |
| 123 } | 151 } |
| 124 | 152 |
| 125 static GridSpan definiteGridSpanWithSpanAgainstOpposite(size_t resolvedOppositeP
osition, const GridPosition& position, GridPositionSide side) | 153 static GridSpan definiteGridSpanWithSpanAgainstOpposite(size_t resolvedOppositeP
osition, const GridPosition& position, GridPositionSide side) |
| 126 { | 154 { |
| 127 size_t positionOffset = position.spanPosition(); | 155 size_t positionOffset = position.spanPosition(); |
| 128 if (side == ColumnStartSide || side == RowStartSide) | 156 if (side == ColumnStartSide || side == RowStartSide) |
| 129 return GridSpan::untranslatedDefiniteGridSpan(resolvedOppositePosition -
positionOffset, resolvedOppositePosition); | 157 return GridSpan::untranslatedDefiniteGridSpan(resolvedOppositePosition -
positionOffset, resolvedOppositePosition); |
| 130 | 158 |
| 131 return GridSpan::untranslatedDefiniteGridSpan(resolvedOppositePosition, reso
lvedOppositePosition + positionOffset); | 159 return GridSpan::untranslatedDefiniteGridSpan(resolvedOppositePosition, reso
lvedOppositePosition + positionOffset); |
| 132 } | 160 } |
| 133 | 161 |
| 134 static GridSpan resolveGridPositionAgainstOppositePosition(const ComputedStyle&
gridContainerStyle, size_t resolvedOppositePosition, const GridPosition& positio
n, GridPositionSide side) | 162 static GridSpan resolveGridPositionAgainstOppositePosition(const ComputedStyle&
gridContainerStyle, int resolvedOppositePosition, const GridPosition& position,
GridPositionSide side) |
| 135 { | 163 { |
| 136 if (position.isAuto()) { | 164 if (position.isAuto()) { |
| 137 if (side == ColumnStartSide || side == RowStartSide) | 165 if (side == ColumnStartSide || side == RowStartSide) |
| 138 return GridSpan::untranslatedDefiniteGridSpan(resolvedOppositePositi
on - 1, resolvedOppositePosition); | 166 return GridSpan::untranslatedDefiniteGridSpan(resolvedOppositePositi
on - 1, resolvedOppositePosition); |
| 139 return GridSpan::untranslatedDefiniteGridSpan(resolvedOppositePosition,
resolvedOppositePosition + 1); | 167 return GridSpan::untranslatedDefiniteGridSpan(resolvedOppositePosition,
resolvedOppositePosition + 1); |
| 140 } | 168 } |
| 141 | 169 |
| 142 ASSERT(position.isSpan()); | 170 ASSERT(position.isSpan()); |
| 143 ASSERT(position.spanPosition() > 0); | 171 ASSERT(position.spanPosition() > 0); |
| 144 | 172 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 160 | 188 |
| 161 if (initialPosition.isAuto() && finalPosition.isAuto()) | 189 if (initialPosition.isAuto() && finalPosition.isAuto()) |
| 162 return 1; | 190 return 1; |
| 163 | 191 |
| 164 GridPosition position = initialPosition.isSpan() ? initialPosition : finalPo
sition; | 192 GridPosition position = initialPosition.isSpan() ? initialPosition : finalPo
sition; |
| 165 ASSERT(position.isSpan()); | 193 ASSERT(position.isSpan()); |
| 166 ASSERT(position.spanPosition()); | 194 ASSERT(position.spanPosition()); |
| 167 return position.spanPosition(); | 195 return position.spanPosition(); |
| 168 } | 196 } |
| 169 | 197 |
| 170 size_t GridResolvedPosition::explicitGridColumnCount(const ComputedStyle& gridCo
ntainerStyle) | 198 static int resolveNamedGridLinePositionFromStyle(const ComputedStyle& gridContai
nerStyle, const GridPosition& position, GridPositionSide side) |
| 171 { | |
| 172 return std::min<size_t>(gridContainerStyle.gridTemplateColumns().size(), kGr
idMaxTracks); | |
| 173 } | |
| 174 | |
| 175 size_t GridResolvedPosition::explicitGridRowCount(const ComputedStyle& gridConta
inerStyle) | |
| 176 { | |
| 177 return std::min<size_t>(gridContainerStyle.gridTemplateRows().size(), kGridM
axTracks); | |
| 178 } | |
| 179 | |
| 180 static size_t explicitGridSizeForSide(const ComputedStyle& gridContainerStyle, G
ridPositionSide side) | |
| 181 { | |
| 182 return (side == ColumnStartSide || side == ColumnEndSide) ? GridResolvedPosi
tion::explicitGridColumnCount(gridContainerStyle) : GridResolvedPosition::explic
itGridRowCount(gridContainerStyle); | |
| 183 } | |
| 184 | |
| 185 static size_t resolveNamedGridLinePositionFromStyle(const ComputedStyle& gridCon
tainerStyle, const GridPosition& position, GridPositionSide side) | |
| 186 { | 199 { |
| 187 ASSERT(!position.namedGridLine().isNull()); | 200 ASSERT(!position.namedGridLine().isNull()); |
| 188 | 201 |
| 189 const NamedGridLinesMap& gridLinesNames = gridLinesForSide(gridContainerStyl
e, side); | 202 const NamedGridLinesMap& gridLinesNames = gridLinesForSide(gridContainerStyl
e, side); |
| 190 NamedGridLinesMap::const_iterator it = gridLinesNames.find(position.namedGri
dLine()); | 203 NamedGridLinesMap::const_iterator it = gridLinesNames.find(position.namedGri
dLine()); |
| 191 if (it == gridLinesNames.end()) { | 204 const Vector<size_t>* gridLines = it == gridLinesNames.end() ? nullptr : &it
->value; |
| 192 if (position.isPositive()) | 205 size_t lastLine = explicitGridSizeForSide(gridContainerStyle, side); |
| 193 return 0; | |
| 194 size_t lastLine = explicitGridSizeForSide(gridContainerStyle, side); | |
| 195 return lastLine; | |
| 196 } | |
| 197 | |
| 198 size_t namedGridLineIndex; | |
| 199 if (position.isPositive()) | 206 if (position.isPositive()) |
| 200 namedGridLineIndex = std::min<size_t>(position.integerPosition(), it->va
lue.size()) - 1; | 207 return lookAheadForNamedGridLine(0, abs(position.integerPosition()), gri
dLines, lastLine); |
| 201 else | 208 else |
| 202 namedGridLineIndex = std::max<int>(it->value.size() - abs(position.integ
erPosition()), 0); | 209 return lookBackForNamedGridLine(lastLine, abs(position.integerPosition()
), gridLines, lastLine); |
| 203 return it->value[namedGridLineIndex]; | |
| 204 } | 210 } |
| 205 | 211 |
| 206 static int resolveGridPositionFromStyle(const ComputedStyle& gridContainerStyle,
const GridPosition& position, GridPositionSide side) | 212 static int resolveGridPositionFromStyle(const ComputedStyle& gridContainerStyle,
const GridPosition& position, GridPositionSide side) |
| 207 { | 213 { |
| 208 switch (position.type()) { | 214 switch (position.type()) { |
| 209 case ExplicitPosition: { | 215 case ExplicitPosition: { |
| 210 ASSERT(position.integerPosition()); | 216 ASSERT(position.integerPosition()); |
| 211 | 217 |
| 212 if (!position.namedGridLine().isNull()) | 218 if (!position.namedGridLine().isNull()) |
| 213 return resolveNamedGridLinePositionFromStyle(gridContainerStyle, pos
ition, side); | 219 return resolveNamedGridLinePositionFromStyle(gridContainerStyle, pos
ition, side); |
| 214 | 220 |
| 215 // Handle <integer> explicit position. | 221 // Handle <integer> explicit position. |
| 216 if (position.isPositive()) | 222 if (position.isPositive()) |
| 217 return position.integerPosition() - 1; | 223 return position.integerPosition() - 1; |
| 218 | 224 |
| 219 size_t resolvedPosition = abs(position.integerPosition()) - 1; | 225 size_t resolvedPosition = abs(position.integerPosition()) - 1; |
| 220 size_t endOfTrack = explicitGridSizeForSide(gridContainerStyle, side); | 226 size_t endOfTrack = explicitGridSizeForSide(gridContainerStyle, side); |
| 221 | 227 |
| 222 return endOfTrack - resolvedPosition; | 228 return endOfTrack - resolvedPosition; |
| 223 } | 229 } |
| 224 case NamedGridAreaPosition: | 230 case NamedGridAreaPosition: |
| 225 { | 231 { |
| 226 // First attempt to match the grid area's edge to a named grid area: if
there is a named line with the name | 232 // First attempt to match the grid area's edge to a named grid area: if
there is a named line with the name |
| 227 // ''<custom-ident>-start (for grid-*-start) / <custom-ident>-end'' (for
grid-*-end), contributes the first such | 233 // ''<custom-ident>-start (for grid-*-start) / <custom-ident>-end'' (for
grid-*-end), contributes the first such |
| 228 // line to the grid item's placement. | 234 // line to the grid item's placement. |
| 229 String namedGridLine = position.namedGridLine(); | 235 String namedGridLine = position.namedGridLine(); |
| 230 ASSERT(GridResolvedPosition::isValidNamedLineOrArea(namedGridLine, gridC
ontainerStyle, side)); | 236 ASSERT(!position.namedGridLine().isNull()); |
| 231 | 237 |
| 232 const NamedGridLinesMap& gridLineNames = gridLinesForSide(gridContainerS
tyle, side); | 238 const NamedGridLinesMap& gridLineNames = gridLinesForSide(gridContainerS
tyle, side); |
| 233 NamedGridLinesMap::const_iterator implicitLineIter = gridLineNames.find(
implicitNamedGridLineForSide(namedGridLine, side)); | 239 NamedGridLinesMap::const_iterator implicitLineIter = gridLineNames.find(
implicitNamedGridLineForSide(namedGridLine, side)); |
| 234 if (implicitLineIter != gridLineNames.end()) | 240 if (implicitLineIter != gridLineNames.end()) |
| 235 return implicitLineIter->value[0]; | 241 return implicitLineIter->value[0]; |
| 236 | 242 |
| 237 // Otherwise, if there is a named line with the specified name, contribu
tes the first such line to the grid | 243 // Otherwise, if there is a named line with the specified name, contribu
tes the first such line to the grid |
| 238 // item's placement. | 244 // item's placement. |
| 239 NamedGridLinesMap::const_iterator explicitLineIter = gridLineNames.find(
namedGridLine); | 245 NamedGridLinesMap::const_iterator explicitLineIter = gridLineNames.find(
namedGridLine); |
| 240 if (explicitLineIter != gridLineNames.end()) | 246 if (explicitLineIter != gridLineNames.end()) |
| 241 return explicitLineIter->value[0]; | 247 return explicitLineIter->value[0]; |
| 242 | 248 |
| 243 // If none of the above works specs mandate us to treat it as auto BUT w
e should have detected it before calling | 249 ASSERT(!GridResolvedPosition::isValidNamedLineOrArea(namedGridLine, grid
ContainerStyle, side)); |
| 244 // this function in GridResolvedPosition::resolveGridPositionsFromStyle(
). We should be also covered by the | 250 // If none of the above works specs mandate to assume that all the lines
in the implicit grid have this name. |
| 245 // ASSERT at the beginning of this block. | 251 size_t lastLine = explicitGridSizeForSide(gridContainerStyle, side); |
| 246 ASSERT_NOT_REACHED(); | 252 return lastLine + 1; |
| 247 return 0; | |
| 248 } | 253 } |
| 249 case AutoPosition: | 254 case AutoPosition: |
| 250 case SpanPosition: | 255 case SpanPosition: |
| 251 // 'auto' and span depend on the opposite position for resolution (e.g.
grid-row: auto / 1 or grid-column: span 3 / "myHeader"). | 256 // 'auto' and span depend on the opposite position for resolution (e.g.
grid-row: auto / 1 or grid-column: span 3 / "myHeader"). |
| 252 ASSERT_NOT_REACHED(); | 257 ASSERT_NOT_REACHED(); |
| 253 return 0; | 258 return 0; |
| 254 } | 259 } |
| 255 ASSERT_NOT_REACHED(); | 260 ASSERT_NOT_REACHED(); |
| 256 return 0; | 261 return 0; |
| 257 } | 262 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 286 | 291 |
| 287 if (resolvedFinalPosition < resolvedInitialPosition) | 292 if (resolvedFinalPosition < resolvedInitialPosition) |
| 288 std::swap(resolvedFinalPosition, resolvedInitialPosition); | 293 std::swap(resolvedFinalPosition, resolvedInitialPosition); |
| 289 else if (resolvedFinalPosition == resolvedInitialPosition) | 294 else if (resolvedFinalPosition == resolvedInitialPosition) |
| 290 resolvedFinalPosition = resolvedInitialPosition + 1; | 295 resolvedFinalPosition = resolvedInitialPosition + 1; |
| 291 | 296 |
| 292 return GridSpan::untranslatedDefiniteGridSpan(resolvedInitialPosition, resol
vedFinalPosition); | 297 return GridSpan::untranslatedDefiniteGridSpan(resolvedInitialPosition, resol
vedFinalPosition); |
| 293 } | 298 } |
| 294 | 299 |
| 295 } // namespace blink | 300 } // namespace blink |
| OLD | NEW |