| 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 "GridPositionsResolver.h" | 5 #include "GridPositionsResolver.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutBox.h" | 7 #include "core/layout/LayoutBox.h" |
| 8 #include "core/style/GridArea.h" | 8 #include "core/style/GridArea.h" |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 if (!m_autoRepeatNamedLinesIndexes || line < m_insertionPoint) | 90 if (!m_autoRepeatNamedLinesIndexes || line < m_insertionPoint) |
| 91 return m_namedLinesIndexes ? m_namedLinesIndexes->find(line) : kNotFound; | 91 return m_namedLinesIndexes ? m_namedLinesIndexes->find(line) : kNotFound; |
| 92 | 92 |
| 93 if (line <= (m_insertionPoint + m_autoRepeatTotalTracks)) { | 93 if (line <= (m_insertionPoint + m_autoRepeatTotalTracks)) { |
| 94 size_t localIndex = line - m_insertionPoint; | 94 size_t localIndex = line - m_insertionPoint; |
| 95 | 95 |
| 96 size_t indexInFirstRepetition = localIndex % m_autoRepeatTrackListLength; | 96 size_t indexInFirstRepetition = localIndex % m_autoRepeatTrackListLength; |
| 97 if (indexInFirstRepetition) | 97 if (indexInFirstRepetition) |
| 98 return m_autoRepeatNamedLinesIndexes->find(indexInFirstRepetition); | 98 return m_autoRepeatNamedLinesIndexes->find(indexInFirstRepetition); |
| 99 | 99 |
| 100 // The line names defined in the last line are also present in the first lin
e of the next | 100 // The line names defined in the last line are also present in the first |
| 101 // repetition (if any). Same for the line names defined in the first line. | 101 // line of the next repetition (if any). Same for the line names defined in |
| 102 // the first line. |
| 102 if (localIndex == m_autoRepeatTotalTracks) | 103 if (localIndex == m_autoRepeatTotalTracks) |
| 103 return m_autoRepeatNamedLinesIndexes->find(m_autoRepeatTrackListLength); | 104 return m_autoRepeatNamedLinesIndexes->find(m_autoRepeatTrackListLength); |
| 104 size_t position = | 105 size_t position = |
| 105 m_autoRepeatNamedLinesIndexes->find(static_cast<size_t>(0)); | 106 m_autoRepeatNamedLinesIndexes->find(static_cast<size_t>(0)); |
| 106 if (position != kNotFound) | 107 if (position != kNotFound) |
| 107 return position; | 108 return position; |
| 108 return localIndex == 0 ? kNotFound | 109 return localIndex == 0 ? kNotFound |
| 109 : m_autoRepeatNamedLinesIndexes->find( | 110 : m_autoRepeatNamedLinesIndexes->find( |
| 110 m_autoRepeatTrackListLength); | 111 m_autoRepeatTrackListLength); |
| 111 } | 112 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 const LayoutBox& gridItem, | 162 const LayoutBox& gridItem, |
| 162 GridTrackSizingDirection direction, | 163 GridTrackSizingDirection direction, |
| 163 GridPosition& initialPosition, | 164 GridPosition& initialPosition, |
| 164 GridPosition& finalPosition) { | 165 GridPosition& finalPosition) { |
| 165 initialPosition = (direction == ForColumns) | 166 initialPosition = (direction == ForColumns) |
| 166 ? gridItem.style()->gridColumnStart() | 167 ? gridItem.style()->gridColumnStart() |
| 167 : gridItem.style()->gridRowStart(); | 168 : gridItem.style()->gridRowStart(); |
| 168 finalPosition = (direction == ForColumns) ? gridItem.style()->gridColumnEnd() | 169 finalPosition = (direction == ForColumns) ? gridItem.style()->gridColumnEnd() |
| 169 : gridItem.style()->gridRowEnd(); | 170 : gridItem.style()->gridRowEnd(); |
| 170 | 171 |
| 171 // We must handle the placement error handling code here instead of in the Sty
leAdjuster because we don't want to | 172 // We must handle the placement error handling code here instead of in the |
| 172 // overwrite the specified values. | 173 // StyleAdjuster because we don't want to overwrite the specified values. |
| 173 if (initialPosition.isSpan() && finalPosition.isSpan()) | 174 if (initialPosition.isSpan() && finalPosition.isSpan()) |
| 174 finalPosition.setAutoPosition(); | 175 finalPosition.setAutoPosition(); |
| 175 | 176 |
| 176 if (gridItem.isOutOfFlowPositioned()) { | 177 if (gridItem.isOutOfFlowPositioned()) { |
| 177 // Early detect the case of non existing named grid lines for positioned ite
ms. | 178 // Early detect the case of non existing named grid lines for positioned |
| 179 // items. |
| 178 if (initialPosition.isNamedGridArea() && | 180 if (initialPosition.isNamedGridArea() && |
| 179 !NamedLineCollection::isValidNamedLineOrArea( | 181 !NamedLineCollection::isValidNamedLineOrArea( |
| 180 initialPosition.namedGridLine(), gridContainerStyle, | 182 initialPosition.namedGridLine(), gridContainerStyle, |
| 181 GridPositionsResolver::initialPositionSide(direction))) | 183 GridPositionsResolver::initialPositionSide(direction))) |
| 182 initialPosition.setAutoPosition(); | 184 initialPosition.setAutoPosition(); |
| 183 | 185 |
| 184 if (finalPosition.isNamedGridArea() && | 186 if (finalPosition.isNamedGridArea() && |
| 185 !NamedLineCollection::isValidNamedLineOrArea( | 187 !NamedLineCollection::isValidNamedLineOrArea( |
| 186 finalPosition.namedGridLine(), gridContainerStyle, | 188 finalPosition.namedGridLine(), gridContainerStyle, |
| 187 GridPositionsResolver::finalPositionSide(direction))) | 189 GridPositionsResolver::finalPositionSide(direction))) |
| 188 finalPosition.setAutoPosition(); | 190 finalPosition.setAutoPosition(); |
| 189 } | 191 } |
| 190 | 192 |
| 191 // If the grid item has an automatic position and a grid span for a named line
in a given dimension, instead treat the grid span as one. | 193 // If the grid item has an automatic position and a grid span for a named line |
| 194 // in a given dimension, instead treat the grid span as one. |
| 192 if (initialPosition.isAuto() && finalPosition.isSpan() && | 195 if (initialPosition.isAuto() && finalPosition.isSpan() && |
| 193 !finalPosition.namedGridLine().isNull()) | 196 !finalPosition.namedGridLine().isNull()) |
| 194 finalPosition.setSpanPosition(1, nullAtom); | 197 finalPosition.setSpanPosition(1, nullAtom); |
| 195 if (finalPosition.isAuto() && initialPosition.isSpan() && | 198 if (finalPosition.isAuto() && initialPosition.isSpan() && |
| 196 !initialPosition.namedGridLine().isNull()) | 199 !initialPosition.namedGridLine().isNull()) |
| 197 initialPosition.setSpanPosition(1, nullAtom); | 200 initialPosition.setSpanPosition(1, nullAtom); |
| 198 } | 201 } |
| 199 | 202 |
| 200 static size_t lookAheadForNamedGridLine(int start, | 203 static size_t lookAheadForNamedGridLine(int start, |
| 201 size_t numberOfLines, | 204 size_t numberOfLines, |
| 202 size_t gridLastLine, | 205 size_t gridLastLine, |
| 203 NamedLineCollection& linesCollection) { | 206 NamedLineCollection& linesCollection) { |
| 204 ASSERT(numberOfLines); | 207 ASSERT(numberOfLines); |
| 205 | 208 |
| 206 // Only implicit lines on the search direction are assumed to have the given n
ame, so we can start to look from first line. | 209 // Only implicit lines on the search direction are assumed to have the given |
| 210 // name, so we can start to look from first line. |
| 207 // See: https://drafts.csswg.org/css-grid/#grid-placement-span-int | 211 // See: https://drafts.csswg.org/css-grid/#grid-placement-span-int |
| 208 size_t end = std::max(start, 0); | 212 size_t end = std::max(start, 0); |
| 209 | 213 |
| 210 if (!linesCollection.hasNamedLines()) { | 214 if (!linesCollection.hasNamedLines()) { |
| 211 end = std::max(end, gridLastLine + 1); | 215 end = std::max(end, gridLastLine + 1); |
| 212 return end + numberOfLines - 1; | 216 return end + numberOfLines - 1; |
| 213 } | 217 } |
| 214 | 218 |
| 215 for (; numberOfLines; ++end) { | 219 for (; numberOfLines; ++end) { |
| 216 if (end > gridLastLine || linesCollection.contains(end)) | 220 if (end > gridLastLine || linesCollection.contains(end)) |
| 217 numberOfLines--; | 221 numberOfLines--; |
| 218 } | 222 } |
| 219 | 223 |
| 220 ASSERT(end); | 224 ASSERT(end); |
| 221 return end - 1; | 225 return end - 1; |
| 222 } | 226 } |
| 223 | 227 |
| 224 static int lookBackForNamedGridLine(int end, | 228 static int lookBackForNamedGridLine(int end, |
| 225 size_t numberOfLines, | 229 size_t numberOfLines, |
| 226 int gridLastLine, | 230 int gridLastLine, |
| 227 NamedLineCollection& linesCollection) { | 231 NamedLineCollection& linesCollection) { |
| 228 ASSERT(numberOfLines); | 232 ASSERT(numberOfLines); |
| 229 | 233 |
| 230 // Only implicit lines on the search direction are assumed to have the given n
ame, so we can start to look from last line. | 234 // Only implicit lines on the search direction are assumed to have the given |
| 235 // name, so we can start to look from last line. |
| 231 // See: https://drafts.csswg.org/css-grid/#grid-placement-span-int | 236 // See: https://drafts.csswg.org/css-grid/#grid-placement-span-int |
| 232 int start = std::min(end, gridLastLine); | 237 int start = std::min(end, gridLastLine); |
| 233 | 238 |
| 234 if (!linesCollection.hasNamedLines()) { | 239 if (!linesCollection.hasNamedLines()) { |
| 235 start = std::min(start, -1); | 240 start = std::min(start, -1); |
| 236 return start - numberOfLines + 1; | 241 return start - numberOfLines + 1; |
| 237 } | 242 } |
| 238 | 243 |
| 239 for (; numberOfLines; --start) { | 244 for (; numberOfLines; --start) { |
| 240 if (start < 0 || linesCollection.contains(start)) | 245 if (start < 0 || linesCollection.contains(start)) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 } | 300 } |
| 296 | 301 |
| 297 static GridSpan resolveNamedGridLinePositionAgainstOppositePosition( | 302 static GridSpan resolveNamedGridLinePositionAgainstOppositePosition( |
| 298 const ComputedStyle& gridContainerStyle, | 303 const ComputedStyle& gridContainerStyle, |
| 299 int oppositeLine, | 304 int oppositeLine, |
| 300 const GridPosition& position, | 305 const GridPosition& position, |
| 301 size_t autoRepeatTracksCount, | 306 size_t autoRepeatTracksCount, |
| 302 GridPositionSide side) { | 307 GridPositionSide side) { |
| 303 ASSERT(position.isSpan()); | 308 ASSERT(position.isSpan()); |
| 304 ASSERT(!position.namedGridLine().isNull()); | 309 ASSERT(!position.namedGridLine().isNull()); |
| 305 // Negative positions are not allowed per the specification and should have be
en handled during parsing. | 310 // Negative positions are not allowed per the specification and should have |
| 311 // been handled during parsing. |
| 306 ASSERT(position.spanPosition() > 0); | 312 ASSERT(position.spanPosition() > 0); |
| 307 | 313 |
| 308 size_t lastLine = | 314 size_t lastLine = |
| 309 explicitGridSizeForSide(gridContainerStyle, side, autoRepeatTracksCount); | 315 explicitGridSizeForSide(gridContainerStyle, side, autoRepeatTracksCount); |
| 310 NamedLineCollection linesCollection( | 316 NamedLineCollection linesCollection( |
| 311 gridContainerStyle, position.namedGridLine(), directionFromSide(side), | 317 gridContainerStyle, position.namedGridLine(), directionFromSide(side), |
| 312 lastLine, autoRepeatTracksCount); | 318 lastLine, autoRepeatTracksCount); |
| 313 return definiteGridSpanWithNamedSpanAgainstOpposite( | 319 return definiteGridSpanWithNamedSpanAgainstOpposite( |
| 314 oppositeLine, position, side, lastLine, linesCollection); | 320 oppositeLine, position, side, lastLine, linesCollection); |
| 315 } | 321 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 338 return GridSpan::untranslatedDefiniteGridSpan(oppositeLine - 1, | 344 return GridSpan::untranslatedDefiniteGridSpan(oppositeLine - 1, |
| 339 oppositeLine); | 345 oppositeLine); |
| 340 return GridSpan::untranslatedDefiniteGridSpan(oppositeLine, | 346 return GridSpan::untranslatedDefiniteGridSpan(oppositeLine, |
| 341 oppositeLine + 1); | 347 oppositeLine + 1); |
| 342 } | 348 } |
| 343 | 349 |
| 344 ASSERT(position.isSpan()); | 350 ASSERT(position.isSpan()); |
| 345 ASSERT(position.spanPosition() > 0); | 351 ASSERT(position.spanPosition() > 0); |
| 346 | 352 |
| 347 if (!position.namedGridLine().isNull()) { | 353 if (!position.namedGridLine().isNull()) { |
| 348 // span 2 'c' -> we need to find the appropriate grid line before / after ou
r opposite position. | 354 // span 2 'c' -> we need to find the appropriate grid line before / after |
| 355 // our opposite position. |
| 349 return resolveNamedGridLinePositionAgainstOppositePosition( | 356 return resolveNamedGridLinePositionAgainstOppositePosition( |
| 350 gridContainerStyle, oppositeLine, position, autoRepeatTracksCount, | 357 gridContainerStyle, oppositeLine, position, autoRepeatTracksCount, |
| 351 side); | 358 side); |
| 352 } | 359 } |
| 353 | 360 |
| 354 return definiteGridSpanWithSpanAgainstOpposite(oppositeLine, position, side); | 361 return definiteGridSpanWithSpanAgainstOpposite(oppositeLine, position, side); |
| 355 } | 362 } |
| 356 | 363 |
| 357 size_t GridPositionsResolver::spanSizeForAutoPlacedItem( | 364 size_t GridPositionsResolver::spanSizeForAutoPlacedItem( |
| 358 const ComputedStyle& gridContainerStyle, | 365 const ComputedStyle& gridContainerStyle, |
| 359 const LayoutBox& gridItem, | 366 const LayoutBox& gridItem, |
| 360 GridTrackSizingDirection direction) { | 367 GridTrackSizingDirection direction) { |
| 361 GridPosition initialPosition, finalPosition; | 368 GridPosition initialPosition, finalPosition; |
| 362 initialAndFinalPositionsFromStyle(gridContainerStyle, gridItem, direction, | 369 initialAndFinalPositionsFromStyle(gridContainerStyle, gridItem, direction, |
| 363 initialPosition, finalPosition); | 370 initialPosition, finalPosition); |
| 364 | 371 |
| 365 // This method will only be used when both positions need to be resolved again
st the opposite one. | 372 // This method will only be used when both positions need to be resolved |
| 373 // against the opposite one. |
| 366 ASSERT(initialPosition.shouldBeResolvedAgainstOppositePosition() && | 374 ASSERT(initialPosition.shouldBeResolvedAgainstOppositePosition() && |
| 367 finalPosition.shouldBeResolvedAgainstOppositePosition()); | 375 finalPosition.shouldBeResolvedAgainstOppositePosition()); |
| 368 | 376 |
| 369 if (initialPosition.isAuto() && finalPosition.isAuto()) | 377 if (initialPosition.isAuto() && finalPosition.isAuto()) |
| 370 return 1; | 378 return 1; |
| 371 | 379 |
| 372 GridPosition position = | 380 GridPosition position = |
| 373 initialPosition.isSpan() ? initialPosition : finalPosition; | 381 initialPosition.isSpan() ? initialPosition : finalPosition; |
| 374 ASSERT(position.isSpan()); | 382 ASSERT(position.isSpan()); |
| 375 ASSERT(position.spanPosition()); | 383 ASSERT(position.spanPosition()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 if (position.isPositive()) | 421 if (position.isPositive()) |
| 414 return position.integerPosition() - 1; | 422 return position.integerPosition() - 1; |
| 415 | 423 |
| 416 size_t resolvedPosition = abs(position.integerPosition()) - 1; | 424 size_t resolvedPosition = abs(position.integerPosition()) - 1; |
| 417 size_t endOfTrack = explicitGridSizeForSide(gridContainerStyle, side, | 425 size_t endOfTrack = explicitGridSizeForSide(gridContainerStyle, side, |
| 418 autoRepeatTracksCount); | 426 autoRepeatTracksCount); |
| 419 | 427 |
| 420 return endOfTrack - resolvedPosition; | 428 return endOfTrack - resolvedPosition; |
| 421 } | 429 } |
| 422 case NamedGridAreaPosition: { | 430 case NamedGridAreaPosition: { |
| 423 // First attempt to match the grid area's edge to a named grid area: if th
ere is a named line with the name | 431 // First attempt to match the grid area's edge to a named grid area: if |
| 424 // ''<custom-ident>-start (for grid-*-start) / <custom-ident>-end'' (for g
rid-*-end), contributes the first such | 432 // there is a named line with the name ''<custom-ident>-start (for |
| 425 // line to the grid item's placement. | 433 // grid-*-start) / <custom-ident>-end'' (for grid-*-end), contributes the |
| 434 // first such line to the grid item's placement. |
| 426 String namedGridLine = position.namedGridLine(); | 435 String namedGridLine = position.namedGridLine(); |
| 427 ASSERT(!position.namedGridLine().isNull()); | 436 ASSERT(!position.namedGridLine().isNull()); |
| 428 | 437 |
| 429 size_t lastLine = explicitGridSizeForSide(gridContainerStyle, side, | 438 size_t lastLine = explicitGridSizeForSide(gridContainerStyle, side, |
| 430 autoRepeatTracksCount); | 439 autoRepeatTracksCount); |
| 431 NamedLineCollection implicitLines( | 440 NamedLineCollection implicitLines( |
| 432 gridContainerStyle, implicitNamedGridLineForSide(namedGridLine, side), | 441 gridContainerStyle, implicitNamedGridLineForSide(namedGridLine, side), |
| 433 directionFromSide(side), lastLine, autoRepeatTracksCount); | 442 directionFromSide(side), lastLine, autoRepeatTracksCount); |
| 434 if (implicitLines.hasNamedLines()) | 443 if (implicitLines.hasNamedLines()) |
| 435 return implicitLines.firstPosition(); | 444 return implicitLines.firstPosition(); |
| 436 | 445 |
| 437 // Otherwise, if there is a named line with the specified name, contribute
s the first such line to the grid | 446 // Otherwise, if there is a named line with the specified name, |
| 438 // item's placement. | 447 // contributes the first such line to the grid item's placement. |
| 439 NamedLineCollection explicitLines(gridContainerStyle, namedGridLine, | 448 NamedLineCollection explicitLines(gridContainerStyle, namedGridLine, |
| 440 directionFromSide(side), lastLine, | 449 directionFromSide(side), lastLine, |
| 441 autoRepeatTracksCount); | 450 autoRepeatTracksCount); |
| 442 if (explicitLines.hasNamedLines()) | 451 if (explicitLines.hasNamedLines()) |
| 443 return explicitLines.firstPosition(); | 452 return explicitLines.firstPosition(); |
| 444 | 453 |
| 445 ASSERT(!NamedLineCollection::isValidNamedLineOrArea( | 454 ASSERT(!NamedLineCollection::isValidNamedLineOrArea( |
| 446 namedGridLine, gridContainerStyle, side)); | 455 namedGridLine, gridContainerStyle, side)); |
| 447 // If none of the above works specs mandate to assume that all the lines i
n the implicit grid have this name. | 456 // If none of the above works specs mandate to assume that all the lines |
| 457 // in the implicit grid have this name. |
| 448 return lastLine + 1; | 458 return lastLine + 1; |
| 449 } | 459 } |
| 450 case AutoPosition: | 460 case AutoPosition: |
| 451 case SpanPosition: | 461 case SpanPosition: |
| 452 // 'auto' and span depend on the opposite position for resolution (e.g. gr
id-row: auto / 1 or grid-column: span 3 / "myHeader"). | 462 // 'auto' and span depend on the opposite position for resolution (e.g. |
| 463 // grid-row: auto / 1 or grid-column: span 3 / "myHeader"). |
| 453 ASSERT_NOT_REACHED(); | 464 ASSERT_NOT_REACHED(); |
| 454 return 0; | 465 return 0; |
| 455 } | 466 } |
| 456 ASSERT_NOT_REACHED(); | 467 ASSERT_NOT_REACHED(); |
| 457 return 0; | 468 return 0; |
| 458 } | 469 } |
| 459 | 470 |
| 460 GridSpan GridPositionsResolver::resolveGridPositionsFromStyle( | 471 GridSpan GridPositionsResolver::resolveGridPositionsFromStyle( |
| 461 const ComputedStyle& gridContainerStyle, | 472 const ComputedStyle& gridContainerStyle, |
| 462 const LayoutBox& gridItem, | 473 const LayoutBox& gridItem, |
| 463 GridTrackSizingDirection direction, | 474 GridTrackSizingDirection direction, |
| 464 size_t autoRepeatTracksCount) { | 475 size_t autoRepeatTracksCount) { |
| 465 GridPosition initialPosition, finalPosition; | 476 GridPosition initialPosition, finalPosition; |
| 466 initialAndFinalPositionsFromStyle(gridContainerStyle, gridItem, direction, | 477 initialAndFinalPositionsFromStyle(gridContainerStyle, gridItem, direction, |
| 467 initialPosition, finalPosition); | 478 initialPosition, finalPosition); |
| 468 | 479 |
| 469 GridPositionSide initialSide = initialPositionSide(direction); | 480 GridPositionSide initialSide = initialPositionSide(direction); |
| 470 GridPositionSide finalSide = finalPositionSide(direction); | 481 GridPositionSide finalSide = finalPositionSide(direction); |
| 471 | 482 |
| 472 if (initialPosition.shouldBeResolvedAgainstOppositePosition() && | 483 if (initialPosition.shouldBeResolvedAgainstOppositePosition() && |
| 473 finalPosition.shouldBeResolvedAgainstOppositePosition()) { | 484 finalPosition.shouldBeResolvedAgainstOppositePosition()) { |
| 474 // We can't get our grid positions without running the auto placement algori
thm. | 485 // We can't get our grid positions without running the auto placement |
| 486 // algorithm. |
| 475 return GridSpan::indefiniteGridSpan(); | 487 return GridSpan::indefiniteGridSpan(); |
| 476 } | 488 } |
| 477 | 489 |
| 478 if (initialPosition.shouldBeResolvedAgainstOppositePosition()) { | 490 if (initialPosition.shouldBeResolvedAgainstOppositePosition()) { |
| 479 // Infer the position from the final position ('auto / 1' or 'span 2 / 3' ca
se). | 491 // Infer the position from the final position ('auto / 1' or 'span 2 / 3' |
| 492 // case). |
| 480 int endLine = resolveGridPositionFromStyle( | 493 int endLine = resolveGridPositionFromStyle( |
| 481 gridContainerStyle, finalPosition, finalSide, autoRepeatTracksCount); | 494 gridContainerStyle, finalPosition, finalSide, autoRepeatTracksCount); |
| 482 return resolveGridPositionAgainstOppositePosition( | 495 return resolveGridPositionAgainstOppositePosition( |
| 483 gridContainerStyle, endLine, initialPosition, initialSide, | 496 gridContainerStyle, endLine, initialPosition, initialSide, |
| 484 autoRepeatTracksCount); | 497 autoRepeatTracksCount); |
| 485 } | 498 } |
| 486 | 499 |
| 487 if (finalPosition.shouldBeResolvedAgainstOppositePosition()) { | 500 if (finalPosition.shouldBeResolvedAgainstOppositePosition()) { |
| 488 // Infer our position from the initial position ('1 / auto' or '3 / span 2'
case). | 501 // Infer our position from the initial position ('1 / auto' or '3 / span 2' |
| 502 // case). |
| 489 int startLine = | 503 int startLine = |
| 490 resolveGridPositionFromStyle(gridContainerStyle, initialPosition, | 504 resolveGridPositionFromStyle(gridContainerStyle, initialPosition, |
| 491 initialSide, autoRepeatTracksCount); | 505 initialSide, autoRepeatTracksCount); |
| 492 return resolveGridPositionAgainstOppositePosition( | 506 return resolveGridPositionAgainstOppositePosition( |
| 493 gridContainerStyle, startLine, finalPosition, finalSide, | 507 gridContainerStyle, startLine, finalPosition, finalSide, |
| 494 autoRepeatTracksCount); | 508 autoRepeatTracksCount); |
| 495 } | 509 } |
| 496 | 510 |
| 497 int startLine = resolveGridPositionFromStyle( | 511 int startLine = resolveGridPositionFromStyle( |
| 498 gridContainerStyle, initialPosition, initialSide, autoRepeatTracksCount); | 512 gridContainerStyle, initialPosition, initialSide, autoRepeatTracksCount); |
| 499 int endLine = resolveGridPositionFromStyle(gridContainerStyle, finalPosition, | 513 int endLine = resolveGridPositionFromStyle(gridContainerStyle, finalPosition, |
| 500 finalSide, autoRepeatTracksCount); | 514 finalSide, autoRepeatTracksCount); |
| 501 | 515 |
| 502 if (endLine < startLine) | 516 if (endLine < startLine) |
| 503 std::swap(endLine, startLine); | 517 std::swap(endLine, startLine); |
| 504 else if (endLine == startLine) | 518 else if (endLine == startLine) |
| 505 endLine = startLine + 1; | 519 endLine = startLine + 1; |
| 506 | 520 |
| 507 return GridSpan::untranslatedDefiniteGridSpan(startLine, endLine); | 521 return GridSpan::untranslatedDefiniteGridSpan(startLine, endLine); |
| 508 } | 522 } |
| 509 | 523 |
| 510 } // namespace blink | 524 } // namespace blink |
| OLD | NEW |