Changeset 201498 in webkit for trunk/Source/WebCore/rendering/RenderGrid.cpp
- Timestamp:
- May 30, 2016, 1:14:31 AM (10 years ago)
- File:
-
- 1 edited
-
trunk/Source/WebCore/rendering/RenderGrid.cpp (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/rendering/RenderGrid.cpp
r201399 r201498 40 40 41 41 static const int infinity = -1; 42 static constexpr ItemPosition selfAlignmentNormalBehavior = ItemPositionStretch; 42 43 43 44 class GridTrack { … … 265 266 static inline bool defaultAlignmentChangedToStretchInRowAxis(const RenderStyle& oldStyle, const RenderStyle& newStyle) 266 267 { 267 return !defaultAlignmentIsStretch(oldStyle.justifyItems Position()) && defaultAlignmentIsStretch(newStyle.justifyItemsPosition());268 return !defaultAlignmentIsStretch(oldStyle.justifyItems().position()) && defaultAlignmentIsStretch(newStyle.justifyItems().position()); 268 269 } 269 270 270 271 static inline bool defaultAlignmentChangedFromStretchInRowAxis(const RenderStyle& oldStyle, const RenderStyle& newStyle) 271 272 { 272 return defaultAlignmentIsStretch(oldStyle.justifyItems Position()) && !defaultAlignmentIsStretch(newStyle.justifyItemsPosition());273 return defaultAlignmentIsStretch(oldStyle.justifyItems().position()) && !defaultAlignmentIsStretch(newStyle.justifyItems().position()); 273 274 } 274 275 275 276 static inline bool defaultAlignmentChangedFromStretchInColumnAxis(const RenderStyle& oldStyle, const RenderStyle& newStyle) 276 277 { 277 return defaultAlignmentIsStretch(oldStyle.alignItems Position()) && !defaultAlignmentIsStretch(newStyle.alignItemsPosition());278 return defaultAlignmentIsStretch(oldStyle.alignItems().position()) && !defaultAlignmentIsStretch(newStyle.alignItems().position()); 278 279 } 279 280 280 281 static inline bool selfAlignmentChangedToStretchInRowAxis(const RenderStyle& oldStyle, const RenderStyle& newStyle, const RenderStyle& childStyle) 281 282 { 282 return RenderStyle::resolveJustification(oldStyle, childStyle, ItemPositionStretch) != ItemPositionStretch283 && RenderStyle::resolveJustification(newStyle, childStyle, ItemPositionStretch) == ItemPositionStretch;283 return childStyle.resolvedJustifySelf(oldStyle, selfAlignmentNormalBehavior).position() != ItemPositionStretch 284 && childStyle.resolvedJustifySelf(newStyle, selfAlignmentNormalBehavior).position() == ItemPositionStretch; 284 285 } 285 286 286 287 static inline bool selfAlignmentChangedFromStretchInRowAxis(const RenderStyle& oldStyle, const RenderStyle& newStyle, const RenderStyle& childStyle) 287 288 { 288 return RenderStyle::resolveJustification(oldStyle, childStyle, ItemPositionStretch) == ItemPositionStretch289 && RenderStyle::resolveJustification(newStyle, childStyle, ItemPositionStretch) != ItemPositionStretch;289 return childStyle.resolvedJustifySelf(oldStyle, selfAlignmentNormalBehavior).position() == ItemPositionStretch 290 && childStyle.resolvedJustifySelf(newStyle, selfAlignmentNormalBehavior).position() != ItemPositionStretch; 290 291 } 291 292 292 293 static inline bool selfAlignmentChangedFromStretchInColumnAxis(const RenderStyle& oldStyle, const RenderStyle& newStyle, const RenderStyle& childStyle) 293 294 { 294 return RenderStyle::resolveAlignment(oldStyle, childStyle, ItemPositionStretch) == ItemPositionStretch295 && RenderStyle::resolveAlignment(newStyle, childStyle, ItemPositionStretch) != ItemPositionStretch;295 return childStyle.resolvedAlignSelf(oldStyle, selfAlignmentNormalBehavior).position() == ItemPositionStretch 296 && childStyle.resolvedAlignSelf(newStyle, selfAlignmentNormalBehavior).position() != ItemPositionStretch; 296 297 } 297 298 … … 1512 1513 } 1513 1514 1514 static const StyleContentAlignmentData& normalValueBehaviorGrid()1515 static const StyleContentAlignmentData& contentAlignmentNormalBehaviorGrid() 1515 1516 { 1516 1517 static const StyleContentAlignmentData normalBehavior = {ContentPositionNormal, ContentDistributionStretch}; … … 1523 1524 if (!freeSpace 1524 1525 || freeSpace.value() <= 0 1525 || (direction == ForColumns && style().resolvedJustifyContentDistribution( normalValueBehaviorGrid()) != ContentDistributionStretch)1526 || (direction == ForRows && style().resolvedAlignContentDistribution( normalValueBehaviorGrid()) != ContentDistributionStretch))1526 || (direction == ForColumns && style().resolvedJustifyContentDistribution(contentAlignmentNormalBehaviorGrid()) != ContentDistributionStretch) 1527 || (direction == ForRows && style().resolvedAlignContentDistribution(contentAlignmentNormalBehaviorGrid()) != ContentDistributionStretch)) 1527 1528 return; 1528 1529 … … 1804 1805 bool RenderGrid::needToStretchChildLogicalHeight(const RenderBox& child) const 1805 1806 { 1806 if ( RenderStyle::resolveAlignment(style(), child.style(), ItemPositionStretch) != ItemPositionStretch)1807 if (child.style().resolvedAlignSelf(style(), selfAlignmentNormalBehavior).position() != ItemPositionStretch) 1807 1808 return false; 1808 1809 … … 1853 1854 bool hasAutoSizeInColumnAxis = isHorizontalMode ? childStyle.height().isAuto() : childStyle.width().isAuto(); 1854 1855 bool allowedToStretchChildAlongColumnAxis = hasAutoSizeInColumnAxis && !childStyle.marginBeforeUsing(&gridStyle).isAuto() && !childStyle.marginAfterUsing(&gridStyle).isAuto(); 1855 if (allowedToStretchChildAlongColumnAxis && RenderStyle::resolveAlignment(gridStyle, childStyle, ItemPositionStretch) == ItemPositionStretch) {1856 if (allowedToStretchChildAlongColumnAxis && childStyle.resolvedAlignSelf(style(), selfAlignmentNormalBehavior).position() == ItemPositionStretch) { 1856 1857 // TODO (lajava): If the child has orthogonal flow, then it already has an override height set, so use it. 1857 1858 // TODO (lajava): grid track sizing and positioning do not support orthogonal modes yet. … … 1934 1935 bool hasSameWritingMode = child.style().writingMode() == style().writingMode(); 1935 1936 1936 switch ( RenderStyle::resolveAlignment(style(), child.style(), ItemPositionStretch)) {1937 switch (child.style().resolvedAlignSelf(style(), selfAlignmentNormalBehavior).position()) { 1937 1938 case ItemPositionSelfStart: 1938 1939 // If orthogonal writing-modes, this computes to 'start'. … … 1970 1971 return GridAxisStart; 1971 1972 case ItemPositionAuto: 1973 case ItemPositionNormal: 1972 1974 break; 1973 1975 } … … 1983 1985 bool isLTR = style().isLeftToRightDirection(); 1984 1986 1985 switch ( RenderStyle::resolveJustification(style(), child.style(), ItemPositionStretch)) {1987 switch (child.style().resolvedJustifySelf(style(), selfAlignmentNormalBehavior).position()) { 1986 1988 case ItemPositionSelfStart: 1987 1989 // For orthogonal writing-modes, this computes to 'start' … … 2012 2014 return GridAxisStart; 2013 2015 case ItemPositionAuto: 2016 case ItemPositionNormal: 2014 2017 break; 2015 2018 } … … 2041 2044 endOfRow -= guttersSize(ForRows, 2) + m_offsetBetweenRows; 2042 2045 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHeight(); 2043 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(RenderStyle::resolveAlignmentOverflow(style(), child.style()), endOfRow - startOfRow, childBreadth); 2046 auto overflow = child.style().resolvedAlignSelf(style(), selfAlignmentNormalBehavior).overflow(); 2047 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(overflow, endOfRow - startOfRow, childBreadth); 2044 2048 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPosition : offsetFromStartPosition / 2); 2045 2049 } … … 2073 2077 endOfColumn -= guttersSize(ForColumns, 2) + m_offsetBetweenColumns; 2074 2078 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidth(); 2075 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(RenderStyle::resolveJustificationOverflow(style(), child.style()), endOfColumn - startOfColumn, childBreadth); 2079 auto overflow = child.style().resolvedJustifySelf(style(), selfAlignmentNormalBehavior).overflow(); 2080 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(overflow, endOfColumn - startOfColumn, childBreadth); 2076 2081 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPosition : offsetFromStartPosition / 2); 2077 2082 } … … 2135 2140 { 2136 2141 bool isRowAxis = direction == ForColumns; 2137 ContentPosition position = isRowAxis ? style().resolvedJustifyContentPosition(normalValueBehaviorGrid()) : style().resolvedAlignContentPosition(normalValueBehaviorGrid());2138 ContentDistributionType distribution = isRowAxis ? style().resolvedJustifyContentDistribution(normalValueBehaviorGrid()) : style().resolvedAlignContentDistribution(normalValueBehaviorGrid());2142 auto position = isRowAxis ? style().resolvedJustifyContentPosition(contentAlignmentNormalBehaviorGrid()) : style().resolvedAlignContentPosition(contentAlignmentNormalBehaviorGrid()); 2143 auto distribution = isRowAxis ? style().resolvedJustifyContentDistribution(contentAlignmentNormalBehaviorGrid()) : style().resolvedAlignContentDistribution(contentAlignmentNormalBehaviorGrid()); 2139 2144 // If <content-distribution> value can't be applied, 'position' will become the associated 2140 2145 // <content-position> fallback value. 2141 ContentAlignmentDatacontentAlignment = contentDistributionOffset(availableFreeSpace, position, distribution, numberOfGridTracks);2146 auto contentAlignment = contentDistributionOffset(availableFreeSpace, position, distribution, numberOfGridTracks); 2142 2147 if (contentAlignment.isValid()) 2143 2148 return contentAlignment; 2144 2149 2145 OverflowAlignmentoverflow = isRowAxis ? style().justifyContentOverflowAlignment() : style().alignContentOverflowAlignment();2150 auto overflow = isRowAxis ? style().justifyContentOverflowAlignment() : style().alignContentOverflowAlignment(); 2146 2151 if (availableFreeSpace <= 0 && overflow == OverflowAlignmentSafe) 2147 2152 return {0, 0};
Note:
See TracChangeset
for help on using the changeset viewer.