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 19 matching lines...) Expand all Loading... |
30 #include "core/paint/GridPainter.h" | 30 #include "core/paint/GridPainter.h" |
31 #include "core/paint/PaintLayer.h" | 31 #include "core/paint/PaintLayer.h" |
32 #include "core/style/ComputedStyle.h" | 32 #include "core/style/ComputedStyle.h" |
33 #include "core/style/GridArea.h" | 33 #include "core/style/GridArea.h" |
34 #include "platform/LengthFunctions.h" | 34 #include "platform/LengthFunctions.h" |
35 #include <algorithm> | 35 #include <algorithm> |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 static const int infinity = -1; | 39 static const int infinity = -1; |
| 40 static const ItemPosition selfAlignmentNormalBehavior = ItemPositionStretch; |
40 | 41 |
41 class GridItemWithSpan; | 42 class GridItemWithSpan; |
42 | 43 |
43 class GridTrack { | 44 class GridTrack { |
44 public: | 45 public: |
45 GridTrack() | 46 GridTrack() |
46 : m_baseSize(0) | 47 : m_baseSize(0) |
47 , m_growthLimit(0) | 48 , m_growthLimit(0) |
48 , m_plannedSize(0) | 49 , m_plannedSize(0) |
49 , m_sizeDuringDistribution(0) | 50 , m_sizeDuringDistribution(0) |
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1530 // the grid and its children are correctly laid out according to the new sty
le rules. | 1531 // the grid and its children are correctly laid out according to the new sty
le rules. |
1531 setNeedsLayout(LayoutInvalidationReason::GridChanged); | 1532 setNeedsLayout(LayoutInvalidationReason::GridChanged); |
1532 | 1533 |
1533 m_grid.resize(0); | 1534 m_grid.resize(0); |
1534 m_gridItemArea.clear(); | 1535 m_gridItemArea.clear(); |
1535 m_gridItemsOverflowingGridArea.resize(0); | 1536 m_gridItemsOverflowingGridArea.resize(0); |
1536 m_gridItemsIndexesMap.clear(); | 1537 m_gridItemsIndexesMap.clear(); |
1537 m_gridIsDirty = true; | 1538 m_gridIsDirty = true; |
1538 } | 1539 } |
1539 | 1540 |
1540 static const StyleContentAlignmentData& normalValueBehavior() | 1541 static const StyleContentAlignmentData& contentAlignmentNormalBehavior() |
1541 { | 1542 { |
1542 static const StyleContentAlignmentData normalBehavior = {ContentPositionNorm
al, ContentDistributionStretch}; | 1543 static const StyleContentAlignmentData normalBehavior = {ContentPositionNorm
al, ContentDistributionStretch}; |
1543 return normalBehavior; | 1544 return normalBehavior; |
1544 } | 1545 } |
1545 | 1546 |
1546 void LayoutGrid::applyStretchAlignmentToTracksIfNeeded(GridTrackSizingDirection
direction, GridSizingData& sizingData) | 1547 void LayoutGrid::applyStretchAlignmentToTracksIfNeeded(GridTrackSizingDirection
direction, GridSizingData& sizingData) |
1547 { | 1548 { |
1548 LayoutUnit& availableSpace = sizingData.freeSpaceForDirection(direction); | 1549 LayoutUnit& availableSpace = sizingData.freeSpaceForDirection(direction); |
1549 if (availableSpace <= 0 | 1550 if (availableSpace <= 0 |
1550 || (direction == ForColumns && styleRef().resolvedJustifyContentDistribu
tion(normalValueBehavior()) != ContentDistributionStretch) | 1551 || (direction == ForColumns && styleRef().resolvedJustifyContentDistribu
tion(contentAlignmentNormalBehavior()) != ContentDistributionStretch) |
1551 || (direction == ForRows && styleRef().resolvedAlignContentDistribution(
normalValueBehavior()) != ContentDistributionStretch)) | 1552 || (direction == ForRows && styleRef().resolvedAlignContentDistribution(
contentAlignmentNormalBehavior()) != ContentDistributionStretch)) |
1552 return; | 1553 return; |
1553 | 1554 |
1554 // Spec defines auto-sized tracks as the ones with an 'auto' max-sizing func
tion. | 1555 // Spec defines auto-sized tracks as the ones with an 'auto' max-sizing func
tion. |
1555 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra
cks : sizingData.rowTracks; | 1556 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra
cks : sizingData.rowTracks; |
1556 Vector<unsigned> autoSizedTracksIndex; | 1557 Vector<unsigned> autoSizedTracksIndex; |
1557 for (unsigned i = 0; i < tracks.size(); ++i) { | 1558 for (unsigned i = 0; i < tracks.size(); ++i) { |
1558 const GridTrackSize& trackSize = gridTrackSize(direction, i); | 1559 const GridTrackSize& trackSize = gridTrackSize(direction, i); |
1559 if (trackSize.hasAutoMaxTrackBreadth()) | 1560 if (trackSize.hasAutoMaxTrackBreadth()) |
1560 autoSizedTracksIndex.append(i); | 1561 autoSizedTracksIndex.append(i); |
1561 } | 1562 } |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1880 void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child) | 1881 void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child) |
1881 { | 1882 { |
1882 // We clear height override values because we will decide now whether it's a
llowed or | 1883 // We clear height override values because we will decide now whether it's a
llowed or |
1883 // not, evaluating the conditions which might have changed since the old val
ues were set. | 1884 // not, evaluating the conditions which might have changed since the old val
ues were set. |
1884 child.clearOverrideLogicalContentHeight(); | 1885 child.clearOverrideLogicalContentHeight(); |
1885 | 1886 |
1886 auto& childStyle = child.styleRef(); | 1887 auto& childStyle = child.styleRef(); |
1887 bool isHorizontalMode = isHorizontalWritingMode(); | 1888 bool isHorizontalMode = isHorizontalWritingMode(); |
1888 bool hasAutoSizeInColumnAxis = isHorizontalMode ? childStyle.height().isAuto
() : childStyle.width().isAuto(); | 1889 bool hasAutoSizeInColumnAxis = isHorizontalMode ? childStyle.height().isAuto
() : childStyle.width().isAuto(); |
1889 bool allowedToStretchChildAlongColumnAxis = hasAutoSizeInColumnAxis && !chil
dStyle.marginBeforeUsing(style()).isAuto() && !childStyle.marginAfterUsing(style
()).isAuto(); | 1890 bool allowedToStretchChildAlongColumnAxis = hasAutoSizeInColumnAxis && !chil
dStyle.marginBeforeUsing(style()).isAuto() && !childStyle.marginAfterUsing(style
()).isAuto(); |
1890 if (allowedToStretchChildAlongColumnAxis && ComputedStyle::resolveAlignment(
styleRef(), childStyle, ItemPositionStretch) == ItemPositionStretch) { | 1891 if (allowedToStretchChildAlongColumnAxis && childStyle.resolvedAlignSelf(sel
fAlignmentNormalBehavior).position() == ItemPositionStretch) { |
1891 // TODO (lajava): If the child has orthogonal flow, then it already has
an override height set, so use it. | 1892 // TODO (lajava): If the child has orthogonal flow, then it already has
an override height set, so use it. |
1892 // TODO (lajava): grid track sizing and positioning do not support ortho
gonal modes yet. | 1893 // TODO (lajava): grid track sizing and positioning do not support ortho
gonal modes yet. |
1893 if (child.isHorizontalWritingMode() == isHorizontalMode) { | 1894 if (child.isHorizontalWritingMode() == isHorizontalMode) { |
1894 LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildB
eforeStretching(child.overrideContainingBlockContentLogicalHeight(), child); | 1895 LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildB
eforeStretching(child.overrideContainingBlockContentLogicalHeight(), child); |
1895 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM
ax(stretchedLogicalHeight, LayoutUnit(-1)); | 1896 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM
ax(stretchedLogicalHeight, LayoutUnit(-1)); |
1896 child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.b
orderAndPaddingLogicalHeight()); | 1897 child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.b
orderAndPaddingLogicalHeight()); |
1897 if (desiredLogicalHeight != child.logicalHeight()) { | 1898 if (desiredLogicalHeight != child.logicalHeight()) { |
1898 // TODO (lajava): Can avoid laying out here in some cases. See h
ttps://webkit.org/b/87905. | 1899 // TODO (lajava): Can avoid laying out here in some cases. See h
ttps://webkit.org/b/87905. |
1899 child.setLogicalHeight(LayoutUnit()); | 1900 child.setLogicalHeight(LayoutUnit()); |
1900 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); | 1901 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1958 child.setMarginBefore(availableAlignmentSpace, style()); | 1959 child.setMarginBefore(availableAlignmentSpace, style()); |
1959 } else if (marginAfter.isAuto()) { | 1960 } else if (marginAfter.isAuto()) { |
1960 child.setMarginAfter(availableAlignmentSpace, style()); | 1961 child.setMarginAfter(availableAlignmentSpace, style()); |
1961 } | 1962 } |
1962 } | 1963 } |
1963 | 1964 |
1964 GridAxisPosition LayoutGrid::columnAxisPositionForChild(const LayoutBox& child)
const | 1965 GridAxisPosition LayoutGrid::columnAxisPositionForChild(const LayoutBox& child)
const |
1965 { | 1966 { |
1966 bool hasSameWritingMode = child.styleRef().getWritingMode() == styleRef().ge
tWritingMode(); | 1967 bool hasSameWritingMode = child.styleRef().getWritingMode() == styleRef().ge
tWritingMode(); |
1967 | 1968 |
1968 switch (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPo
sitionStretch)) { | 1969 switch (child.styleRef().resolvedAlignSelf(selfAlignmentNormalBehavior).posi
tion()) { |
1969 case ItemPositionSelfStart: | 1970 case ItemPositionSelfStart: |
1970 // If orthogonal writing-modes, this computes to 'start'. | 1971 // If orthogonal writing-modes, this computes to 'start'. |
1971 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. | 1972 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. |
1972 // 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. | 1973 // 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. |
1973 return (isOrthogonalChild(child) || hasSameWritingMode) ? GridAxisStart
: GridAxisEnd; | 1974 return (isOrthogonalChild(child) || hasSameWritingMode) ? GridAxisStart
: GridAxisEnd; |
1974 case ItemPositionSelfEnd: | 1975 case ItemPositionSelfEnd: |
1975 // If orthogonal writing-modes, this computes to 'end'. | 1976 // If orthogonal writing-modes, this computes to 'end'. |
1976 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. | 1977 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. |
1977 // 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. | 1978 // 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. |
1978 return (isOrthogonalChild(child) || hasSameWritingMode) ? GridAxisEnd :
GridAxisStart; | 1979 return (isOrthogonalChild(child) || hasSameWritingMode) ? GridAxisEnd :
GridAxisStart; |
(...skipping 16 matching lines...) Expand all Loading... |
1995 case ItemPositionEnd: | 1996 case ItemPositionEnd: |
1996 return GridAxisEnd; | 1997 return GridAxisEnd; |
1997 case ItemPositionStretch: | 1998 case ItemPositionStretch: |
1998 return GridAxisStart; | 1999 return GridAxisStart; |
1999 case ItemPositionBaseline: | 2000 case ItemPositionBaseline: |
2000 case ItemPositionLastBaseline: | 2001 case ItemPositionLastBaseline: |
2001 // FIXME: These two require implementing Baseline Alignment. For now, we
always 'start' align the child. | 2002 // FIXME: These two require implementing Baseline Alignment. For now, we
always 'start' align the child. |
2002 // crbug.com/234191 | 2003 // crbug.com/234191 |
2003 return GridAxisStart; | 2004 return GridAxisStart; |
2004 case ItemPositionAuto: | 2005 case ItemPositionAuto: |
| 2006 case ItemPositionNormal: |
2005 break; | 2007 break; |
2006 } | 2008 } |
2007 | 2009 |
2008 ASSERT_NOT_REACHED(); | 2010 ASSERT_NOT_REACHED(); |
2009 return GridAxisStart; | 2011 return GridAxisStart; |
2010 } | 2012 } |
2011 | 2013 |
2012 GridAxisPosition LayoutGrid::rowAxisPositionForChild(const LayoutBox& child) con
st | 2014 GridAxisPosition LayoutGrid::rowAxisPositionForChild(const LayoutBox& child) con
st |
2013 { | 2015 { |
2014 bool hasSameDirection = child.styleRef().direction() == styleRef().direction
(); | 2016 bool hasSameDirection = child.styleRef().direction() == styleRef().direction
(); |
2015 bool isLTR = styleRef().isLeftToRightDirection(); | 2017 bool isLTR = styleRef().isLeftToRightDirection(); |
2016 | 2018 |
2017 switch (ComputedStyle::resolveJustification(styleRef(), child.styleRef(), It
emPositionStretch)) { | 2019 switch (child.styleRef().resolvedJustifySelf(selfAlignmentNormalBehavior).po
sition()) { |
2018 case ItemPositionSelfStart: | 2020 case ItemPositionSelfStart: |
2019 // For orthogonal writing-modes, this computes to 'start' | 2021 // For orthogonal writing-modes, this computes to 'start' |
2020 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. | 2022 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. |
2021 // self-start is based on the child's direction. That's why we need to c
heck against the grid container's direction. | 2023 // self-start is based on the child's direction. That's why we need to c
heck against the grid container's direction. |
2022 return (isOrthogonalChild(child) || hasSameDirection) ? GridAxisStart :
GridAxisEnd; | 2024 return (isOrthogonalChild(child) || hasSameDirection) ? GridAxisStart :
GridAxisEnd; |
2023 case ItemPositionSelfEnd: | 2025 case ItemPositionSelfEnd: |
2024 // For orthogonal writing-modes, this computes to 'start' | 2026 // For orthogonal writing-modes, this computes to 'start' |
2025 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. | 2027 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. |
2026 return (isOrthogonalChild(child) || hasSameDirection) ? GridAxisEnd : Gr
idAxisStart; | 2028 return (isOrthogonalChild(child) || hasSameDirection) ? GridAxisEnd : Gr
idAxisStart; |
2027 case ItemPositionLeft: | 2029 case ItemPositionLeft: |
2028 return isLTR ? GridAxisStart : GridAxisEnd; | 2030 return isLTR ? GridAxisStart : GridAxisEnd; |
2029 case ItemPositionRight: | 2031 case ItemPositionRight: |
2030 return isLTR ? GridAxisEnd : GridAxisStart; | 2032 return isLTR ? GridAxisEnd : GridAxisStart; |
2031 case ItemPositionCenter: | 2033 case ItemPositionCenter: |
2032 return GridAxisCenter; | 2034 return GridAxisCenter; |
2033 case ItemPositionFlexStart: // Only used in flex layout, otherwise equivalen
t to 'start'. | 2035 case ItemPositionFlexStart: // Only used in flex layout, otherwise equivalen
t to 'start'. |
2034 case ItemPositionStart: | 2036 case ItemPositionStart: |
2035 return GridAxisStart; | 2037 return GridAxisStart; |
2036 case ItemPositionFlexEnd: // Only used in flex layout, otherwise equivalent
to 'end'. | 2038 case ItemPositionFlexEnd: // Only used in flex layout, otherwise equivalent
to 'end'. |
2037 case ItemPositionEnd: | 2039 case ItemPositionEnd: |
2038 return GridAxisEnd; | 2040 return GridAxisEnd; |
2039 case ItemPositionStretch: | 2041 case ItemPositionStretch: |
2040 return GridAxisStart; | 2042 return GridAxisStart; |
2041 case ItemPositionBaseline: | 2043 case ItemPositionBaseline: |
2042 case ItemPositionLastBaseline: | 2044 case ItemPositionLastBaseline: |
2043 // FIXME: These two require implementing Baseline Alignment. For now, we
always 'start' align the child. | 2045 // FIXME: These two require implementing Baseline Alignment. For now, we
always 'start' align the child. |
2044 // crbug.com/234191 | 2046 // crbug.com/234191 |
2045 return GridAxisStart; | 2047 return GridAxisStart; |
2046 case ItemPositionAuto: | 2048 case ItemPositionAuto: |
| 2049 case ItemPositionNormal: |
2047 break; | 2050 break; |
2048 } | 2051 } |
2049 | 2052 |
2050 ASSERT_NOT_REACHED(); | 2053 ASSERT_NOT_REACHED(); |
2051 return GridAxisStart; | 2054 return GridAxisStart; |
2052 } | 2055 } |
2053 | 2056 |
2054 LayoutUnit LayoutGrid::columnAxisOffsetForChild(const LayoutBox& child, GridSizi
ngData& sizingData) const | 2057 LayoutUnit LayoutGrid::columnAxisOffsetForChild(const LayoutBox& child, GridSizi
ngData& sizingData) const |
2055 { | 2058 { |
2056 const GridSpan& rowsSpan = cachedGridSpan(child, ForRows); | 2059 const GridSpan& rowsSpan = cachedGridSpan(child, ForRows); |
(...skipping 12 matching lines...) Expand all Loading... |
2069 LayoutUnit endOfRow = m_rowPositions[childEndLine]; | 2072 LayoutUnit endOfRow = m_rowPositions[childEndLine]; |
2070 // m_rowPositions include distribution offset (because of content alignm
ent) and gutters | 2073 // m_rowPositions include distribution offset (because of content alignm
ent) and gutters |
2071 // so we need to subtract them to get the actual end position for a give
n row | 2074 // so we need to subtract them to get the actual end position for a give
n row |
2072 // (this does not have to be done for the last track as there are no mor
e m_columnPositions after it). | 2075 // (this does not have to be done for the last track as there are no mor
e m_columnPositions after it). |
2073 LayoutUnit trackGap = guttersSize(ForRows, 2); | 2076 LayoutUnit trackGap = guttersSize(ForRows, 2); |
2074 if (childEndLine < m_rowPositions.size() - 1) { | 2077 if (childEndLine < m_rowPositions.size() - 1) { |
2075 endOfRow -= trackGap; | 2078 endOfRow -= trackGap; |
2076 endOfRow -= m_offsetBetweenRows; | 2079 endOfRow -= m_offsetBetweenRows; |
2077 } | 2080 } |
2078 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHei
ght(); | 2081 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHei
ght(); |
2079 OverflowAlignment overflow = child.styleRef().resolvedAlignment(styleRef
(), ItemPositionStretch).overflow(); | 2082 OverflowAlignment overflow = child.styleRef().resolvedAlignSelf(selfAlig
nmentNormalBehavior).overflow(); |
2080 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over
flow, endOfRow - startOfRow, childBreadth); | 2083 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over
flow, endOfRow - startOfRow, childBreadth); |
2081 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); | 2084 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); |
2082 } | 2085 } |
2083 } | 2086 } |
2084 | 2087 |
2085 ASSERT_NOT_REACHED(); | 2088 ASSERT_NOT_REACHED(); |
2086 return LayoutUnit(); | 2089 return LayoutUnit(); |
2087 } | 2090 } |
2088 | 2091 |
2089 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child, GridSizingD
ata& sizingData) const | 2092 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child, GridSizingD
ata& sizingData) const |
(...skipping 14 matching lines...) Expand all Loading... |
2104 LayoutUnit endOfColumn = m_columnPositions[childEndLine]; | 2107 LayoutUnit endOfColumn = m_columnPositions[childEndLine]; |
2105 // m_columnPositions include distribution offset (because of content ali
gnment) and gutters | 2108 // m_columnPositions include distribution offset (because of content ali
gnment) and gutters |
2106 // so we need to subtract them to get the actual end position for a give
n column | 2109 // so we need to subtract them to get the actual end position for a give
n column |
2107 // (this does not have to be done for the last track as there are no mor
e m_columnPositions after it). | 2110 // (this does not have to be done for the last track as there are no mor
e m_columnPositions after it). |
2108 LayoutUnit trackGap = guttersSize(ForColumns, 2); | 2111 LayoutUnit trackGap = guttersSize(ForColumns, 2); |
2109 if (childEndLine < m_columnPositions.size() - 1) { | 2112 if (childEndLine < m_columnPositions.size() - 1) { |
2110 endOfColumn -= trackGap; | 2113 endOfColumn -= trackGap; |
2111 endOfColumn -= m_offsetBetweenColumns; | 2114 endOfColumn -= m_offsetBetweenColumns; |
2112 } | 2115 } |
2113 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidt
h(); | 2116 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidt
h(); |
2114 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil
d.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, childB
readth); | 2117 OverflowAlignment overflow = child.styleRef().resolvedJustifySelf(selfAl
ignmentNormalBehavior).overflow(); |
| 2118 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over
flow, endOfColumn - startOfColumn, childBreadth); |
2115 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); | 2119 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); |
2116 } | 2120 } |
2117 } | 2121 } |
2118 | 2122 |
2119 ASSERT_NOT_REACHED(); | 2123 ASSERT_NOT_REACHED(); |
2120 return LayoutUnit(); | 2124 return LayoutUnit(); |
2121 } | 2125 } |
2122 | 2126 |
2123 ContentPosition static resolveContentDistributionFallback(ContentDistributionTyp
e distribution) | 2127 ContentPosition static resolveContentDistributionFallback(ContentDistributionTyp
e distribution) |
2124 { | 2128 { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2166 return {}; | 2170 return {}; |
2167 } | 2171 } |
2168 | 2172 |
2169 ASSERT_NOT_REACHED(); | 2173 ASSERT_NOT_REACHED(); |
2170 return {}; | 2174 return {}; |
2171 } | 2175 } |
2172 | 2176 |
2173 ContentAlignmentData LayoutGrid::computeContentPositionAndDistributionOffset(Gri
dTrackSizingDirection direction, const LayoutUnit& availableFreeSpace, unsigned
numberOfGridTracks) const | 2177 ContentAlignmentData LayoutGrid::computeContentPositionAndDistributionOffset(Gri
dTrackSizingDirection direction, const LayoutUnit& availableFreeSpace, unsigned
numberOfGridTracks) const |
2174 { | 2178 { |
2175 bool isRowAxis = direction == ForColumns; | 2179 bool isRowAxis = direction == ForColumns; |
2176 ContentPosition position = isRowAxis ? styleRef().resolvedJustifyContentPosi
tion(normalValueBehavior()) : styleRef().resolvedAlignContentPosition(normalValu
eBehavior()); | 2180 ContentPosition position = isRowAxis ? styleRef().resolvedJustifyContentPosi
tion(contentAlignmentNormalBehavior()) : styleRef().resolvedAlignContentPosition
(contentAlignmentNormalBehavior()); |
2177 ContentDistributionType distribution = isRowAxis ? styleRef().resolvedJustif
yContentDistribution(normalValueBehavior()) : styleRef().resolvedAlignContentDis
tribution(normalValueBehavior()); | 2181 ContentDistributionType distribution = isRowAxis ? styleRef().resolvedJustif
yContentDistribution(contentAlignmentNormalBehavior()) : styleRef().resolvedAlig
nContentDistribution(contentAlignmentNormalBehavior()); |
2178 // If <content-distribution> value can't be applied, 'position' will become
the associated | 2182 // If <content-distribution> value can't be applied, 'position' will become
the associated |
2179 // <content-position> fallback value. | 2183 // <content-position> fallback value. |
2180 ContentAlignmentData contentAlignment = contentDistributionOffset(availableF
reeSpace, position, distribution, numberOfGridTracks); | 2184 ContentAlignmentData contentAlignment = contentDistributionOffset(availableF
reeSpace, position, distribution, numberOfGridTracks); |
2181 if (contentAlignment.isValid()) | 2185 if (contentAlignment.isValid()) |
2182 return contentAlignment; | 2186 return contentAlignment; |
2183 | 2187 |
2184 OverflowAlignment overflow = isRowAxis ? styleRef().justifyContentOverflowAl
ignment() : styleRef().alignContentOverflowAlignment(); | 2188 OverflowAlignment overflow = isRowAxis ? styleRef().justifyContentOverflowAl
ignment() : styleRef().alignContentOverflowAlignment(); |
2185 if (availableFreeSpace <= 0 && overflow == OverflowAlignmentSafe) | 2189 if (availableFreeSpace <= 0 && overflow == OverflowAlignmentSafe) |
2186 return {LayoutUnit(), LayoutUnit()}; | 2190 return {LayoutUnit(), LayoutUnit()}; |
2187 | 2191 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2240 | 2244 |
2241 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData
)); | 2245 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData
)); |
2242 } | 2246 } |
2243 | 2247 |
2244 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const | 2248 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const |
2245 { | 2249 { |
2246 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2250 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
2247 } | 2251 } |
2248 | 2252 |
2249 } // namespace blink | 2253 } // namespace blink |
OLD | NEW |