| 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 // FIXME: The following checks could be narrowed down if we kept track of | 98 // FIXME: The following checks could be narrowed down if we kept track of |
| 99 // which type of grid items we have: | 99 // which type of grid items we have: |
| 100 // - explicit grid size changes impact negative explicitely positioned and | 100 // - explicit grid size changes impact negative explicitely positioned and |
| 101 // auto-placed grid items. | 101 // auto-placed grid items. |
| 102 // - named grid lines only impact grid items with named grid lines. | 102 // - named grid lines only impact grid items with named grid lines. |
| 103 // - auto-flow changes only impacts auto-placed children. | 103 // - auto-flow changes only impacts auto-placed children. |
| 104 | 104 |
| 105 if (explicitGridDidResize(*oldStyle) || | 105 if (explicitGridDidResize(*oldStyle) || |
| 106 namedGridLinesDefinitionDidChange(*oldStyle) || | 106 namedGridLinesDefinitionDidChange(*oldStyle) || |
| 107 oldStyle->getGridAutoFlow() != styleRef().getGridAutoFlow() || | 107 oldStyle->getGridAutoFlow() != styleRef().getGridAutoFlow() || |
| 108 (diff.needsLayout() && (styleRef().gridAutoRepeatColumns().size() || | 108 (diff.needsLayout() && |
| 109 styleRef().gridAutoRepeatRows().size()))) | 109 (styleRef().gridAutoRepeatColumns().size() || |
| 110 styleRef().gridAutoRepeatRows().size()))) |
| 110 dirtyGrid(); | 111 dirtyGrid(); |
| 111 } | 112 } |
| 112 | 113 |
| 113 bool LayoutGrid::explicitGridDidResize(const ComputedStyle& oldStyle) const { | 114 bool LayoutGrid::explicitGridDidResize(const ComputedStyle& oldStyle) const { |
| 114 return oldStyle.gridTemplateColumns().size() != | 115 return oldStyle.gridTemplateColumns().size() != |
| 115 styleRef().gridTemplateColumns().size() || | 116 styleRef().gridTemplateColumns().size() || |
| 116 oldStyle.gridTemplateRows().size() != | 117 oldStyle.gridTemplateRows().size() != |
| 117 styleRef().gridTemplateRows().size() || | 118 styleRef().gridTemplateRows().size() || |
| 118 oldStyle.namedGridAreaColumnCount() != | 119 oldStyle.namedGridAreaColumnCount() != |
| 119 styleRef().namedGridAreaColumnCount() || | 120 styleRef().namedGridAreaColumnCount() || |
| (...skipping 19 matching lines...) Expand all Loading... |
| 139 logicalHeight += row.baseSize(); | 140 logicalHeight += row.baseSize(); |
| 140 | 141 |
| 141 logicalHeight += guttersSize(m_grid, ForRows, 0, allRows.size(), TrackSizing); | 142 logicalHeight += guttersSize(m_grid, ForRows, 0, allRows.size(), TrackSizing); |
| 142 | 143 |
| 143 return logicalHeight; | 144 return logicalHeight; |
| 144 } | 145 } |
| 145 | 146 |
| 146 void LayoutGrid::computeTrackSizesForDefiniteSize( | 147 void LayoutGrid::computeTrackSizesForDefiniteSize( |
| 147 GridTrackSizingDirection direction, | 148 GridTrackSizingDirection direction, |
| 148 LayoutUnit availableSpace) { | 149 LayoutUnit availableSpace) { |
| 149 LayoutUnit freeSpace = | 150 LayoutUnit freeSpace = availableSpace - |
| 150 availableSpace - guttersSize(m_grid, direction, 0, | 151 guttersSize(m_grid, direction, 0, |
| 151 m_grid.numTracks(direction), TrackSizing); | 152 m_grid.numTracks(direction), TrackSizing); |
| 152 m_trackSizingAlgorithm.setup(direction, numTracks(direction, m_grid), | 153 m_trackSizingAlgorithm.setup(direction, numTracks(direction, m_grid), |
| 153 TrackSizing, availableSpace, freeSpace); | 154 TrackSizing, availableSpace, freeSpace); |
| 154 m_trackSizingAlgorithm.run(); | 155 m_trackSizingAlgorithm.run(); |
| 155 | 156 |
| 156 #if DCHECK_IS_ON() | 157 #if DCHECK_IS_ON() |
| 157 DCHECK(m_trackSizingAlgorithm.tracksAreWiderThanMinTrackBreadth()); | 158 DCHECK(m_trackSizingAlgorithm.tracksAreWiderThanMinTrackBreadth()); |
| 158 #endif | 159 #endif |
| 159 } | 160 } |
| 160 | 161 |
| 161 void LayoutGrid::repeatTracksSizingIfNeeded(LayoutUnit availableSpaceForColumns, | 162 void LayoutGrid::repeatTracksSizingIfNeeded(LayoutUnit availableSpaceForColumns, |
| (...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1603 // If an item participates in baseline alignmen, we select such item. | 1604 // If an item participates in baseline alignmen, we select such item. |
| 1604 if (isInlineBaselineAlignedChild(child)) { | 1605 if (isInlineBaselineAlignedChild(child)) { |
| 1605 // TODO (lajava): self-baseline and content-baseline alignment | 1606 // TODO (lajava): self-baseline and content-baseline alignment |
| 1606 // still not implemented. | 1607 // still not implemented. |
| 1607 baselineChild = child; | 1608 baselineChild = child; |
| 1608 isBaselineAligned = true; | 1609 isBaselineAligned = true; |
| 1609 break; | 1610 break; |
| 1610 } | 1611 } |
| 1611 if (!baselineChild) { | 1612 if (!baselineChild) { |
| 1612 // Use dom order for items in the same cell. | 1613 // Use dom order for items in the same cell. |
| 1613 if (!firstChild || (m_grid.gridItemPaintOrder(*child) < | 1614 if (!firstChild || |
| 1614 m_grid.gridItemPaintOrder(*firstChild))) | 1615 (m_grid.gridItemPaintOrder(*child) < |
| 1616 m_grid.gridItemPaintOrder(*firstChild))) |
| 1615 firstChild = child; | 1617 firstChild = child; |
| 1616 } | 1618 } |
| 1617 } | 1619 } |
| 1618 if (!baselineChild && firstChild) | 1620 if (!baselineChild && firstChild) |
| 1619 baselineChild = firstChild; | 1621 baselineChild = firstChild; |
| 1620 } | 1622 } |
| 1621 | 1623 |
| 1622 if (!baselineChild) | 1624 if (!baselineChild) |
| 1623 return -1; | 1625 return -1; |
| 1624 | 1626 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1836 endOfRow -= trackGap; | 1838 endOfRow -= trackGap; |
| 1837 endOfRow -= m_offsetBetweenRows; | 1839 endOfRow -= m_offsetBetweenRows; |
| 1838 } | 1840 } |
| 1839 LayoutUnit columnAxisChildSize = | 1841 LayoutUnit columnAxisChildSize = |
| 1840 isOrthogonalChild(child) | 1842 isOrthogonalChild(child) |
| 1841 ? child.logicalWidth() + child.marginLogicalWidth() | 1843 ? child.logicalWidth() + child.marginLogicalWidth() |
| 1842 : child.logicalHeight() + child.marginLogicalHeight(); | 1844 : child.logicalHeight() + child.marginLogicalHeight(); |
| 1843 OverflowAlignment overflow = alignSelfForChild(child).overflow(); | 1845 OverflowAlignment overflow = alignSelfForChild(child).overflow(); |
| 1844 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset( | 1846 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset( |
| 1845 overflow, endOfRow - startOfRow, columnAxisChildSize); | 1847 overflow, endOfRow - startOfRow, columnAxisChildSize); |
| 1846 return startPosition + (axisPosition == GridAxisEnd | 1848 return startPosition + |
| 1847 ? offsetFromStartPosition | 1849 (axisPosition == GridAxisEnd ? offsetFromStartPosition |
| 1848 : offsetFromStartPosition / 2); | 1850 : offsetFromStartPosition / 2); |
| 1849 } | 1851 } |
| 1850 } | 1852 } |
| 1851 | 1853 |
| 1852 ASSERT_NOT_REACHED(); | 1854 ASSERT_NOT_REACHED(); |
| 1853 return LayoutUnit(); | 1855 return LayoutUnit(); |
| 1854 } | 1856 } |
| 1855 | 1857 |
| 1856 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child) const { | 1858 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child) const { |
| 1857 const GridSpan& columnsSpan = | 1859 const GridSpan& columnsSpan = |
| 1858 m_trackSizingAlgorithm.grid().gridItemSpan(child, ForColumns); | 1860 m_trackSizingAlgorithm.grid().gridItemSpan(child, ForColumns); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1878 endOfColumn -= trackGap; | 1880 endOfColumn -= trackGap; |
| 1879 endOfColumn -= m_offsetBetweenColumns; | 1881 endOfColumn -= m_offsetBetweenColumns; |
| 1880 } | 1882 } |
| 1881 LayoutUnit rowAxisChildSize = | 1883 LayoutUnit rowAxisChildSize = |
| 1882 isOrthogonalChild(child) | 1884 isOrthogonalChild(child) |
| 1883 ? child.logicalHeight() + child.marginLogicalHeight() | 1885 ? child.logicalHeight() + child.marginLogicalHeight() |
| 1884 : child.logicalWidth() + child.marginLogicalWidth(); | 1886 : child.logicalWidth() + child.marginLogicalWidth(); |
| 1885 OverflowAlignment overflow = justifySelfForChild(child).overflow(); | 1887 OverflowAlignment overflow = justifySelfForChild(child).overflow(); |
| 1886 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset( | 1888 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset( |
| 1887 overflow, endOfColumn - startOfColumn, rowAxisChildSize); | 1889 overflow, endOfColumn - startOfColumn, rowAxisChildSize); |
| 1888 return startPosition + (axisPosition == GridAxisEnd | 1890 return startPosition + |
| 1889 ? offsetFromStartPosition | 1891 (axisPosition == GridAxisEnd ? offsetFromStartPosition |
| 1890 : offsetFromStartPosition / 2); | 1892 : offsetFromStartPosition / 2); |
| 1891 } | 1893 } |
| 1892 } | 1894 } |
| 1893 | 1895 |
| 1894 ASSERT_NOT_REACHED(); | 1896 ASSERT_NOT_REACHED(); |
| 1895 return LayoutUnit(); | 1897 return LayoutUnit(); |
| 1896 } | 1898 } |
| 1897 | 1899 |
| 1898 ContentPosition static resolveContentDistributionFallback( | 1900 ContentPosition static resolveContentDistributionFallback( |
| 1899 ContentDistributionType distribution) { | 1901 ContentDistributionType distribution) { |
| 1900 switch (distribution) { | 1902 switch (distribution) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1953 GridTrackSizingDirection direction, | 1955 GridTrackSizingDirection direction, |
| 1954 const LayoutUnit& availableFreeSpace, | 1956 const LayoutUnit& availableFreeSpace, |
| 1955 unsigned numberOfGridTracks) const { | 1957 unsigned numberOfGridTracks) const { |
| 1956 bool isRowAxis = direction == ForColumns; | 1958 bool isRowAxis = direction == ForColumns; |
| 1957 ContentPosition position = isRowAxis | 1959 ContentPosition position = isRowAxis |
| 1958 ? styleRef().resolvedJustifyContentPosition( | 1960 ? styleRef().resolvedJustifyContentPosition( |
| 1959 contentAlignmentNormalBehavior()) | 1961 contentAlignmentNormalBehavior()) |
| 1960 : styleRef().resolvedAlignContentPosition( | 1962 : styleRef().resolvedAlignContentPosition( |
| 1961 contentAlignmentNormalBehavior()); | 1963 contentAlignmentNormalBehavior()); |
| 1962 ContentDistributionType distribution = | 1964 ContentDistributionType distribution = |
| 1963 isRowAxis | 1965 isRowAxis ? styleRef().resolvedJustifyContentDistribution( |
| 1964 ? styleRef().resolvedJustifyContentDistribution( | 1966 contentAlignmentNormalBehavior()) |
| 1965 contentAlignmentNormalBehavior()) | 1967 : styleRef().resolvedAlignContentDistribution( |
| 1966 : styleRef().resolvedAlignContentDistribution( | 1968 contentAlignmentNormalBehavior()); |
| 1967 contentAlignmentNormalBehavior()); | |
| 1968 // If <content-distribution> value can't be applied, 'position' will become | 1969 // If <content-distribution> value can't be applied, 'position' will become |
| 1969 // the associated <content-position> fallback value. | 1970 // the associated <content-position> fallback value. |
| 1970 ContentAlignmentData contentAlignment = contentDistributionOffset( | 1971 ContentAlignmentData contentAlignment = contentDistributionOffset( |
| 1971 availableFreeSpace, position, distribution, numberOfGridTracks); | 1972 availableFreeSpace, position, distribution, numberOfGridTracks); |
| 1972 if (contentAlignment.isValid()) | 1973 if (contentAlignment.isValid()) |
| 1973 return contentAlignment; | 1974 return contentAlignment; |
| 1974 | 1975 |
| 1975 OverflowAlignment overflow = | 1976 OverflowAlignment overflow = |
| 1976 isRowAxis ? styleRef().justifyContentOverflowAlignment() | 1977 isRowAxis ? styleRef().justifyContentOverflowAlignment() |
| 1977 : styleRef().alignContentOverflowAlignment(); | 1978 : styleRef().alignContentOverflowAlignment(); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2091 if (direction == ForRows) | 2092 if (direction == ForRows) |
| 2092 return grid.numTracks(ForRows); | 2093 return grid.numTracks(ForRows); |
| 2093 | 2094 |
| 2094 return grid.numTracks(ForRows) | 2095 return grid.numTracks(ForRows) |
| 2095 ? grid.numTracks(ForColumns) | 2096 ? grid.numTracks(ForColumns) |
| 2096 : GridPositionsResolver::explicitGridColumnCount( | 2097 : GridPositionsResolver::explicitGridColumnCount( |
| 2097 styleRef(), grid.autoRepeatTracks(ForColumns)); | 2098 styleRef(), grid.autoRepeatTracks(ForColumns)); |
| 2098 } | 2099 } |
| 2099 | 2100 |
| 2100 } // namespace blink | 2101 } // namespace blink |
| OLD | NEW |