Changeset 183660 in webkit
- Timestamp:
- Apr 30, 2015 6:14:20 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r183659 r183660 1 2015-04-30 Javier Fernandez <jfernandez@igalia.com> 2 3 [CSS Grid Layout] overflow-position keyword for align and justify properties. 4 https://bugs.webkit.org/show_bug.cgi?id=144235 5 6 Reviewed by Sergio Villar Senin. 7 8 Implementation of overflow-keyword handling for Grid Layout on 9 align-self and justify-self properties. 10 11 * fast/css-grid-layout/grid-align-justify-overflow-expected.txt: Added. 12 * fast/css-grid-layout/grid-align-justify-overflow.html: Added. 13 1 14 2015-04-30 Jon Davis <jond@apple.com> 2 15 -
trunk/Source/WebCore/ChangeLog
r183657 r183660 1 2015-04-30 Javier Fernandez <jfernandez@igalia.com> 2 3 [CSS Grid Layout] overflow-position keyword for align and justify properties. 4 https://bugs.webkit.org/show_bug.cgi?id=144235 5 6 Reviewed by Sergio Villar Senin. 7 8 When the alignment subject is larger than the alignment container, 9 it will overflow. Some alignment modes, if honored in this 10 situation, may cause data loss; an overflow alignment mode can be 11 explicitly specified to avoid this. 12 13 This patch implements overflow-keyword handling for Grid Layout on 14 align-self and justify-self properties. 15 16 Test: fast/css-grid-layout/grid-align-justify-overflow.html 17 18 * rendering/RenderGrid.cpp: 19 (WebCore::computeOverflowAlignmentOffset): 20 (WebCore::RenderGrid::rowPositionForChild): 21 (WebCore::RenderGrid::columnPositionForChild): 22 (WebCore::RenderGrid::rowAxisPositionForChild): Deleted. 23 * rendering/style/RenderStyle.cpp: 24 (WebCore::resolveAlignmentData): 25 (WebCore::resolveJustificationData): 26 (WebCore::RenderStyle::resolveAlignment): 27 (WebCore::RenderStyle::resolveAlignmentOverflow): 28 (WebCore::RenderStyle::resolveJustification): 29 (WebCore::RenderStyle::resolveJustificationOverflow): 30 * rendering/style/RenderStyle.h: 31 1 32 2015-04-30 Jon Honeycutt <jhoneycutt@apple.com> 2 33 -
trunk/Source/WebCore/rendering/RenderGrid.cpp
r183399 r183660 1237 1237 for (unsigned i = 0; i < m_rowPositions.size() - 1; ++i) 1238 1238 m_rowPositions[i + 1] = m_rowPositions[i] + sizingData.rowTracks[i].baseSize(); 1239 } 1240 1241 static inline LayoutUnit computeOverflowAlignmentOffset(OverflowAlignment overflow, LayoutUnit trackBreadth, LayoutUnit childBreadth) 1242 { 1243 LayoutUnit offset = trackBreadth - childBreadth; 1244 switch (overflow) { 1245 case OverflowAlignmentSafe: 1246 // If overflow is 'safe', we have to make sure we don't overflow the 'start' 1247 // edge (potentially cause some data loss as the overflow is unreachable). 1248 return std::max<LayoutUnit>(0, offset); 1249 case OverflowAlignmentTrue: 1250 case OverflowAlignmentDefault: 1251 // If we overflow our alignment container and overflow is 'true' (default), we 1252 // ignore the overflow and just return the value regardless (which may cause data 1253 // loss as we overflow the 'start' edge). 1254 return offset; 1255 } 1256 1257 ASSERT_NOT_REACHED(); 1258 return 0; 1239 1259 } 1240 1260 … … 1386 1406 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.next().toInt()]; 1387 1407 LayoutUnit startPosition = startOfRow + marginBeforeForChild(child); 1388 // FIXME: This should account for the grid item's <overflow-position>. 1389 LayoutUnit offsetFromStartPosition = endOfRow - startOfRow - child.logicalHeight() - child.marginLogicalHeight(); 1408 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(RenderStyle::resolveAlignmentOverflow(style(), child.style()), endOfRow - startOfRow, child.logicalHeight() + child.marginLogicalHeight()); 1390 1409 1391 1410 switch (columnAxisPositionForChild(child)) { … … 1409 1428 LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalPosition.next().toInt()]; 1410 1429 LayoutUnit startPosition = startOfColumn + marginStartForChild(child); 1411 // FIXME: This should account for the grid item's <overflow-position>. 1412 LayoutUnit offsetFromStartPosition = endOfColumn - startOfColumn - child.logicalWidth() - child.marginLogicalWidth(); 1430 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(RenderStyle::resolveJustificationOverflow(style(), child.style()), endOfColumn - startOfColumn, child.logicalWidth() + child.marginLogicalWidth()); 1413 1431 1414 1432 switch (rowAxisPositionForChild(child)) { -
trunk/Source/WebCore/rendering/style/RenderStyle.cpp
r183591 r183660 40 40 #include "StyleResolver.h" 41 41 #include "StyleScrollSnapPoints.h" 42 #include "StyleSelfAlignmentData.h" 42 43 #include <wtf/MathExtras.h> 43 44 #include <wtf/StdLibExtras.h> … … 172 173 } 173 174 174 ItemPosition RenderStyle::resolveAlignment(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer)175 static inline StyleSelfAlignmentData resolveAlignmentData(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer) 175 176 { 176 177 // The auto keyword computes to the parent's align-items computed value, or to "stretch", if not set or "auto". 177 178 if (childStyle.alignSelfPosition() == ItemPositionAuto) 178 return (parentStyle.alignItemsPosition() == ItemPositionAuto) ? resolvedAutoPositionForRenderer : parentStyle.alignItemsPosition(); 179 return childStyle.alignSelfPosition(); 180 } 181 182 ItemPosition RenderStyle::resolveJustification(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject) 183 { 179 return (parentStyle.alignItemsPosition() == ItemPositionAuto) ? StyleSelfAlignmentData(resolvedAutoPositionForRenderer, OverflowAlignmentDefault) : parentStyle.alignItems(); 180 return childStyle.alignSelf(); 181 } 182 183 static inline StyleSelfAlignmentData resolveJustificationData(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer) 184 { 185 // The auto keyword computes to the parent's justify-items computed value, or to "stretch", if not set or "auto". 184 186 if (childStyle.justifySelfPosition() == ItemPositionAuto) 185 return (parentStyle.justifyItemsPosition() == ItemPositionAuto) ? resolvedAutoPositionForLayoutObject : parentStyle.justifyItemsPosition(); 186 return childStyle.justifySelfPosition(); 187 return (parentStyle.justifyItemsPosition() == ItemPositionAuto) ? StyleSelfAlignmentData(resolvedAutoPositionForRenderer, OverflowAlignmentDefault) : parentStyle.justifyItems(); 188 return childStyle.justifySelf(); 189 } 190 191 ItemPosition RenderStyle::resolveAlignment(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer) 192 { 193 return resolveAlignmentData(parentStyle, childStyle, resolvedAutoPositionForRenderer).position(); 194 } 195 196 OverflowAlignment RenderStyle::resolveAlignmentOverflow(const RenderStyle& parentStyle, const RenderStyle& childStyle) 197 { 198 return resolveJustificationData(parentStyle, childStyle, ItemPositionStretch).overflow(); 199 } 200 201 ItemPosition RenderStyle::resolveJustification(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer) 202 { 203 return resolveJustificationData(parentStyle, childStyle, resolvedAutoPositionForRenderer).position(); 204 } 205 206 OverflowAlignment RenderStyle::resolveJustificationOverflow(const RenderStyle& parentStyle, const RenderStyle& childStyle) 207 { 208 return resolveJustificationData(parentStyle, childStyle, ItemPositionStretch).overflow(); 187 209 } 188 210 -
trunk/Source/WebCore/rendering/style/RenderStyle.h
r183591 r183660 493 493 494 494 static ItemPosition resolveAlignment(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer); 495 static ItemPosition resolveJustification(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject); 495 static OverflowAlignment resolveAlignmentOverflow(const RenderStyle& parentStyle, const RenderStyle& childStyle); 496 static ItemPosition resolveJustification(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer); 497 static OverflowAlignment resolveJustificationOverflow(const RenderStyle& parentStyle, const RenderStyle& childStyle); 496 498 497 499 enum IsAtShadowBoundary {
Note: See TracChangeset
for help on using the changeset viewer.