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 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 633 child->clearContainingBlockOverrideSize(); | 633 child->clearContainingBlockOverrideSize(); |
| 634 child->forceLayout(); | 634 child->forceLayout(); |
| 635 } | 635 } |
| 636 } | 636 } |
| 637 | 637 |
| 638 updateLogicalWidth(); | 638 updateLogicalWidth(); |
| 639 m_hasDefiniteLogicalHeight = hasDefiniteLogicalHeight(); | 639 m_hasDefiniteLogicalHeight = hasDefiniteLogicalHeight(); |
| 640 | 640 |
| 641 TextAutosizer::LayoutScope textAutosizerLayoutScope(this, &layoutScope); | 641 TextAutosizer::LayoutScope textAutosizerLayoutScope(this, &layoutScope); |
| 642 | 642 |
| 643 // TODO(svillar): we won't need to do this once the intrinsic width | |
| 644 // computation is isolated from the LayoutGrid object state (it should not | |
| 645 // touch any attribute) (see crbug.com/627812) | |
| 646 size_t autoRepeatColumns = m_grid.autoRepeatTracks(ForColumns); | |
| 647 if (autoRepeatColumns && | |
| 648 autoRepeatColumns != | |
| 649 computeAutoRepeatTracksCount(ForColumns, TrackSizing)) | |
| 650 dirtyGrid(); | |
| 651 placeItemsOnGrid(m_grid, TrackSizing); | 643 placeItemsOnGrid(m_grid, TrackSizing); |
| 652 | 644 |
| 653 GridSizingData sizingData(numTracks(ForColumns, m_grid), | 645 GridSizingData sizingData(numTracks(ForColumns, m_grid), |
| 654 numTracks(ForRows, m_grid), m_grid); | 646 numTracks(ForRows, m_grid), m_grid); |
| 655 | 647 |
| 656 // 1- First, the track sizing algorithm is used to resolve the sizes of the | 648 // 1- First, the track sizing algorithm is used to resolve the sizes of the |
| 657 // grid columns. | 649 // grid columns. |
| 658 // At this point the logical width is always definite as the above call to | 650 // At this point the logical width is always definite as the above call to |
| 659 // updateLogicalWidth() properly resolves intrinsic sizes. We cannot do the | 651 // updateLogicalWidth() properly resolves intrinsic sizes. We cannot do the |
| 660 // same for heights though because many code paths inside | 652 // same for heights though because many code paths inside |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 801 if (nonEmptyTracksAfterEndLine) | 793 if (nonEmptyTracksAfterEndLine) |
| 802 gapAccumulator += gap; | 794 gapAccumulator += gap; |
| 803 } | 795 } |
| 804 | 796 |
| 805 return gapAccumulator; | 797 return gapAccumulator; |
| 806 } | 798 } |
| 807 | 799 |
| 808 void LayoutGrid::computeIntrinsicLogicalWidths( | 800 void LayoutGrid::computeIntrinsicLogicalWidths( |
| 809 LayoutUnit& minLogicalWidth, | 801 LayoutUnit& minLogicalWidth, |
| 810 LayoutUnit& maxLogicalWidth) const { | 802 LayoutUnit& maxLogicalWidth) const { |
| 811 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(const_cast<Grid&>(m_grid), | 803 Grid grid(this); |
| 812 IntrinsicSizeComputation); | 804 placeItemsOnGrid(grid, IntrinsicSizeComputation); |
|
jfernandez
2016/12/20 15:57:55
What do you think about creating the new Grid inst
svillar
2016/12/20 16:21:43
We cannot move it inside the method because for th
| |
| 813 | 805 |
| 814 GridSizingData sizingData(numTracks(ForColumns, m_grid), | 806 GridSizingData sizingData(numTracks(ForColumns, grid), |
| 815 numTracks(ForRows, m_grid), | 807 numTracks(ForRows, grid), grid); |
| 816 const_cast<Grid&>(m_grid)); | 808 |
| 817 computeTrackSizesForIndefiniteSize(ForColumns, sizingData, minLogicalWidth, | 809 computeTrackSizesForIndefiniteSize(ForColumns, sizingData, minLogicalWidth, |
| 818 maxLogicalWidth); | 810 maxLogicalWidth); |
| 819 | 811 |
| 820 LayoutUnit scrollbarWidth = LayoutUnit(scrollbarLogicalWidth()); | 812 LayoutUnit scrollbarWidth = LayoutUnit(scrollbarLogicalWidth()); |
| 821 minLogicalWidth += scrollbarWidth; | 813 minLogicalWidth += scrollbarWidth; |
| 822 maxLogicalWidth += scrollbarWidth; | 814 maxLogicalWidth += scrollbarWidth; |
| 823 } | 815 } |
| 824 | 816 |
| 825 void LayoutGrid::computeTrackSizesForIndefiniteSize( | 817 void LayoutGrid::computeTrackSizesForIndefiniteSize( |
| 826 GridTrackSizingDirection direction, | 818 GridTrackSizingDirection direction, |
| (...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2062 | 2054 |
| 2063 std::unique_ptr<OrderedTrackIndexSet> emptyTrackIndexes; | 2055 std::unique_ptr<OrderedTrackIndexSet> emptyTrackIndexes; |
| 2064 size_t insertionPoint = isRowAxis | 2056 size_t insertionPoint = isRowAxis |
| 2065 ? styleRef().gridAutoRepeatColumnsInsertionPoint() | 2057 ? styleRef().gridAutoRepeatColumnsInsertionPoint() |
| 2066 : styleRef().gridAutoRepeatRowsInsertionPoint(); | 2058 : styleRef().gridAutoRepeatRowsInsertionPoint(); |
| 2067 size_t firstAutoRepeatTrack = | 2059 size_t firstAutoRepeatTrack = |
| 2068 insertionPoint + std::abs(grid.smallestTrackStart(direction)); | 2060 insertionPoint + std::abs(grid.smallestTrackStart(direction)); |
| 2069 size_t lastAutoRepeatTrack = | 2061 size_t lastAutoRepeatTrack = |
| 2070 firstAutoRepeatTrack + grid.autoRepeatTracks(direction); | 2062 firstAutoRepeatTrack + grid.autoRepeatTracks(direction); |
| 2071 | 2063 |
| 2072 if (!m_grid.hasGridItems()) { | 2064 if (!grid.hasGridItems()) { |
| 2073 emptyTrackIndexes = WTF::wrapUnique(new OrderedTrackIndexSet); | 2065 emptyTrackIndexes = WTF::wrapUnique(new OrderedTrackIndexSet); |
| 2074 for (size_t trackIndex = firstAutoRepeatTrack; | 2066 for (size_t trackIndex = firstAutoRepeatTrack; |
| 2075 trackIndex < lastAutoRepeatTrack; ++trackIndex) | 2067 trackIndex < lastAutoRepeatTrack; ++trackIndex) |
| 2076 emptyTrackIndexes->add(trackIndex); | 2068 emptyTrackIndexes->add(trackIndex); |
| 2077 } else { | 2069 } else { |
| 2078 for (size_t trackIndex = firstAutoRepeatTrack; | 2070 for (size_t trackIndex = firstAutoRepeatTrack; |
| 2079 trackIndex < lastAutoRepeatTrack; ++trackIndex) { | 2071 trackIndex < lastAutoRepeatTrack; ++trackIndex) { |
| 2080 GridIterator iterator(grid, direction, trackIndex); | 2072 GridIterator iterator(grid, direction, trackIndex); |
| 2081 if (!iterator.nextGridItem()) { | 2073 if (!iterator.nextGridItem()) { |
| 2082 if (!emptyTrackIndexes) | 2074 if (!emptyTrackIndexes) |
| 2083 emptyTrackIndexes = WTF::wrapUnique(new OrderedTrackIndexSet); | 2075 emptyTrackIndexes = WTF::wrapUnique(new OrderedTrackIndexSet); |
| 2084 emptyTrackIndexes->add(trackIndex); | 2076 emptyTrackIndexes->add(trackIndex); |
| 2085 } | 2077 } |
| 2086 } | 2078 } |
| 2087 } | 2079 } |
| 2088 return emptyTrackIndexes; | 2080 return emptyTrackIndexes; |
| 2089 } | 2081 } |
| 2090 | 2082 |
| 2091 void LayoutGrid::placeItemsOnGrid(LayoutGrid::Grid& grid, | 2083 void LayoutGrid::placeItemsOnGrid(LayoutGrid::Grid& grid, |
| 2092 SizingOperation sizingOperation) { | 2084 SizingOperation sizingOperation) const { |
| 2085 size_t autoRepeatRows = | |
| 2086 computeAutoRepeatTracksCount(ForRows, sizingOperation); | |
| 2087 size_t autoRepeatColumns = | |
| 2088 computeAutoRepeatTracksCount(ForColumns, sizingOperation); | |
| 2089 if (autoRepeatRows != grid.autoRepeatTracks(ForRows) || | |
| 2090 autoRepeatColumns != grid.autoRepeatTracks(ForColumns)) { | |
| 2091 grid.setNeedsItemsPlacement(true); | |
| 2092 grid.setAutoRepeatTracks(autoRepeatRows, autoRepeatColumns); | |
|
jfernandez
2016/12/20 15:57:55
Since we are going to get the autoRepeatRows/Colum
svillar
2016/12/20 16:21:43
Because I don't want to add any placement behavior
| |
| 2093 } | |
| 2094 | |
| 2093 if (!grid.needsItemsPlacement()) | 2095 if (!grid.needsItemsPlacement()) |
| 2094 return; | 2096 return; |
| 2095 | 2097 |
| 2096 DCHECK(!grid.hasGridItems()); | 2098 DCHECK(!grid.hasGridItems()); |
| 2097 | |
| 2098 size_t autoRepeatColumns; | |
| 2099 size_t autoRepeatRows = | |
| 2100 computeAutoRepeatTracksCount(ForRows, sizingOperation); | |
| 2101 if (sizingOperation == IntrinsicSizeComputation) { | |
| 2102 autoRepeatColumns = styleRef().gridAutoRepeatColumns().size(); | |
| 2103 } else { | |
| 2104 autoRepeatColumns = | |
| 2105 computeAutoRepeatTracksCount(ForColumns, sizingOperation); | |
| 2106 } | |
| 2107 m_grid.setAutoRepeatTracks(autoRepeatRows, autoRepeatColumns); | |
| 2108 | |
| 2109 populateExplicitGridAndOrderIterator(grid); | 2099 populateExplicitGridAndOrderIterator(grid); |
| 2110 | 2100 |
| 2111 Vector<LayoutBox*> autoMajorAxisAutoGridItems; | 2101 Vector<LayoutBox*> autoMajorAxisAutoGridItems; |
| 2112 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; | 2102 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; |
| 2113 #if ENABLE(ASSERT) | 2103 #if ENABLE(ASSERT) |
| 2114 DCHECK(!grid.hasAnyGridItemPaintOrder()); | 2104 DCHECK(!grid.hasAnyGridItemPaintOrder()); |
| 2115 #endif | 2105 #endif |
| 2116 DCHECK(!grid.hasAnyOrthogonalGridItem()); | 2106 DCHECK(!grid.hasAnyOrthogonalGridItem()); |
| 2117 bool hasAnyOrthogonalGridItem = false; | 2107 bool hasAnyOrthogonalGridItem = false; |
| 2118 size_t childIndex = 0; | 2108 size_t childIndex = 0; |
| (...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3627 if (direction == ForRows) | 3617 if (direction == ForRows) |
| 3628 return grid.numTracks(ForRows); | 3618 return grid.numTracks(ForRows); |
| 3629 | 3619 |
| 3630 return grid.numTracks(ForRows) | 3620 return grid.numTracks(ForRows) |
| 3631 ? grid.numTracks(ForColumns) | 3621 ? grid.numTracks(ForColumns) |
| 3632 : GridPositionsResolver::explicitGridColumnCount( | 3622 : GridPositionsResolver::explicitGridColumnCount( |
| 3633 styleRef(), grid.autoRepeatTracks(ForColumns)); | 3623 styleRef(), grid.autoRepeatTracks(ForColumns)); |
| 3634 } | 3624 } |
| 3635 | 3625 |
| 3636 } // namespace blink | 3626 } // namespace blink |
| OLD | NEW |