Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 
| 3 * | 3 * | 
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without | 
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions | 
| 6 * are met: | 6 * are met: | 
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright | 
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. | 
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright | 
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the | 
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 Vector<GridTrack> columnTracks; | 244 Vector<GridTrack> columnTracks; | 
| 245 Vector<GridTrack> rowTracks; | 245 Vector<GridTrack> rowTracks; | 
| 246 Vector<size_t> contentSizedTracksIndex; | 246 Vector<size_t> contentSizedTracksIndex; | 
| 247 | 247 | 
| 248 // Performance optimization: hold onto these Vectors until the end of Layout to avoid repeated malloc / free. | 248 // Performance optimization: hold onto these Vectors until the end of Layout to avoid repeated malloc / free. | 
| 249 Vector<GridTrack*> filteredTracks; | 249 Vector<GridTrack*> filteredTracks; | 
| 250 Vector<GridItemWithSpan> itemsSortedByIncreasingSpan; | 250 Vector<GridItemWithSpan> itemsSortedByIncreasingSpan; | 
| 251 Vector<GridTrack*> growBeyondGrowthLimitsTracks; | 251 Vector<GridTrack*> growBeyondGrowthLimitsTracks; | 
| 252 | 252 | 
| 253 LayoutUnit& freeSpaceForDirection(GridTrackSizingDirection direction) { retu rn direction == ForColumns ? freeSpaceForColumns : freeSpaceForRows; } | 253 LayoutUnit& freeSpaceForDirection(GridTrackSizingDirection direction) { retu rn direction == ForColumns ? freeSpaceForColumns : freeSpaceForRows; } | 
| 254 void setTrackGapsForDirection(GridTrackSizingDirection direction, LayoutUnit gap) | |
| 255 { | |
| 256 if (direction == ForColumns) | |
| 257 gapsForColumns = gap; | |
| 258 else | |
| 259 gapsForRows = gap; | |
| 260 } | |
| 261 LayoutUnit trackGapsForDirection(GridTrackSizingDirection direction) const { return direction == ForColumns ? gapsForColumns : gapsForRows; } | |
| 262 LayoutUnit guttersSize(GridTrackSizingDirection direction, size_t span) cons t { return span <= 1 ? LayoutUnit() : trackGapsForDirection(direction) * (span - 1); } | |
| 254 | 263 | 
| 255 SizingOperation sizingOperation { TrackSizing }; | 264 SizingOperation sizingOperation { TrackSizing }; | 
| 256 enum SizingState { ColumnSizingFirstIteration, RowSizingFirstIteration, Colu mnSizingSecondIteration, RowSizingSecondIteration}; | 265 enum SizingState { ColumnSizingFirstIteration, RowSizingFirstIteration, Colu mnSizingSecondIteration, RowSizingSecondIteration}; | 
| 257 SizingState sizingState { ColumnSizingFirstIteration }; | 266 SizingState sizingState { ColumnSizingFirstIteration }; | 
| 258 void nextState() | 267 void nextState() | 
| 259 { | 268 { | 
| 260 switch (sizingState) { | 269 switch (sizingState) { | 
| 261 case ColumnSizingFirstIteration: | 270 case ColumnSizingFirstIteration: | 
| 262 sizingState = RowSizingFirstIteration; | 271 sizingState = RowSizingFirstIteration; | 
| 263 return; | 272 return; | 
| (...skipping 23 matching lines...) Expand all Loading... | |
| 287 return true; | 296 return true; | 
| 288 case RowSizingSecondIteration: | 297 case RowSizingSecondIteration: | 
| 289 return direction == ForRows ? true : false; | 298 return direction == ForRows ? true : false; | 
| 290 } | 299 } | 
| 291 NOTREACHED(); | 300 NOTREACHED(); | 
| 292 return false; | 301 return false; | 
| 293 } | 302 } | 
| 294 private: | 303 private: | 
| 295 LayoutUnit freeSpaceForColumns { }; | 304 LayoutUnit freeSpaceForColumns { }; | 
| 296 LayoutUnit freeSpaceForRows { }; | 305 LayoutUnit freeSpaceForRows { }; | 
| 306 LayoutUnit gapsForColumns { }; | |
| 307 LayoutUnit gapsForRows { }; | |
| 297 }; | 308 }; | 
| 298 | 309 | 
| 299 struct GridItemsSpanGroupRange { | 310 struct GridItemsSpanGroupRange { | 
| 300 Vector<GridItemWithSpan>::iterator rangeStart; | 311 Vector<GridItemWithSpan>::iterator rangeStart; | 
| 301 Vector<GridItemWithSpan>::iterator rangeEnd; | 312 Vector<GridItemWithSpan>::iterator rangeEnd; | 
| 302 }; | 313 }; | 
| 303 | 314 | 
| 304 LayoutGrid::LayoutGrid(Element* element) | 315 LayoutGrid::LayoutGrid(Element* element) | 
| 305 : LayoutBlock(element) | 316 : LayoutBlock(element) | 
| 306 , m_gridIsDirty(true) | 317 , m_gridIsDirty(true) | 
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 return m_grid.size(); | 391 return m_grid.size(); | 
| 381 } | 392 } | 
| 382 | 393 | 
| 383 LayoutUnit LayoutGrid::computeTrackBasedLogicalHeight(const GridSizingData& sizi ngData) const | 394 LayoutUnit LayoutGrid::computeTrackBasedLogicalHeight(const GridSizingData& sizi ngData) const | 
| 384 { | 395 { | 
| 385 LayoutUnit logicalHeight; | 396 LayoutUnit logicalHeight; | 
| 386 | 397 | 
| 387 for (const auto& row : sizingData.rowTracks) | 398 for (const auto& row : sizingData.rowTracks) | 
| 388 logicalHeight += row.baseSize(); | 399 logicalHeight += row.baseSize(); | 
| 389 | 400 | 
| 390 logicalHeight += guttersSize(ForRows, sizingData.rowTracks.size()); | 401 logicalHeight += sizingData.guttersSize(ForRows, sizingData.rowTracks.size() ); | 
| 391 | 402 | 
| 392 return logicalHeight; | 403 return logicalHeight; | 
| 393 } | 404 } | 
| 394 | 405 | 
| 395 void LayoutGrid::computeTrackSizesForDirection(GridTrackSizingDirection directio n, GridSizingData& sizingData, LayoutUnit freeSpace) | 406 void LayoutGrid::computeTrackSizesForDirection(GridTrackSizingDirection directio n, GridSizingData& sizingData, LayoutUnit freeSpace) | 
| 396 { | 407 { | 
| 397 DCHECK(sizingData.isValidTransitionForDirection(direction)); | 408 DCHECK(sizingData.isValidTransitionForDirection(direction)); | 
| 398 sizingData.freeSpaceForDirection(direction) = freeSpace - guttersSize(direct ion, direction == ForRows ? gridRowCount() : gridColumnCount()); | 409 sizingData.freeSpaceForDirection(direction) = freeSpace - sizingData.gutters Size(direction, direction == ForRows ? gridRowCount() : gridColumnCount()); | 
| 399 sizingData.sizingOperation = TrackSizing; | 410 sizingData.sizingOperation = TrackSizing; | 
| 400 | 411 | 
| 401 LayoutUnit baseSizes, growthLimits; | 412 LayoutUnit baseSizes, growthLimits; | 
| 402 computeUsedBreadthOfGridTracks(direction, sizingData, baseSizes, growthLimit s); | 413 computeUsedBreadthOfGridTracks(direction, sizingData, baseSizes, growthLimit s); | 
| 403 ASSERT(tracksAreWiderThanMinTrackBreadth(direction, sizingData)); | 414 ASSERT(tracksAreWiderThanMinTrackBreadth(direction, sizingData)); | 
| 404 sizingData.nextState(); | 415 sizingData.nextState(); | 
| 405 } | 416 } | 
| 406 | 417 | 
| 407 void LayoutGrid::repeatTracksSizingIfNeeded(GridSizingData& sizingData, LayoutUn it availableSpaceForColumns, LayoutUnit availableSpaceForRows) | 418 void LayoutGrid::repeatTracksSizingIfNeeded(GridSizingData& sizingData, LayoutUn it availableSpaceForColumns, LayoutUnit availableSpaceForRows) | 
| 408 { | 419 { | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 placeItemsOnGrid(); | 457 placeItemsOnGrid(); | 
| 447 | 458 | 
| 448 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 459 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 
| 449 | 460 | 
| 450 // 1- First, the track sizing algorithm is used to resolve the sizes of the grid columns. | 461 // 1- First, the track sizing algorithm is used to resolve the sizes of the grid columns. | 
| 451 // At this point the logical width is always definite as the above call to updateLogicalWidth() | 462 // At this point the logical width is always definite as the above call to updateLogicalWidth() | 
| 452 // properly resolves intrinsic sizes. We cannot do the same for heights though because many code | 463 // properly resolves intrinsic sizes. We cannot do the same for heights though because many code | 
| 453 // paths inside updateLogicalHeight() require a previous call to setLogi calHeight() to resolve | 464 // paths inside updateLogicalHeight() require a previous call to setLogi calHeight() to resolve | 
| 454 // heights properly (like for positioned items for example). | 465 // heights properly (like for positioned items for example). | 
| 455 LayoutUnit availableSpaceForColumns = availableLogicalWidth(); | 466 LayoutUnit availableSpaceForColumns = availableLogicalWidth(); | 
| 467 sizingData.setTrackGapsForDirection(ForColumns, guttersSize(ForColumns, 2, availableSpaceForColumns)); | |
| 456 computeTrackSizesForDirection(ForColumns, sizingData, availableSpaceForC olumns); | 468 computeTrackSizesForDirection(ForColumns, sizingData, availableSpaceForC olumns); | 
| 457 | 469 | 
| 458 // 2- Next, the track sizing algorithm resolves the sizes of the grid ro ws, using the | 470 // 2- Next, the track sizing algorithm resolves the sizes of the grid ro ws, using the | 
| 459 // grid column sizes calculated in the previous step. | 471 // grid column sizes calculated in the previous step. | 
| 460 if (logicalHeightWasIndefinite) | 472 if (logicalHeightWasIndefinite) { | 
| 473 sizingData.setTrackGapsForDirection(ForRows, guttersSize(ForRows, 2, LayoutUnit())); | |
| 461 computeIntrinsicLogicalHeight(sizingData); | 474 computeIntrinsicLogicalHeight(sizingData); | 
| 462 else | 475 } else { | 
| 463 computeTrackSizesForDirection(ForRows, sizingData, availableLogicalH eight(ExcludeMarginBorderPadding)); | 476 LayoutUnit availableHeight = availableLogicalHeight(ExcludeMarginBor derPadding); | 
| 477 sizingData.setTrackGapsForDirection(ForRows, guttersSize(ForRows, 2, availableHeight)); | |
| 478 computeTrackSizesForDirection(ForRows, sizingData, availableHeight); | |
| 479 } | |
| 464 setLogicalHeight(computeTrackBasedLogicalHeight(sizingData) + borderAndP addingLogicalHeight() + scrollbarLogicalHeight()); | 480 setLogicalHeight(computeTrackBasedLogicalHeight(sizingData) + borderAndP addingLogicalHeight() + scrollbarLogicalHeight()); | 
| 465 | 481 | 
| 466 LayoutUnit oldClientAfterEdge = clientLogicalBottom(); | 482 LayoutUnit oldClientAfterEdge = clientLogicalBottom(); | 
| 467 updateLogicalHeight(); | 483 updateLogicalHeight(); | 
| 468 | 484 | 
| 469 // The above call might have changed the grid's logical height depending on min|max height restrictions. | 485 // The above call might have changed the grid's logical height depending on min|max height restrictions. | 
| 470 // Update the sizes of the rows whose size depends on the logical height (also on definite|indefinite sizes). | 486 // Update the sizes of the rows whose size depends on the logical height (also on definite|indefinite sizes). | 
| 471 LayoutUnit availableSpaceForRows = contentLogicalHeight(); | 487 LayoutUnit availableSpaceForRows = contentLogicalHeight(); | 
| 472 if (logicalHeightWasIndefinite) | 488 if (logicalHeightWasIndefinite) | 
| 473 computeTrackSizesForDirection(ForRows, sizingData, availableSpaceFor Rows); | 489 computeTrackSizesForDirection(ForRows, sizingData, availableSpaceFor Rows); | 
| (...skipping 19 matching lines...) Expand all Loading... | |
| 493 | 509 | 
| 494 computeOverflow(oldClientAfterEdge); | 510 computeOverflow(oldClientAfterEdge); | 
| 495 } | 511 } | 
| 496 | 512 | 
| 497 updateLayerTransformAfterLayout(); | 513 updateLayerTransformAfterLayout(); | 
| 498 updateAfterLayout(); | 514 updateAfterLayout(); | 
| 499 | 515 | 
| 500 clearNeedsLayout(); | 516 clearNeedsLayout(); | 
| 501 } | 517 } | 
| 502 | 518 | 
| 503 LayoutUnit LayoutGrid::guttersSize(GridTrackSizingDirection direction, size_t sp an) const | 519 LayoutUnit LayoutGrid::guttersSize(GridTrackSizingDirection direction, size_t sp an, LayoutUnit availableSize) const | 
| 504 { | 520 { | 
| 505 if (span <= 1) | 521 if (span <= 1) | 
| 506 return LayoutUnit(); | 522 return LayoutUnit(); | 
| 507 | 523 | 
| 508 const Length& trackGap = direction == ForColumns ? styleRef().gridColumnGap( ) : styleRef().gridRowGap(); | 524 const Length& trackGap = direction == ForColumns ? styleRef().gridColumnGap( ) : styleRef().gridRowGap(); | 
| 509 return valueForLength(trackGap, LayoutUnit()) * (span - 1); | 525 return valueForLength(trackGap, availableSize) * (span - 1); | 
| 510 } | 526 } | 
| 511 | 527 | 
| 512 void LayoutGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const | 528 void LayoutGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const | 
| 513 { | 529 { | 
| 514 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(); | 530 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(); | 
| 515 | 531 | 
| 516 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 532 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 
| 517 sizingData.freeSpaceForDirection(ForColumns) = LayoutUnit(); | 533 sizingData.freeSpaceForDirection(ForColumns) = LayoutUnit(); | 
| 518 sizingData.sizingOperation = IntrinsicSizeComputation; | 534 sizingData.sizingOperation = IntrinsicSizeComputation; | 
| 535 sizingData.setTrackGapsForDirection(ForColumns, guttersSize(ForColumns, 2, L ayoutUnit())); | |
| 519 const_cast<LayoutGrid*>(this)->computeUsedBreadthOfGridTracks(ForColumns, si zingData, minLogicalWidth, maxLogicalWidth); | 536 const_cast<LayoutGrid*>(this)->computeUsedBreadthOfGridTracks(ForColumns, si zingData, minLogicalWidth, maxLogicalWidth); | 
| 520 | 537 | 
| 521 LayoutUnit totalGuttersSize = guttersSize(ForColumns, sizingData.columnTrack s.size()); | 538 LayoutUnit totalGuttersSize = sizingData.guttersSize(ForColumns, sizingData. columnTracks.size()); | 
| 
 
Manuel Rego
2016/07/01 06:45:57
I think you've just calculated the gap size a few
 
 | |
| 522 minLogicalWidth += totalGuttersSize; | 539 minLogicalWidth += totalGuttersSize; | 
| 523 maxLogicalWidth += totalGuttersSize; | 540 maxLogicalWidth += totalGuttersSize; | 
| 524 | 541 | 
| 525 LayoutUnit scrollbarWidth = LayoutUnit(scrollbarLogicalWidth()); | 542 LayoutUnit scrollbarWidth = LayoutUnit(scrollbarLogicalWidth()); | 
| 526 minLogicalWidth += scrollbarWidth; | 543 minLogicalWidth += scrollbarWidth; | 
| 527 maxLogicalWidth += scrollbarWidth; | 544 maxLogicalWidth += scrollbarWidth; | 
| 528 } | 545 } | 
| 529 | 546 | 
| 530 void LayoutGrid::computeIntrinsicLogicalHeight(GridSizingData& sizingData) | 547 void LayoutGrid::computeIntrinsicLogicalHeight(GridSizingData& sizingData) | 
| 531 { | 548 { | 
| 532 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData)); | 549 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData)); | 
| 533 sizingData.freeSpaceForDirection(ForRows) = LayoutUnit(); | 550 sizingData.freeSpaceForDirection(ForRows) = LayoutUnit(); | 
| 534 sizingData.sizingOperation = IntrinsicSizeComputation; | 551 sizingData.sizingOperation = IntrinsicSizeComputation; | 
| 552 sizingData.setTrackGapsForDirection(ForRows, guttersSize(ForRows, 2, LayoutU nit())); | |
| 535 computeUsedBreadthOfGridTracks(ForRows, sizingData, m_minContentHeight, m_ma xContentHeight); | 553 computeUsedBreadthOfGridTracks(ForRows, sizingData, m_minContentHeight, m_ma xContentHeight); | 
| 536 | 554 | 
| 537 LayoutUnit totalGuttersSize = guttersSize(ForRows, gridRowCount()); | 555 LayoutUnit totalGuttersSize = sizingData.guttersSize(ForRows, gridRowCount() ); | 
| 
 
Manuel Rego
2016/07/01 06:45:57
Ditto.
 
 | |
| 538 m_minContentHeight += totalGuttersSize; | 556 m_minContentHeight += totalGuttersSize; | 
| 539 m_maxContentHeight += totalGuttersSize; | 557 m_maxContentHeight += totalGuttersSize; | 
| 540 | 558 | 
| 541 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData)); | 559 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData)); | 
| 542 } | 560 } | 
| 543 | 561 | 
| 544 LayoutUnit LayoutGrid::computeIntrinsicLogicalContentHeightUsing(const Length& l ogicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddi ng) const | 562 LayoutUnit LayoutGrid::computeIntrinsicLogicalContentHeightUsing(const Length& l ogicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddi ng) const | 
| 545 { | 563 { | 
| 546 if (logicalHeightLength.isMinContent()) | 564 if (logicalHeightLength.isMinContent()) | 
| 547 return m_minContentHeight; | 565 return m_minContentHeight; | 
| (...skipping 16 matching lines...) Expand all Loading... | |
| 564 | 582 | 
| 565 static inline double normalizedFlexFraction(const GridTrack& track, double flexF actor) | 583 static inline double normalizedFlexFraction(const GridTrack& track, double flexF actor) | 
| 566 { | 584 { | 
| 567 return track.baseSize() / std::max<double>(1, flexFactor); | 585 return track.baseSize() / std::max<double>(1, flexFactor); | 
| 568 } | 586 } | 
| 569 | 587 | 
| 570 void LayoutGrid::computeUsedBreadthOfGridTracks(GridTrackSizingDirection directi on, GridSizingData& sizingData, LayoutUnit& baseSizesWithoutMaximization, Layout Unit& growthLimitsWithoutMaximization) | 588 void LayoutGrid::computeUsedBreadthOfGridTracks(GridTrackSizingDirection directi on, GridSizingData& sizingData, LayoutUnit& baseSizesWithoutMaximization, Layout Unit& growthLimitsWithoutMaximization) | 
| 571 { | 589 { | 
| 572 LayoutUnit& freeSpace = sizingData.freeSpaceForDirection(direction); | 590 LayoutUnit& freeSpace = sizingData.freeSpaceForDirection(direction); | 
| 573 const LayoutUnit initialFreeSpace = freeSpace; | 591 const LayoutUnit initialFreeSpace = freeSpace; | 
| 574 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra cks : sizingData.rowTracks; | 592 bool isRowAxis = direction == ForColumns; | 
| 593 Vector<GridTrack>& tracks = isRowAxis ? sizingData.columnTracks : sizingData .rowTracks; | |
| 575 Vector<size_t> flexibleSizedTracksIndex; | 594 Vector<size_t> flexibleSizedTracksIndex; | 
| 576 sizingData.contentSizedTracksIndex.shrink(0); | 595 sizingData.contentSizedTracksIndex.shrink(0); | 
| 577 | 596 | 
| 578 LayoutUnit maxSize = std::max(LayoutUnit(), initialFreeSpace); | 597 LayoutUnit maxSize = std::max(LayoutUnit(), initialFreeSpace); | 
| 579 // Grid gutters were removed from freeSpace by the caller, but we must use t hem to compute relative (i.e. percentages) sizes. | 598 // Grid gutters were removed from freeSpace by the caller, but we must use t hem to compute relative (i.e. percentages) sizes. | 
| 580 bool hasDefiniteFreeSpace = sizingData.sizingOperation == TrackSizing; | 599 bool hasDefiniteFreeSpace = sizingData.sizingOperation == TrackSizing; | 
| 581 if (hasDefiniteFreeSpace) | 600 if (hasDefiniteFreeSpace) | 
| 582 maxSize += guttersSize(direction, direction == ForRows ? gridRowCount() : gridColumnCount()); | 601 maxSize += sizingData.guttersSize(direction, isRowAxis ? gridColumnCount () : gridRowCount()); | 
| 583 | 602 | 
| 584 // 1. Initialize per Grid track variables. | 603 // 1. Initialize per Grid track variables. | 
| 585 for (size_t i = 0; i < tracks.size(); ++i) { | 604 for (size_t i = 0; i < tracks.size(); ++i) { | 
| 586 GridTrack& track = tracks[i]; | 605 GridTrack& track = tracks[i]; | 
| 587 GridTrackSize trackSize = gridTrackSize(direction, i, sizingData.sizingO peration); | 606 GridTrackSize trackSize = gridTrackSize(direction, i, sizingData.sizingO peration); | 
| 588 const GridLength& minTrackBreadth = trackSize.minTrackBreadth(); | 607 const GridLength& minTrackBreadth = trackSize.minTrackBreadth(); | 
| 589 const GridLength& maxTrackBreadth = trackSize.maxTrackBreadth(); | 608 const GridLength& maxTrackBreadth = trackSize.maxTrackBreadth(); | 
| 590 | 609 | 
| 591 track.setBaseSize(computeUsedBreadthOfMinLength(minTrackBreadth, maxSize )); | 610 track.setBaseSize(computeUsedBreadthOfMinLength(minTrackBreadth, maxSize )); | 
| 592 track.setGrowthLimit(computeUsedBreadthOfMaxLength(maxTrackBreadth, trac k.baseSize(), maxSize)); | 611 track.setGrowthLimit(computeUsedBreadthOfMaxLength(maxTrackBreadth, trac k.baseSize(), maxSize)); | 
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1166 return LayoutUnit(); | 1185 return LayoutUnit(); | 
| 1167 } | 1186 } | 
| 1168 | 1187 | 
| 1169 ASSERT_NOT_REACHED(); | 1188 ASSERT_NOT_REACHED(); | 
| 1170 return LayoutUnit(); | 1189 return LayoutUnit(); | 
| 1171 } | 1190 } | 
| 1172 | 1191 | 
| 1173 template <TrackSizeComputationPhase phase> | 1192 template <TrackSizeComputationPhase phase> | 
| 1174 void LayoutGrid::resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizing Direction direction, GridSizingData& sizingData, const GridItemsSpanGroupRange& gridItemsWithSpan) | 1193 void LayoutGrid::resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizing Direction direction, GridSizingData& sizingData, const GridItemsSpanGroupRange& gridItemsWithSpan) | 
| 1175 { | 1194 { | 
| 1176 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra cks : sizingData.rowTracks; | 1195 bool isRowAxis = direction == ForColumns; | 
| 1196 Vector<GridTrack>& tracks = isRowAxis ? sizingData.columnTracks : sizingData .rowTracks; | |
| 1177 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { | 1197 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { | 
| 1178 GridTrack& track = tracks[trackIndex]; | 1198 GridTrack& track = tracks[trackIndex]; | 
| 1179 track.setPlannedSize(trackSizeForTrackSizeComputationPhase(phase, track, AllowInfinity)); | 1199 track.setPlannedSize(trackSizeForTrackSizeComputationPhase(phase, track, AllowInfinity)); | 
| 1180 } | 1200 } | 
| 1181 | 1201 | 
| 1182 for (auto it = gridItemsWithSpan.rangeStart; it != gridItemsWithSpan.rangeEn d; ++it) { | 1202 for (auto it = gridItemsWithSpan.rangeStart; it != gridItemsWithSpan.rangeEn d; ++it) { | 
| 1183 GridItemWithSpan& gridItemWithSpan = *it; | 1203 GridItemWithSpan& gridItemWithSpan = *it; | 
| 1184 ASSERT(gridItemWithSpan.getGridSpan().integerSpan() > 1); | 1204 ASSERT(gridItemWithSpan.getGridSpan().integerSpan() > 1); | 
| 1185 const GridSpan& itemSpan = gridItemWithSpan.getGridSpan(); | 1205 const GridSpan& itemSpan = gridItemWithSpan.getGridSpan(); | 
| 1186 | 1206 | 
| 1187 sizingData.growBeyondGrowthLimitsTracks.shrink(0); | 1207 sizingData.growBeyondGrowthLimitsTracks.shrink(0); | 
| 1188 sizingData.filteredTracks.shrink(0); | 1208 sizingData.filteredTracks.shrink(0); | 
| 1189 LayoutUnit spanningTracksSize; | 1209 LayoutUnit spanningTracksSize; | 
| 1190 for (const auto& trackPosition : itemSpan) { | 1210 for (const auto& trackPosition : itemSpan) { | 
| 1191 GridTrackSize trackSize = gridTrackSize(direction, trackPosition); | 1211 GridTrackSize trackSize = gridTrackSize(direction, trackPosition); | 
| 1192 GridTrack& track = (direction == ForColumns) ? sizingData.columnTrac ks[trackPosition] : sizingData.rowTracks[trackPosition]; | 1212 GridTrack& track = isRowAxis ? sizingData.columnTracks[trackPosition ] : sizingData.rowTracks[trackPosition]; | 
| 1193 spanningTracksSize += trackSizeForTrackSizeComputationPhase(phase, t rack, ForbidInfinity); | 1213 spanningTracksSize += trackSizeForTrackSizeComputationPhase(phase, t rack, ForbidInfinity); | 
| 1194 if (!shouldProcessTrackForTrackSizeComputationPhase(phase, trackSize )) | 1214 if (!shouldProcessTrackForTrackSizeComputationPhase(phase, trackSize )) | 
| 1195 continue; | 1215 continue; | 
| 1196 | 1216 | 
| 1197 sizingData.filteredTracks.append(&track); | 1217 sizingData.filteredTracks.append(&track); | 
| 1198 | 1218 | 
| 1199 if (trackShouldGrowBeyondGrowthLimitsForTrackSizeComputationPhase(ph ase, trackSize)) | 1219 if (trackShouldGrowBeyondGrowthLimitsForTrackSizeComputationPhase(ph ase, trackSize)) | 
| 1200 sizingData.growBeyondGrowthLimitsTracks.append(&track); | 1220 sizingData.growBeyondGrowthLimitsTracks.append(&track); | 
| 1201 } | 1221 } | 
| 1202 | 1222 | 
| 1203 if (sizingData.filteredTracks.isEmpty()) | 1223 if (sizingData.filteredTracks.isEmpty()) | 
| 1204 continue; | 1224 continue; | 
| 1205 | 1225 | 
| 1206 spanningTracksSize += guttersSize(direction, itemSpan.integerSpan()); | 1226 spanningTracksSize += sizingData.guttersSize(direction, itemSpan.integer Span()); | 
| 1207 | 1227 | 
| 1208 LayoutUnit extraSpace = currentItemSizeForTrackSizeComputationPhase(phas e, gridItemWithSpan.gridItem(), direction, sizingData) - spanningTracksSize; | 1228 LayoutUnit extraSpace = currentItemSizeForTrackSizeComputationPhase(phas e, gridItemWithSpan.gridItem(), direction, sizingData) - spanningTracksSize; | 
| 1209 extraSpace = extraSpace.clampNegativeToZero(); | 1229 extraSpace = extraSpace.clampNegativeToZero(); | 
| 1210 auto& tracksToGrowBeyondGrowthLimits = sizingData.growBeyondGrowthLimits Tracks.isEmpty() ? sizingData.filteredTracks : sizingData.growBeyondGrowthLimits Tracks; | 1230 auto& tracksToGrowBeyondGrowthLimits = sizingData.growBeyondGrowthLimits Tracks.isEmpty() ? sizingData.filteredTracks : sizingData.growBeyondGrowthLimits Tracks; | 
| 1211 distributeSpaceToTracks<phase>(sizingData.filteredTracks, &tracksToGrowB eyondGrowthLimits, sizingData, extraSpace); | 1231 distributeSpaceToTracks<phase>(sizingData.filteredTracks, &tracksToGrowB eyondGrowthLimits, sizingData, extraSpace); | 
| 1212 } | 1232 } | 
| 1213 | 1233 | 
| 1214 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { | 1234 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { | 
| 1215 GridTrack& track = tracks[trackIndex]; | 1235 GridTrack& track = tracks[trackIndex]; | 
| 1216 markAsInfinitelyGrowableForTrackSizeComputationPhase(phase, track); | 1236 markAsInfinitelyGrowableForTrackSizeComputationPhase(phase, track); | 
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1359 const Vector<GridTrackSize>& trackSizes = isRowAxis ? styleRef().gridTemplat eColumns() : styleRef().gridTemplateRows(); | 1379 const Vector<GridTrackSize>& trackSizes = isRowAxis ? styleRef().gridTemplat eColumns() : styleRef().gridTemplateRows(); | 
| 1360 | 1380 | 
| 1361 for (const auto& track : trackSizes) { | 1381 for (const auto& track : trackSizes) { | 
| 1362 bool hasDefiniteMaxTrackBreadth = track.maxTrackBreadth().isLength() && !track.maxTrackBreadth().isContentSized(); | 1382 bool hasDefiniteMaxTrackBreadth = track.maxTrackBreadth().isLength() && !track.maxTrackBreadth().isContentSized(); | 
| 1363 DCHECK(hasDefiniteMaxTrackBreadth || (track.minTrackBreadth().isLength() && !track.minTrackBreadth().isContentSized())); | 1383 DCHECK(hasDefiniteMaxTrackBreadth || (track.minTrackBreadth().isLength() && !track.minTrackBreadth().isContentSized())); | 
| 1364 tracksSize += valueForLength(hasDefiniteMaxTrackBreadth ? track.maxTrack Breadth().length() : track.minTrackBreadth().length(), availableSize); | 1384 tracksSize += valueForLength(hasDefiniteMaxTrackBreadth ? track.maxTrack Breadth().length() : track.minTrackBreadth().length(), availableSize); | 
| 1365 } | 1385 } | 
| 1366 | 1386 | 
| 1367 // Add gutters as if there where only 1 auto repeat track. Gaps between auto repeat tracks will be added later when | 1387 // Add gutters as if there where only 1 auto repeat track. Gaps between auto repeat tracks will be added later when | 
| 1368 // computing the repetitions. | 1388 // computing the repetitions. | 
| 1369 LayoutUnit gapSize = guttersSize(direction, 2); | 1389 LayoutUnit gapSize = guttersSize(direction, 2, availableSize); | 
| 1370 tracksSize += gapSize * trackSizes.size(); | 1390 tracksSize += gapSize * trackSizes.size(); | 
| 1371 | 1391 | 
| 1372 LayoutUnit freeSpace = availableSize - tracksSize; | 1392 LayoutUnit freeSpace = availableSize - tracksSize; | 
| 1373 if (freeSpace <= 0) | 1393 if (freeSpace <= 0) | 
| 1374 return 1; | 1394 return 1; | 
| 1375 | 1395 | 
| 1376 size_t repetitions = 1 + (freeSpace / (autoRepeatTrackSize + gapSize)).toInt (); | 1396 size_t repetitions = 1 + (freeSpace / (autoRepeatTrackSize + gapSize)).toInt (); | 
| 1377 | 1397 | 
| 1378 // Provided the grid container does not have a definite size or max-size in the relevant axis, | 1398 // Provided the grid container does not have a definite size or max-size in the relevant axis, | 
| 1379 // if the min size is definite then the number of repetitions is the largest possible positive | 1399 // if the min size is definite then the number of repetitions is the largest possible positive | 
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1802 if (isForColumns) { | 1822 if (isForColumns) { | 
| 1803 if (styleRef().isLeftToRightDirection()) | 1823 if (styleRef().isLeftToRightDirection()) | 
| 1804 start = m_columnPositions[startLine] - borderLogicalLeft(); | 1824 start = m_columnPositions[startLine] - borderLogicalLeft(); | 
| 1805 else | 1825 else | 
| 1806 start = logicalWidth() - translateRTLCoordinate(m_columnPosition s[startLine]) - borderLogicalRight(); | 1826 start = logicalWidth() - translateRTLCoordinate(m_columnPosition s[startLine]) - borderLogicalRight(); | 
| 1807 } else { | 1827 } else { | 
| 1808 start = m_rowPositions[startLine] - borderBefore(); | 1828 start = m_rowPositions[startLine] - borderBefore(); | 
| 1809 } | 1829 } | 
| 1810 } | 1830 } | 
| 1811 | 1831 | 
| 1832 bool logicalHeightWasIndefinite = computeContentLogicalHeight(MainOrPreferre dSize, style()->logicalHeight(), LayoutUnit(-1)) == LayoutUnit(-1); | |
| 
 
Manuel Rego
2016/07/01 06:45:57
We know this check is wrong, but it's part of bug
 
 | |
| 1812 LayoutUnit end = isForColumns ? clientLogicalWidth() : clientLogicalHeight() ; | 1833 LayoutUnit end = isForColumns ? clientLogicalWidth() : clientLogicalHeight() ; | 
| 1813 if (!endIsAuto) { | 1834 if (!endIsAuto) { | 
| 1814 if (isForColumns) { | 1835 if (isForColumns) { | 
| 1815 if (styleRef().isLeftToRightDirection()) | 1836 if (styleRef().isLeftToRightDirection()) | 
| 1816 end = m_columnPositions[endLine] - borderLogicalLeft(); | 1837 end = m_columnPositions[endLine] - borderLogicalLeft(); | 
| 1817 else | 1838 else | 
| 1818 end = logicalWidth() - translateRTLCoordinate(m_columnPositions[ endLine]) - borderLogicalRight(); | 1839 end = logicalWidth() - translateRTLCoordinate(m_columnPositions[ endLine]) - borderLogicalRight(); | 
| 1819 } else { | 1840 } else { | 
| 1820 end = m_rowPositions[endLine] - borderBefore(); | 1841 end = m_rowPositions[endLine] - borderBefore(); | 
| 1821 } | 1842 } | 
| 1822 | 1843 | 
| 1823 // These vectors store line positions including gaps, but we shouldn't c onsider them for the edges of the grid. | 1844 // These vectors store line positions including gaps, but we shouldn't c onsider them for the edges of the grid. | 
| 1824 if (endLine > 0 && endLine < lastLine) { | 1845 if (endLine > 0 && endLine < lastLine) { | 
| 1825 end -= guttersSize(direction, 2); | 1846 end -= guttersSize(direction, 2, isForColumns ? logicalWidth() : log icalHeightWasIndefinite ? LayoutUnit() : contentLogicalHeight()); | 
| 
 
Manuel Rego
2016/07/01 06:45:57
This is weird, you're using here logicalWidth() an
 
 | |
| 1826 end -= isForColumns ? m_offsetBetweenColumns : m_offsetBetweenRows; | 1847 end -= isForColumns ? m_offsetBetweenColumns : m_offsetBetweenRows; | 
| 1827 } | 1848 } | 
| 1828 } | 1849 } | 
| 1829 | 1850 | 
| 1830 breadth = end - start; | 1851 breadth = end - start; | 
| 1831 offset = start; | 1852 offset = start; | 
| 1832 | 1853 | 
| 1833 if (isForColumns && !styleRef().isLeftToRightDirection() && !child.styleRef( ).hasStaticInlinePosition(child.isHorizontalWritingMode())) { | 1854 if (isForColumns && !styleRef().isLeftToRightDirection() && !child.styleRef( ).hasStaticInlinePosition(child.isHorizontalWritingMode())) { | 
| 1834 // If the child doesn't have a static inline position (i.e. "left" and/o r "right" aren't "auto", | 1855 // If the child doesn't have a static inline position (i.e. "left" and/o r "right" aren't "auto", | 
| 1835 // we need to calculate the offset from the left (even if we're in RTL). | 1856 // we need to calculate the offset from the left (even if we're in RTL). | 
| 1836 if (endIsAuto) { | 1857 if (endIsAuto) { | 
| 1837 offset = LayoutUnit(); | 1858 offset = LayoutUnit(); | 
| 1838 } else { | 1859 } else { | 
| 1839 offset = translateRTLCoordinate(m_columnPositions[endLine]) - border LogicalLeft(); | 1860 offset = translateRTLCoordinate(m_columnPositions[endLine]) - border LogicalLeft(); | 
| 1840 | 1861 | 
| 1841 if (endLine > 0 && endLine < lastLine) { | 1862 if (endLine > 0 && endLine < lastLine) { | 
| 1842 offset += guttersSize(direction, 2); | 1863 offset += guttersSize(direction, 2, isForColumns ? logicalWidth( ) : logicalHeightWasIndefinite ? LayoutUnit() : contentLogicalHeight()); | 
| 
 
Manuel Rego
2016/07/01 06:45:57
Ditto.
 
 | |
| 1843 offset += isForColumns ? m_offsetBetweenColumns : m_offsetBetwee nRows; | 1864 offset += isForColumns ? m_offsetBetweenColumns : m_offsetBetwee nRows; | 
| 1844 } | 1865 } | 
| 1845 } | 1866 } | 
| 1846 } | 1867 } | 
| 1847 | 1868 | 
| 1848 } | 1869 } | 
| 1849 | 1870 | 
| 1850 GridArea LayoutGrid::cachedGridArea(const LayoutBox& gridItem) const | 1871 GridArea LayoutGrid::cachedGridArea(const LayoutBox& gridItem) const | 
| 1851 { | 1872 { | 
| 1852 ASSERT(m_gridItemArea.contains(&gridItem)); | 1873 ASSERT(m_gridItemArea.contains(&gridItem)); | 
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1867 bool gridAreaIsIndefinite = false; | 1888 bool gridAreaIsIndefinite = false; | 
| 1868 LayoutUnit containingBlockAvailableSize = containingBlockLogicalHeightForCon tent(ExcludeMarginBorderPadding); | 1889 LayoutUnit containingBlockAvailableSize = containingBlockLogicalHeightForCon tent(ExcludeMarginBorderPadding); | 
| 1869 for (auto trackPosition : span) { | 1890 for (auto trackPosition : span) { | 
| 1870 const GridLength& maxTrackSize = gridTrackSize(ForRows, trackPosition, s izingOperation).maxTrackBreadth(); | 1891 const GridLength& maxTrackSize = gridTrackSize(ForRows, trackPosition, s izingOperation).maxTrackBreadth(); | 
| 1871 if (maxTrackSize.isContentSized() || maxTrackSize.isFlex()) | 1892 if (maxTrackSize.isContentSized() || maxTrackSize.isFlex()) | 
| 1872 gridAreaIsIndefinite = true; | 1893 gridAreaIsIndefinite = true; | 
| 1873 else | 1894 else | 
| 1874 gridAreaSize += valueForLength(maxTrackSize.length(), containingBloc kAvailableSize); | 1895 gridAreaSize += valueForLength(maxTrackSize.length(), containingBloc kAvailableSize); | 
| 1875 } | 1896 } | 
| 1876 | 1897 | 
| 1877 gridAreaSize += guttersSize(ForRows, span.integerSpan()); | 1898 gridAreaSize += guttersSize(ForRows, span.integerSpan(), LayoutUnit()); | 
| 
 
Manuel Rego
2016/07/01 06:45:57
I'm not sure if this call is right, if the sizingO
 
 | |
| 1878 | 1899 | 
| 1879 return gridAreaIsIndefinite ? std::max(child.maxPreferredLogicalWidth(), gri dAreaSize) : gridAreaSize; | 1900 return gridAreaIsIndefinite ? std::max(child.maxPreferredLogicalWidth(), gri dAreaSize) : gridAreaSize; | 
| 1880 } | 1901 } | 
| 1881 | 1902 | 
| 1882 LayoutUnit LayoutGrid::gridAreaBreadthForChild(const LayoutBox& child, GridTrack SizingDirection direction, const GridSizingData& sizingData) const | 1903 LayoutUnit LayoutGrid::gridAreaBreadthForChild(const LayoutBox& child, GridTrack SizingDirection direction, const GridSizingData& sizingData) const | 
| 1883 { | 1904 { | 
| 1884 // To determine the column track's size based on an orthogonal grid item we need it's logical height, which | 1905 // To determine the column track's size based on an orthogonal grid item we need it's logical height, which | 
| 1885 // may depend on the row track's size. It's possible that the row tracks siz ing logic has not been performed yet, | 1906 // may depend on the row track's size. It's possible that the row tracks siz ing logic has not been performed yet, | 
| 1886 // so we will need to do an estimation. | 1907 // so we will need to do an estimation. | 
| 1887 if (direction == ForRows && sizingData.sizingState == GridSizingData::Column SizingFirstIteration) | 1908 if (direction == ForRows && sizingData.sizingState == GridSizingData::Column SizingFirstIteration) | 
| 1888 return assumedRowsSizeForOrthogonalChild(child, sizingData.sizingOperati on); | 1909 return assumedRowsSizeForOrthogonalChild(child, sizingData.sizingOperati on); | 
| 1889 | 1910 | 
| 1890 const Vector<GridTrack>& tracks = direction == ForColumns ? sizingData.colum nTracks : sizingData.rowTracks; | 1911 const Vector<GridTrack>& tracks = direction == ForColumns ? sizingData.colum nTracks : sizingData.rowTracks; | 
| 1891 const GridSpan& span = cachedGridSpan(child, direction); | 1912 const GridSpan& span = cachedGridSpan(child, direction); | 
| 1892 LayoutUnit gridAreaBreadth; | 1913 LayoutUnit gridAreaBreadth; | 
| 1893 for (const auto& trackPosition : span) | 1914 for (const auto& trackPosition : span) | 
| 1894 gridAreaBreadth += tracks[trackPosition].baseSize(); | 1915 gridAreaBreadth += tracks[trackPosition].baseSize(); | 
| 1895 | 1916 | 
| 1896 gridAreaBreadth += guttersSize(direction, span.integerSpan()); | 1917 gridAreaBreadth += sizingData.guttersSize(direction, span.integerSpan()); | 
| 1897 | 1918 | 
| 1898 return gridAreaBreadth; | 1919 return gridAreaBreadth; | 
| 1899 } | 1920 } | 
| 1900 | 1921 | 
| 1901 LayoutUnit LayoutGrid::gridAreaBreadthForChildIncludingAlignmentOffsets(const La youtBox& child, GridTrackSizingDirection direction, const GridSizingData& sizing Data) const | 1922 LayoutUnit LayoutGrid::gridAreaBreadthForChildIncludingAlignmentOffsets(const La youtBox& child, GridTrackSizingDirection direction, const GridSizingData& sizing Data) const | 
| 1902 { | 1923 { | 
| 1903 // We need the cached value when available because Content Distribution alig nment properties | 1924 // We need the cached value when available because Content Distribution alig nment properties | 
| 1904 // may have some influence in the final grid area breadth. | 1925 // may have some influence in the final grid area breadth. | 
| 1905 const Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.col umnTracks : sizingData.rowTracks; | 1926 const Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.col umnTracks : sizingData.rowTracks; | 
| 1906 const GridSpan& span = cachedGridSpan(child, direction); | 1927 const GridSpan& span = cachedGridSpan(child, direction); | 
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1919 | 1940 | 
| 1920 // The grid container's frame elements (border, padding and <content-positio n> offset) are sensible to the | 1941 // The grid container's frame elements (border, padding and <content-positio n> offset) are sensible to the | 
| 1921 // inline-axis flow direction. However, column lines positions are 'directio n' unaware. This simplification | 1942 // inline-axis flow direction. However, column lines positions are 'directio n' unaware. This simplification | 
| 1922 // allows us to use the same indexes to identify the columns independently o n the inline-axis direction. | 1943 // allows us to use the same indexes to identify the columns independently o n the inline-axis direction. | 
| 1923 bool isRowAxis = direction == ForColumns; | 1944 bool isRowAxis = direction == ForColumns; | 
| 1924 auto& tracks = isRowAxis ? sizingData.columnTracks : sizingData.rowTracks; | 1945 auto& tracks = isRowAxis ? sizingData.columnTracks : sizingData.rowTracks; | 
| 1925 size_t numberOfTracks = tracks.size(); | 1946 size_t numberOfTracks = tracks.size(); | 
| 1926 size_t numberOfLines = numberOfTracks + 1; | 1947 size_t numberOfLines = numberOfTracks + 1; | 
| 1927 size_t lastLine = numberOfLines - 1; | 1948 size_t lastLine = numberOfLines - 1; | 
| 1928 ContentAlignmentData offset = computeContentPositionAndDistributionOffset(di rection, sizingData.freeSpaceForDirection(direction), numberOfTracks); | 1949 ContentAlignmentData offset = computeContentPositionAndDistributionOffset(di rection, sizingData.freeSpaceForDirection(direction), numberOfTracks); | 
| 1929 LayoutUnit trackGap = guttersSize(direction, 2); | 1950 LayoutUnit trackGap = sizingData.trackGapsForDirection(direction); | 
| 1930 auto& positions = isRowAxis ? m_columnPositions : m_rowPositions; | 1951 auto& positions = isRowAxis ? m_columnPositions : m_rowPositions; | 
| 1931 positions.resize(numberOfLines); | 1952 positions.resize(numberOfLines); | 
| 1932 auto borderAndPadding = isRowAxis ? borderAndPaddingLogicalLeft() : borderAn dPaddingBefore(); | 1953 auto borderAndPadding = isRowAxis ? borderAndPaddingLogicalLeft() : borderAn dPaddingBefore(); | 
| 1933 positions[0] = borderAndPadding + offset.positionOffset; | 1954 positions[0] = borderAndPadding + offset.positionOffset; | 
| 1934 if (numberOfLines > 1) { | 1955 if (numberOfLines > 1) { | 
| 1935 size_t nextToLastLine = numberOfLines - 2; | 1956 size_t nextToLastLine = numberOfLines - 2; | 
| 1936 for (size_t i = 0; i < nextToLastLine; ++i) | 1957 for (size_t i = 0; i < nextToLastLine; ++i) | 
| 1937 positions[i + 1] = positions[i] + offset.distributionOffset + tracks [i].baseSize() + trackGap; | 1958 positions[i + 1] = positions[i] + offset.distributionOffset + tracks [i].baseSize() + trackGap; | 
| 1938 positions[lastLine] = positions[nextToLastLine] + tracks[nextToLastLine] .baseSize(); | 1959 positions[lastLine] = positions[nextToLastLine] + tracks[nextToLastLine] .baseSize(); | 
| 1939 } | 1960 } | 
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2179 switch (axisPosition) { | 2200 switch (axisPosition) { | 
| 2180 case GridAxisStart: | 2201 case GridAxisStart: | 
| 2181 return startPosition; | 2202 return startPosition; | 
| 2182 case GridAxisEnd: | 2203 case GridAxisEnd: | 
| 2183 case GridAxisCenter: { | 2204 case GridAxisCenter: { | 
| 2184 size_t childEndLine = rowsSpan.endLine(); | 2205 size_t childEndLine = rowsSpan.endLine(); | 
| 2185 LayoutUnit endOfRow = m_rowPositions[childEndLine]; | 2206 LayoutUnit endOfRow = m_rowPositions[childEndLine]; | 
| 2186 // m_rowPositions include distribution offset (because of content alignm ent) and gutters | 2207 // m_rowPositions include distribution offset (because of content alignm ent) and gutters | 
| 2187 // so we need to subtract them to get the actual end position for a give n row | 2208 // so we need to subtract them to get the actual end position for a give n row | 
| 2188 // (this does not have to be done for the last track as there are no mor e m_columnPositions after it). | 2209 // (this does not have to be done for the last track as there are no mor e m_columnPositions after it). | 
| 2189 LayoutUnit trackGap = guttersSize(ForRows, 2); | 2210 LayoutUnit trackGap = sizingData.trackGapsForDirection(ForRows); | 
| 2190 if (childEndLine < m_rowPositions.size() - 1) { | 2211 if (childEndLine < m_rowPositions.size() - 1) { | 
| 2191 endOfRow -= trackGap; | 2212 endOfRow -= trackGap; | 
| 2192 endOfRow -= m_offsetBetweenRows; | 2213 endOfRow -= m_offsetBetweenRows; | 
| 2193 } | 2214 } | 
| 2194 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHei ght(); | 2215 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHei ght(); | 
| 2195 OverflowAlignment overflow = child.styleRef().resolvedAlignment(styleRef (), ItemPositionStretch).overflow(); | 2216 OverflowAlignment overflow = child.styleRef().resolvedAlignment(styleRef (), ItemPositionStretch).overflow(); | 
| 2196 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over flow, endOfRow - startOfRow, childBreadth); | 2217 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over flow, endOfRow - startOfRow, childBreadth); | 
| 2197 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); | 2218 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); | 
| 2198 } | 2219 } | 
| 2199 } | 2220 } | 
| (...skipping 14 matching lines...) Expand all Loading... | |
| 2214 switch (axisPosition) { | 2235 switch (axisPosition) { | 
| 2215 case GridAxisStart: | 2236 case GridAxisStart: | 
| 2216 return startPosition; | 2237 return startPosition; | 
| 2217 case GridAxisEnd: | 2238 case GridAxisEnd: | 
| 2218 case GridAxisCenter: { | 2239 case GridAxisCenter: { | 
| 2219 size_t childEndLine = columnsSpan.endLine(); | 2240 size_t childEndLine = columnsSpan.endLine(); | 
| 2220 LayoutUnit endOfColumn = m_columnPositions[childEndLine]; | 2241 LayoutUnit endOfColumn = m_columnPositions[childEndLine]; | 
| 2221 // m_columnPositions include distribution offset (because of content ali gnment) and gutters | 2242 // m_columnPositions include distribution offset (because of content ali gnment) and gutters | 
| 2222 // so we need to subtract them to get the actual end position for a give n column | 2243 // so we need to subtract them to get the actual end position for a give n column | 
| 2223 // (this does not have to be done for the last track as there are no mor e m_columnPositions after it). | 2244 // (this does not have to be done for the last track as there are no mor e m_columnPositions after it). | 
| 2224 LayoutUnit trackGap = guttersSize(ForColumns, 2); | 2245 LayoutUnit trackGap = sizingData.trackGapsForDirection(ForColumns); | 
| 2225 if (childEndLine < m_columnPositions.size() - 1) { | 2246 if (childEndLine < m_columnPositions.size() - 1) { | 
| 2226 endOfColumn -= trackGap; | 2247 endOfColumn -= trackGap; | 
| 2227 endOfColumn -= m_offsetBetweenColumns; | 2248 endOfColumn -= m_offsetBetweenColumns; | 
| 2228 } | 2249 } | 
| 2229 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidt h(); | 2250 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidt h(); | 
| 2230 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil d.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, childB readth); | 2251 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil d.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, childB readth); | 
| 2231 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); | 2252 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); | 
| 2232 } | 2253 } | 
| 2233 } | 2254 } | 
| 2234 | 2255 | 
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2363 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation; | 2384 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation; | 
| 2364 } | 2385 } | 
| 2365 | 2386 | 
| 2366 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const | 2387 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const | 
| 2367 { | 2388 { | 
| 2368 if (!m_gridItemArea.isEmpty()) | 2389 if (!m_gridItemArea.isEmpty()) | 
| 2369 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2390 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 
| 2370 } | 2391 } | 
| 2371 | 2392 | 
| 2372 } // namespace blink | 2393 } // namespace blink | 
| OLD | NEW |