| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 for (size_t row = oldRowSize; row < numTracks(ForRows); ++row) | 56 for (size_t row = oldRowSize; row < numTracks(ForRows); ++row) |
| 57 m_grid[row].grow(numTracks(ForColumns)); | 57 m_grid[row].grow(numTracks(ForColumns)); |
| 58 } | 58 } |
| 59 | 59 |
| 60 if (maximumColumnSize > numTracks(ForColumns)) { | 60 if (maximumColumnSize > numTracks(ForColumns)) { |
| 61 for (size_t row = 0; row < numTracks(ForRows); ++row) | 61 for (size_t row = 0; row < numTracks(ForRows); ++row) |
| 62 m_grid[row].grow(maximumColumnSize); | 62 m_grid[row].grow(maximumColumnSize); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 void LayoutGrid::Grid::insert(LayoutBox& child, | 66 void LayoutGrid::Grid::insert(LayoutBox& child, const GridArea& area) { |
| 67 const GridArea& area, | |
| 68 bool isOrthogonalChild) { | |
| 69 DCHECK(area.rows.isTranslatedDefinite() && | 67 DCHECK(area.rows.isTranslatedDefinite() && |
| 70 area.columns.isTranslatedDefinite()); | 68 area.columns.isTranslatedDefinite()); |
| 71 ensureGridSize(area.rows.endLine(), area.columns.endLine()); | 69 ensureGridSize(area.rows.endLine(), area.columns.endLine()); |
| 72 | 70 |
| 73 for (const auto& row : area.rows) { | 71 for (const auto& row : area.rows) { |
| 74 for (const auto& column : area.columns) | 72 for (const auto& column : area.columns) |
| 75 m_grid[row][column].append(&child); | 73 m_grid[row][column].append(&child); |
| 76 } | 74 } |
| 77 | 75 |
| 78 setGridItemArea(child, area); | 76 setGridItemArea(child, area); |
| 79 | |
| 80 m_hasAnyOrthogonalChildren = m_hasAnyOrthogonalChildren || isOrthogonalChild; | |
| 81 } | 77 } |
| 82 | 78 |
| 83 void LayoutGrid::Grid::setSmallestTracksStart(int rowStart, int columnStart) { | 79 void LayoutGrid::Grid::setSmallestTracksStart(int rowStart, int columnStart) { |
| 84 m_smallestRowStart = rowStart; | 80 m_smallestRowStart = rowStart; |
| 85 m_smallestColumnStart = columnStart; | 81 m_smallestColumnStart = columnStart; |
| 86 } | 82 } |
| 87 | 83 |
| 88 int LayoutGrid::Grid::smallestTrackStart( | 84 int LayoutGrid::Grid::smallestTrackStart( |
| 89 GridTrackSizingDirection direction) const { | 85 GridTrackSizingDirection direction) const { |
| 90 return direction == ForRows ? m_smallestRowStart : m_smallestColumnStart; | 86 return direction == ForRows ? m_smallestRowStart : m_smallestColumnStart; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 : m_autoRepeatEmptyRows.get(); | 151 : m_autoRepeatEmptyRows.get(); |
| 156 } | 152 } |
| 157 | 153 |
| 158 GridSpan LayoutGrid::Grid::gridItemSpan( | 154 GridSpan LayoutGrid::Grid::gridItemSpan( |
| 159 const LayoutBox& gridItem, | 155 const LayoutBox& gridItem, |
| 160 GridTrackSizingDirection direction) const { | 156 GridTrackSizingDirection direction) const { |
| 161 GridArea area = gridItemArea(gridItem); | 157 GridArea area = gridItemArea(gridItem); |
| 162 return direction == ForColumns ? area.columns : area.rows; | 158 return direction == ForColumns ? area.columns : area.rows; |
| 163 } | 159 } |
| 164 | 160 |
| 161 void LayoutGrid::Grid::setHasAnyOrthogonalGridItem( |
| 162 bool hasAnyOrthogonalGridItem) { |
| 163 m_hasAnyOrthogonalGridItem = hasAnyOrthogonalGridItem; |
| 164 } |
| 165 |
| 165 void LayoutGrid::Grid::clear() { | 166 void LayoutGrid::Grid::clear() { |
| 166 m_grid.resize(0); | 167 m_grid.resize(0); |
| 167 m_gridItemArea.clear(); | 168 m_gridItemArea.clear(); |
| 168 m_gridItemsIndexesMap.clear(); | 169 m_gridItemsIndexesMap.clear(); |
| 169 m_hasAnyOrthogonalChildren = false; | 170 m_hasAnyOrthogonalGridItem = false; |
| 170 m_smallestRowStart = 0; | 171 m_smallestRowStart = 0; |
| 171 m_smallestColumnStart = 0; | 172 m_smallestColumnStart = 0; |
| 172 m_autoRepeatColumns = 0; | 173 m_autoRepeatColumns = 0; |
| 173 m_autoRepeatRows = 0; | 174 m_autoRepeatRows = 0; |
| 174 m_autoRepeatEmptyColumns = nullptr; | 175 m_autoRepeatEmptyColumns = nullptr; |
| 175 m_autoRepeatEmptyRows = nullptr; | 176 m_autoRepeatEmptyRows = nullptr; |
| 176 } | 177 } |
| 177 | 178 |
| 178 class GridTrack { | 179 class GridTrack { |
| 179 public: | 180 public: |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 // In orthogonal flow cases column track's size is determined by using the | 571 // In orthogonal flow cases column track's size is determined by using the |
| 571 // computed row track's size, which it was estimated during the first cycle of | 572 // computed row track's size, which it was estimated during the first cycle of |
| 572 // the sizing algorithm. | 573 // the sizing algorithm. |
| 573 // Hence we need to repeat computeUsedBreadthOfGridTracks for both, columns | 574 // Hence we need to repeat computeUsedBreadthOfGridTracks for both, columns |
| 574 // and rows, to determine the final values. | 575 // and rows, to determine the final values. |
| 575 // TODO (lajava): orthogonal flows is just one of the cases which may require | 576 // TODO (lajava): orthogonal flows is just one of the cases which may require |
| 576 // a new cycle of the sizing algorithm; there may be more. In addition, not | 577 // a new cycle of the sizing algorithm; there may be more. In addition, not |
| 577 // all the cases with orthogonal flows require this extra cycle; we need a | 578 // all the cases with orthogonal flows require this extra cycle; we need a |
| 578 // more specific condition to detect whether child's min-content contribution | 579 // more specific condition to detect whether child's min-content contribution |
| 579 // has changed or not. | 580 // has changed or not. |
| 580 if (m_grid.hasAnyOrthogonalChildren()) { | 581 if (m_grid.hasAnyOrthogonalGridItem()) { |
| 581 computeTrackSizesForDefiniteSize(ForColumns, sizingData, | 582 computeTrackSizesForDefiniteSize(ForColumns, sizingData, |
| 582 availableSpaceForColumns); | 583 availableSpaceForColumns); |
| 583 computeTrackSizesForDefiniteSize(ForRows, sizingData, | 584 computeTrackSizesForDefiniteSize(ForRows, sizingData, |
| 584 availableSpaceForRows); | 585 availableSpaceForRows); |
| 585 } | 586 } |
| 586 } | 587 } |
| 587 | 588 |
| 588 void LayoutGrid::layoutBlock(bool relayoutChildren) { | 589 void LayoutGrid::layoutBlock(bool relayoutChildren) { |
| 589 ASSERT(needsLayout()); | 590 ASSERT(needsLayout()); |
| 590 | 591 |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 tracks, GridSpan::translatedDefiniteGridSpan(0, tracks.size()), | 950 tracks, GridSpan::translatedDefiniteGridSpan(0, tracks.size()), |
| 950 direction, initialFreeSpace); | 951 direction, initialFreeSpace); |
| 951 } else { | 952 } else { |
| 952 for (const auto& trackIndex : flexibleSizedTracksIndex) | 953 for (const auto& trackIndex : flexibleSizedTracksIndex) |
| 953 flexFraction = std::max( | 954 flexFraction = std::max( |
| 954 flexFraction, | 955 flexFraction, |
| 955 normalizedFlexFraction( | 956 normalizedFlexFraction( |
| 956 tracks[trackIndex], | 957 tracks[trackIndex], |
| 957 gridTrackSize(direction, trackIndex).maxTrackBreadth().flex())); | 958 gridTrackSize(direction, trackIndex).maxTrackBreadth().flex())); |
| 958 | 959 |
| 959 if (m_grid.hasInFlowGridItems()) { | 960 if (m_grid.hasGridItems()) { |
| 960 for (size_t i = 0; i < flexibleSizedTracksIndex.size(); ++i) { | 961 for (size_t i = 0; i < flexibleSizedTracksIndex.size(); ++i) { |
| 961 GridIterator iterator(m_grid, direction, flexibleSizedTracksIndex[i]); | 962 GridIterator iterator(m_grid, direction, flexibleSizedTracksIndex[i]); |
| 962 while (LayoutBox* gridItem = iterator.nextGridItem()) { | 963 while (LayoutBox* gridItem = iterator.nextGridItem()) { |
| 963 const GridSpan& span = m_grid.gridItemSpan(*gridItem, direction); | 964 const GridSpan& span = m_grid.gridItemSpan(*gridItem, direction); |
| 964 | 965 |
| 965 // Do not include already processed items. | 966 // Do not include already processed items. |
| 966 if (i > 0 && span.startLine() <= flexibleSizedTracksIndex[i - 1]) | 967 if (i > 0 && span.startLine() <= flexibleSizedTracksIndex[i - 1]) |
| 967 continue; | 968 continue; |
| 968 | 969 |
| 969 flexFraction = std::max( | 970 flexFraction = std::max( |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 return true; | 1478 return true; |
| 1478 } | 1479 } |
| 1479 | 1480 |
| 1480 return false; | 1481 return false; |
| 1481 } | 1482 } |
| 1482 | 1483 |
| 1483 void LayoutGrid::resolveContentBasedTrackSizingFunctions( | 1484 void LayoutGrid::resolveContentBasedTrackSizingFunctions( |
| 1484 GridTrackSizingDirection direction, | 1485 GridTrackSizingDirection direction, |
| 1485 GridSizingData& sizingData) const { | 1486 GridSizingData& sizingData) const { |
| 1486 sizingData.itemsSortedByIncreasingSpan.shrink(0); | 1487 sizingData.itemsSortedByIncreasingSpan.shrink(0); |
| 1487 if (m_grid.hasInFlowGridItems()) { | 1488 if (m_grid.hasGridItems()) { |
| 1488 HashSet<LayoutBox*> itemsSet; | 1489 HashSet<LayoutBox*> itemsSet; |
| 1489 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { | 1490 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { |
| 1490 GridIterator iterator(m_grid, direction, trackIndex); | 1491 GridIterator iterator(m_grid, direction, trackIndex); |
| 1491 GridTrack& track = (direction == ForColumns) | 1492 GridTrack& track = (direction == ForColumns) |
| 1492 ? sizingData.columnTracks[trackIndex] | 1493 ? sizingData.columnTracks[trackIndex] |
| 1493 : sizingData.rowTracks[trackIndex]; | 1494 : sizingData.rowTracks[trackIndex]; |
| 1494 while (LayoutBox* gridItem = iterator.nextGridItem()) { | 1495 while (LayoutBox* gridItem = iterator.nextGridItem()) { |
| 1495 if (itemsSet.add(gridItem).isNewEntry) { | 1496 if (itemsSet.add(gridItem).isNewEntry) { |
| 1496 const GridSpan& span = m_grid.gridItemSpan(*gridItem, direction); | 1497 const GridSpan& span = m_grid.gridItemSpan(*gridItem, direction); |
| 1497 if (span.integerSpan() == 1) { | 1498 if (span.integerSpan() == 1) { |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2016 | 2017 |
| 2017 std::unique_ptr<OrderedTrackIndexSet> emptyTrackIndexes; | 2018 std::unique_ptr<OrderedTrackIndexSet> emptyTrackIndexes; |
| 2018 size_t insertionPoint = isRowAxis | 2019 size_t insertionPoint = isRowAxis |
| 2019 ? styleRef().gridAutoRepeatColumnsInsertionPoint() | 2020 ? styleRef().gridAutoRepeatColumnsInsertionPoint() |
| 2020 : styleRef().gridAutoRepeatRowsInsertionPoint(); | 2021 : styleRef().gridAutoRepeatRowsInsertionPoint(); |
| 2021 size_t firstAutoRepeatTrack = | 2022 size_t firstAutoRepeatTrack = |
| 2022 insertionPoint + std::abs(m_grid.smallestTrackStart(direction)); | 2023 insertionPoint + std::abs(m_grid.smallestTrackStart(direction)); |
| 2023 size_t lastAutoRepeatTrack = | 2024 size_t lastAutoRepeatTrack = |
| 2024 firstAutoRepeatTrack + autoRepeatCountForDirection(direction); | 2025 firstAutoRepeatTrack + autoRepeatCountForDirection(direction); |
| 2025 | 2026 |
| 2026 if (!m_grid.hasInFlowGridItems()) { | 2027 if (!m_grid.hasGridItems()) { |
| 2027 emptyTrackIndexes = wrapUnique(new OrderedTrackIndexSet); | 2028 emptyTrackIndexes = wrapUnique(new OrderedTrackIndexSet); |
| 2028 for (size_t trackIndex = firstAutoRepeatTrack; | 2029 for (size_t trackIndex = firstAutoRepeatTrack; |
| 2029 trackIndex < lastAutoRepeatTrack; ++trackIndex) | 2030 trackIndex < lastAutoRepeatTrack; ++trackIndex) |
| 2030 emptyTrackIndexes->add(trackIndex); | 2031 emptyTrackIndexes->add(trackIndex); |
| 2031 } else { | 2032 } else { |
| 2032 for (size_t trackIndex = firstAutoRepeatTrack; | 2033 for (size_t trackIndex = firstAutoRepeatTrack; |
| 2033 trackIndex < lastAutoRepeatTrack; ++trackIndex) { | 2034 trackIndex < lastAutoRepeatTrack; ++trackIndex) { |
| 2034 GridIterator iterator(m_grid, direction, trackIndex); | 2035 GridIterator iterator(m_grid, direction, trackIndex); |
| 2035 if (!iterator.nextGridItem()) { | 2036 if (!iterator.nextGridItem()) { |
| 2036 if (!emptyTrackIndexes) | 2037 if (!emptyTrackIndexes) |
| 2037 emptyTrackIndexes = wrapUnique(new OrderedTrackIndexSet); | 2038 emptyTrackIndexes = wrapUnique(new OrderedTrackIndexSet); |
| 2038 emptyTrackIndexes->add(trackIndex); | 2039 emptyTrackIndexes->add(trackIndex); |
| 2039 } | 2040 } |
| 2040 } | 2041 } |
| 2041 } | 2042 } |
| 2042 return emptyTrackIndexes; | 2043 return emptyTrackIndexes; |
| 2043 } | 2044 } |
| 2044 | 2045 |
| 2045 void LayoutGrid::placeItemsOnGrid(SizingOperation sizingOperation) { | 2046 void LayoutGrid::placeItemsOnGrid(SizingOperation sizingOperation) { |
| 2046 if (!m_gridIsDirty) | 2047 if (!m_gridIsDirty) |
| 2047 return; | 2048 return; |
| 2048 | 2049 |
| 2049 DCHECK(!m_grid.hasInFlowGridItems()); | 2050 DCHECK(!m_grid.hasGridItems()); |
| 2050 | 2051 |
| 2051 size_t autoRepeatColumns; | 2052 size_t autoRepeatColumns; |
| 2052 size_t autoRepeatRows = | 2053 size_t autoRepeatRows = |
| 2053 computeAutoRepeatTracksCount(ForRows, sizingOperation); | 2054 computeAutoRepeatTracksCount(ForRows, sizingOperation); |
| 2054 if (sizingOperation == IntrinsicSizeComputation) { | 2055 if (sizingOperation == IntrinsicSizeComputation) { |
| 2055 autoRepeatColumns = styleRef().gridAutoRepeatColumns().size(); | 2056 autoRepeatColumns = styleRef().gridAutoRepeatColumns().size(); |
| 2056 } else { | 2057 } else { |
| 2057 autoRepeatColumns = | 2058 autoRepeatColumns = |
| 2058 computeAutoRepeatTracksCount(ForColumns, sizingOperation); | 2059 computeAutoRepeatTracksCount(ForColumns, sizingOperation); |
| 2059 } | 2060 } |
| 2060 m_grid.setAutoRepeatTracks(autoRepeatRows, autoRepeatColumns); | 2061 m_grid.setAutoRepeatTracks(autoRepeatRows, autoRepeatColumns); |
| 2061 | 2062 |
| 2062 populateExplicitGridAndOrderIterator(); | 2063 populateExplicitGridAndOrderIterator(); |
| 2063 | 2064 |
| 2064 // We clear the dirty bit here as the grid sizes have been updated. | 2065 // We clear the dirty bit here as the grid sizes have been updated. |
| 2065 m_gridIsDirty = false; | 2066 m_gridIsDirty = false; |
| 2067 bool hasAnyOrthogonalGridItem = false; |
| 2066 | 2068 |
| 2067 Vector<LayoutBox*> autoMajorAxisAutoGridItems; | 2069 Vector<LayoutBox*> autoMajorAxisAutoGridItems; |
| 2068 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; | 2070 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; |
| 2069 #if ENABLE(ASSERT) | 2071 #if ENABLE(ASSERT) |
| 2070 DCHECK(!m_grid.hasAnyGridItemPaintOrder()); | 2072 DCHECK(!m_grid.hasAnyGridItemPaintOrder()); |
| 2071 #endif | 2073 #endif |
| 2072 DCHECK(!m_grid.hasAnyOrthogonalChildren()); | 2074 DCHECK(!m_grid.hasAnyOrthogonalGridItem()); |
| 2073 size_t childIndex = 0; | 2075 size_t childIndex = 0; |
| 2074 for (LayoutBox* child = m_grid.orderIterator().first(); child; | 2076 for (LayoutBox* child = m_grid.orderIterator().first(); child; |
| 2075 child = m_grid.orderIterator().next()) { | 2077 child = m_grid.orderIterator().next()) { |
| 2076 if (child->isOutOfFlowPositioned()) | 2078 if (child->isOutOfFlowPositioned()) |
| 2077 continue; | 2079 continue; |
| 2078 | 2080 |
| 2081 hasAnyOrthogonalGridItem = |
| 2082 hasAnyOrthogonalGridItem || isOrthogonalChild(*child); |
| 2079 m_grid.setGridItemPaintOrder(*child, childIndex++); | 2083 m_grid.setGridItemPaintOrder(*child, childIndex++); |
| 2080 | 2084 |
| 2081 GridArea area = m_grid.gridItemArea(*child); | 2085 GridArea area = m_grid.gridItemArea(*child); |
| 2082 if (!area.rows.isIndefinite()) | 2086 if (!area.rows.isIndefinite()) |
| 2083 area.rows.translate(abs(m_grid.smallestTrackStart(ForRows))); | 2087 area.rows.translate(abs(m_grid.smallestTrackStart(ForRows))); |
| 2084 if (!area.columns.isIndefinite()) | 2088 if (!area.columns.isIndefinite()) |
| 2085 area.columns.translate(abs(m_grid.smallestTrackStart(ForColumns))); | 2089 area.columns.translate(abs(m_grid.smallestTrackStart(ForColumns))); |
| 2086 | 2090 |
| 2087 if (area.rows.isIndefinite() || area.columns.isIndefinite()) { | 2091 if (area.rows.isIndefinite() || area.columns.isIndefinite()) { |
| 2088 m_grid.setGridItemArea(*child, area); | 2092 m_grid.setGridItemArea(*child, area); |
| 2089 GridSpan majorAxisPositions = | 2093 GridSpan majorAxisPositions = |
| 2090 (autoPlacementMajorAxisDirection() == ForColumns) ? area.columns | 2094 (autoPlacementMajorAxisDirection() == ForColumns) ? area.columns |
| 2091 : area.rows; | 2095 : area.rows; |
| 2092 if (majorAxisPositions.isIndefinite()) | 2096 if (majorAxisPositions.isIndefinite()) |
| 2093 autoMajorAxisAutoGridItems.append(child); | 2097 autoMajorAxisAutoGridItems.append(child); |
| 2094 else | 2098 else |
| 2095 specifiedMajorAxisAutoGridItems.append(child); | 2099 specifiedMajorAxisAutoGridItems.append(child); |
| 2096 continue; | 2100 continue; |
| 2097 } | 2101 } |
| 2098 m_grid.insert(*child, area, isOrthogonalChild(*child)); | 2102 m_grid.insert(*child, area); |
| 2099 } | 2103 } |
| 2104 m_grid.setHasAnyOrthogonalGridItem(hasAnyOrthogonalGridItem); |
| 2100 | 2105 |
| 2101 #if ENABLE(ASSERT) | 2106 #if ENABLE(ASSERT) |
| 2102 if (m_grid.hasInFlowGridItems()) { | 2107 if (m_grid.hasGridItems()) { |
| 2103 DCHECK_GE(m_grid.numTracks(ForRows), | 2108 DCHECK_GE(m_grid.numTracks(ForRows), |
| 2104 GridPositionsResolver::explicitGridRowCount( | 2109 GridPositionsResolver::explicitGridRowCount( |
| 2105 *style(), m_grid.autoRepeatTracks(ForRows))); | 2110 *style(), m_grid.autoRepeatTracks(ForRows))); |
| 2106 DCHECK_GE(m_grid.numTracks(ForColumns), | 2111 DCHECK_GE(m_grid.numTracks(ForColumns), |
| 2107 GridPositionsResolver::explicitGridColumnCount( | 2112 GridPositionsResolver::explicitGridColumnCount( |
| 2108 *style(), m_grid.autoRepeatTracks(ForColumns))); | 2113 *style(), m_grid.autoRepeatTracks(ForColumns))); |
| 2109 } | 2114 } |
| 2110 #endif | 2115 #endif |
| 2111 | 2116 |
| 2112 placeSpecifiedMajorAxisItemsOnGrid(specifiedMajorAxisAutoGridItems); | 2117 placeSpecifiedMajorAxisItemsOnGrid(specifiedMajorAxisAutoGridItems); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2238 majorAxisPositions.startLine(), | 2243 majorAxisPositions.startLine(), |
| 2239 isGridAutoFlowDense | 2244 isGridAutoFlowDense |
| 2240 ? 0 | 2245 ? 0 |
| 2241 : minorAxisCursors.get(majorAxisInitialPosition)); | 2246 : minorAxisCursors.get(majorAxisInitialPosition)); |
| 2242 std::unique_ptr<GridArea> emptyGridArea = iterator.nextEmptyGridArea( | 2247 std::unique_ptr<GridArea> emptyGridArea = iterator.nextEmptyGridArea( |
| 2243 majorAxisPositions.integerSpan(), minorAxisSpanSize); | 2248 majorAxisPositions.integerSpan(), minorAxisSpanSize); |
| 2244 if (!emptyGridArea) | 2249 if (!emptyGridArea) |
| 2245 emptyGridArea = createEmptyGridAreaAtSpecifiedPositionsOutsideGrid( | 2250 emptyGridArea = createEmptyGridAreaAtSpecifiedPositionsOutsideGrid( |
| 2246 *autoGridItem, autoPlacementMajorAxisDirection(), majorAxisPositions); | 2251 *autoGridItem, autoPlacementMajorAxisDirection(), majorAxisPositions); |
| 2247 | 2252 |
| 2248 m_grid.insert(*autoGridItem, *emptyGridArea, | 2253 m_grid.insert(*autoGridItem, *emptyGridArea); |
| 2249 isOrthogonalChild(*autoGridItem)); | |
| 2250 | 2254 |
| 2251 if (!isGridAutoFlowDense) | 2255 if (!isGridAutoFlowDense) |
| 2252 minorAxisCursors.set(majorAxisInitialPosition, | 2256 minorAxisCursors.set(majorAxisInitialPosition, |
| 2253 isForColumns ? emptyGridArea->rows.startLine() | 2257 isForColumns ? emptyGridArea->rows.startLine() |
| 2254 : emptyGridArea->columns.startLine()); | 2258 : emptyGridArea->columns.startLine()); |
| 2255 } | 2259 } |
| 2256 } | 2260 } |
| 2257 | 2261 |
| 2258 void LayoutGrid::placeAutoMajorAxisItemsOnGrid( | 2262 void LayoutGrid::placeAutoMajorAxisItemsOnGrid( |
| 2259 const Vector<LayoutBox*>& autoGridItems) { | 2263 const Vector<LayoutBox*>& autoGridItems) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2344 // auto-placement cursor in the minor axis. | 2348 // auto-placement cursor in the minor axis. |
| 2345 minorAxisAutoPlacementCursor = 0; | 2349 minorAxisAutoPlacementCursor = 0; |
| 2346 } | 2350 } |
| 2347 | 2351 |
| 2348 if (!emptyGridArea) | 2352 if (!emptyGridArea) |
| 2349 emptyGridArea = createEmptyGridAreaAtSpecifiedPositionsOutsideGrid( | 2353 emptyGridArea = createEmptyGridAreaAtSpecifiedPositionsOutsideGrid( |
| 2350 gridItem, autoPlacementMinorAxisDirection(), | 2354 gridItem, autoPlacementMinorAxisDirection(), |
| 2351 GridSpan::translatedDefiniteGridSpan(0, minorAxisSpanSize)); | 2355 GridSpan::translatedDefiniteGridSpan(0, minorAxisSpanSize)); |
| 2352 } | 2356 } |
| 2353 | 2357 |
| 2354 m_grid.insert(gridItem, *emptyGridArea, isOrthogonalChild(gridItem)); | 2358 m_grid.insert(gridItem, *emptyGridArea); |
| 2355 // Move auto-placement cursor to the new position. | 2359 // Move auto-placement cursor to the new position. |
| 2356 autoPlacementCursor.first = emptyGridArea->rows.startLine(); | 2360 autoPlacementCursor.first = emptyGridArea->rows.startLine(); |
| 2357 autoPlacementCursor.second = emptyGridArea->columns.startLine(); | 2361 autoPlacementCursor.second = emptyGridArea->columns.startLine(); |
| 2358 } | 2362 } |
| 2359 | 2363 |
| 2360 GridTrackSizingDirection LayoutGrid::autoPlacementMajorAxisDirection() const { | 2364 GridTrackSizingDirection LayoutGrid::autoPlacementMajorAxisDirection() const { |
| 2361 return style()->isGridAutoFlowDirectionColumn() ? ForColumns : ForRows; | 2365 return style()->isGridAutoFlowDirectionColumn() ? ForColumns : ForRows; |
| 2362 } | 2366 } |
| 2363 | 2367 |
| 2364 GridTrackSizingDirection LayoutGrid::autoPlacementMinorAxisDirection() const { | 2368 GridTrackSizingDirection LayoutGrid::autoPlacementMinorAxisDirection() const { |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3057 | 3061 |
| 3058 return baseline + beforeMarginInLineDirection(direction); | 3062 return baseline + beforeMarginInLineDirection(direction); |
| 3059 } | 3063 } |
| 3060 | 3064 |
| 3061 bool LayoutGrid::isInlineBaselineAlignedChild(const LayoutBox* child) const { | 3065 bool LayoutGrid::isInlineBaselineAlignedChild(const LayoutBox* child) const { |
| 3062 return alignSelfForChild(*child).position() == ItemPositionBaseline && | 3066 return alignSelfForChild(*child).position() == ItemPositionBaseline && |
| 3063 !isOrthogonalChild(*child) && !hasAutoMarginsInColumnAxis(*child); | 3067 !isOrthogonalChild(*child) && !hasAutoMarginsInColumnAxis(*child); |
| 3064 } | 3068 } |
| 3065 | 3069 |
| 3066 int LayoutGrid::firstLineBoxBaseline() const { | 3070 int LayoutGrid::firstLineBoxBaseline() const { |
| 3067 if (isWritingModeRoot() || !m_grid.hasInFlowGridItems()) | 3071 if (isWritingModeRoot() || !m_grid.hasGridItems()) |
| 3068 return -1; | 3072 return -1; |
| 3069 const LayoutBox* baselineChild = nullptr; | 3073 const LayoutBox* baselineChild = nullptr; |
| 3070 const LayoutBox* firstChild = nullptr; | 3074 const LayoutBox* firstChild = nullptr; |
| 3071 bool isBaselineAligned = false; | 3075 bool isBaselineAligned = false; |
| 3072 // Finding the first grid item in grid order. | 3076 // Finding the first grid item in grid order. |
| 3073 for (size_t column = 0; | 3077 for (size_t column = 0; |
| 3074 !isBaselineAligned && column < m_grid.numTracks(ForColumns); column++) { | 3078 !isBaselineAligned && column < m_grid.numTracks(ForColumns); column++) { |
| 3075 for (size_t index = 0; index < m_grid.cell(0, column).size(); index++) { | 3079 for (size_t index = 0; index < m_grid.cell(0, column).size(); index++) { |
| 3076 const LayoutBox* child = m_grid.cell(0, column)[index]; | 3080 const LayoutBox* child = m_grid.cell(0, column)[index]; |
| 3077 DCHECK(!child->isOutOfFlowPositioned()); | 3081 DCHECK(!child->isOutOfFlowPositioned()); |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3542 // See comment in findChildLogicalPosition() about why we need sometimes to | 3546 // See comment in findChildLogicalPosition() about why we need sometimes to |
| 3543 // translate from RTL to LTR the rowAxisOffset coordinate. | 3547 // translate from RTL to LTR the rowAxisOffset coordinate. |
| 3544 return LayoutPoint(style()->isLeftToRightDirection() | 3548 return LayoutPoint(style()->isLeftToRightDirection() |
| 3545 ? rowAxisOffset | 3549 ? rowAxisOffset |
| 3546 : translateRTLCoordinate(rowAxisOffset), | 3550 : translateRTLCoordinate(rowAxisOffset), |
| 3547 columnAxisOffset); | 3551 columnAxisOffset); |
| 3548 } | 3552 } |
| 3549 | 3553 |
| 3550 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, | 3554 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, |
| 3551 const LayoutPoint& paintOffset) const { | 3555 const LayoutPoint& paintOffset) const { |
| 3552 if (m_grid.hasInFlowGridItems()) | 3556 if (m_grid.hasGridItems()) |
| 3553 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 3557 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
| 3554 } | 3558 } |
| 3555 | 3559 |
| 3556 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const { | 3560 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const { |
| 3557 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); | 3561 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); |
| 3558 return m_hasDefiniteLogicalHeight.value(); | 3562 return m_hasDefiniteLogicalHeight.value(); |
| 3559 } | 3563 } |
| 3560 | 3564 |
| 3561 size_t LayoutGrid::numTracks(GridTrackSizingDirection direction) const { | 3565 size_t LayoutGrid::numTracks(GridTrackSizingDirection direction) const { |
| 3562 // Due to limitations in our internal representation, we cannot know the | 3566 // Due to limitations in our internal representation, we cannot know the |
| 3563 // number of columns from m_grid *if* there is no row (because m_grid would be | 3567 // number of columns from m_grid *if* there is no row (because m_grid would be |
| 3564 // empty). That's why in that case we need to get it from the style. Note that | 3568 // empty). That's why in that case we need to get it from the style. Note that |
| 3565 // we know for sure that there are't any implicit tracks, because not having | 3569 // we know for sure that there are't any implicit tracks, because not having |
| 3566 // rows implies that there are no "normal" children (out-of-flow children are | 3570 // rows implies that there are no "normal" children (out-of-flow children are |
| 3567 // not stored in m_grid). | 3571 // not stored in m_grid). |
| 3568 if (direction == ForRows) | 3572 if (direction == ForRows) |
| 3569 return m_grid.numTracks(ForRows); | 3573 return m_grid.numTracks(ForRows); |
| 3570 | 3574 |
| 3571 return m_grid.numTracks(ForRows) | 3575 return m_grid.numTracks(ForRows) |
| 3572 ? m_grid.numTracks(ForColumns) | 3576 ? m_grid.numTracks(ForColumns) |
| 3573 : GridPositionsResolver::explicitGridColumnCount( | 3577 : GridPositionsResolver::explicitGridColumnCount( |
| 3574 styleRef(), m_grid.autoRepeatTracks(ForColumns)); | 3578 styleRef(), m_grid.autoRepeatTracks(ForColumns)); |
| 3575 } | 3579 } |
| 3576 | 3580 |
| 3577 } // namespace blink | 3581 } // namespace blink |
| OLD | NEW |