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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 393 return m_grid.size(); | 393 return m_grid.size(); |
| 394 } | 394 } |
| 395 | 395 |
| 396 LayoutUnit LayoutGrid::computeTrackBasedLogicalHeight(const GridSizingData& sizi ngData) const | 396 LayoutUnit LayoutGrid::computeTrackBasedLogicalHeight(const GridSizingData& sizi ngData) const |
| 397 { | 397 { |
| 398 LayoutUnit logicalHeight; | 398 LayoutUnit logicalHeight; |
| 399 | 399 |
| 400 for (const auto& row : sizingData.rowTracks) | 400 for (const auto& row : sizingData.rowTracks) |
| 401 logicalHeight += row.baseSize(); | 401 logicalHeight += row.baseSize(); |
| 402 | 402 |
| 403 logicalHeight += guttersSize(ForRows, 0, sizingData.rowTracks.size()); | 403 logicalHeight += guttersSize(ForRows, 0, sizingData.rowTracks.size(), sizing Data.sizingOperation); |
| 404 | 404 |
| 405 return logicalHeight; | 405 return logicalHeight; |
| 406 } | 406 } |
| 407 | 407 |
| 408 void LayoutGrid::computeTrackSizesForDirection(GridTrackSizingDirection directio n, GridSizingData& sizingData, LayoutUnit availableSpace) | 408 void LayoutGrid::computeTrackSizesForDirection(GridTrackSizingDirection directio n, GridSizingData& sizingData, LayoutUnit availableSpace) |
| 409 { | 409 { |
| 410 DCHECK(sizingData.isValidTransition(direction)); | 410 DCHECK(sizingData.isValidTransition(direction)); |
| 411 sizingData.setAvailableSpace(availableSpace); | 411 sizingData.setAvailableSpace(availableSpace); |
| 412 sizingData.freeSpace(direction) = availableSpace - guttersSize(direction, 0, direction == ForRows ? gridRowCount() : gridColumnCount()); | 412 sizingData.freeSpace(direction) = availableSpace - guttersSize(direction, 0, direction == ForRows ? gridRowCount() : gridColumnCount(), sizingData.sizingOpe ration); |
| 413 sizingData.sizingOperation = TrackSizing; | 413 sizingData.sizingOperation = TrackSizing; |
| 414 | 414 |
| 415 LayoutUnit baseSizes, growthLimits; | 415 LayoutUnit baseSizes, growthLimits; |
| 416 computeUsedBreadthOfGridTracks(direction, sizingData, baseSizes, growthLimit s); | 416 computeUsedBreadthOfGridTracks(direction, sizingData, baseSizes, growthLimit s); |
| 417 ASSERT(tracksAreWiderThanMinTrackBreadth(direction, sizingData)); | 417 ASSERT(tracksAreWiderThanMinTrackBreadth(direction, sizingData)); |
| 418 sizingData.nextState(); | 418 sizingData.nextState(); |
| 419 } | 419 } |
| 420 | 420 |
| 421 void LayoutGrid::repeatTracksSizingIfNeeded(GridSizingData& sizingData, LayoutUn it availableSpaceForColumns, LayoutUnit availableSpaceForRows) | 421 void LayoutGrid::repeatTracksSizingIfNeeded(GridSizingData& sizingData, LayoutUn it availableSpaceForColumns, LayoutUnit availableSpaceForRows) |
| 422 { | 422 { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 522 { | 522 { |
| 523 return direction == ForColumns ? !!m_autoRepeatEmptyColumns : !!m_autoRepeat EmptyRows; | 523 return direction == ForColumns ? !!m_autoRepeatEmptyColumns : !!m_autoRepeat EmptyRows; |
| 524 } | 524 } |
| 525 | 525 |
| 526 bool LayoutGrid::isEmptyAutoRepeatTrack(GridTrackSizingDirection direction, size _t line) const | 526 bool LayoutGrid::isEmptyAutoRepeatTrack(GridTrackSizingDirection direction, size _t line) const |
| 527 { | 527 { |
| 528 DCHECK(hasAutoRepeatEmptyTracks(direction)); | 528 DCHECK(hasAutoRepeatEmptyTracks(direction)); |
| 529 return direction == ForColumns ? m_autoRepeatEmptyColumns->contains(line) : m_autoRepeatEmptyRows->contains(line); | 529 return direction == ForColumns ? m_autoRepeatEmptyColumns->contains(line) : m_autoRepeatEmptyRows->contains(line); |
| 530 } | 530 } |
| 531 | 531 |
| 532 LayoutUnit LayoutGrid::gridGapForDirection(GridTrackSizingDirection direction) c onst | 532 LayoutUnit LayoutGrid::gridGapForDirection(GridTrackSizingDirection direction, S izingOperation sizingOperation) const |
| 533 { | 533 { |
| 534 return valueForLength(direction == ForColumns ? styleRef().gridColumnGap() : styleRef().gridRowGap(), LayoutUnit()); | 534 LayoutUnit availableSize = LayoutUnit(); |
| 535 if (sizingOperation == TrackSizing) { | |
| 536 if (direction == ForColumns) | |
| 537 availableSize = availableLogicalWidth(); | |
| 538 else | |
| 539 availableSize = availableLogicalHeightForPercentageComputation(); | |
|
svillar
2016/09/08 16:03:35
Ternary operator?.
Also it's enough to declare L
Manuel Rego
2016/09/08 16:34:23
Acknowledged.
| |
| 540 } | |
| 541 | |
| 542 return valueForLength(direction == ForColumns ? styleRef().gridColumnGap() : styleRef().gridRowGap(), availableSize); | |
|
jfernandez
2016/09/08 15:48:02
Perhaps something to consider for the future (pote
Manuel Rego
2016/09/08 16:34:23
Done.
| |
| 535 } | 543 } |
| 536 | 544 |
| 537 LayoutUnit LayoutGrid::guttersSize(GridTrackSizingDirection direction, size_t st artLine, size_t span) const | 545 LayoutUnit LayoutGrid::guttersSize(GridTrackSizingDirection direction, size_t st artLine, size_t span, SizingOperation sizingOperation) const |
| 538 { | 546 { |
| 539 if (span <= 1) | 547 if (span <= 1) |
| 540 return LayoutUnit(); | 548 return LayoutUnit(); |
| 541 | 549 |
| 542 bool isRowAxis = direction == ForColumns; | 550 bool isRowAxis = direction == ForColumns; |
| 543 LayoutUnit gap = gridGapForDirection(direction); | 551 LayoutUnit gap = gridGapForDirection(direction, sizingOperation); |
| 544 | 552 |
| 545 // Fast path, no collapsing tracks. | 553 // Fast path, no collapsing tracks. |
| 546 if (!hasAutoRepeatEmptyTracks(direction)) | 554 if (!hasAutoRepeatEmptyTracks(direction)) |
| 547 return gap * (span - 1); | 555 return gap * (span - 1); |
| 548 | 556 |
| 549 // If there are collapsing tracks we need to be sure that gutters are proper ly collapsed. Apart | 557 // If there are collapsing tracks we need to be sure that gutters are proper ly collapsed. Apart |
| 550 // from that, if we have a collapsed track in the edges of the span we're co nsidering, we need | 558 // from that, if we have a collapsed track in the edges of the span we're co nsidering, we need |
| 551 // to move forward (or backwards) in order to know whether the collapsed tra cks reach the end of | 559 // to move forward (or backwards) in order to know whether the collapsed tra cks reach the end of |
| 552 // the grid (so the gap becomes 0) or there is a non empty track before that . | 560 // the grid (so the gap becomes 0) or there is a non empty track before that . |
| 553 | 561 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 593 void LayoutGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const | 601 void LayoutGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const |
| 594 { | 602 { |
| 595 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(IntrinsicSizeComputation); | 603 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(IntrinsicSizeComputation); |
| 596 | 604 |
| 597 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 605 GridSizingData sizingData(gridColumnCount(), gridRowCount()); |
| 598 sizingData.setAvailableSpace(LayoutUnit()); | 606 sizingData.setAvailableSpace(LayoutUnit()); |
| 599 sizingData.freeSpace(ForColumns) = LayoutUnit(); | 607 sizingData.freeSpace(ForColumns) = LayoutUnit(); |
| 600 sizingData.sizingOperation = IntrinsicSizeComputation; | 608 sizingData.sizingOperation = IntrinsicSizeComputation; |
| 601 computeUsedBreadthOfGridTracks(ForColumns, sizingData, minLogicalWidth, maxL ogicalWidth); | 609 computeUsedBreadthOfGridTracks(ForColumns, sizingData, minLogicalWidth, maxL ogicalWidth); |
| 602 | 610 |
| 603 LayoutUnit totalGuttersSize = guttersSize(ForColumns, 0, sizingData.columnTr acks.size()); | 611 LayoutUnit totalGuttersSize = guttersSize(ForColumns, 0, sizingData.columnTr acks.size(), sizingData.sizingOperation); |
| 604 minLogicalWidth += totalGuttersSize; | 612 minLogicalWidth += totalGuttersSize; |
| 605 maxLogicalWidth += totalGuttersSize; | 613 maxLogicalWidth += totalGuttersSize; |
| 606 | 614 |
| 607 LayoutUnit scrollbarWidth = LayoutUnit(scrollbarLogicalWidth()); | 615 LayoutUnit scrollbarWidth = LayoutUnit(scrollbarLogicalWidth()); |
| 608 minLogicalWidth += scrollbarWidth; | 616 minLogicalWidth += scrollbarWidth; |
| 609 maxLogicalWidth += scrollbarWidth; | 617 maxLogicalWidth += scrollbarWidth; |
| 610 } | 618 } |
| 611 | 619 |
| 612 void LayoutGrid::computeIntrinsicLogicalHeight(GridSizingData& sizingData) | 620 void LayoutGrid::computeIntrinsicLogicalHeight(GridSizingData& sizingData) |
| 613 { | 621 { |
| 614 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData)); | 622 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData)); |
| 615 sizingData.setAvailableSpace(LayoutUnit()); | 623 sizingData.setAvailableSpace(LayoutUnit()); |
| 616 sizingData.freeSpace(ForRows) = LayoutUnit(); | 624 sizingData.freeSpace(ForRows) = LayoutUnit(); |
| 617 sizingData.sizingOperation = IntrinsicSizeComputation; | 625 sizingData.sizingOperation = IntrinsicSizeComputation; |
| 618 computeUsedBreadthOfGridTracks(ForRows, sizingData, m_minContentHeight, m_ma xContentHeight); | 626 computeUsedBreadthOfGridTracks(ForRows, sizingData, m_minContentHeight, m_ma xContentHeight); |
| 619 | 627 |
| 620 LayoutUnit totalGuttersSize = guttersSize(ForRows, 0, gridRowCount()); | 628 LayoutUnit totalGuttersSize = guttersSize(ForRows, 0, gridRowCount(), sizing Data.sizingOperation); |
|
jfernandez
2016/09/08 15:48:02
Isn't this always IntrinsicSizeComputation ?
Manuel Rego
2016/09/08 16:34:23
Yeah, but in case we change it at some point
we wo
| |
| 621 m_minContentHeight += totalGuttersSize; | 629 m_minContentHeight += totalGuttersSize; |
| 622 m_maxContentHeight += totalGuttersSize; | 630 m_maxContentHeight += totalGuttersSize; |
| 623 | 631 |
| 624 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData)); | 632 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData)); |
| 625 } | 633 } |
| 626 | 634 |
| 627 LayoutUnit LayoutGrid::computeIntrinsicLogicalContentHeightUsing(const Length& l ogicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddi ng) const | 635 LayoutUnit LayoutGrid::computeIntrinsicLogicalContentHeightUsing(const Length& l ogicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddi ng) const |
| 628 { | 636 { |
| 629 if (logicalHeightLength.isMinContent()) | 637 if (logicalHeightLength.isMinContent()) |
| 630 return m_minContentHeight; | 638 return m_minContentHeight; |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1302 | 1310 |
| 1303 sizingData.filteredTracks.append(&track); | 1311 sizingData.filteredTracks.append(&track); |
| 1304 | 1312 |
| 1305 if (trackShouldGrowBeyondGrowthLimitsForTrackSizeComputationPhase(ph ase, trackSize)) | 1313 if (trackShouldGrowBeyondGrowthLimitsForTrackSizeComputationPhase(ph ase, trackSize)) |
| 1306 sizingData.growBeyondGrowthLimitsTracks.append(&track); | 1314 sizingData.growBeyondGrowthLimitsTracks.append(&track); |
| 1307 } | 1315 } |
| 1308 | 1316 |
| 1309 if (sizingData.filteredTracks.isEmpty()) | 1317 if (sizingData.filteredTracks.isEmpty()) |
| 1310 continue; | 1318 continue; |
| 1311 | 1319 |
| 1312 spanningTracksSize += guttersSize(direction, itemSpan.startLine(), itemS pan.integerSpan()); | 1320 spanningTracksSize += guttersSize(direction, itemSpan.startLine(), itemS pan.integerSpan(), sizingData.sizingOperation); |
|
jfernandez
2016/09/08 15:48:02
Ditto.
| |
| 1313 | 1321 |
| 1314 LayoutUnit extraSpace = currentItemSizeForTrackSizeComputationPhase(phas e, gridItemWithSpan.gridItem(), direction, sizingData) - spanningTracksSize; | 1322 LayoutUnit extraSpace = currentItemSizeForTrackSizeComputationPhase(phas e, gridItemWithSpan.gridItem(), direction, sizingData) - spanningTracksSize; |
| 1315 extraSpace = extraSpace.clampNegativeToZero(); | 1323 extraSpace = extraSpace.clampNegativeToZero(); |
| 1316 auto& tracksToGrowBeyondGrowthLimits = sizingData.growBeyondGrowthLimits Tracks.isEmpty() ? sizingData.filteredTracks : sizingData.growBeyondGrowthLimits Tracks; | 1324 auto& tracksToGrowBeyondGrowthLimits = sizingData.growBeyondGrowthLimits Tracks.isEmpty() ? sizingData.filteredTracks : sizingData.growBeyondGrowthLimits Tracks; |
| 1317 distributeSpaceToTracks<phase>(sizingData.filteredTracks, &tracksToGrowB eyondGrowthLimits, sizingData, extraSpace); | 1325 distributeSpaceToTracks<phase>(sizingData.filteredTracks, &tracksToGrowB eyondGrowthLimits, sizingData, extraSpace); |
| 1318 } | 1326 } |
| 1319 | 1327 |
| 1320 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { | 1328 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { |
| 1321 GridTrack& track = tracks[trackIndex]; | 1329 GridTrack& track = tracks[trackIndex]; |
| 1322 markAsInfinitelyGrowableForTrackSizeComputationPhase(phase, track); | 1330 markAsInfinitelyGrowableForTrackSizeComputationPhase(phase, track); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1491 const Vector<GridTrackSize>& trackSizes = isRowAxis ? styleRef().gridTemplat eColumns() : styleRef().gridTemplateRows(); | 1499 const Vector<GridTrackSize>& trackSizes = isRowAxis ? styleRef().gridTemplat eColumns() : styleRef().gridTemplateRows(); |
| 1492 | 1500 |
| 1493 for (const auto& track : trackSizes) { | 1501 for (const auto& track : trackSizes) { |
| 1494 bool hasDefiniteMaxTrackBreadth = track.maxTrackBreadth().isLength() && !track.maxTrackBreadth().isContentSized(); | 1502 bool hasDefiniteMaxTrackBreadth = track.maxTrackBreadth().isLength() && !track.maxTrackBreadth().isContentSized(); |
| 1495 DCHECK(hasDefiniteMaxTrackBreadth || (track.minTrackBreadth().isLength() && !track.minTrackBreadth().isContentSized())); | 1503 DCHECK(hasDefiniteMaxTrackBreadth || (track.minTrackBreadth().isLength() && !track.minTrackBreadth().isContentSized())); |
| 1496 tracksSize += valueForLength(hasDefiniteMaxTrackBreadth ? track.maxTrack Breadth().length() : track.minTrackBreadth().length(), availableSize); | 1504 tracksSize += valueForLength(hasDefiniteMaxTrackBreadth ? track.maxTrack Breadth().length() : track.minTrackBreadth().length(), availableSize); |
| 1497 } | 1505 } |
| 1498 | 1506 |
| 1499 // Add gutters as if there where only 1 auto repeat track. Gaps between auto repeat tracks will be added later when | 1507 // Add gutters as if there where only 1 auto repeat track. Gaps between auto repeat tracks will be added later when |
| 1500 // computing the repetitions. | 1508 // computing the repetitions. |
| 1501 LayoutUnit gapSize = gridGapForDirection(direction); | 1509 LayoutUnit gapSize = gridGapForDirection(direction, sizingOperation); |
| 1502 tracksSize += gapSize * trackSizes.size(); | 1510 tracksSize += gapSize * trackSizes.size(); |
| 1503 | 1511 |
| 1504 LayoutUnit freeSpace = availableSize - tracksSize; | 1512 LayoutUnit freeSpace = availableSize - tracksSize; |
| 1505 if (freeSpace <= 0) | 1513 if (freeSpace <= 0) |
| 1506 return autoRepeatTrackListLength; | 1514 return autoRepeatTrackListLength; |
| 1507 | 1515 |
| 1508 size_t repetitions = 1 + (freeSpace / (autoRepeatTracksSize + gapSize)).toIn t(); | 1516 size_t repetitions = 1 + (freeSpace / (autoRepeatTracksSize + gapSize)).toIn t(); |
| 1509 | 1517 |
| 1510 // Provided the grid container does not have a definite size or max-size in the relevant axis, | 1518 // Provided the grid container does not have a definite size or max-size in the relevant axis, |
| 1511 // if the min size is definite then the number of repetitions is the largest possible positive | 1519 // if the min size is definite then the number of repetitions is the largest possible positive |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1813 bool isRowAxis = direction == ForColumns; | 1821 bool isRowAxis = direction == ForColumns; |
| 1814 auto& positions = isRowAxis ? m_columnPositions : m_rowPositions; | 1822 auto& positions = isRowAxis ? m_columnPositions : m_rowPositions; |
| 1815 size_t numPositions = positions.size(); | 1823 size_t numPositions = positions.size(); |
| 1816 LayoutUnit offsetBetweenTracks = isRowAxis ? m_offsetBetweenColumns : m_offs etBetweenRows; | 1824 LayoutUnit offsetBetweenTracks = isRowAxis ? m_offsetBetweenColumns : m_offs etBetweenRows; |
| 1817 | 1825 |
| 1818 Vector<LayoutUnit> tracks; | 1826 Vector<LayoutUnit> tracks; |
| 1819 if (numPositions < 2) | 1827 if (numPositions < 2) |
| 1820 return tracks; | 1828 return tracks; |
| 1821 | 1829 |
| 1822 bool hasCollapsedTracks = hasAutoRepeatEmptyTracks(direction); | 1830 bool hasCollapsedTracks = hasAutoRepeatEmptyTracks(direction); |
| 1823 LayoutUnit gap = !hasCollapsedTracks ? gridGapForDirection(direction) : Layo utUnit(); | 1831 LayoutUnit gap = !hasCollapsedTracks ? gridGapForDirection(direction, TrackS izing) : LayoutUnit(); |
| 1824 tracks.reserveCapacity(numPositions - 1); | 1832 tracks.reserveCapacity(numPositions - 1); |
| 1825 for (size_t i = 0; i < numPositions - 2; ++i) | 1833 for (size_t i = 0; i < numPositions - 2; ++i) |
| 1826 tracks.append(positions[i + 1] - positions[i] - offsetBetweenTracks - ga p); | 1834 tracks.append(positions[i + 1] - positions[i] - offsetBetweenTracks - ga p); |
| 1827 tracks.append(positions[numPositions - 1] - positions[numPositions - 2]); | 1835 tracks.append(positions[numPositions - 1] - positions[numPositions - 2]); |
| 1828 | 1836 |
| 1829 if (!hasCollapsedTracks) | 1837 if (!hasCollapsedTracks) |
| 1830 return tracks; | 1838 return tracks; |
| 1831 | 1839 |
| 1832 size_t remainingEmptyTracks = isRowAxis ? m_autoRepeatEmptyColumns->size() : m_autoRepeatEmptyRows->size(); | 1840 size_t remainingEmptyTracks = isRowAxis ? m_autoRepeatEmptyColumns->size() : m_autoRepeatEmptyRows->size(); |
| 1833 size_t lastLine = tracks.size(); | 1841 size_t lastLine = tracks.size(); |
| 1834 gap = gridGapForDirection(direction); | 1842 gap = gridGapForDirection(direction, TrackSizing); |
| 1835 for (size_t i = 1; i < lastLine; ++i) { | 1843 for (size_t i = 1; i < lastLine; ++i) { |
| 1836 if (isEmptyAutoRepeatTrack(direction, i - 1)) { | 1844 if (isEmptyAutoRepeatTrack(direction, i - 1)) { |
| 1837 --remainingEmptyTracks; | 1845 --remainingEmptyTracks; |
| 1838 } else { | 1846 } else { |
| 1839 // Remove the gap between consecutive non empty tracks. Remove it al so just once for an | 1847 // Remove the gap between consecutive non empty tracks. Remove it al so just once for an |
| 1840 // arbitrary number of empty tracks between two non empty ones. | 1848 // arbitrary number of empty tracks between two non empty ones. |
| 1841 bool allRemainingTracksAreEmpty = remainingEmptyTracks == (lastLine - i); | 1849 bool allRemainingTracksAreEmpty = remainingEmptyTracks == (lastLine - i); |
| 1842 if (!allRemainingTracksAreEmpty || !isEmptyAutoRepeatTrack(direction , i)) | 1850 if (!allRemainingTracksAreEmpty || !isEmptyAutoRepeatTrack(direction , i)) |
| 1843 tracks[i - 1] -= gap; | 1851 tracks[i - 1] -= gap; |
| 1844 } | 1852 } |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2030 if (styleRef().isLeftToRightDirection()) | 2038 if (styleRef().isLeftToRightDirection()) |
| 2031 end = m_columnPositions[endLine] - borderLogicalLeft(); | 2039 end = m_columnPositions[endLine] - borderLogicalLeft(); |
| 2032 else | 2040 else |
| 2033 end = logicalWidth() - translateRTLCoordinate(m_columnPositions[ endLine]) - borderLogicalRight(); | 2041 end = logicalWidth() - translateRTLCoordinate(m_columnPositions[ endLine]) - borderLogicalRight(); |
| 2034 } else { | 2042 } else { |
| 2035 end = m_rowPositions[endLine] - borderBefore(); | 2043 end = m_rowPositions[endLine] - borderBefore(); |
| 2036 } | 2044 } |
| 2037 | 2045 |
| 2038 // These vectors store line positions including gaps, but we shouldn't c onsider them for the edges of the grid. | 2046 // These vectors store line positions including gaps, but we shouldn't c onsider them for the edges of the grid. |
| 2039 if (endLine > 0 && endLine < lastLine) { | 2047 if (endLine > 0 && endLine < lastLine) { |
| 2040 end -= guttersSize(direction, endLine - 1, 2); | 2048 end -= guttersSize(direction, endLine - 1, 2, TrackSizing); |
| 2041 end -= isForColumns ? m_offsetBetweenColumns : m_offsetBetweenRows; | 2049 end -= isForColumns ? m_offsetBetweenColumns : m_offsetBetweenRows; |
| 2042 } | 2050 } |
| 2043 } | 2051 } |
| 2044 | 2052 |
| 2045 breadth = std::max(end - start, LayoutUnit()); | 2053 breadth = std::max(end - start, LayoutUnit()); |
| 2046 offset = start; | 2054 offset = start; |
| 2047 | 2055 |
| 2048 if (isForColumns && !styleRef().isLeftToRightDirection() && !child.styleRef( ).hasStaticInlinePosition(child.isHorizontalWritingMode())) { | 2056 if (isForColumns && !styleRef().isLeftToRightDirection() && !child.styleRef( ).hasStaticInlinePosition(child.isHorizontalWritingMode())) { |
| 2049 // If the child doesn't have a static inline position (i.e. "left" and/o r "right" aren't "auto", | 2057 // If the child doesn't have a static inline position (i.e. "left" and/o r "right" aren't "auto", |
| 2050 // we need to calculate the offset from the left (even if we're in RTL). | 2058 // we need to calculate the offset from the left (even if we're in RTL). |
| 2051 if (endIsAuto) { | 2059 if (endIsAuto) { |
| 2052 offset = LayoutUnit(); | 2060 offset = LayoutUnit(); |
| 2053 } else { | 2061 } else { |
| 2054 offset = translateRTLCoordinate(m_columnPositions[endLine]) - border LogicalLeft(); | 2062 offset = translateRTLCoordinate(m_columnPositions[endLine]) - border LogicalLeft(); |
| 2055 | 2063 |
| 2056 if (endLine > 0 && endLine < lastLine) { | 2064 if (endLine > 0 && endLine < lastLine) { |
| 2057 offset += guttersSize(direction, endLine - 1, 2); | 2065 offset += guttersSize(direction, endLine - 1, 2, TrackSizing); |
| 2058 offset += isForColumns ? m_offsetBetweenColumns : m_offsetBetwee nRows; | 2066 offset += isForColumns ? m_offsetBetweenColumns : m_offsetBetwee nRows; |
| 2059 } | 2067 } |
| 2060 } | 2068 } |
| 2061 } | 2069 } |
| 2062 | 2070 |
| 2063 } | 2071 } |
| 2064 | 2072 |
| 2065 GridArea LayoutGrid::cachedGridArea(const LayoutBox& gridItem) const | 2073 GridArea LayoutGrid::cachedGridArea(const LayoutBox& gridItem) const |
| 2066 { | 2074 { |
| 2067 ASSERT(m_gridItemArea.contains(&gridItem)); | 2075 ASSERT(m_gridItemArea.contains(&gridItem)); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 2082 bool gridAreaIsIndefinite = false; | 2090 bool gridAreaIsIndefinite = false; |
| 2083 LayoutUnit containingBlockAvailableSize = containingBlockLogicalHeightForCon tent(ExcludeMarginBorderPadding); | 2091 LayoutUnit containingBlockAvailableSize = containingBlockLogicalHeightForCon tent(ExcludeMarginBorderPadding); |
| 2084 for (auto trackPosition : span) { | 2092 for (auto trackPosition : span) { |
| 2085 const GridLength& maxTrackSize = gridTrackSize(ForRows, trackPosition, s izingOperation).maxTrackBreadth(); | 2093 const GridLength& maxTrackSize = gridTrackSize(ForRows, trackPosition, s izingOperation).maxTrackBreadth(); |
| 2086 if (maxTrackSize.isContentSized() || maxTrackSize.isFlex()) | 2094 if (maxTrackSize.isContentSized() || maxTrackSize.isFlex()) |
| 2087 gridAreaIsIndefinite = true; | 2095 gridAreaIsIndefinite = true; |
| 2088 else | 2096 else |
| 2089 gridAreaSize += valueForLength(maxTrackSize.length(), containingBloc kAvailableSize); | 2097 gridAreaSize += valueForLength(maxTrackSize.length(), containingBloc kAvailableSize); |
| 2090 } | 2098 } |
| 2091 | 2099 |
| 2092 gridAreaSize += guttersSize(ForRows, span.startLine(), span.integerSpan()); | 2100 gridAreaSize += guttersSize(ForRows, span.startLine(), span.integerSpan(), s izingOperation); |
| 2093 | 2101 |
| 2094 return gridAreaIsIndefinite ? std::max(child.maxPreferredLogicalWidth(), gri dAreaSize) : gridAreaSize; | 2102 return gridAreaIsIndefinite ? std::max(child.maxPreferredLogicalWidth(), gri dAreaSize) : gridAreaSize; |
| 2095 } | 2103 } |
| 2096 | 2104 |
| 2097 LayoutUnit LayoutGrid::gridAreaBreadthForChild(const LayoutBox& child, GridTrack SizingDirection direction, const GridSizingData& sizingData) const | 2105 LayoutUnit LayoutGrid::gridAreaBreadthForChild(const LayoutBox& child, GridTrack SizingDirection direction, const GridSizingData& sizingData) const |
| 2098 { | 2106 { |
| 2099 // To determine the column track's size based on an orthogonal grid item we need it's logical height, which | 2107 // To determine the column track's size based on an orthogonal grid item we need it's logical height, which |
| 2100 // may depend on the row track's size. It's possible that the row tracks siz ing logic has not been performed yet, | 2108 // may depend on the row track's size. It's possible that the row tracks siz ing logic has not been performed yet, |
| 2101 // so we will need to do an estimation. | 2109 // so we will need to do an estimation. |
| 2102 if (direction == ForRows && sizingData.sizingState == GridSizingData::Column SizingFirstIteration) | 2110 if (direction == ForRows && sizingData.sizingState == GridSizingData::Column SizingFirstIteration) |
| 2103 return assumedRowsSizeForOrthogonalChild(child, sizingData.sizingOperati on); | 2111 return assumedRowsSizeForOrthogonalChild(child, sizingData.sizingOperati on); |
| 2104 | 2112 |
| 2105 const Vector<GridTrack>& tracks = direction == ForColumns ? sizingData.colum nTracks : sizingData.rowTracks; | 2113 const Vector<GridTrack>& tracks = direction == ForColumns ? sizingData.colum nTracks : sizingData.rowTracks; |
| 2106 const GridSpan& span = cachedGridSpan(child, direction); | 2114 const GridSpan& span = cachedGridSpan(child, direction); |
| 2107 LayoutUnit gridAreaBreadth; | 2115 LayoutUnit gridAreaBreadth; |
| 2108 for (const auto& trackPosition : span) | 2116 for (const auto& trackPosition : span) |
| 2109 gridAreaBreadth += tracks[trackPosition].baseSize(); | 2117 gridAreaBreadth += tracks[trackPosition].baseSize(); |
| 2110 | 2118 |
| 2111 gridAreaBreadth += guttersSize(direction, span.startLine(), span.integerSpan ()); | 2119 gridAreaBreadth += guttersSize(direction, span.startLine(), span.integerSpan (), sizingData.sizingOperation); |
| 2112 | 2120 |
| 2113 return gridAreaBreadth; | 2121 return gridAreaBreadth; |
| 2114 } | 2122 } |
| 2115 | 2123 |
| 2116 LayoutUnit LayoutGrid::gridAreaBreadthForChildIncludingAlignmentOffsets(const La youtBox& child, GridTrackSizingDirection direction, const GridSizingData& sizing Data) const | 2124 LayoutUnit LayoutGrid::gridAreaBreadthForChildIncludingAlignmentOffsets(const La youtBox& child, GridTrackSizingDirection direction, const GridSizingData& sizing Data) const |
| 2117 { | 2125 { |
| 2118 // We need the cached value when available because Content Distribution alig nment properties | 2126 // We need the cached value when available because Content Distribution alig nment properties |
| 2119 // may have some influence in the final grid area breadth. | 2127 // may have some influence in the final grid area breadth. |
| 2120 const Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.col umnTracks : sizingData.rowTracks; | 2128 const Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.col umnTracks : sizingData.rowTracks; |
| 2121 const GridSpan& span = cachedGridSpan(child, direction); | 2129 const GridSpan& span = cachedGridSpan(child, direction); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 2142 size_t lastLine = numberOfLines - 1; | 2150 size_t lastLine = numberOfLines - 1; |
| 2143 ContentAlignmentData offset = computeContentPositionAndDistributionOffset(di rection, sizingData.freeSpace(direction), numberOfTracks); | 2151 ContentAlignmentData offset = computeContentPositionAndDistributionOffset(di rection, sizingData.freeSpace(direction), numberOfTracks); |
| 2144 auto& positions = isRowAxis ? m_columnPositions : m_rowPositions; | 2152 auto& positions = isRowAxis ? m_columnPositions : m_rowPositions; |
| 2145 positions.resize(numberOfLines); | 2153 positions.resize(numberOfLines); |
| 2146 auto borderAndPadding = isRowAxis ? borderAndPaddingLogicalLeft() : borderAn dPaddingBefore(); | 2154 auto borderAndPadding = isRowAxis ? borderAndPaddingLogicalLeft() : borderAn dPaddingBefore(); |
| 2147 positions[0] = borderAndPadding + offset.positionOffset; | 2155 positions[0] = borderAndPadding + offset.positionOffset; |
| 2148 if (numberOfLines > 1) { | 2156 if (numberOfLines > 1) { |
| 2149 // If we have collapsed tracks we just ignore gaps here and add them lat er as we might not | 2157 // If we have collapsed tracks we just ignore gaps here and add them lat er as we might not |
| 2150 // compute the gap between two consecutive tracks without examining the surrounding ones. | 2158 // compute the gap between two consecutive tracks without examining the surrounding ones. |
| 2151 bool hasCollapsedTracks = hasAutoRepeatEmptyTracks(direction); | 2159 bool hasCollapsedTracks = hasAutoRepeatEmptyTracks(direction); |
| 2152 LayoutUnit gap = !hasCollapsedTracks ? gridGapForDirection(direction) : LayoutUnit(); | 2160 LayoutUnit gap = !hasCollapsedTracks ? gridGapForDirection(direction, si zingData.sizingOperation) : LayoutUnit(); |
| 2153 size_t nextToLastLine = numberOfLines - 2; | 2161 size_t nextToLastLine = numberOfLines - 2; |
| 2154 for (size_t i = 0; i < nextToLastLine; ++i) | 2162 for (size_t i = 0; i < nextToLastLine; ++i) |
| 2155 positions[i + 1] = positions[i] + offset.distributionOffset + tracks [i].baseSize() + gap; | 2163 positions[i + 1] = positions[i] + offset.distributionOffset + tracks [i].baseSize() + gap; |
| 2156 positions[lastLine] = positions[nextToLastLine] + tracks[nextToLastLine] .baseSize(); | 2164 positions[lastLine] = positions[nextToLastLine] + tracks[nextToLastLine] .baseSize(); |
| 2157 | 2165 |
| 2158 // Adjust collapsed gaps. Collapsed tracks cause the surrounding gutters to collapse (they | 2166 // Adjust collapsed gaps. Collapsed tracks cause the surrounding gutters to collapse (they |
| 2159 // coincide exactly) except on the edges of the grid where they become 0 . | 2167 // coincide exactly) except on the edges of the grid where they become 0 . |
| 2160 if (hasCollapsedTracks) { | 2168 if (hasCollapsedTracks) { |
| 2161 gap = gridGapForDirection(direction); | 2169 gap = gridGapForDirection(direction, sizingData.sizingOperation); |
| 2162 size_t remainingEmptyTracks = isRowAxis ? m_autoRepeatEmptyColumns-> size() : m_autoRepeatEmptyRows->size(); | 2170 size_t remainingEmptyTracks = isRowAxis ? m_autoRepeatEmptyColumns-> size() : m_autoRepeatEmptyRows->size(); |
| 2163 LayoutUnit gapAccumulator; | 2171 LayoutUnit gapAccumulator; |
| 2164 for (size_t i = 1; i < lastLine; ++i) { | 2172 for (size_t i = 1; i < lastLine; ++i) { |
| 2165 if (isEmptyAutoRepeatTrack(direction, i - 1)) { | 2173 if (isEmptyAutoRepeatTrack(direction, i - 1)) { |
| 2166 --remainingEmptyTracks; | 2174 --remainingEmptyTracks; |
| 2167 } else { | 2175 } else { |
| 2168 // Add gap between consecutive non empty tracks. Add it also just once for an | 2176 // Add gap between consecutive non empty tracks. Add it also just once for an |
| 2169 // arbitrary number of empty tracks between two non empty on es. | 2177 // arbitrary number of empty tracks between two non empty on es. |
| 2170 bool allRemainingTracksAreEmpty = remainingEmptyTracks == (l astLine - i); | 2178 bool allRemainingTracksAreEmpty = remainingEmptyTracks == (l astLine - i); |
| 2171 if (!allRemainingTracksAreEmpty || !isEmptyAutoRepeatTrack(d irection, i)) | 2179 if (!allRemainingTracksAreEmpty || !isEmptyAutoRepeatTrack(d irection, i)) |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2473 switch (axisPosition) { | 2481 switch (axisPosition) { |
| 2474 case GridAxisStart: | 2482 case GridAxisStart: |
| 2475 return startPosition; | 2483 return startPosition; |
| 2476 case GridAxisEnd: | 2484 case GridAxisEnd: |
| 2477 case GridAxisCenter: { | 2485 case GridAxisCenter: { |
| 2478 size_t childEndLine = rowsSpan.endLine(); | 2486 size_t childEndLine = rowsSpan.endLine(); |
| 2479 LayoutUnit endOfRow = m_rowPositions[childEndLine]; | 2487 LayoutUnit endOfRow = m_rowPositions[childEndLine]; |
| 2480 // m_rowPositions include distribution offset (because of content alignm ent) and gutters | 2488 // m_rowPositions include distribution offset (because of content alignm ent) and gutters |
| 2481 // so we need to subtract them to get the actual end position for a give n row | 2489 // so we need to subtract them to get the actual end position for a give n row |
| 2482 // (this does not have to be done for the last track as there are no mor e m_columnPositions after it). | 2490 // (this does not have to be done for the last track as there are no mor e m_columnPositions after it). |
| 2483 LayoutUnit trackGap = gridGapForDirection(ForRows); | 2491 LayoutUnit trackGap = gridGapForDirection(ForRows, sizingData.sizingOper ation); |
| 2484 if (childEndLine < m_rowPositions.size() - 1) { | 2492 if (childEndLine < m_rowPositions.size() - 1) { |
| 2485 endOfRow -= trackGap; | 2493 endOfRow -= trackGap; |
| 2486 endOfRow -= m_offsetBetweenRows; | 2494 endOfRow -= m_offsetBetweenRows; |
| 2487 } | 2495 } |
| 2488 LayoutUnit columnAxisChildSize = isOrthogonalChild(child) ? child.logica lWidth() + child.marginLogicalWidth() : child.logicalHeight() + child.marginLogi calHeight(); | 2496 LayoutUnit columnAxisChildSize = isOrthogonalChild(child) ? child.logica lWidth() + child.marginLogicalWidth() : child.logicalHeight() + child.marginLogi calHeight(); |
| 2489 OverflowAlignment overflow = alignSelfForChild(child).overflow(); | 2497 OverflowAlignment overflow = alignSelfForChild(child).overflow(); |
| 2490 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over flow, endOfRow - startOfRow, columnAxisChildSize); | 2498 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over flow, endOfRow - startOfRow, columnAxisChildSize); |
| 2491 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); | 2499 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); |
| 2492 } | 2500 } |
| 2493 } | 2501 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 2508 switch (axisPosition) { | 2516 switch (axisPosition) { |
| 2509 case GridAxisStart: | 2517 case GridAxisStart: |
| 2510 return startPosition; | 2518 return startPosition; |
| 2511 case GridAxisEnd: | 2519 case GridAxisEnd: |
| 2512 case GridAxisCenter: { | 2520 case GridAxisCenter: { |
| 2513 size_t childEndLine = columnsSpan.endLine(); | 2521 size_t childEndLine = columnsSpan.endLine(); |
| 2514 LayoutUnit endOfColumn = m_columnPositions[childEndLine]; | 2522 LayoutUnit endOfColumn = m_columnPositions[childEndLine]; |
| 2515 // m_columnPositions include distribution offset (because of content ali gnment) and gutters | 2523 // m_columnPositions include distribution offset (because of content ali gnment) and gutters |
| 2516 // so we need to subtract them to get the actual end position for a give n column | 2524 // so we need to subtract them to get the actual end position for a give n column |
| 2517 // (this does not have to be done for the last track as there are no mor e m_columnPositions after it). | 2525 // (this does not have to be done for the last track as there are no mor e m_columnPositions after it). |
| 2518 LayoutUnit trackGap = gridGapForDirection(ForColumns); | 2526 LayoutUnit trackGap = gridGapForDirection(ForColumns, sizingData.sizingO peration); |
| 2519 if (childEndLine < m_columnPositions.size() - 1) { | 2527 if (childEndLine < m_columnPositions.size() - 1) { |
| 2520 endOfColumn -= trackGap; | 2528 endOfColumn -= trackGap; |
| 2521 endOfColumn -= m_offsetBetweenColumns; | 2529 endOfColumn -= m_offsetBetweenColumns; |
| 2522 } | 2530 } |
| 2523 LayoutUnit rowAxisChildSize = isOrthogonalChild(child) ? child.logicalHe ight() + child.marginLogicalHeight() : child.logicalWidth() + child.marginLogica lWidth(); | 2531 LayoutUnit rowAxisChildSize = isOrthogonalChild(child) ? child.logicalHe ight() + child.marginLogicalHeight() : child.logicalWidth() + child.marginLogica lWidth(); |
| 2524 OverflowAlignment overflow = justifySelfForChild(child).overflow(); | 2532 OverflowAlignment overflow = justifySelfForChild(child).overflow(); |
| 2525 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over flow, endOfColumn - startOfColumn, rowAxisChildSize); | 2533 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over flow, endOfColumn - startOfColumn, rowAxisChildSize); |
| 2526 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); | 2534 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); |
| 2527 } | 2535 } |
| 2528 } | 2536 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2658 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation; | 2666 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation; |
| 2659 } | 2667 } |
| 2660 | 2668 |
| 2661 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const | 2669 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const |
| 2662 { | 2670 { |
| 2663 if (!m_gridItemArea.isEmpty()) | 2671 if (!m_gridItemArea.isEmpty()) |
| 2664 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2672 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
| 2665 } | 2673 } |
| 2666 | 2674 |
| 2667 } // namespace blink | 2675 } // namespace blink |
| OLD | NEW |