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

Side by Side Diff: Source/core/rendering/RenderGrid.cpp

Issue 297483005: [CSS Grid Layout] Implementation of the align-self property in grid. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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
« no previous file with comments | « Source/core/rendering/RenderGrid.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::rowPositionForChild(const RenderBox* child) const 1093 LayoutUnit RenderGrid::endOfRowForChild(const RenderBox* child) const
1094 { 1094 {
1095 const GridCoordinate& coordinate = cachedGridCoordinate(child); 1095 const GridCoordinate& coordinate = cachedGridCoordinate(child);
1096 1096
1097 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted. 1097 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted.
1098 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi on.toInt()]; 1098 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi on.toInt()];
1099 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child); 1099 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child);
1100 1100
1101 // FIXME: This function should account for 'align-self'. 1101 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n ext().toInt()];
1102
1103 // FIXME: This should account for the grid item's <overflow-position>.
1104 return rowPosition + std::max<LayoutUnit>(0, endOfRow - startOfRow - child-> logicalHeight());
1105 }
1106
1107 LayoutUnit RenderGrid::startOfRowForChild(const RenderBox* child) const
1108 {
1109 const GridCoordinate& coordinate = cachedGridCoordinate(child);
1110
1111 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted.
1112 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi on.toInt()];
1113 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child);
1102 1114
1103 return rowPosition; 1115 return rowPosition;
1104 } 1116 }
1105 1117
1118 LayoutUnit RenderGrid::centeredRowPositionForChild(const RenderBox* child) const
1119 {
1120 const GridCoordinate& coordinate = cachedGridCoordinate(child);
1121 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi on.toInt()];
1122 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n ext().toInt()];
1123 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child);
Julien - ping for review 2014/05/21 14:41:38 We should repeat the comment about shifting the gr
jfernandez 2014/05/23 14:06:48 Done.
1124 return rowPosition + std::max<LayoutUnit>(0, endOfRow - startOfRow - child-> logicalHeight()) / 2;
1125 }
1126
1127 LayoutUnit RenderGrid::rowPositionForChild(const RenderBox* child) const
1128 {
1129 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHorizo ntalWritingMode();
1130 ItemPosition childAlignSelf = child->style()->alignSelf();
1131 switch (childAlignSelf) {
Julien - ping for review 2014/05/21 14:41:38 No need for the |childAlignSelf| variable.
jfernandez 2014/05/23 14:06:48 Done.
1132 case ItemPositionSelfStart:
1133 return startOfRowForChild(child);
Julien - ping for review 2014/05/21 14:41:38 I think this needs a bit more logic: - orthogonal
jfernandez 2014/05/23 14:06:48 right, although such change is still only in the e
1134 case ItemPositionSelfEnd:
1135 return endOfRowForChild(child);
Julien - ping for review 2014/05/21 14:41:38 Same comment.
jfernandez 2014/05/23 14:06:48 Done.
1136
1137 case ItemPositionFlexStart:
1138 case ItemPositionFlexEnd:
1139 // Only used in flex layout, for other layout, it's equivalent to 'start '.
1140 return startOfRowForChild(child);
1141
1142 case ItemPositionLeft:
1143 case ItemPositionRight:
1144 // self-align's axis is always orthogonal to the inline axis, except in orthogonal
1145 // writing-mode, so this is equivalent to ‘start’.
1146 // FIXME: Properly support orthogonal writing mode.
1147 if (hasOrthogonalWritingMode)
1148 return 0;
1149
1150 return startOfRowForChild(child);
1151
1152 case ItemPositionCenter:
1153 return centeredRowPositionForChild(child);
1154 case ItemPositionStart:
1155 return startOfRowForChild(child);
1156 case ItemPositionEnd:
1157 return endOfRowForChild(child);
1158
1159 case ItemPositionAuto:
1160 case ItemPositionStretch:
1161 case ItemPositionBaseline:
1162 // FIXME: Implement the previous values. For now, we always start align the child.
1163 return startOfRowForChild(child);
1164 }
1165
1166 ASSERT_NOT_REACHED();
1167 return 0;
1168 }
1169
1106 LayoutPoint RenderGrid::findChildLogicalPosition(const RenderBox* child) const 1170 LayoutPoint RenderGrid::findChildLogicalPosition(const RenderBox* child) const
1107 { 1171 {
1108 return LayoutPoint(columnPositionForChild(child), rowPositionForChild(child) ); 1172 return LayoutPoint(columnPositionForChild(child), rowPositionForChild(child) );
1109 } 1173 }
1110 1174
1111 static GridSpan dirtiedGridAreas(const Vector<LayoutUnit>& coordinates, LayoutUn it start, LayoutUnit end) 1175 static GridSpan dirtiedGridAreas(const Vector<LayoutUnit>& coordinates, LayoutUn it start, LayoutUnit end)
1112 { 1176 {
1113 // This function does a binary search over the coordinates. 1177 // This function does a binary search over the coordinates.
1114 // FIXME: This doesn't work with grid items overflowing their grid areas and should be tested & fixed. 1178 // FIXME: This doesn't work with grid items overflowing their grid areas and should be tested & fixed.
1115 1179
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 if (isOutOfFlowPositioned()) 1289 if (isOutOfFlowPositioned())
1226 return "RenderGrid (positioned)"; 1290 return "RenderGrid (positioned)";
1227 if (isAnonymous()) 1291 if (isAnonymous())
1228 return "RenderGrid (generated)"; 1292 return "RenderGrid (generated)";
1229 if (isRelPositioned()) 1293 if (isRelPositioned())
1230 return "RenderGrid (relative positioned)"; 1294 return "RenderGrid (relative positioned)";
1231 return "RenderGrid"; 1295 return "RenderGrid";
1232 } 1296 }
1233 1297
1234 } // namespace WebCore 1298 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderGrid.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698