| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 108 } |
| 109 | 109 |
| 110 #if DCHECK_IS_ON() | 110 #if DCHECK_IS_ON() |
| 111 bool LayoutGrid::Grid::hasAnyGridItemPaintOrder() const { | 111 bool LayoutGrid::Grid::hasAnyGridItemPaintOrder() const { |
| 112 return !m_gridItemsIndexesMap.isEmpty(); | 112 return !m_gridItemsIndexesMap.isEmpty(); |
| 113 } | 113 } |
| 114 #endif | 114 #endif |
| 115 | 115 |
| 116 void LayoutGrid::Grid::setAutoRepeatTracks(size_t autoRepeatRows, | 116 void LayoutGrid::Grid::setAutoRepeatTracks(size_t autoRepeatRows, |
| 117 size_t autoRepeatColumns) { | 117 size_t autoRepeatColumns) { |
| 118 DCHECK_GE(static_cast<unsigned>(kGridMaxTracks), |
| 119 numTracks(ForRows) + autoRepeatRows); |
| 120 DCHECK_GE(static_cast<unsigned>(kGridMaxTracks), |
| 121 numTracks(ForColumns) + autoRepeatColumns); |
| 118 m_autoRepeatRows = autoRepeatRows; | 122 m_autoRepeatRows = autoRepeatRows; |
| 119 m_autoRepeatColumns = autoRepeatColumns; | 123 m_autoRepeatColumns = autoRepeatColumns; |
| 120 } | 124 } |
| 121 | 125 |
| 122 size_t LayoutGrid::Grid::autoRepeatTracks( | 126 size_t LayoutGrid::Grid::autoRepeatTracks( |
| 123 GridTrackSizingDirection direction) const { | 127 GridTrackSizingDirection direction) const { |
| 124 return direction == ForRows ? m_autoRepeatRows : m_autoRepeatColumns; | 128 return direction == ForRows ? m_autoRepeatRows : m_autoRepeatColumns; |
| 125 } | 129 } |
| 126 | 130 |
| 127 void LayoutGrid::Grid::setAutoRepeatEmptyColumns( | 131 void LayoutGrid::Grid::setAutoRepeatEmptyColumns( |
| (...skipping 1907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2035 size_t repetitions = | 2039 size_t repetitions = |
| 2036 1 + (freeSpace / (autoRepeatTracksSize + gapSize)).toInt(); | 2040 1 + (freeSpace / (autoRepeatTracksSize + gapSize)).toInt(); |
| 2037 | 2041 |
| 2038 // Provided the grid container does not have a definite size or max-size in | 2042 // Provided the grid container does not have a definite size or max-size in |
| 2039 // the relevant axis, if the min size is definite then the number of | 2043 // the relevant axis, if the min size is definite then the number of |
| 2040 // repetitions is the largest possible positive integer that fulfills that | 2044 // repetitions is the largest possible positive integer that fulfills that |
| 2041 // minimum requirement. | 2045 // minimum requirement. |
| 2042 if (needsToFulfillMinimumSize) | 2046 if (needsToFulfillMinimumSize) |
| 2043 ++repetitions; | 2047 ++repetitions; |
| 2044 | 2048 |
| 2045 // Clamp the number of repetitions so we don't end up with too many tracks. | |
| 2046 if (repetitions > kGridMaxTracks) { | |
| 2047 DCHECK_GT(autoRepeatTrackListLength, 0u); | |
| 2048 repetitions = | |
| 2049 (kGridMaxTracks - trackSizes.size()) / autoRepeatTrackListLength; | |
| 2050 } | |
| 2051 | |
| 2052 return repetitions * autoRepeatTrackListLength; | 2049 return repetitions * autoRepeatTrackListLength; |
| 2053 } | 2050 } |
| 2054 | 2051 |
| 2055 std::unique_ptr<LayoutGrid::OrderedTrackIndexSet> | 2052 std::unique_ptr<LayoutGrid::OrderedTrackIndexSet> |
| 2056 LayoutGrid::computeEmptyTracksForAutoRepeat( | 2053 LayoutGrid::computeEmptyTracksForAutoRepeat( |
| 2057 Grid& grid, | 2054 Grid& grid, |
| 2058 GridTrackSizingDirection direction) const { | 2055 GridTrackSizingDirection direction) const { |
| 2059 bool isRowAxis = direction == ForColumns; | 2056 bool isRowAxis = direction == ForColumns; |
| 2060 if ((isRowAxis && styleRef().gridAutoRepeatColumnsType() != AutoFit) || | 2057 if ((isRowAxis && styleRef().gridAutoRepeatColumnsType() != AutoFit) || |
| 2061 (!isRowAxis && styleRef().gridAutoRepeatRowsType() != AutoFit)) | 2058 (!isRowAxis && styleRef().gridAutoRepeatRowsType() != AutoFit)) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2082 if (!iterator.nextGridItem()) { | 2079 if (!iterator.nextGridItem()) { |
| 2083 if (!emptyTrackIndexes) | 2080 if (!emptyTrackIndexes) |
| 2084 emptyTrackIndexes = WTF::wrapUnique(new OrderedTrackIndexSet); | 2081 emptyTrackIndexes = WTF::wrapUnique(new OrderedTrackIndexSet); |
| 2085 emptyTrackIndexes->add(trackIndex); | 2082 emptyTrackIndexes->add(trackIndex); |
| 2086 } | 2083 } |
| 2087 } | 2084 } |
| 2088 } | 2085 } |
| 2089 return emptyTrackIndexes; | 2086 return emptyTrackIndexes; |
| 2090 } | 2087 } |
| 2091 | 2088 |
| 2089 size_t LayoutGrid::clampAutoRepeatTracks(GridTrackSizingDirection direction, |
| 2090 size_t autoRepeatTracks) const { |
| 2091 if (!autoRepeatTracks) |
| 2092 return 0; |
| 2093 |
| 2094 size_t insertionPoint = direction == ForColumns |
| 2095 ? styleRef().gridAutoRepeatColumnsInsertionPoint() |
| 2096 : styleRef().gridAutoRepeatRowsInsertionPoint(); |
| 2097 |
| 2098 if (insertionPoint == 0) |
| 2099 return std::min<size_t>(autoRepeatTracks, kGridMaxTracks); |
| 2100 |
| 2101 if (insertionPoint >= kGridMaxTracks) |
| 2102 return 0; |
| 2103 |
| 2104 return std::min(autoRepeatTracks, |
| 2105 static_cast<size_t>(kGridMaxTracks) - insertionPoint); |
| 2106 } |
| 2107 |
| 2092 void LayoutGrid::placeItemsOnGrid(LayoutGrid::Grid& grid, | 2108 void LayoutGrid::placeItemsOnGrid(LayoutGrid::Grid& grid, |
| 2093 SizingOperation sizingOperation) const { | 2109 SizingOperation sizingOperation) const { |
| 2094 size_t autoRepeatRows = | 2110 size_t autoRepeatRows = |
| 2095 computeAutoRepeatTracksCount(ForRows, sizingOperation); | 2111 computeAutoRepeatTracksCount(ForRows, sizingOperation); |
| 2096 size_t autoRepeatColumns = | 2112 size_t autoRepeatColumns = |
| 2097 computeAutoRepeatTracksCount(ForColumns, sizingOperation); | 2113 computeAutoRepeatTracksCount(ForColumns, sizingOperation); |
| 2114 |
| 2115 autoRepeatRows = clampAutoRepeatTracks(ForRows, autoRepeatRows); |
| 2116 autoRepeatColumns = clampAutoRepeatTracks(ForColumns, autoRepeatColumns); |
| 2117 |
| 2098 if (autoRepeatRows != grid.autoRepeatTracks(ForRows) || | 2118 if (autoRepeatRows != grid.autoRepeatTracks(ForRows) || |
| 2099 autoRepeatColumns != grid.autoRepeatTracks(ForColumns)) { | 2119 autoRepeatColumns != grid.autoRepeatTracks(ForColumns)) { |
| 2100 grid.setNeedsItemsPlacement(true); | 2120 grid.setNeedsItemsPlacement(true); |
| 2101 grid.setAutoRepeatTracks(autoRepeatRows, autoRepeatColumns); | 2121 grid.setAutoRepeatTracks(autoRepeatRows, autoRepeatColumns); |
| 2102 } | 2122 } |
| 2103 | 2123 |
| 2104 if (!grid.needsItemsPlacement()) | 2124 if (!grid.needsItemsPlacement()) |
| 2105 return; | 2125 return; |
| 2106 | 2126 |
| 2107 DCHECK(!grid.hasGridItems()); | 2127 DCHECK(!grid.hasGridItems()); |
| (...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3628 if (direction == ForRows) | 3648 if (direction == ForRows) |
| 3629 return grid.numTracks(ForRows); | 3649 return grid.numTracks(ForRows); |
| 3630 | 3650 |
| 3631 return grid.numTracks(ForRows) | 3651 return grid.numTracks(ForRows) |
| 3632 ? grid.numTracks(ForColumns) | 3652 ? grid.numTracks(ForColumns) |
| 3633 : GridPositionsResolver::explicitGridColumnCount( | 3653 : GridPositionsResolver::explicitGridColumnCount( |
| 3634 styleRef(), grid.autoRepeatTracks(ForColumns)); | 3654 styleRef(), grid.autoRepeatTracks(ForColumns)); |
| 3635 } | 3655 } |
| 3636 | 3656 |
| 3637 } // namespace blink | 3657 } // namespace blink |
| OLD | NEW |