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 1804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1815 | 1815 |
1816 LayoutUnit sizeToIncrease = availableSpace / numberOfAutoSizedTracks; | 1816 LayoutUnit sizeToIncrease = availableSpace / numberOfAutoSizedTracks; |
1817 for (const auto& trackIndex : autoSizedTracksIndex) { | 1817 for (const auto& trackIndex : autoSizedTracksIndex) { |
1818 GridTrack* track = tracks.data() + trackIndex; | 1818 GridTrack* track = tracks.data() + trackIndex; |
1819 LayoutUnit baseSize = track->baseSize() + sizeToIncrease; | 1819 LayoutUnit baseSize = track->baseSize() + sizeToIncrease; |
1820 track->setBaseSize(baseSize); | 1820 track->setBaseSize(baseSize); |
1821 } | 1821 } |
1822 availableSpace = LayoutUnit(); | 1822 availableSpace = LayoutUnit(); |
1823 } | 1823 } |
1824 | 1824 |
1825 bool LayoutGrid::isChildOverflowingContainingBlockHeight(const LayoutBox& child) const | |
1826 { | |
1827 // TODO (lajava) We must consider margins to determine whether it overflows or not (see https://crbug/628155) | |
1828 LayoutUnit containingBlockContentHeight = child.hasOverrideContainingBlockHe ight() ? child.overrideContainingBlockContentHeight() : LayoutUnit(); | |
1829 return child.size().height() > containingBlockContentHeight; | |
1830 } | |
1831 | |
1832 bool LayoutGrid::isChildOverflowingContainingBlockWidth(const LayoutBox& child) const | |
1833 { | |
1834 // TODO (lajava) We must consider margins to determine whether it overflows or not (see https://crbug/628155) | |
1835 LayoutUnit containingBlockContentWidth = child.hasOverrideContainingBlockWid th() ? child.overrideContainingBlockContentWidth() : LayoutUnit(); | |
1836 return child.size().width() > containingBlockContentWidth; | |
1837 } | |
1838 | |
1825 void LayoutGrid::layoutGridItems(GridSizingData& sizingData) | 1839 void LayoutGrid::layoutGridItems(GridSizingData& sizingData) |
1826 { | 1840 { |
1827 populateGridPositionsForDirection(sizingData, ForColumns); | 1841 populateGridPositionsForDirection(sizingData, ForColumns); |
1828 populateGridPositionsForDirection(sizingData, ForRows); | 1842 populateGridPositionsForDirection(sizingData, ForRows); |
1829 m_gridItemsOverflowingGridArea.resize(0); | 1843 m_gridItemsOverflowingGridArea.resize(0); |
1830 | 1844 |
1831 for (LayoutBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { | 1845 for (LayoutBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { |
1832 if (child->isOutOfFlowPositioned()) { | 1846 if (child->isOutOfFlowPositioned()) { |
1833 prepareChildForPositionedLayout(*child); | 1847 prepareChildForPositionedLayout(*child); |
1834 continue; | 1848 continue; |
1835 } | 1849 } |
1836 | 1850 |
1837 // Because the grid area cannot be styled, we don't need to adjust | 1851 // Because the grid area cannot be styled, we don't need to adjust |
1838 // the grid breadth to account for 'box-sizing'. | 1852 // the grid breadth to account for 'box-sizing'. |
1839 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOve rrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogica lWidth() : LayoutUnit(); | 1853 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOve rrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogica lWidth() : LayoutUnit(); |
1840 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOv errideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogi calHeight() : LayoutUnit(); | 1854 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOv errideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogi calHeight() : LayoutUnit(); |
1841 | 1855 |
1842 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthF orChildIncludingAlignmentOffsets(*child, ForColumns, sizingData); | 1856 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthF orChildIncludingAlignmentOffsets(*child, ForColumns, sizingData); |
1843 LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadth ForChildIncludingAlignmentOffsets(*child, ForRows, sizingData); | 1857 LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadth ForChildIncludingAlignmentOffsets(*child, ForRows, sizingData); |
1844 | 1858 |
1845 SubtreeLayoutScope layoutScope(*child); | 1859 SubtreeLayoutScope layoutScope(*child); |
1846 if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingB lockContentLogicalWidth || (oldOverrideContainingBlockContentLogicalHeight != ov errideContainingBlockContentLogicalHeight && (child->hasRelativeLogicalHeight() || isOrthogonalChild(*child)))) | 1860 if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingB lockContentLogicalWidth || (oldOverrideContainingBlockContentLogicalHeight != ov errideContainingBlockContentLogicalHeight && child->hasRelativeLogicalHeight())) |
svillar
2016/07/20 09:23:36
Why don't we need to force a layout for orthogonal
jfernandez
2016/07/20 13:46:14
Sincerely, that condition has been added in r40124
| |
1847 layoutScope.setNeedsLayout(child, LayoutInvalidationReason::GridChan ged); | 1861 layoutScope.setNeedsLayout(child, LayoutInvalidationReason::GridChan ged); |
1848 | 1862 |
1849 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingB lockContentLogicalWidth); | 1863 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingB lockContentLogicalWidth); |
1850 child->setOverrideContainingBlockContentLogicalHeight(overrideContaining BlockContentLogicalHeight); | 1864 child->setOverrideContainingBlockContentLogicalHeight(overrideContaining BlockContentLogicalHeight); |
1851 | 1865 |
1852 // Stretching logic might force a child layout, so we need to run it bef ore the layoutIfNeeded | 1866 // Stretching logic might force a child layout, so we need to run it bef ore the layoutIfNeeded |
1853 // call to avoid unnecessary relayouts. This might imply that child marg ins, needed to correctly | 1867 // call to avoid unnecessary relayouts. This might imply that child marg ins, needed to correctly |
1854 // determine the available space before stretching, are not set yet. | 1868 // determine the available space before stretching, are not set yet. |
1855 applyStretchAlignmentToChildIfNeeded(*child); | 1869 applyStretchAlignmentToChildIfNeeded(*child); |
1856 | 1870 |
1857 child->layoutIfNeeded(); | 1871 child->layoutIfNeeded(); |
1858 | 1872 |
1859 // We need pending layouts to be done in order to compute auto-margins p roperly. | 1873 // We need pending layouts to be done in order to compute auto-margins p roperly. |
1860 updateAutoMarginsInColumnAxisIfNeeded(*child); | 1874 updateAutoMarginsInColumnAxisIfNeeded(*child); |
1861 updateAutoMarginsInRowAxisIfNeeded(*child); | 1875 updateAutoMarginsInRowAxisIfNeeded(*child); |
1862 | 1876 |
1863 #if ENABLE(ASSERT) | 1877 #if ENABLE(ASSERT) |
1864 const GridArea& area = cachedGridArea(*child); | 1878 const GridArea& area = cachedGridArea(*child); |
1865 ASSERT(area.columns.startLine() < sizingData.columnTracks.size()); | 1879 ASSERT(area.columns.startLine() < sizingData.columnTracks.size()); |
1866 ASSERT(area.rows.startLine() < sizingData.rowTracks.size()); | 1880 ASSERT(area.rows.startLine() < sizingData.rowTracks.size()); |
1867 #endif | 1881 #endif |
1868 child->setLogicalLocation(findChildLogicalPosition(*child, sizingData)); | 1882 child->setLogicalLocation(findChildLogicalPosition(*child, sizingData)); |
1869 | 1883 |
1870 // Keep track of children overflowing their grid area as we might need t o paint them even if the grid-area is | 1884 // Keep track of children overflowing their grid area as we might need t o paint them even if the grid-area is |
1871 // not visible | 1885 // not visible. |
1872 if (child->logicalHeight() > overrideContainingBlockContentLogicalHeight | 1886 // Using physical dimensions for simplicity, so we can forget about orth ogonalty. |
1873 || child->logicalWidth() > overrideContainingBlockContentLogicalWidt h) | 1887 if (isChildOverflowingContainingBlockHeight(*child) |
1888 || isChildOverflowingContainingBlockWidth(*child)) | |
svillar
2016/07/20 09:23:36
One line.
jfernandez
2016/07/20 13:46:14
Done.
| |
1874 m_gridItemsOverflowingGridArea.append(child); | 1889 m_gridItemsOverflowingGridArea.append(child); |
1875 } | 1890 } |
1876 } | 1891 } |
1877 | 1892 |
1878 void LayoutGrid::prepareChildForPositionedLayout(LayoutBox& child) | 1893 void LayoutGrid::prepareChildForPositionedLayout(LayoutBox& child) |
1879 { | 1894 { |
1880 ASSERT(child.isOutOfFlowPositioned()); | 1895 ASSERT(child.isOutOfFlowPositioned()); |
1881 child.containingBlock()->insertPositionedObject(&child); | 1896 child.containingBlock()->insertPositionedObject(&child); |
1882 | 1897 |
1883 PaintLayer* childLayer = child.layer(); | 1898 PaintLayer* childLayer = child.layer(); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2110 } | 2125 } |
2111 positions[i] += gapAccumulator; | 2126 positions[i] += gapAccumulator; |
2112 } | 2127 } |
2113 positions[lastLine] += gapAccumulator; | 2128 positions[lastLine] += gapAccumulator; |
2114 } | 2129 } |
2115 } | 2130 } |
2116 auto& offsetBetweenTracks = isRowAxis ? m_offsetBetweenColumns : m_offsetBet weenRows; | 2131 auto& offsetBetweenTracks = isRowAxis ? m_offsetBetweenColumns : m_offsetBet weenRows; |
2117 offsetBetweenTracks = offset.distributionOffset; | 2132 offsetBetweenTracks = offset.distributionOffset; |
2118 } | 2133 } |
2119 | 2134 |
2120 static LayoutUnit computeOverflowAlignmentOffset(OverflowAlignment overflow, Lay outUnit trackBreadth, LayoutUnit childBreadth) | 2135 static LayoutUnit computeOverflowAlignmentOffset(OverflowAlignment overflow, Lay outUnit trackSize, LayoutUnit childSize) |
2121 { | 2136 { |
2122 LayoutUnit offset = trackBreadth - childBreadth; | 2137 LayoutUnit offset = trackSize - childSize; |
2123 switch (overflow) { | 2138 switch (overflow) { |
2124 case OverflowAlignmentSafe: | 2139 case OverflowAlignmentSafe: |
2125 // If overflow is 'safe', we have to make sure we don't overflow the 'st art' | 2140 // If overflow is 'safe', we have to make sure we don't overflow the 'st art' |
2126 // edge (potentially cause some data loss as the overflow is unreachable ). | 2141 // edge (potentially cause some data loss as the overflow is unreachable ). |
2127 return offset.clampNegativeToZero(); | 2142 return offset.clampNegativeToZero(); |
2128 case OverflowAlignmentUnsafe: | 2143 case OverflowAlignmentUnsafe: |
2129 case OverflowAlignmentDefault: | 2144 case OverflowAlignmentDefault: |
2130 // If we overflow our alignment container and overflow is 'true' (defaul t), we | 2145 // If we overflow our alignment container and overflow is 'true' (defaul t), we |
2131 // ignore the overflow and just return the value regardless (which may c ause data | 2146 // ignore the overflow and just return the value regardless (which may c ause data |
2132 // loss as we overflow the 'start' edge). | 2147 // loss as we overflow the 'start' edge). |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2249 } else if (marginBefore.isAuto()) { | 2264 } else if (marginBefore.isAuto()) { |
2250 child.setMarginBefore(availableAlignmentSpace, style()); | 2265 child.setMarginBefore(availableAlignmentSpace, style()); |
2251 } else if (marginAfter.isAuto()) { | 2266 } else if (marginAfter.isAuto()) { |
2252 child.setMarginAfter(availableAlignmentSpace, style()); | 2267 child.setMarginAfter(availableAlignmentSpace, style()); |
2253 } | 2268 } |
2254 } | 2269 } |
2255 | 2270 |
2256 GridAxisPosition LayoutGrid::columnAxisPositionForChild(const LayoutBox& child) const | 2271 GridAxisPosition LayoutGrid::columnAxisPositionForChild(const LayoutBox& child) const |
2257 { | 2272 { |
2258 bool hasSameWritingMode = child.styleRef().getWritingMode() == styleRef().ge tWritingMode(); | 2273 bool hasSameWritingMode = child.styleRef().getWritingMode() == styleRef().ge tWritingMode(); |
2259 | 2274 |
svillar
2016/07/20 09:23:36
I think it'd be a good idea to store in a bool the
jfernandez
2016/07/20 13:46:14
Acknowledged.
| |
2260 switch (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPo sitionStretch)) { | 2275 switch (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPo sitionStretch)) { |
2261 case ItemPositionSelfStart: | 2276 case ItemPositionSelfStart: |
2262 // If orthogonal writing-modes, this computes to 'start'. | 2277 // Aligns the alignment subject to be flush with the edge of the alignme nt container |
2263 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. | 2278 // corresponding to the alignment subject's 'start' side in the column a xis. |
2264 // self-start is based on the child's block axis direction. That's why w e need to check against the grid container's block flow. | 2279 if (isOrthogonalChild(child)) { |
2265 return (isOrthogonalChild(child) || hasSameWritingMode) ? GridAxisStart : GridAxisEnd; | 2280 // If orthogonal writing-modes, self-start will be based on the chil d's inline-axis |
2281 // direction (inline-start), because it's the one parallel to the co lumn axis. | |
2282 if (isFlippedBlocksWritingMode(style()->getWritingMode())) | |
2283 return child.style()->isLeftToRightDirection() ? GridAxisEnd : G ridAxisStart; | |
2284 return child.style()->isLeftToRightDirection() ? GridAxisStart : Gri dAxisEnd; | |
2285 } | |
svillar
2016/07/20 09:23:36
I definitely think we should move this code block
jfernandez
2016/07/20 13:46:14
This logic, and the similar one implemented in row
| |
2286 // self-start is based on the child's block-flow direction. That's why w e need to check against the grid container's block-flow direction. | |
2287 return hasSameWritingMode ? GridAxisStart : GridAxisEnd; | |
2266 case ItemPositionSelfEnd: | 2288 case ItemPositionSelfEnd: |
2267 // If orthogonal writing-modes, this computes to 'end'. | 2289 // Aligns the alignment subject to be flush with the edge of the alignme nt container |
2268 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. | 2290 // corresponding to the alignment subject's 'end' side in the column axi s. |
2269 // self-end is based on the child's block axis direction. That's why we need to check against the grid container's block flow. | 2291 if (isOrthogonalChild(child)) { |
2270 return (isOrthogonalChild(child) || hasSameWritingMode) ? GridAxisEnd : GridAxisStart; | 2292 // If orthogonal writing-modes, self-end will be based on the child' s inline-axis |
2293 // direction, (inline-end) because it's the one parallel to the colu mn axis. | |
2294 if (isFlippedBlocksWritingMode(style()->getWritingMode())) | |
2295 return child.style()->isLeftToRightDirection() ? GridAxisStart : GridAxisEnd; | |
2296 return child.style()->isLeftToRightDirection() ? GridAxisEnd : GridA xisStart; | |
2297 } | |
2298 // self-end is based on the child's block-flow direction. That's why we need to check against the grid container's block-flow direction. | |
2299 return hasSameWritingMode ? GridAxisEnd : GridAxisStart; | |
2271 case ItemPositionLeft: | 2300 case ItemPositionLeft: |
2272 // The alignment axis (column axis) and the inline axis are parallell in | 2301 // Aligns the alignment subject to be flush with the alignment container 's 'line-left' edge. |
2273 // orthogonal writing mode. Otherwise this this is equivalent to 'start' . | 2302 // The alignment axis (column axis) is always orthogonal to the inline a xis, hence this value behaves as 'start'. |
2274 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. | |
2275 return GridAxisStart; | 2303 return GridAxisStart; |
2276 case ItemPositionRight: | 2304 case ItemPositionRight: |
2277 // The alignment axis (column axis) and the inline axis are parallell in | 2305 // Aligns the alignment subject to be flush with the alignment container 's 'line-right' edge. |
2278 // orthogonal writing mode. Otherwise this this is equivalent to 'start' . | 2306 // The alignment axis (column axis) is always orthogonal to the inline a xis, hence this value behaves as 'start'. |
2279 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. | 2307 return GridAxisStart; |
2280 return isOrthogonalChild(child) ? GridAxisEnd : GridAxisStart; | |
2281 case ItemPositionCenter: | 2308 case ItemPositionCenter: |
2282 return GridAxisCenter; | 2309 return GridAxisCenter; |
2283 case ItemPositionFlexStart: // Only used in flex layout, otherwise equivalen t to 'start'. | 2310 case ItemPositionFlexStart: // Only used in flex layout, otherwise equivalen t to 'start'. |
2311 // Aligns the alignment subject to be flush with the alignment container 's 'start' edge (block-start) in the column axis. | |
2284 case ItemPositionStart: | 2312 case ItemPositionStart: |
2285 return GridAxisStart; | 2313 return GridAxisStart; |
2286 case ItemPositionFlexEnd: // Only used in flex layout, otherwise equivalent to 'end'. | 2314 case ItemPositionFlexEnd: // Only used in flex layout, otherwise equivalent to 'end'. |
2315 // Aligns the alignment subject to be flush with the alignment container 's 'end' edge (block-end) in the column axis. | |
2287 case ItemPositionEnd: | 2316 case ItemPositionEnd: |
2288 return GridAxisEnd; | 2317 return GridAxisEnd; |
2289 case ItemPositionStretch: | 2318 case ItemPositionStretch: |
2290 return GridAxisStart; | 2319 return GridAxisStart; |
2291 case ItemPositionBaseline: | 2320 case ItemPositionBaseline: |
2292 case ItemPositionLastBaseline: | 2321 case ItemPositionLastBaseline: |
2293 // FIXME: These two require implementing Baseline Alignment. For now, we always 'start' align the child. | 2322 // FIXME: These two require implementing Baseline Alignment. For now, we always 'start' align the child. |
2294 // crbug.com/234191 | 2323 // crbug.com/234191 |
2295 return GridAxisStart; | 2324 return GridAxisStart; |
2296 case ItemPositionAuto: | 2325 case ItemPositionAuto: |
2297 break; | 2326 break; |
2298 } | 2327 } |
2299 | 2328 |
2300 ASSERT_NOT_REACHED(); | 2329 ASSERT_NOT_REACHED(); |
2301 return GridAxisStart; | 2330 return GridAxisStart; |
2302 } | 2331 } |
2303 | 2332 |
2304 GridAxisPosition LayoutGrid::rowAxisPositionForChild(const LayoutBox& child) con st | 2333 GridAxisPosition LayoutGrid::rowAxisPositionForChild(const LayoutBox& child) con st |
2305 { | 2334 { |
2306 bool hasSameDirection = child.styleRef().direction() == styleRef().direction (); | 2335 bool hasSameDirection = child.styleRef().direction() == styleRef().direction (); |
2307 bool isLTR = styleRef().isLeftToRightDirection(); | |
2308 | 2336 |
2309 switch (ComputedStyle::resolveJustification(styleRef(), child.styleRef(), It emPositionStretch)) { | 2337 switch (ComputedStyle::resolveJustification(styleRef(), child.styleRef(), It emPositionStretch)) { |
2310 case ItemPositionSelfStart: | 2338 case ItemPositionSelfStart: |
2311 // For orthogonal writing-modes, this computes to 'start' | 2339 // Aligns the alignment subject to be flush with the edge of the alignme nt container |
2312 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. | 2340 // corresponding to the alignment subject's 'start' side in the row axis . |
2313 // self-start is based on the child's direction. That's why we need to c heck against the grid container's direction. | 2341 if (isOrthogonalChild(child)) { |
2314 return (isOrthogonalChild(child) || hasSameDirection) ? GridAxisStart : GridAxisEnd; | 2342 // If orthogonal writing-modes, self-start will be based on the chil d's block-axis |
2343 // direction, because it's the one parallel to the row axis. | |
2344 if (isFlippedBlocksWritingMode(child.style()->getWritingMode())) | |
2345 return styleRef().isLeftToRightDirection() ? GridAxisEnd : GridA xisStart; | |
2346 return styleRef().isLeftToRightDirection() ? GridAxisStart : GridAxi sEnd; | |
2347 } | |
2348 // self-start is based on the child's inline-flow direction. That's why we need to check against the grid container's direction. | |
2349 return hasSameDirection ? GridAxisStart : GridAxisEnd; | |
2315 case ItemPositionSelfEnd: | 2350 case ItemPositionSelfEnd: |
2316 // For orthogonal writing-modes, this computes to 'start' | 2351 // Aligns the alignment subject to be flush with the edge of the alignme nt container |
2317 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. | 2352 // corresponding to the alignment subject's 'end' side in the row axis. |
2318 return (isOrthogonalChild(child) || hasSameDirection) ? GridAxisEnd : Gr idAxisStart; | 2353 if (isOrthogonalChild(child)) { |
2354 // If orthogonal writing-modes, self-end will be based on the child' s block-axis | |
2355 // direction, because it's the one parallel to the row axis. | |
2356 if (isFlippedBlocksWritingMode(child.style()->getWritingMode())) | |
2357 return styleRef().isLeftToRightDirection() ? GridAxisStart : Gri dAxisEnd; | |
2358 return styleRef().isLeftToRightDirection() ? GridAxisEnd : GridAxisS tart; | |
2359 } | |
2360 // self-end is based on the child's inline-flow direction. That's why we need to check against the grid container's direction. | |
2361 return hasSameDirection ? GridAxisEnd : GridAxisStart; | |
2319 case ItemPositionLeft: | 2362 case ItemPositionLeft: |
2320 return isLTR ? GridAxisStart : GridAxisEnd; | 2363 // Aligns the alignment subject to be flush with the alignment container 's 'line-left' edge. |
2364 // We want the physical 'left' side, so we have to take account, contain er's inline-flow direction. | |
2365 return styleRef().isLeftToRightDirection() ? GridAxisStart : GridAxisEnd ; | |
2321 case ItemPositionRight: | 2366 case ItemPositionRight: |
2322 return isLTR ? GridAxisEnd : GridAxisStart; | 2367 // Aligns the alignment subject to be flush with the alignment container 's 'line-right' edge. |
2368 // We want the physical 'right' side, so we have to take account, contai ner's inline-flow direction. | |
2369 return styleRef().isLeftToRightDirection() ? GridAxisEnd : GridAxisStart ; | |
2323 case ItemPositionCenter: | 2370 case ItemPositionCenter: |
2324 return GridAxisCenter; | 2371 return GridAxisCenter; |
2325 case ItemPositionFlexStart: // Only used in flex layout, otherwise equivalen t to 'start'. | 2372 case ItemPositionFlexStart: // Only used in flex layout, otherwise equivalen t to 'start'. |
2373 // Aligns the alignment subject to be flush with the alignment container 's 'start' edge (inline-start) in the row axis. | |
2326 case ItemPositionStart: | 2374 case ItemPositionStart: |
2327 return GridAxisStart; | 2375 return GridAxisStart; |
2328 case ItemPositionFlexEnd: // Only used in flex layout, otherwise equivalent to 'end'. | 2376 case ItemPositionFlexEnd: // Only used in flex layout, otherwise equivalent to 'end'. |
2377 // Aligns the alignment subject to be flush with the alignment container 's 'end' edge (inline-end) in the row axis. | |
2329 case ItemPositionEnd: | 2378 case ItemPositionEnd: |
2330 return GridAxisEnd; | 2379 return GridAxisEnd; |
2331 case ItemPositionStretch: | 2380 case ItemPositionStretch: |
2332 return GridAxisStart; | 2381 return GridAxisStart; |
2333 case ItemPositionBaseline: | 2382 case ItemPositionBaseline: |
2334 case ItemPositionLastBaseline: | 2383 case ItemPositionLastBaseline: |
2335 // FIXME: These two require implementing Baseline Alignment. For now, we always 'start' align the child. | 2384 // FIXME: These two require implementing Baseline Alignment. For now, we always 'start' align the child. |
2336 // crbug.com/234191 | 2385 // crbug.com/234191 |
2337 return GridAxisStart; | 2386 return GridAxisStart; |
2338 case ItemPositionAuto: | 2387 case ItemPositionAuto: |
(...skipping 21 matching lines...) Expand all Loading... | |
2360 size_t childEndLine = rowsSpan.endLine(); | 2409 size_t childEndLine = rowsSpan.endLine(); |
2361 LayoutUnit endOfRow = m_rowPositions[childEndLine]; | 2410 LayoutUnit endOfRow = m_rowPositions[childEndLine]; |
2362 // m_rowPositions include distribution offset (because of content alignm ent) and gutters | 2411 // m_rowPositions include distribution offset (because of content alignm ent) and gutters |
2363 // so we need to subtract them to get the actual end position for a give n row | 2412 // so we need to subtract them to get the actual end position for a give n row |
2364 // (this does not have to be done for the last track as there are no mor e m_columnPositions after it). | 2413 // (this does not have to be done for the last track as there are no mor e m_columnPositions after it). |
2365 LayoutUnit trackGap = gridGapForDirection(ForRows); | 2414 LayoutUnit trackGap = gridGapForDirection(ForRows); |
2366 if (childEndLine < m_rowPositions.size() - 1) { | 2415 if (childEndLine < m_rowPositions.size() - 1) { |
2367 endOfRow -= trackGap; | 2416 endOfRow -= trackGap; |
2368 endOfRow -= m_offsetBetweenRows; | 2417 endOfRow -= m_offsetBetweenRows; |
2369 } | 2418 } |
2370 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHei ght(); | 2419 LayoutUnit columnAxisChildSize = isOrthogonalChild(child) ? child.logica lWidth() + child.marginLogicalWidth() : child.logicalHeight() + child.marginLogi calHeight(); |
2371 OverflowAlignment overflow = child.styleRef().resolvedAlignment(styleRef (), ItemPositionStretch).overflow(); | 2420 OverflowAlignment overflow = child.styleRef().resolvedAlignment(styleRef (), ItemPositionStretch).overflow(); |
2372 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over flow, endOfRow - startOfRow, childBreadth); | 2421 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over flow, endOfRow - startOfRow, columnAxisChildSize); |
2373 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); | 2422 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); |
2374 } | 2423 } |
2375 } | 2424 } |
2376 | 2425 |
2377 ASSERT_NOT_REACHED(); | 2426 ASSERT_NOT_REACHED(); |
2378 return LayoutUnit(); | 2427 return LayoutUnit(); |
2379 } | 2428 } |
2380 | 2429 |
2381 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child, GridSizingD ata& sizingData) const | 2430 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child, GridSizingD ata& sizingData) const |
2382 { | 2431 { |
(...skipping 12 matching lines...) Expand all Loading... | |
2395 size_t childEndLine = columnsSpan.endLine(); | 2444 size_t childEndLine = columnsSpan.endLine(); |
2396 LayoutUnit endOfColumn = m_columnPositions[childEndLine]; | 2445 LayoutUnit endOfColumn = m_columnPositions[childEndLine]; |
2397 // m_columnPositions include distribution offset (because of content ali gnment) and gutters | 2446 // m_columnPositions include distribution offset (because of content ali gnment) and gutters |
2398 // so we need to subtract them to get the actual end position for a give n column | 2447 // so we need to subtract them to get the actual end position for a give n column |
2399 // (this does not have to be done for the last track as there are no mor e m_columnPositions after it). | 2448 // (this does not have to be done for the last track as there are no mor e m_columnPositions after it). |
2400 LayoutUnit trackGap = gridGapForDirection(ForColumns); | 2449 LayoutUnit trackGap = gridGapForDirection(ForColumns); |
2401 if (childEndLine < m_columnPositions.size() - 1) { | 2450 if (childEndLine < m_columnPositions.size() - 1) { |
2402 endOfColumn -= trackGap; | 2451 endOfColumn -= trackGap; |
2403 endOfColumn -= m_offsetBetweenColumns; | 2452 endOfColumn -= m_offsetBetweenColumns; |
2404 } | 2453 } |
2405 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidt h(); | 2454 LayoutUnit rowAxisChildSize = isOrthogonalChild(child) ? child.logicalHe ight() + child.marginLogicalHeight() : child.logicalWidth() + child.marginLogica lWidth(); |
2406 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil d.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, childB readth); | 2455 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil d.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, rowAxi sChildSize); |
2407 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); | 2456 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); |
2408 } | 2457 } |
2409 } | 2458 } |
2410 | 2459 |
2411 ASSERT_NOT_REACHED(); | 2460 ASSERT_NOT_REACHED(); |
2412 return LayoutUnit(); | 2461 return LayoutUnit(); |
2413 } | 2462 } |
2414 | 2463 |
2415 ContentPosition static resolveContentDistributionFallback(ContentDistributionTyp e distribution) | 2464 ContentPosition static resolveContentDistributionFallback(ContentDistributionTyp e distribution) |
2416 { | 2465 { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2522 return rightGridEdgePosition + alignmentOffset - coordinate; | 2571 return rightGridEdgePosition + alignmentOffset - coordinate; |
2523 } | 2572 } |
2524 | 2573 |
2525 LayoutPoint LayoutGrid::findChildLogicalPosition(const LayoutBox& child, GridSiz ingData& sizingData) const | 2574 LayoutPoint LayoutGrid::findChildLogicalPosition(const LayoutBox& child, GridSiz ingData& sizingData) const |
2526 { | 2575 { |
2527 LayoutUnit columnAxisOffset = columnAxisOffsetForChild(child, sizingData); | 2576 LayoutUnit columnAxisOffset = columnAxisOffsetForChild(child, sizingData); |
2528 LayoutUnit rowAxisOffset = rowAxisOffsetForChild(child, sizingData); | 2577 LayoutUnit rowAxisOffset = rowAxisOffsetForChild(child, sizingData); |
2529 // We stored m_columnPosition's data ignoring the direction, hence we might need now | 2578 // We stored m_columnPosition's data ignoring the direction, hence we might need now |
2530 // to translate positions from RTL to LTR, as it's more convenient for paint ing. | 2579 // to translate positions from RTL to LTR, as it's more convenient for paint ing. |
2531 if (!style()->isLeftToRightDirection()) | 2580 if (!style()->isLeftToRightDirection()) |
2532 rowAxisOffset = translateRTLCoordinate(rowAxisOffset) - child.logicalWid th(); | 2581 rowAxisOffset = translateRTLCoordinate(rowAxisOffset) - (isOrthogonalChi ld(child) ? child.logicalHeight() : child.logicalWidth()); |
2533 | 2582 |
2534 // "In the positioning phase [...] calculations are performed according to t he writing mode | 2583 // "In the positioning phase [...] calculations are performed according to t he writing mode |
2535 // of the containing block of the box establishing the orthogonal flow." How ever, the | 2584 // of the containing block of the box establishing the orthogonal flow." How ever, the |
2536 // resulting LayoutPoint will be used in 'setLogicalPosition' in order to se t the child's | 2585 // resulting LayoutPoint will be used in 'setLogicalPosition' in order to se t the child's |
2537 // logical position, which will only take into account the child's writing-m ode. | 2586 // logical position, which will only take into account the child's writing-m ode. |
2538 LayoutPoint childLocation(rowAxisOffset, columnAxisOffset); | 2587 LayoutPoint childLocation(rowAxisOffset, columnAxisOffset); |
2539 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation; | 2588 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation; |
2540 } | 2589 } |
2541 | 2590 |
2542 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const | 2591 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const |
2543 { | 2592 { |
2544 if (!m_gridItemArea.isEmpty()) | 2593 if (!m_gridItemArea.isEmpty()) |
2545 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2594 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
2546 } | 2595 } |
2547 | 2596 |
2548 } // namespace blink | 2597 } // namespace blink |
OLD | NEW |