| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 size_t LayoutGrid::Grid::gridItemPaintOrder(const LayoutBox& item) const { | 99 size_t LayoutGrid::Grid::gridItemPaintOrder(const LayoutBox& item) const { |
| 100 return m_gridItemsIndexesMap.get(&item); | 100 return m_gridItemsIndexesMap.get(&item); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void LayoutGrid::Grid::setGridItemPaintOrder(const LayoutBox& item, | 103 void LayoutGrid::Grid::setGridItemPaintOrder(const LayoutBox& item, |
| 104 size_t order) { | 104 size_t order) { |
| 105 m_gridItemsIndexesMap.set(&item, order); | 105 m_gridItemsIndexesMap.set(&item, order); |
| 106 } | 106 } |
| 107 | 107 |
| 108 #if ENABLE(ASSERT) | 108 #if DCHECK_IS_ON() |
| 109 bool LayoutGrid::Grid::hasAnyGridItemPaintOrder() const { | 109 bool LayoutGrid::Grid::hasAnyGridItemPaintOrder() const { |
| 110 return !m_gridItemsIndexesMap.isEmpty(); | 110 return !m_gridItemsIndexesMap.isEmpty(); |
| 111 } | 111 } |
| 112 #endif | 112 #endif |
| 113 | 113 |
| 114 void LayoutGrid::Grid::setAutoRepeatTracks(size_t autoRepeatRows, | 114 void LayoutGrid::Grid::setAutoRepeatTracks(size_t autoRepeatRows, |
| 115 size_t autoRepeatColumns) { | 115 size_t autoRepeatColumns) { |
| 116 m_autoRepeatRows = autoRepeatRows; | 116 m_autoRepeatRows = autoRepeatRows; |
| 117 m_autoRepeatColumns = autoRepeatColumns; | 117 m_autoRepeatColumns = autoRepeatColumns; |
| 118 } | 118 } |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 | 829 |
| 830 size_t numberOfTracks = direction == ForColumns | 830 size_t numberOfTracks = direction == ForColumns |
| 831 ? sizingData.columnTracks.size() | 831 ? sizingData.columnTracks.size() |
| 832 : sizingData.rowTracks.size(); | 832 : sizingData.rowTracks.size(); |
| 833 LayoutUnit totalGuttersSize = | 833 LayoutUnit totalGuttersSize = |
| 834 guttersSize(sizingData.grid(), direction, 0, numberOfTracks, | 834 guttersSize(sizingData.grid(), direction, 0, numberOfTracks, |
| 835 sizingData.sizingOperation); | 835 sizingData.sizingOperation); |
| 836 minIntrinsicSize += totalGuttersSize; | 836 minIntrinsicSize += totalGuttersSize; |
| 837 maxIntrinsicSize += totalGuttersSize; | 837 maxIntrinsicSize += totalGuttersSize; |
| 838 | 838 |
| 839 #if ENABLE(ASSERT) | 839 #if DCHECK_IS_ON() |
| 840 DCHECK(tracksAreWiderThanMinTrackBreadth(direction, sizingData)); | 840 DCHECK(tracksAreWiderThanMinTrackBreadth(direction, sizingData)); |
| 841 #endif | 841 #endif |
| 842 } | 842 } |
| 843 | 843 |
| 844 LayoutUnit LayoutGrid::computeIntrinsicLogicalContentHeightUsing( | 844 LayoutUnit LayoutGrid::computeIntrinsicLogicalContentHeightUsing( |
| 845 const Length& logicalHeightLength, | 845 const Length& logicalHeightLength, |
| 846 LayoutUnit intrinsicContentHeight, | 846 LayoutUnit intrinsicContentHeight, |
| 847 LayoutUnit borderAndPadding) const { | 847 LayoutUnit borderAndPadding) const { |
| 848 if (logicalHeightLength.isMinContent()) | 848 if (logicalHeightLength.isMinContent()) |
| 849 return m_minContentHeight; | 849 return m_minContentHeight; |
| (...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1915 } | 1915 } |
| 1916 } | 1916 } |
| 1917 | 1917 |
| 1918 for (auto* track : tracks) | 1918 for (auto* track : tracks) |
| 1919 track->setPlannedSize( | 1919 track->setPlannedSize( |
| 1920 track->plannedSize() == infinity | 1920 track->plannedSize() == infinity |
| 1921 ? track->sizeDuringDistribution() | 1921 ? track->sizeDuringDistribution() |
| 1922 : std::max(track->plannedSize(), track->sizeDuringDistribution())); | 1922 : std::max(track->plannedSize(), track->sizeDuringDistribution())); |
| 1923 } | 1923 } |
| 1924 | 1924 |
| 1925 #if ENABLE(ASSERT) | 1925 #if DCHECK_IS_ON() |
| 1926 bool LayoutGrid::tracksAreWiderThanMinTrackBreadth( | 1926 bool LayoutGrid::tracksAreWiderThanMinTrackBreadth( |
| 1927 GridTrackSizingDirection direction, | 1927 GridTrackSizingDirection direction, |
| 1928 GridSizingData& sizingData) const { | 1928 GridSizingData& sizingData) const { |
| 1929 const Vector<GridTrack>& tracks = (direction == ForColumns) | 1929 const Vector<GridTrack>& tracks = (direction == ForColumns) |
| 1930 ? sizingData.columnTracks | 1930 ? sizingData.columnTracks |
| 1931 : sizingData.rowTracks; | 1931 : sizingData.rowTracks; |
| 1932 LayoutUnit maxSize = sizingData.availableSpace().clampNegativeToZero(); | 1932 LayoutUnit maxSize = sizingData.availableSpace().clampNegativeToZero(); |
| 1933 for (size_t i = 0; i < tracks.size(); ++i) { | 1933 for (size_t i = 0; i < tracks.size(); ++i) { |
| 1934 GridTrackSize trackSize = gridTrackSize(direction, i, sizingData); | 1934 GridTrackSize trackSize = gridTrackSize(direction, i, sizingData); |
| 1935 if (computeUsedBreadthOfMinLength(trackSize, maxSize) > | 1935 if (computeUsedBreadthOfMinLength(trackSize, maxSize) > |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2093 } | 2093 } |
| 2094 | 2094 |
| 2095 if (!grid.needsItemsPlacement()) | 2095 if (!grid.needsItemsPlacement()) |
| 2096 return; | 2096 return; |
| 2097 | 2097 |
| 2098 DCHECK(!grid.hasGridItems()); | 2098 DCHECK(!grid.hasGridItems()); |
| 2099 populateExplicitGridAndOrderIterator(grid); | 2099 populateExplicitGridAndOrderIterator(grid); |
| 2100 | 2100 |
| 2101 Vector<LayoutBox*> autoMajorAxisAutoGridItems; | 2101 Vector<LayoutBox*> autoMajorAxisAutoGridItems; |
| 2102 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; | 2102 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; |
| 2103 #if ENABLE(ASSERT) | 2103 #if DCHECK_IS_ON() |
| 2104 DCHECK(!grid.hasAnyGridItemPaintOrder()); | 2104 DCHECK(!grid.hasAnyGridItemPaintOrder()); |
| 2105 #endif | 2105 #endif |
| 2106 DCHECK(!grid.hasAnyOrthogonalGridItem()); | 2106 DCHECK(!grid.hasAnyOrthogonalGridItem()); |
| 2107 bool hasAnyOrthogonalGridItem = false; | 2107 bool hasAnyOrthogonalGridItem = false; |
| 2108 size_t childIndex = 0; | 2108 size_t childIndex = 0; |
| 2109 for (LayoutBox* child = grid.orderIterator().first(); child; | 2109 for (LayoutBox* child = grid.orderIterator().first(); child; |
| 2110 child = grid.orderIterator().next()) { | 2110 child = grid.orderIterator().next()) { |
| 2111 if (child->isOutOfFlowPositioned()) | 2111 if (child->isOutOfFlowPositioned()) |
| 2112 continue; | 2112 continue; |
| 2113 | 2113 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2129 if (majorAxisPositions.isIndefinite()) | 2129 if (majorAxisPositions.isIndefinite()) |
| 2130 autoMajorAxisAutoGridItems.push_back(child); | 2130 autoMajorAxisAutoGridItems.push_back(child); |
| 2131 else | 2131 else |
| 2132 specifiedMajorAxisAutoGridItems.push_back(child); | 2132 specifiedMajorAxisAutoGridItems.push_back(child); |
| 2133 continue; | 2133 continue; |
| 2134 } | 2134 } |
| 2135 grid.insert(*child, area); | 2135 grid.insert(*child, area); |
| 2136 } | 2136 } |
| 2137 grid.setHasAnyOrthogonalGridItem(hasAnyOrthogonalGridItem); | 2137 grid.setHasAnyOrthogonalGridItem(hasAnyOrthogonalGridItem); |
| 2138 | 2138 |
| 2139 #if ENABLE(ASSERT) | 2139 #if DCHECK_IS_ON() |
| 2140 if (grid.hasGridItems()) { | 2140 if (grid.hasGridItems()) { |
| 2141 DCHECK_GE(grid.numTracks(ForRows), | 2141 DCHECK_GE(grid.numTracks(ForRows), |
| 2142 GridPositionsResolver::explicitGridRowCount( | 2142 GridPositionsResolver::explicitGridRowCount( |
| 2143 *style(), grid.autoRepeatTracks(ForRows))); | 2143 *style(), grid.autoRepeatTracks(ForRows))); |
| 2144 DCHECK_GE(grid.numTracks(ForColumns), | 2144 DCHECK_GE(grid.numTracks(ForColumns), |
| 2145 GridPositionsResolver::explicitGridColumnCount( | 2145 GridPositionsResolver::explicitGridColumnCount( |
| 2146 *style(), grid.autoRepeatTracks(ForColumns))); | 2146 *style(), grid.autoRepeatTracks(ForColumns))); |
| 2147 } | 2147 } |
| 2148 #endif | 2148 #endif |
| 2149 | 2149 |
| 2150 placeSpecifiedMajorAxisItemsOnGrid(grid, specifiedMajorAxisAutoGridItems); | 2150 placeSpecifiedMajorAxisItemsOnGrid(grid, specifiedMajorAxisAutoGridItems); |
| 2151 placeAutoMajorAxisItemsOnGrid(grid, autoMajorAxisAutoGridItems); | 2151 placeAutoMajorAxisItemsOnGrid(grid, autoMajorAxisAutoGridItems); |
| 2152 | 2152 |
| 2153 // Compute collapsable tracks for auto-fit. | 2153 // Compute collapsable tracks for auto-fit. |
| 2154 grid.setAutoRepeatEmptyColumns( | 2154 grid.setAutoRepeatEmptyColumns( |
| 2155 computeEmptyTracksForAutoRepeat(grid, ForColumns)); | 2155 computeEmptyTracksForAutoRepeat(grid, ForColumns)); |
| 2156 grid.setAutoRepeatEmptyRows(computeEmptyTracksForAutoRepeat(grid, ForRows)); | 2156 grid.setAutoRepeatEmptyRows(computeEmptyTracksForAutoRepeat(grid, ForRows)); |
| 2157 | 2157 |
| 2158 grid.setNeedsItemsPlacement(false); | 2158 grid.setNeedsItemsPlacement(false); |
| 2159 | 2159 |
| 2160 #if ENABLE(ASSERT) | 2160 #if DCHECK_IS_ON() |
| 2161 for (LayoutBox* child = grid.orderIterator().first(); child; | 2161 for (LayoutBox* child = grid.orderIterator().first(); child; |
| 2162 child = grid.orderIterator().next()) { | 2162 child = grid.orderIterator().next()) { |
| 2163 if (child->isOutOfFlowPositioned()) | 2163 if (child->isOutOfFlowPositioned()) |
| 2164 continue; | 2164 continue; |
| 2165 | 2165 |
| 2166 GridArea area = grid.gridItemArea(*child); | 2166 GridArea area = grid.gridItemArea(*child); |
| 2167 ASSERT(area.rows.isTranslatedDefinite() && | 2167 ASSERT(area.rows.isTranslatedDefinite() && |
| 2168 area.columns.isTranslatedDefinite()); | 2168 area.columns.isTranslatedDefinite()); |
| 2169 } | 2169 } |
| 2170 #endif | 2170 #endif |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2557 applyStretchAlignmentToChildIfNeeded(*child); | 2557 applyStretchAlignmentToChildIfNeeded(*child); |
| 2558 | 2558 |
| 2559 child->layoutIfNeeded(); | 2559 child->layoutIfNeeded(); |
| 2560 | 2560 |
| 2561 // We need pending layouts to be done in order to compute auto-margins | 2561 // We need pending layouts to be done in order to compute auto-margins |
| 2562 // properly. | 2562 // properly. |
| 2563 updateAutoMarginsInColumnAxisIfNeeded(*child); | 2563 updateAutoMarginsInColumnAxisIfNeeded(*child); |
| 2564 updateAutoMarginsInRowAxisIfNeeded(*child); | 2564 updateAutoMarginsInRowAxisIfNeeded(*child); |
| 2565 | 2565 |
| 2566 const GridArea& area = sizingData.grid().gridItemArea(*child); | 2566 const GridArea& area = sizingData.grid().gridItemArea(*child); |
| 2567 #if ENABLE(ASSERT) | 2567 #if DCHECK_IS_ON() |
| 2568 ASSERT(area.columns.startLine() < sizingData.columnTracks.size()); | 2568 ASSERT(area.columns.startLine() < sizingData.columnTracks.size()); |
| 2569 ASSERT(area.rows.startLine() < sizingData.rowTracks.size()); | 2569 ASSERT(area.rows.startLine() < sizingData.rowTracks.size()); |
| 2570 #endif | 2570 #endif |
| 2571 child->setLogicalLocation(findChildLogicalPosition(*child, sizingData)); | 2571 child->setLogicalLocation(findChildLogicalPosition(*child, sizingData)); |
| 2572 | 2572 |
| 2573 // Keep track of children overflowing their grid area as we might need to | 2573 // Keep track of children overflowing their grid area as we might need to |
| 2574 // paint them even if the grid-area is not visible. Using physical | 2574 // paint them even if the grid-area is not visible. Using physical |
| 2575 // dimensions for simplicity, so we can forget about orthogonalty. | 2575 // dimensions for simplicity, so we can forget about orthogonalty. |
| 2576 LayoutUnit childGridAreaHeight = | 2576 LayoutUnit childGridAreaHeight = |
| 2577 isHorizontalWritingMode() ? overrideContainingBlockContentLogicalHeight | 2577 isHorizontalWritingMode() ? overrideContainingBlockContentLogicalHeight |
| (...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3618 if (direction == ForRows) | 3618 if (direction == ForRows) |
| 3619 return grid.numTracks(ForRows); | 3619 return grid.numTracks(ForRows); |
| 3620 | 3620 |
| 3621 return grid.numTracks(ForRows) | 3621 return grid.numTracks(ForRows) |
| 3622 ? grid.numTracks(ForColumns) | 3622 ? grid.numTracks(ForColumns) |
| 3623 : GridPositionsResolver::explicitGridColumnCount( | 3623 : GridPositionsResolver::explicitGridColumnCount( |
| 3624 styleRef(), grid.autoRepeatTracks(ForColumns)); | 3624 styleRef(), grid.autoRepeatTracks(ForColumns)); |
| 3625 } | 3625 } |
| 3626 | 3626 |
| 3627 } // namespace blink | 3627 } // namespace blink |
| OLD | NEW |