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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 // grid column sizes calculated in the previous step. | 477 // grid column sizes calculated in the previous step. |
478 if (cachedHasDefiniteLogicalHeight()) | 478 if (cachedHasDefiniteLogicalHeight()) |
479 computeTrackSizesForDirection(ForRows, sizingData, availableLogicalH
eight(ExcludeMarginBorderPadding)); | 479 computeTrackSizesForDirection(ForRows, sizingData, availableLogicalH
eight(ExcludeMarginBorderPadding)); |
480 else | 480 else |
481 computeIntrinsicLogicalHeight(sizingData); | 481 computeIntrinsicLogicalHeight(sizingData); |
482 setLogicalHeight(computeTrackBasedLogicalHeight(sizingData) + borderAndP
addingLogicalHeight() + scrollbarLogicalHeight()); | 482 setLogicalHeight(computeTrackBasedLogicalHeight(sizingData) + borderAndP
addingLogicalHeight() + scrollbarLogicalHeight()); |
483 | 483 |
484 LayoutUnit oldClientAfterEdge = clientLogicalBottom(); | 484 LayoutUnit oldClientAfterEdge = clientLogicalBottom(); |
485 updateLogicalHeight(); | 485 updateLogicalHeight(); |
486 | 486 |
487 // The above call might have changed the grid's logical height depending
on min|max height restrictions. | |
488 // Update the sizes of the rows whose size depends on the logical height
(also on definite|indefinite sizes). | |
489 LayoutUnit availableSpaceForRows = contentLogicalHeight(); | |
490 if (!cachedHasDefiniteLogicalHeight()) | |
491 computeTrackSizesForDirection(ForRows, sizingData, availableSpaceFor
Rows); | |
492 | |
493 // 3- If the min-content contribution of any grid items have changed bas
ed on the row | 487 // 3- If the min-content contribution of any grid items have changed bas
ed on the row |
494 // sizes calculated in step 2, steps 1 and 2 are repeated with the new m
in-content | 488 // sizes calculated in step 2, steps 1 and 2 are repeated with the new m
in-content |
495 // contribution (once only). | 489 // contribution (once only). |
496 repeatTracksSizingIfNeeded(sizingData, availableSpaceForColumns, availab
leSpaceForRows); | 490 repeatTracksSizingIfNeeded(sizingData, availableSpaceForColumns, content
LogicalHeight()); |
497 | 491 |
498 // Grid container should have the minimum height of a line if it's edita
ble. That doesn't affect track sizing though. | 492 // Grid container should have the minimum height of a line if it's edita
ble. That doesn't affect track sizing though. |
499 if (hasLineIfEmpty()) | 493 if (hasLineIfEmpty()) |
500 setLogicalHeight(std::max(logicalHeight(), minimumLogicalHeightForEm
ptyLine())); | 494 setLogicalHeight(std::max(logicalHeight(), minimumLogicalHeightForEm
ptyLine())); |
501 | 495 |
502 applyStretchAlignmentToTracksIfNeeded(ForColumns, sizingData); | 496 applyStretchAlignmentToTracksIfNeeded(ForColumns, sizingData); |
503 applyStretchAlignmentToTracksIfNeeded(ForRows, sizingData); | 497 applyStretchAlignmentToTracksIfNeeded(ForRows, sizingData); |
504 | 498 |
505 layoutGridItems(sizingData); | 499 layoutGridItems(sizingData); |
506 | 500 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 minLogicalWidth += totalGuttersSize; | 610 minLogicalWidth += totalGuttersSize; |
617 maxLogicalWidth += totalGuttersSize; | 611 maxLogicalWidth += totalGuttersSize; |
618 | 612 |
619 LayoutUnit scrollbarWidth = LayoutUnit(scrollbarLogicalWidth()); | 613 LayoutUnit scrollbarWidth = LayoutUnit(scrollbarLogicalWidth()); |
620 minLogicalWidth += scrollbarWidth; | 614 minLogicalWidth += scrollbarWidth; |
621 maxLogicalWidth += scrollbarWidth; | 615 maxLogicalWidth += scrollbarWidth; |
622 } | 616 } |
623 | 617 |
624 void LayoutGrid::computeIntrinsicLogicalHeight(GridSizingData& sizingData) | 618 void LayoutGrid::computeIntrinsicLogicalHeight(GridSizingData& sizingData) |
625 { | 619 { |
| 620 DCHECK(sizingData.isValidTransition(ForRows)); |
626 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData)); | 621 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData)); |
627 sizingData.setAvailableSpace(LayoutUnit()); | 622 sizingData.setAvailableSpace(LayoutUnit()); |
628 sizingData.freeSpace(ForRows) = LayoutUnit(); | 623 sizingData.freeSpace(ForRows) = LayoutUnit(); |
629 sizingData.sizingOperation = IntrinsicSizeComputation; | 624 sizingData.sizingOperation = IntrinsicSizeComputation; |
630 computeUsedBreadthOfGridTracks(ForRows, sizingData, m_minContentHeight, m_ma
xContentHeight); | 625 computeUsedBreadthOfGridTracks(ForRows, sizingData, m_minContentHeight, m_ma
xContentHeight); |
631 | 626 |
632 LayoutUnit totalGuttersSize = guttersSize(ForRows, 0, gridRowCount(), sizing
Data.sizingOperation); | 627 LayoutUnit totalGuttersSize = guttersSize(ForRows, 0, gridRowCount(), sizing
Data.sizingOperation); |
633 m_minContentHeight += totalGuttersSize; | 628 m_minContentHeight += totalGuttersSize; |
634 m_maxContentHeight += totalGuttersSize; | 629 m_maxContentHeight += totalGuttersSize; |
635 | 630 |
636 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData)); | 631 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData)); |
| 632 sizingData.nextState(); |
| 633 sizingData.sizingOperation = TrackSizing; |
637 } | 634 } |
638 | 635 |
639 LayoutUnit LayoutGrid::computeIntrinsicLogicalContentHeightUsing(const Length& l
ogicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddi
ng) const | 636 LayoutUnit LayoutGrid::computeIntrinsicLogicalContentHeightUsing(const Length& l
ogicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddi
ng) const |
640 { | 637 { |
641 if (logicalHeightLength.isMinContent()) | 638 if (logicalHeightLength.isMinContent()) |
642 return m_minContentHeight; | 639 return m_minContentHeight; |
643 | 640 |
644 if (logicalHeightLength.isMaxContent()) | 641 if (logicalHeightLength.isMaxContent()) |
645 return m_maxContentHeight; | 642 return m_maxContentHeight; |
646 | 643 |
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1885 for (const auto& trackIndex : autoSizedTracksIndex) { | 1882 for (const auto& trackIndex : autoSizedTracksIndex) { |
1886 GridTrack* track = tracks.data() + trackIndex; | 1883 GridTrack* track = tracks.data() + trackIndex; |
1887 LayoutUnit baseSize = track->baseSize() + sizeToIncrease; | 1884 LayoutUnit baseSize = track->baseSize() + sizeToIncrease; |
1888 track->setBaseSize(baseSize); | 1885 track->setBaseSize(baseSize); |
1889 } | 1886 } |
1890 availableSpace = LayoutUnit(); | 1887 availableSpace = LayoutUnit(); |
1891 } | 1888 } |
1892 | 1889 |
1893 void LayoutGrid::layoutGridItems(GridSizingData& sizingData) | 1890 void LayoutGrid::layoutGridItems(GridSizingData& sizingData) |
1894 { | 1891 { |
| 1892 DCHECK_EQ(sizingData.sizingOperation, TrackSizing); |
1895 populateGridPositionsForDirection(sizingData, ForColumns); | 1893 populateGridPositionsForDirection(sizingData, ForColumns); |
1896 populateGridPositionsForDirection(sizingData, ForRows); | 1894 populateGridPositionsForDirection(sizingData, ForRows); |
1897 m_gridItemsOverflowingGridArea.resize(0); | 1895 m_gridItemsOverflowingGridArea.resize(0); |
1898 | 1896 |
1899 for (LayoutBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { | 1897 for (LayoutBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { |
1900 if (child->isOutOfFlowPositioned()) { | 1898 if (child->isOutOfFlowPositioned()) { |
1901 prepareChildForPositionedLayout(*child); | 1899 prepareChildForPositionedLayout(*child); |
1902 continue; | 1900 continue; |
1903 } | 1901 } |
1904 | 1902 |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2672 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2670 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
2673 } | 2671 } |
2674 | 2672 |
2675 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const | 2673 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const |
2676 { | 2674 { |
2677 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); | 2675 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); |
2678 return m_hasDefiniteLogicalHeight.value(); | 2676 return m_hasDefiniteLogicalHeight.value(); |
2679 } | 2677 } |
2680 | 2678 |
2681 } // namespace blink | 2679 } // namespace blink |
OLD | NEW |