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 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1047 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 1047 GridSizingData sizingData(gridColumnCount(), gridRowCount()); |
1048 computeUsedBreadthOfGridTracks(ForColumns, sizingData); | 1048 computeUsedBreadthOfGridTracks(ForColumns, sizingData); |
1049 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData.columnTracks )); | 1049 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData.columnTracks )); |
1050 computeUsedBreadthOfGridTracks(ForRows, sizingData); | 1050 computeUsedBreadthOfGridTracks(ForRows, sizingData); |
1051 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData.rowTracks)); | 1051 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData.rowTracks)); |
1052 | 1052 |
1053 populateGridPositions(sizingData); | 1053 populateGridPositions(sizingData); |
1054 m_gridItemsOverflowingGridArea.resize(0); | 1054 m_gridItemsOverflowingGridArea.resize(0); |
1055 | 1055 |
1056 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { | 1056 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { |
1057 if (child->isOutOfFlowPositioned()) { | |
1058 // FIXME: Absolute positioned grid items should have a special | |
1059 // behavior as described in the spec (crbug.com/273898): | |
1060 // http://www.w3.org/TR/css-grid-1/#abspos-items | |
Julien - ping for review
2014/10/20 19:34:43
Please do not link to the Working Draft as it's su
| |
1061 child->containingBlock()->insertPositionedObject(child); | |
1062 } | |
1063 | |
1064 // Because the grid area cannot be styled, we don't need to adjust | 1057 // Because the grid area cannot be styled, we don't need to adjust |
1065 // the grid breadth to account for 'box-sizing'. | 1058 // the grid breadth to account for 'box-sizing'. |
1066 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOve rrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogica lWidth() : LayoutUnit(); | 1059 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOve rrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogica lWidth() : LayoutUnit(); |
1067 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOv errideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogi calHeight() : LayoutUnit(); | 1060 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOv errideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogi calHeight() : LayoutUnit(); |
1068 | 1061 |
1069 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthF orChild(*child, ForColumns, sizingData.columnTracks); | 1062 LayoutUnit columnExtraSize = 0; |
1070 LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadth ForChild(*child, ForRows, sizingData.rowTracks); | 1063 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthF orChild(*child, ForColumns, sizingData.columnTracks, &columnExtraSize); |
1064 LayoutUnit rowExtraSize = 0; | |
1065 LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadth ForChild(*child, ForRows, sizingData.rowTracks, &rowExtraSize); | |
1066 | |
1067 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingB lockContentLogicalWidth); | |
1068 child->setOverrideContainingBlockContentLogicalHeight(overrideContaining BlockContentLogicalHeight); | |
1069 | |
1070 if (child->isOutOfFlowPositioned()) { | |
1071 child->containingBlock()->insertPositionedObject(child); | |
1072 | |
1073 bool isHorizontal = isHorizontalWritingMode(); | |
Julien - ping for review
2014/10/20 19:34:44
Not a great variable. How about containerHasHorizo
Manuel Rego
2014/10/23 12:48:38
Acknowledged.
| |
1074 LayoutPoint position = findChildLogicalPosition(*child); | |
Julien - ping for review
2014/10/20 19:34:43
findChildLogicalPosition is going to apply 'justif
Manuel Rego
2014/10/23 12:48:38
Yes, I've changed it to avoid this issue.
| |
1075 | |
1076 RenderLayer* childLayer = child->layer(); | |
1077 // Set the layer position taking into account the extra size | |
1078 // increased in RenderGrid::gridAreaBreadthForChild() due to the | |
1079 // positioned items particularities. | |
1080 childLayer->setStaticInlinePosition(isHorizontal ? position.x() - co lumnExtraSize : position.y() - rowExtraSize); | |
1081 childLayer->setStaticBlockPosition(isHorizontal ? position.y() - row ExtraSize : position.x() - columnExtraSize); | |
1082 | |
1083 continue; | |
1084 } | |
1071 | 1085 |
1072 SubtreeLayoutScope layoutScope(*child); | 1086 SubtreeLayoutScope layoutScope(*child); |
1073 if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingB lockContentLogicalWidth || (oldOverrideContainingBlockContentLogicalHeight != ov errideContainingBlockContentLogicalHeight && child->hasRelativeLogicalHeight())) | 1087 if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingB lockContentLogicalWidth || (oldOverrideContainingBlockContentLogicalHeight != ov errideContainingBlockContentLogicalHeight && child->hasRelativeLogicalHeight())) |
1074 layoutScope.setNeedsLayout(child); | 1088 layoutScope.setNeedsLayout(child); |
1075 | 1089 |
1076 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingB lockContentLogicalWidth); | |
1077 child->setOverrideContainingBlockContentLogicalHeight(overrideContaining BlockContentLogicalHeight); | |
1078 | |
1079 // FIXME: Grid items should stretch to fill their cells. Once we | 1090 // FIXME: Grid items should stretch to fill their cells. Once we |
1080 // implement grid-{column,row}-align, we can also shrink to fit. For | 1091 // implement grid-{column,row}-align, we can also shrink to fit. For |
1081 // now, just size as if we were a regular child. | 1092 // now, just size as if we were a regular child. |
1082 child->layoutIfNeeded(); | 1093 child->layoutIfNeeded(); |
1083 | 1094 |
1084 #if ENABLE(ASSERT) | 1095 #if ENABLE(ASSERT) |
1085 const GridCoordinate& coordinate = cachedGridCoordinate(*child); | 1096 const GridCoordinate& coordinate = cachedGridCoordinate(*child); |
1086 ASSERT(coordinate.columns.resolvedInitialPosition.toInt() < sizingData.c olumnTracks.size()); | 1097 ASSERT(coordinate.columns.resolvedInitialPosition.toInt() < sizingData.c olumnTracks.size()); |
1087 ASSERT(coordinate.rows.resolvedInitialPosition.toInt() < sizingData.rowT racks.size()); | 1098 ASSERT(coordinate.rows.resolvedInitialPosition.toInt() < sizingData.rowT racks.size()); |
1088 #endif | 1099 #endif |
(...skipping 13 matching lines...) Expand all Loading... | |
1102 | 1113 |
1103 setLogicalHeight(logicalHeight() + borderAndPaddingLogicalHeight()); | 1114 setLogicalHeight(logicalHeight() + borderAndPaddingLogicalHeight()); |
1104 } | 1115 } |
1105 | 1116 |
1106 GridCoordinate RenderGrid::cachedGridCoordinate(const RenderBox& gridItem) const | 1117 GridCoordinate RenderGrid::cachedGridCoordinate(const RenderBox& gridItem) const |
1107 { | 1118 { |
1108 ASSERT(m_gridItemCoordinate.contains(&gridItem)); | 1119 ASSERT(m_gridItemCoordinate.contains(&gridItem)); |
1109 return m_gridItemCoordinate.get(&gridItem); | 1120 return m_gridItemCoordinate.get(&gridItem); |
1110 } | 1121 } |
1111 | 1122 |
1112 LayoutUnit RenderGrid::gridAreaBreadthForChild(const RenderBox& child, GridTrack SizingDirection direction, const Vector<GridTrack>& tracks) const | 1123 LayoutUnit RenderGrid::gridAreaBreadthForChild(const RenderBox& child, GridTrack SizingDirection direction, const Vector<GridTrack>& tracks, LayoutUnit* extraSiz e) const |
Julien - ping for review
2014/10/20 19:34:44
This really looks like it should be split into 2 f
Manuel Rego
2014/10/23 12:48:38
I agree, most of my changes were only dealing with
| |
1113 { | 1124 { |
1114 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1125 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
1115 const GridSpan& span = (direction == ForColumns) ? coordinate.columns : coor dinate.rows; | 1126 const GridSpan& span = (direction == ForColumns) ? coordinate.columns : coor dinate.rows; |
1127 | |
1116 LayoutUnit gridAreaBreadth = 0; | 1128 LayoutUnit gridAreaBreadth = 0; |
1117 for (GridSpan::iterator trackPosition = span.begin(); trackPosition != span. end(); ++trackPosition) | 1129 bool startIsAuto = false; |
1118 gridAreaBreadth += tracks[trackPosition.toInt()].m_usedBreadth; | 1130 bool endIsAuto = false; |
1131 if (extraSize && child.isOutOfFlowPositioned()) { | |
1132 // For positioned items the containing block corresponds to the padding | |
1133 // edges of the grid. So, we need to increase the breadth if the | |
1134 // positions are auto. | |
1135 if (direction == ForColumns) { | |
1136 if (child.style()->gridColumnStart().isAuto()) { | |
1137 startIsAuto = true; | |
1138 gridAreaBreadth += paddingLeft(); | |
1139 *extraSize += paddingLeft(); | |
1140 } | |
1141 if (child.style()->gridColumnEnd().isAuto()) { | |
1142 endIsAuto = true; | |
1143 gridAreaBreadth += paddingRight(); | |
1144 } | |
1145 } else { | |
1146 if (child.style()->gridRowStart().isAuto()) { | |
1147 startIsAuto = true; | |
1148 gridAreaBreadth += paddingTop(); | |
1149 *extraSize += paddingTop(); | |
1150 } | |
1151 if (child.style()->gridRowEnd().isAuto()) { | |
1152 endIsAuto = true; | |
1153 gridAreaBreadth += paddingBottom(); | |
1154 } | |
1155 } | |
1156 } | |
1157 | |
1158 GridResolvedPosition initialPosition = startIsAuto ? GridResolvedPosition(0) : span.resolvedInitialPosition; | |
1159 GridResolvedPosition finalPosition = endIsAuto ? GridResolvedPosition((direc tion == ForColumns ? gridColumnCount() : gridRowCount()) - 1) : span.resolvedFin alPosition; | |
1160 GridSpan iteratorSpan(initialPosition, finalPosition); | |
1161 | |
1162 for (GridSpan::iterator trackPosition = iteratorSpan.begin(); trackPosition != iteratorSpan.end(); ++trackPosition) { | |
1163 LayoutUnit trackBreadth = tracks[trackPosition.toInt()].m_usedBreadth; | |
1164 gridAreaBreadth += trackBreadth; | |
1165 if (extraSize && startIsAuto && trackPosition < span.resolvedInitialPosi tion) | |
1166 *extraSize += trackBreadth; | |
1167 } | |
1119 return gridAreaBreadth; | 1168 return gridAreaBreadth; |
1120 } | 1169 } |
1121 | 1170 |
1122 void RenderGrid::populateGridPositions(const GridSizingData& sizingData) | 1171 void RenderGrid::populateGridPositions(const GridSizingData& sizingData) |
1123 { | 1172 { |
1124 m_columnPositions.resize(sizingData.columnTracks.size() + 1); | 1173 m_columnPositions.resize(sizingData.columnTracks.size() + 1); |
1125 m_columnPositions[0] = borderAndPaddingStart(); | 1174 m_columnPositions[0] = borderAndPaddingStart(); |
1126 for (size_t i = 0; i < m_columnPositions.size() - 1; ++i) | 1175 for (size_t i = 0; i < m_columnPositions.size() - 1; ++i) |
1127 m_columnPositions[i + 1] = m_columnPositions[i] + sizingData.columnTrack s[i].m_usedBreadth; | 1176 m_columnPositions[i + 1] = m_columnPositions[i] + sizingData.columnTrack s[i].m_usedBreadth; |
1128 | 1177 |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1388 if (isOutOfFlowPositioned()) | 1437 if (isOutOfFlowPositioned()) |
1389 return "RenderGrid (positioned)"; | 1438 return "RenderGrid (positioned)"; |
1390 if (isAnonymous()) | 1439 if (isAnonymous()) |
1391 return "RenderGrid (generated)"; | 1440 return "RenderGrid (generated)"; |
1392 if (isRelPositioned()) | 1441 if (isRelPositioned()) |
1393 return "RenderGrid (relative positioned)"; | 1442 return "RenderGrid (relative positioned)"; |
1394 return "RenderGrid"; | 1443 return "RenderGrid"; |
1395 } | 1444 } |
1396 | 1445 |
1397 } // namespace blink | 1446 } // namespace blink |
OLD | NEW |