Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutGrid.cpp

Issue 1709963002: [css-align] New CSS Value 'normal' for Self Alignment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: New test for alignment and anonymous boxes. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 // the grid and its children are correctly laid out according to the new sty le rules. 1547 // the grid and its children are correctly laid out according to the new sty le rules.
1548 setNeedsLayout(LayoutInvalidationReason::GridChanged); 1548 setNeedsLayout(LayoutInvalidationReason::GridChanged);
1549 1549
1550 m_grid.resize(0); 1550 m_grid.resize(0);
1551 m_gridItemArea.clear(); 1551 m_gridItemArea.clear();
1552 m_gridItemsOverflowingGridArea.resize(0); 1552 m_gridItemsOverflowingGridArea.resize(0);
1553 m_gridItemsIndexesMap.clear(); 1553 m_gridItemsIndexesMap.clear();
1554 m_gridIsDirty = true; 1554 m_gridIsDirty = true;
1555 } 1555 }
1556 1556
1557 static const StyleContentAlignmentData& normalValueBehavior() 1557 static const StyleContentAlignmentData& contentAlignmentNormalBehavior()
1558 { 1558 {
1559 static const StyleContentAlignmentData normalBehavior = {ContentPositionNorm al, ContentDistributionStretch}; 1559 static const StyleContentAlignmentData normalBehavior = {ContentPositionNorm al, ContentDistributionStretch};
1560 return normalBehavior; 1560 return normalBehavior;
1561 } 1561 }
1562 1562
1563 void LayoutGrid::applyStretchAlignmentToTracksIfNeeded(GridTrackSizingDirection direction, GridSizingData& sizingData) 1563 void LayoutGrid::applyStretchAlignmentToTracksIfNeeded(GridTrackSizingDirection direction, GridSizingData& sizingData)
1564 { 1564 {
1565 LayoutUnit& availableSpace = sizingData.freeSpaceForDirection(direction); 1565 LayoutUnit& availableSpace = sizingData.freeSpaceForDirection(direction);
1566 if (availableSpace <= 0 1566 if (availableSpace <= 0
1567 || (direction == ForColumns && styleRef().resolvedJustifyContentDistribu tion(normalValueBehavior()) != ContentDistributionStretch) 1567 || (direction == ForColumns && styleRef().resolvedJustifyContentDistribu tion(contentAlignmentNormalBehavior()) != ContentDistributionStretch)
1568 || (direction == ForRows && styleRef().resolvedAlignContentDistribution( normalValueBehavior()) != ContentDistributionStretch)) 1568 || (direction == ForRows && styleRef().resolvedAlignContentDistribution( contentAlignmentNormalBehavior()) != ContentDistributionStretch))
1569 return; 1569 return;
1570 1570
1571 // Spec defines auto-sized tracks as the ones with an 'auto' max-sizing func tion. 1571 // Spec defines auto-sized tracks as the ones with an 'auto' max-sizing func tion.
1572 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra cks : sizingData.rowTracks; 1572 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra cks : sizingData.rowTracks;
1573 Vector<unsigned> autoSizedTracksIndex; 1573 Vector<unsigned> autoSizedTracksIndex;
1574 for (unsigned i = 0; i < tracks.size(); ++i) { 1574 for (unsigned i = 0; i < tracks.size(); ++i) {
1575 const GridTrackSize& trackSize = gridTrackSize(direction, i); 1575 const GridTrackSize& trackSize = gridTrackSize(direction, i);
1576 if (trackSize.hasAutoMaxTrackBreadth()) 1576 if (trackSize.hasAutoMaxTrackBreadth())
1577 autoSizedTracksIndex.append(i); 1577 autoSizedTracksIndex.append(i);
1578 } 1578 }
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 } 1879 }
1880 1880
1881 LayoutUnit LayoutGrid::availableAlignmentSpaceForChildBeforeStretching(LayoutUni t gridAreaBreadthForChild, const LayoutBox& child) const 1881 LayoutUnit LayoutGrid::availableAlignmentSpaceForChildBeforeStretching(LayoutUni t gridAreaBreadthForChild, const LayoutBox& child) const
1882 { 1882 {
1883 // Because we want to avoid multiple layouts, stretching logic might be perf ormed before 1883 // Because we want to avoid multiple layouts, stretching logic might be perf ormed before
1884 // children are laid out, so we can't use the child cached values. Hence, we need to 1884 // children are laid out, so we can't use the child cached values. Hence, we need to
1885 // compute margins in order to determine the available height before stretch ing. 1885 // compute margins in order to determine the available height before stretch ing.
1886 return gridAreaBreadthForChild - (child.needsLayout() ? computeMarginLogical SizeForChild(BlockDirection, child) : marginLogicalHeightForChild(child)); 1886 return gridAreaBreadthForChild - (child.needsLayout() ? computeMarginLogical SizeForChild(BlockDirection, child) : marginLogicalHeightForChild(child));
1887 } 1887 }
1888 1888
1889 StyleSelfAlignmentData LayoutGrid::alignSelfForChild(const LayoutBox& child) con st
1890 {
1891 if (!child.isAnonymous())
1892 return child.styleRef().resolvedAlignSelf(selfAlignmentNormalBehavior()) ;
1893 // All the 'auto' values has been solved by the StyleAdjuster, but it's poss ible that
1894 // some grid items generate Anonymous boxes, which need to be solved during layout.
1895 return child.styleRef().resolvedAlignSelf(selfAlignmentNormalBehavior(), sty le());
1896 }
1897
1898 StyleSelfAlignmentData LayoutGrid::justifySelfForChild(const LayoutBox& child) c onst
1899 {
1900 if (!child.isAnonymous())
1901 return child.styleRef().resolvedJustifySelf(ItemPositionStretch);
1902 // All the 'auto' values has been solved by the StyleAdjuster, but it's poss ible that
1903 // some grid items generate Anonymous boxes, which need to be solved during layout.
1904 return child.styleRef().resolvedJustifySelf(ItemPositionStretch, style());
1905 }
1906
1889 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox. 1907 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox.
1890 void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child) 1908 void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child)
1891 { 1909 {
1892 // We clear height override values because we will decide now whether it's a llowed or 1910 // We clear height override values because we will decide now whether it's a llowed or
1893 // not, evaluating the conditions which might have changed since the old val ues were set. 1911 // not, evaluating the conditions which might have changed since the old val ues were set.
1894 child.clearOverrideLogicalContentHeight(); 1912 child.clearOverrideLogicalContentHeight();
1895 1913
1896 auto& childStyle = child.styleRef(); 1914 auto& childStyle = child.styleRef();
1897 bool isHorizontalMode = isHorizontalWritingMode(); 1915 bool isHorizontalMode = isHorizontalWritingMode();
1898 bool hasAutoSizeInColumnAxis = isHorizontalMode ? childStyle.height().isAuto () : childStyle.width().isAuto(); 1916 bool hasAutoSizeInColumnAxis = isHorizontalMode ? childStyle.height().isAuto () : childStyle.width().isAuto();
1899 bool allowedToStretchChildAlongColumnAxis = hasAutoSizeInColumnAxis && !chil dStyle.marginBeforeUsing(style()).isAuto() && !childStyle.marginAfterUsing(style ()).isAuto(); 1917 bool allowedToStretchChildAlongColumnAxis = hasAutoSizeInColumnAxis && !chil dStyle.marginBeforeUsing(style()).isAuto() && !childStyle.marginAfterUsing(style ()).isAuto();
1900 if (allowedToStretchChildAlongColumnAxis && ComputedStyle::resolveAlignment( styleRef(), childStyle, ItemPositionStretch) == ItemPositionStretch) { 1918 if (allowedToStretchChildAlongColumnAxis && alignSelfForChild(child).positio n() == ItemPositionStretch) {
1901 // TODO (lajava): If the child has orthogonal flow, then it already has an override height set, so use it. 1919 // TODO (lajava): If the child has orthogonal flow, then it already has an override height set, so use it.
1902 // TODO (lajava): grid track sizing and positioning do not support ortho gonal modes yet. 1920 // TODO (lajava): grid track sizing and positioning do not support ortho gonal modes yet.
1903 if (child.isHorizontalWritingMode() == isHorizontalMode) { 1921 if (child.isHorizontalWritingMode() == isHorizontalMode) {
1904 LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildB eforeStretching(child.overrideContainingBlockContentLogicalHeight(), child); 1922 LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildB eforeStretching(child.overrideContainingBlockContentLogicalHeight(), child);
1905 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM ax(stretchedLogicalHeight, LayoutUnit(-1)); 1923 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM ax(stretchedLogicalHeight, LayoutUnit(-1));
1906 child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.b orderAndPaddingLogicalHeight()); 1924 child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.b orderAndPaddingLogicalHeight());
1907 if (desiredLogicalHeight != child.logicalHeight()) { 1925 if (desiredLogicalHeight != child.logicalHeight()) {
1908 // TODO (lajava): Can avoid laying out here in some cases. See h ttps://webkit.org/b/87905. 1926 // TODO (lajava): Can avoid laying out here in some cases. See h ttps://webkit.org/b/87905.
1909 child.setLogicalHeight(LayoutUnit()); 1927 child.setLogicalHeight(LayoutUnit());
1910 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); 1928 child.setNeedsLayout(LayoutInvalidationReason::GridChanged);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 child.setMarginBefore(availableAlignmentSpace, style()); 1986 child.setMarginBefore(availableAlignmentSpace, style());
1969 } else if (marginAfter.isAuto()) { 1987 } else if (marginAfter.isAuto()) {
1970 child.setMarginAfter(availableAlignmentSpace, style()); 1988 child.setMarginAfter(availableAlignmentSpace, style());
1971 } 1989 }
1972 } 1990 }
1973 1991
1974 GridAxisPosition LayoutGrid::columnAxisPositionForChild(const LayoutBox& child) const 1992 GridAxisPosition LayoutGrid::columnAxisPositionForChild(const LayoutBox& child) const
1975 { 1993 {
1976 bool hasSameWritingMode = child.styleRef().getWritingMode() == styleRef().ge tWritingMode(); 1994 bool hasSameWritingMode = child.styleRef().getWritingMode() == styleRef().ge tWritingMode();
1977 1995
1978 switch (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPo sitionStretch)) { 1996 switch (alignSelfForChild(child).position()) {
1979 case ItemPositionSelfStart: 1997 case ItemPositionSelfStart:
1980 // If orthogonal writing-modes, this computes to 'start'. 1998 // If orthogonal writing-modes, this computes to 'start'.
1981 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. 1999 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet.
1982 // 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. 2000 // 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.
1983 return (isOrthogonalChild(child) || hasSameWritingMode) ? GridAxisStart : GridAxisEnd; 2001 return (isOrthogonalChild(child) || hasSameWritingMode) ? GridAxisStart : GridAxisEnd;
1984 case ItemPositionSelfEnd: 2002 case ItemPositionSelfEnd:
1985 // If orthogonal writing-modes, this computes to 'end'. 2003 // If orthogonal writing-modes, this computes to 'end'.
1986 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. 2004 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet.
1987 // 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. 2005 // 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.
1988 return (isOrthogonalChild(child) || hasSameWritingMode) ? GridAxisEnd : GridAxisStart; 2006 return (isOrthogonalChild(child) || hasSameWritingMode) ? GridAxisEnd : GridAxisStart;
(...skipping 16 matching lines...) Expand all
2005 case ItemPositionEnd: 2023 case ItemPositionEnd:
2006 return GridAxisEnd; 2024 return GridAxisEnd;
2007 case ItemPositionStretch: 2025 case ItemPositionStretch:
2008 return GridAxisStart; 2026 return GridAxisStart;
2009 case ItemPositionBaseline: 2027 case ItemPositionBaseline:
2010 case ItemPositionLastBaseline: 2028 case ItemPositionLastBaseline:
2011 // FIXME: These two require implementing Baseline Alignment. For now, we always 'start' align the child. 2029 // FIXME: These two require implementing Baseline Alignment. For now, we always 'start' align the child.
2012 // crbug.com/234191 2030 // crbug.com/234191
2013 return GridAxisStart; 2031 return GridAxisStart;
2014 case ItemPositionAuto: 2032 case ItemPositionAuto:
2033 case ItemPositionNormal:
2015 break; 2034 break;
2016 } 2035 }
2017 2036
2018 ASSERT_NOT_REACHED(); 2037 ASSERT_NOT_REACHED();
2019 return GridAxisStart; 2038 return GridAxisStart;
2020 } 2039 }
2021 2040
2022 GridAxisPosition LayoutGrid::rowAxisPositionForChild(const LayoutBox& child) con st 2041 GridAxisPosition LayoutGrid::rowAxisPositionForChild(const LayoutBox& child) con st
2023 { 2042 {
2024 bool hasSameDirection = child.styleRef().direction() == styleRef().direction (); 2043 bool hasSameDirection = child.styleRef().direction() == styleRef().direction ();
2025 bool isLTR = styleRef().isLeftToRightDirection(); 2044 bool isLTR = styleRef().isLeftToRightDirection();
2026 2045
2027 switch (ComputedStyle::resolveJustification(styleRef(), child.styleRef(), It emPositionStretch)) { 2046 switch (justifySelfForChild(child).position()) {
2028 case ItemPositionSelfStart: 2047 case ItemPositionSelfStart:
2029 // For orthogonal writing-modes, this computes to 'start' 2048 // For orthogonal writing-modes, this computes to 'start'
2030 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. 2049 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet.
2031 // self-start is based on the child's direction. That's why we need to c heck against the grid container's direction. 2050 // self-start is based on the child's direction. That's why we need to c heck against the grid container's direction.
2032 return (isOrthogonalChild(child) || hasSameDirection) ? GridAxisStart : GridAxisEnd; 2051 return (isOrthogonalChild(child) || hasSameDirection) ? GridAxisStart : GridAxisEnd;
2033 case ItemPositionSelfEnd: 2052 case ItemPositionSelfEnd:
2034 // For orthogonal writing-modes, this computes to 'start' 2053 // For orthogonal writing-modes, this computes to 'start'
2035 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. 2054 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet.
2036 return (isOrthogonalChild(child) || hasSameDirection) ? GridAxisEnd : Gr idAxisStart; 2055 return (isOrthogonalChild(child) || hasSameDirection) ? GridAxisEnd : Gr idAxisStart;
2037 case ItemPositionLeft: 2056 case ItemPositionLeft:
2038 return isLTR ? GridAxisStart : GridAxisEnd; 2057 return isLTR ? GridAxisStart : GridAxisEnd;
2039 case ItemPositionRight: 2058 case ItemPositionRight:
2040 return isLTR ? GridAxisEnd : GridAxisStart; 2059 return isLTR ? GridAxisEnd : GridAxisStart;
2041 case ItemPositionCenter: 2060 case ItemPositionCenter:
2042 return GridAxisCenter; 2061 return GridAxisCenter;
2043 case ItemPositionFlexStart: // Only used in flex layout, otherwise equivalen t to 'start'. 2062 case ItemPositionFlexStart: // Only used in flex layout, otherwise equivalen t to 'start'.
2044 case ItemPositionStart: 2063 case ItemPositionStart:
2045 return GridAxisStart; 2064 return GridAxisStart;
2046 case ItemPositionFlexEnd: // Only used in flex layout, otherwise equivalent to 'end'. 2065 case ItemPositionFlexEnd: // Only used in flex layout, otherwise equivalent to 'end'.
2047 case ItemPositionEnd: 2066 case ItemPositionEnd:
2048 return GridAxisEnd; 2067 return GridAxisEnd;
2049 case ItemPositionStretch: 2068 case ItemPositionStretch:
2050 return GridAxisStart; 2069 return GridAxisStart;
2051 case ItemPositionBaseline: 2070 case ItemPositionBaseline:
2052 case ItemPositionLastBaseline: 2071 case ItemPositionLastBaseline:
2053 // FIXME: These two require implementing Baseline Alignment. For now, we always 'start' align the child. 2072 // FIXME: These two require implementing Baseline Alignment. For now, we always 'start' align the child.
2054 // crbug.com/234191 2073 // crbug.com/234191
2055 return GridAxisStart; 2074 return GridAxisStart;
2056 case ItemPositionAuto: 2075 case ItemPositionAuto:
2076 case ItemPositionNormal:
2057 break; 2077 break;
2058 } 2078 }
2059 2079
2060 ASSERT_NOT_REACHED(); 2080 ASSERT_NOT_REACHED();
2061 return GridAxisStart; 2081 return GridAxisStart;
2062 } 2082 }
2063 2083
2064 LayoutUnit LayoutGrid::columnAxisOffsetForChild(const LayoutBox& child, GridSizi ngData& sizingData) const 2084 LayoutUnit LayoutGrid::columnAxisOffsetForChild(const LayoutBox& child, GridSizi ngData& sizingData) const
2065 { 2085 {
2066 const GridSpan& rowsSpan = cachedGridSpan(child, ForRows); 2086 const GridSpan& rowsSpan = cachedGridSpan(child, ForRows);
(...skipping 12 matching lines...) Expand all
2079 LayoutUnit endOfRow = m_rowPositions[childEndLine]; 2099 LayoutUnit endOfRow = m_rowPositions[childEndLine];
2080 // m_rowPositions include distribution offset (because of content alignm ent) and gutters 2100 // m_rowPositions include distribution offset (because of content alignm ent) and gutters
2081 // so we need to subtract them to get the actual end position for a give n row 2101 // so we need to subtract them to get the actual end position for a give n row
2082 // (this does not have to be done for the last track as there are no mor e m_columnPositions after it). 2102 // (this does not have to be done for the last track as there are no mor e m_columnPositions after it).
2083 LayoutUnit trackGap = guttersSize(ForRows, 2); 2103 LayoutUnit trackGap = guttersSize(ForRows, 2);
2084 if (childEndLine < m_rowPositions.size() - 1) { 2104 if (childEndLine < m_rowPositions.size() - 1) {
2085 endOfRow -= trackGap; 2105 endOfRow -= trackGap;
2086 endOfRow -= m_offsetBetweenRows; 2106 endOfRow -= m_offsetBetweenRows;
2087 } 2107 }
2088 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHei ght(); 2108 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHei ght();
2089 OverflowAlignment overflow = child.styleRef().resolvedAlignment(styleRef (), ItemPositionStretch).overflow(); 2109 OverflowAlignment overflow = alignSelfForChild(child).overflow();
2090 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over flow, endOfRow - startOfRow, childBreadth); 2110 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over flow, endOfRow - startOfRow, childBreadth);
2091 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); 2111 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2);
2092 } 2112 }
2093 } 2113 }
2094 2114
2095 ASSERT_NOT_REACHED(); 2115 ASSERT_NOT_REACHED();
2096 return LayoutUnit(); 2116 return LayoutUnit();
2097 } 2117 }
2098 2118
2099 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child, GridSizingD ata& sizingData) const 2119 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child, GridSizingD ata& sizingData) const
(...skipping 14 matching lines...) Expand all
2114 LayoutUnit endOfColumn = m_columnPositions[childEndLine]; 2134 LayoutUnit endOfColumn = m_columnPositions[childEndLine];
2115 // m_columnPositions include distribution offset (because of content ali gnment) and gutters 2135 // m_columnPositions include distribution offset (because of content ali gnment) and gutters
2116 // so we need to subtract them to get the actual end position for a give n column 2136 // so we need to subtract them to get the actual end position for a give n column
2117 // (this does not have to be done for the last track as there are no mor e m_columnPositions after it). 2137 // (this does not have to be done for the last track as there are no mor e m_columnPositions after it).
2118 LayoutUnit trackGap = guttersSize(ForColumns, 2); 2138 LayoutUnit trackGap = guttersSize(ForColumns, 2);
2119 if (childEndLine < m_columnPositions.size() - 1) { 2139 if (childEndLine < m_columnPositions.size() - 1) {
2120 endOfColumn -= trackGap; 2140 endOfColumn -= trackGap;
2121 endOfColumn -= m_offsetBetweenColumns; 2141 endOfColumn -= m_offsetBetweenColumns;
2122 } 2142 }
2123 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidt h(); 2143 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidt h();
2124 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil d.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, childB readth); 2144 OverflowAlignment overflow = justifySelfForChild(child).overflow();
2145 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over flow, endOfColumn - startOfColumn, childBreadth);
2125 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); 2146 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2);
2126 } 2147 }
2127 } 2148 }
2128 2149
2129 ASSERT_NOT_REACHED(); 2150 ASSERT_NOT_REACHED();
2130 return LayoutUnit(); 2151 return LayoutUnit();
2131 } 2152 }
2132 2153
2133 ContentPosition static resolveContentDistributionFallback(ContentDistributionTyp e distribution) 2154 ContentPosition static resolveContentDistributionFallback(ContentDistributionTyp e distribution)
2134 { 2155 {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2176 return {}; 2197 return {};
2177 } 2198 }
2178 2199
2179 ASSERT_NOT_REACHED(); 2200 ASSERT_NOT_REACHED();
2180 return {}; 2201 return {};
2181 } 2202 }
2182 2203
2183 ContentAlignmentData LayoutGrid::computeContentPositionAndDistributionOffset(Gri dTrackSizingDirection direction, const LayoutUnit& availableFreeSpace, unsigned numberOfGridTracks) const 2204 ContentAlignmentData LayoutGrid::computeContentPositionAndDistributionOffset(Gri dTrackSizingDirection direction, const LayoutUnit& availableFreeSpace, unsigned numberOfGridTracks) const
2184 { 2205 {
2185 bool isRowAxis = direction == ForColumns; 2206 bool isRowAxis = direction == ForColumns;
2186 ContentPosition position = isRowAxis ? styleRef().resolvedJustifyContentPosi tion(normalValueBehavior()) : styleRef().resolvedAlignContentPosition(normalValu eBehavior()); 2207 ContentPosition position = isRowAxis ? styleRef().resolvedJustifyContentPosi tion(contentAlignmentNormalBehavior()) : styleRef().resolvedAlignContentPosition (contentAlignmentNormalBehavior());
2187 ContentDistributionType distribution = isRowAxis ? styleRef().resolvedJustif yContentDistribution(normalValueBehavior()) : styleRef().resolvedAlignContentDis tribution(normalValueBehavior()); 2208 ContentDistributionType distribution = isRowAxis ? styleRef().resolvedJustif yContentDistribution(contentAlignmentNormalBehavior()) : styleRef().resolvedAlig nContentDistribution(contentAlignmentNormalBehavior());
2188 // If <content-distribution> value can't be applied, 'position' will become the associated 2209 // If <content-distribution> value can't be applied, 'position' will become the associated
2189 // <content-position> fallback value. 2210 // <content-position> fallback value.
2190 ContentAlignmentData contentAlignment = contentDistributionOffset(availableF reeSpace, position, distribution, numberOfGridTracks); 2211 ContentAlignmentData contentAlignment = contentDistributionOffset(availableF reeSpace, position, distribution, numberOfGridTracks);
2191 if (contentAlignment.isValid()) 2212 if (contentAlignment.isValid())
2192 return contentAlignment; 2213 return contentAlignment;
2193 2214
2194 OverflowAlignment overflow = isRowAxis ? styleRef().justifyContentOverflowAl ignment() : styleRef().alignContentOverflowAlignment(); 2215 OverflowAlignment overflow = isRowAxis ? styleRef().justifyContentOverflowAl ignment() : styleRef().alignContentOverflowAlignment();
2195 if (availableFreeSpace <= 0 && overflow == OverflowAlignmentSafe) 2216 if (availableFreeSpace <= 0 && overflow == OverflowAlignmentSafe)
2196 return {LayoutUnit(), LayoutUnit()}; 2217 return {LayoutUnit(), LayoutUnit()};
2197 2218
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2251 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData )); 2272 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData ));
2252 } 2273 }
2253 2274
2254 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const 2275 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const
2255 { 2276 {
2256 if (!m_gridItemArea.isEmpty()) 2277 if (!m_gridItemArea.isEmpty())
2257 GridPainter(*this).paintChildren(paintInfo, paintOffset); 2278 GridPainter(*this).paintChildren(paintInfo, paintOffset);
2258 } 2279 }
2259 2280
2260 } // namespace blink 2281 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698