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 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1083 case ItemPositionStretch: | 1083 case ItemPositionStretch: |
1084 case ItemPositionBaseline: | 1084 case ItemPositionBaseline: |
1085 // FIXME: Implement the previous values. For now, we always start align the child. | 1085 // FIXME: Implement the previous values. For now, we always start align the child. |
1086 return startOfColumnForChild(child); | 1086 return startOfColumnForChild(child); |
1087 } | 1087 } |
1088 | 1088 |
1089 ASSERT_NOT_REACHED(); | 1089 ASSERT_NOT_REACHED(); |
1090 return 0; | 1090 return 0; |
1091 } | 1091 } |
1092 | 1092 |
1093 LayoutUnit RenderGrid::endOfRowForChild(const RenderBox* child) const | |
1094 { | |
1095 const GridCoordinate& coordinate = cachedGridCoordinate(child); | |
1096 | |
1097 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi on.toInt()]; | |
1098 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted. | |
1099 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child); | |
1100 | |
1101 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n ext().toInt()]; | |
1102 // FIXME: This should account for the grid item's <overflow-position>. | |
1103 return rowPosition + std::max<LayoutUnit>(0, endOfRow - startOfRow - child-> logicalHeight()); | |
1104 } | |
1105 | |
1106 LayoutUnit RenderGrid::startOfRowForChild(const RenderBox* child) const | |
1107 { | |
1108 const GridCoordinate& coordinate = cachedGridCoordinate(child); | |
1109 | |
1110 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi on.toInt()]; | |
1111 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted. | |
1112 // FIXME: This should account for the grid item's <overflow-position>. | |
1113 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child); | |
1114 | |
1115 return rowPosition; | |
1116 } | |
1117 | |
1118 LayoutUnit RenderGrid::centeredRowPositionForChild(const RenderBox* child) const | |
1119 { | |
1120 const GridCoordinate& coordinate = cachedGridCoordinate(child); | |
1121 | |
1122 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted. | |
1123 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi on.toInt()] + marginBeforeForChild(child); | |
1124 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n ext().toInt()]; | |
1125 | |
1126 return startOfRow + std::max<LayoutUnit>(0, endOfRow - startOfRow - child->l ogicalHeight()) / 2; | |
cbiesinger
2014/06/17 22:18:31
Shouldn't this also have a FIXME comment for overf
jfernandez
2014/06/20 10:46:00
Done.
| |
1127 } | |
1128 | |
1093 LayoutUnit RenderGrid::rowPositionForChild(const RenderBox* child) const | 1129 LayoutUnit RenderGrid::rowPositionForChild(const RenderBox* child) const |
1094 { | 1130 { |
1095 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1131 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHorizo ntalWritingMode(); |
1132 switch (child->style()->alignSelf()) { | |
1133 case ItemPositionSelfStart: | |
1134 // FIXME: Properly support orthogonal writing mode. | |
1135 if (hasOrthogonalWritingMode) | |
1136 return startOfRowForChild(child); | |
1096 | 1137 |
1097 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted. | 1138 // self-start is based on the child's direction. That's why we need to c heck against the grid container's direction. |
1098 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi on.toInt()]; | 1139 if (child->style()->writingMode() != style()->writingMode()) |
1099 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child); | 1140 return endOfRowForChild(child); |
1100 | 1141 |
1101 // FIXME: This function should account for 'align-self'. | 1142 return startOfRowForChild(child); |
1143 case ItemPositionSelfEnd: | |
1144 // FIXME: Properly support orthogonal writing mode. | |
cbiesinger
2014/06/17 22:18:31
Isn't this the right way to handle it? Quoting htt
jfernandez
2014/06/20 10:46:00
Yes, but the FIXME is about the lack of orthogonal
| |
1145 if (hasOrthogonalWritingMode) | |
1146 return startOfRowForChild(child); | |
1102 | 1147 |
1103 return rowPosition; | 1148 // self-start is based on the child's direction. That's why we need to c heck against the grid container's direction. |
1149 if (child->style()->writingMode() != style()->writingMode()) | |
1150 return startOfRowForChild(child); | |
1151 | |
1152 return endOfRowForChild(child); | |
1153 | |
1154 case ItemPositionFlexStart: | |
1155 case ItemPositionFlexEnd: | |
1156 // Only used in flex layout, for other layout, it's equivalent to 'start '. | |
cbiesinger
2014/06/17 22:18:31
I think it'd be clearer to add these two cases to
jfernandez
2014/06/20 10:46:00
Done.
| |
1157 return startOfRowForChild(child); | |
1158 | |
1159 case ItemPositionLeft: | |
1160 case ItemPositionRight: | |
1161 // self-align's axis is never parallel to the inline axis, except in ort hogonal | |
1162 // writing-mode, so this is equivalent to ‘start’. | |
1163 // FIXME: Properly support orthogonal writing mode. | |
1164 if (hasOrthogonalWritingMode) | |
1165 return 0; | |
cbiesinger
2014/06/17 22:18:31
Is 0 really correct here?
http://dev.w3.org/csswg
jfernandez
2014/06/20 10:46:00
Yes, done that, even though the previously comment
| |
1166 | |
1167 return startOfRowForChild(child); | |
1168 | |
1169 case ItemPositionCenter: | |
1170 return centeredRowPositionForChild(child); | |
1171 case ItemPositionStart: | |
1172 return startOfRowForChild(child); | |
1173 case ItemPositionEnd: | |
1174 return endOfRowForChild(child); | |
1175 | |
1176 case ItemPositionAuto: | |
cbiesinger
2014/06/17 22:18:31
This seems really easy to implement, but OK to do
jfernandez
2014/06/20 10:46:00
Finally implemented in the new patch, It was quite
| |
1177 case ItemPositionStretch: | |
cbiesinger
2014/06/17 22:18:31
http://dev.w3.org/csswg/css-align-3/#valuedef-stre
jfernandez
2014/06/20 10:46:00
Well, it seems "stretch" requires more than such l
cbiesinger
2014/06/21 00:52:36
Indeed. I misread the spec.
| |
1178 case ItemPositionBaseline: | |
1179 // FIXME: Implement the previous values. For now, we always start align the child. | |
1180 return startOfRowForChild(child); | |
1181 } | |
1182 | |
1183 ASSERT_NOT_REACHED(); | |
1184 return 0; | |
1104 } | 1185 } |
1105 | 1186 |
1106 LayoutPoint RenderGrid::findChildLogicalPosition(const RenderBox* child) const | 1187 LayoutPoint RenderGrid::findChildLogicalPosition(const RenderBox* child) const |
1107 { | 1188 { |
1108 return LayoutPoint(columnPositionForChild(child), rowPositionForChild(child) ); | 1189 return LayoutPoint(columnPositionForChild(child), rowPositionForChild(child) ); |
1109 } | 1190 } |
1110 | 1191 |
1111 static GridSpan dirtiedGridAreas(const Vector<LayoutUnit>& coordinates, LayoutUn it start, LayoutUnit end) | 1192 static GridSpan dirtiedGridAreas(const Vector<LayoutUnit>& coordinates, LayoutUn it start, LayoutUnit end) |
1112 { | 1193 { |
1113 // This function does a binary search over the coordinates. | 1194 // This function does a binary search over the coordinates. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1225 if (isOutOfFlowPositioned()) | 1306 if (isOutOfFlowPositioned()) |
1226 return "RenderGrid (positioned)"; | 1307 return "RenderGrid (positioned)"; |
1227 if (isAnonymous()) | 1308 if (isAnonymous()) |
1228 return "RenderGrid (generated)"; | 1309 return "RenderGrid (generated)"; |
1229 if (isRelPositioned()) | 1310 if (isRelPositioned()) |
1230 return "RenderGrid (relative positioned)"; | 1311 return "RenderGrid (relative positioned)"; |
1231 return "RenderGrid"; | 1312 return "RenderGrid"; |
1232 } | 1313 } |
1233 | 1314 |
1234 } // namespace WebCore | 1315 } // namespace WebCore |
OLD | NEW |