| 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 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1072  |  1072  | 
|  1073     return endOfColumnForChild(child); |  1073     return endOfColumnForChild(child); | 
|  1074 } |  1074 } | 
|  1075  |  1075  | 
|  1076 LayoutUnit RenderGrid::centeredColumnPositionForChild(const RenderBox* child) co
      nst |  1076 LayoutUnit RenderGrid::centeredColumnPositionForChild(const RenderBox* child) co
      nst | 
|  1077 { |  1077 { | 
|  1078     const GridCoordinate& coordinate = cachedGridCoordinate(child); |  1078     const GridCoordinate& coordinate = cachedGridCoordinate(child); | 
|  1079     LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit
      ialPosition.toInt()]; |  1079     LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit
      ialPosition.toInt()]; | 
|  1080     LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalP
      osition.next().toInt()]; |  1080     LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalP
      osition.next().toInt()]; | 
|  1081     LayoutUnit columnPosition = startOfColumn + marginStartForChild(child); |  1081     LayoutUnit columnPosition = startOfColumn + marginStartForChild(child); | 
 |  1082     // FIXME: This should account for the grid item's <overflow-position>. | 
|  1082     return columnPosition + std::max<LayoutUnit>(0, endOfColumn - startOfColumn 
      - child->logicalWidth()) / 2; |  1083     return columnPosition + std::max<LayoutUnit>(0, endOfColumn - startOfColumn 
      - child->logicalWidth()) / 2; | 
|  1083 } |  1084 } | 
|  1084  |  1085  | 
|  1085 LayoutUnit RenderGrid::columnPositionForChild(const RenderBox* child) const |  1086 LayoutUnit RenderGrid::columnPositionForChild(const RenderBox* child) const | 
|  1086 { |  1087 { | 
|  1087     ItemPosition childJustifySelf = child->style()->justifySelf(); |  1088     ItemPosition childJustifySelf = child->style()->justifySelf(); | 
|  1088     switch (childJustifySelf) { |  1089     switch (childJustifySelf) { | 
|  1089     case ItemPositionSelfStart: |  1090     case ItemPositionSelfStart: | 
|  1090         // self-start is based on the child's direction. That's why we need to c
      heck against the grid container's direction. |  1091         // self-start is based on the child's direction. That's why we need to c
      heck against the grid container's direction. | 
|  1091         if (child->style()->direction() != style()->direction()) |  1092         if (child->style()->direction() != style()->direction()) | 
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1135     case ItemPositionBaseline: |  1136     case ItemPositionBaseline: | 
|  1136     case ItemPositionLastBaseline: |  1137     case ItemPositionLastBaseline: | 
|  1137         // FIXME: Implement the previous values. For now, we always start align 
      the child. |  1138         // FIXME: Implement the previous values. For now, we always start align 
      the child. | 
|  1138         return startOfColumnForChild(child); |  1139         return startOfColumnForChild(child); | 
|  1139     } |  1140     } | 
|  1140  |  1141  | 
|  1141     ASSERT_NOT_REACHED(); |  1142     ASSERT_NOT_REACHED(); | 
|  1142     return 0; |  1143     return 0; | 
|  1143 } |  1144 } | 
|  1144  |  1145  | 
 |  1146 LayoutUnit RenderGrid::endOfRowForChild(const RenderBox* child) const | 
 |  1147 { | 
 |  1148     const GridCoordinate& coordinate = cachedGridCoordinate(child); | 
 |  1149  | 
 |  1150     LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
      on.toInt()]; | 
 |  1151     // The grid items should be inside the grid container's border box, that's w
      hy they need to be shifted. | 
 |  1152     LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child); | 
 |  1153  | 
 |  1154     LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n
      ext().toInt()]; | 
 |  1155     // FIXME: This should account for the grid item's <overflow-position>. | 
 |  1156     return rowPosition + std::max<LayoutUnit>(0, endOfRow - startOfRow - child->
      logicalHeight()); | 
 |  1157 } | 
 |  1158  | 
 |  1159 LayoutUnit RenderGrid::startOfRowForChild(const RenderBox* child) const | 
 |  1160 { | 
 |  1161     const GridCoordinate& coordinate = cachedGridCoordinate(child); | 
 |  1162  | 
 |  1163     LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
      on.toInt()]; | 
 |  1164     // The grid items should be inside the grid container's border box, that's w
      hy they need to be shifted. | 
 |  1165     // FIXME: This should account for the grid item's <overflow-position>. | 
 |  1166     LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child); | 
 |  1167  | 
 |  1168     return rowPosition; | 
 |  1169 } | 
 |  1170  | 
 |  1171 LayoutUnit RenderGrid::centeredRowPositionForChild(const RenderBox* child) const | 
 |  1172 { | 
 |  1173     const GridCoordinate& coordinate = cachedGridCoordinate(child); | 
 |  1174  | 
 |  1175     // The grid items should be inside the grid container's border box, that's w
      hy they need to be shifted. | 
 |  1176     LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
      on.toInt()] + marginBeforeForChild(child); | 
 |  1177     LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n
      ext().toInt()]; | 
 |  1178  | 
 |  1179     // FIXME: This should account for the grid item's <overflow-position>. | 
 |  1180     return startOfRow + std::max<LayoutUnit>(0, endOfRow - startOfRow - child->l
      ogicalHeight()) / 2; | 
 |  1181 } | 
 |  1182  | 
 |  1183 // FIXME: We should move this logic to the StyleAdjuster or the StyleBuilder. | 
 |  1184 static ItemPosition resolveAlignment(const RenderStyle* parentStyle, const Rende
      rStyle* childStyle) | 
 |  1185 { | 
 |  1186     ItemPosition align = childStyle->alignSelf(); | 
 |  1187     // The auto keyword computes to the computed value of align-items on the par
      ent. | 
 |  1188     if (align == ItemPositionAuto) | 
 |  1189         align = (parentStyle->alignItems() == ItemPositionAuto) ? ItemPositionSt
      retch : parentStyle->alignItems(); | 
 |  1190     return align; | 
 |  1191 } | 
 |  1192  | 
|  1145 LayoutUnit RenderGrid::rowPositionForChild(const RenderBox* child) const |  1193 LayoutUnit RenderGrid::rowPositionForChild(const RenderBox* child) const | 
|  1146 { |  1194 { | 
|  1147     const GridCoordinate& coordinate = cachedGridCoordinate(child); |  1195     bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHorizo
      ntalWritingMode(); | 
 |  1196     ItemPosition alignSelf = resolveAlignment(style(), child->style()); | 
|  1148  |  1197  | 
|  1149     // The grid items should be inside the grid container's border box, that's w
      hy they need to be shifted. |  1198     switch (alignSelf) { | 
|  1150     LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
      on.toInt()]; |  1199     case ItemPositionSelfStart: | 
|  1151     LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child); |  1200         // If orthogonal writing-modes, this computes to 'Start'. | 
 |  1201         // FIXME: grid track sizing and positioning does not support orthogonal 
      modes yet. | 
 |  1202         if (hasOrthogonalWritingMode) | 
 |  1203             return startOfRowForChild(child); | 
|  1152  |  1204  | 
|  1153     // FIXME: This function should account for 'align-self'. |  1205         // self-start is based on the child's block axis direction. That's why w
      e need to check against the grid container's block flow. | 
 |  1206         if (child->style()->writingMode() != style()->writingMode()) | 
 |  1207             return endOfRowForChild(child); | 
|  1154  |  1208  | 
|  1155     return rowPosition; |  1209         return startOfRowForChild(child); | 
 |  1210     case ItemPositionSelfEnd: | 
 |  1211         // If orthogonal writing-modes, this computes to 'End'. | 
 |  1212         // FIXME: grid track sizing and positioning does not support orthogonal 
      modes yet. | 
 |  1213         if (hasOrthogonalWritingMode) | 
 |  1214             return endOfRowForChild(child); | 
 |  1215  | 
 |  1216         // self-end is based on the child's block axis direction. That's why we 
      need to check against the grid container's block flow. | 
 |  1217         if (child->style()->writingMode() != style()->writingMode()) | 
 |  1218             return startOfRowForChild(child); | 
 |  1219  | 
 |  1220         return endOfRowForChild(child); | 
 |  1221  | 
 |  1222     case ItemPositionLeft: | 
 |  1223         // orthogonal modes make property and inline axes to be parallel, but in
       any case | 
 |  1224         // this is always equivalent to 'Start'. | 
 |  1225         // | 
 |  1226         // self-align's axis is never parallel to the inline axis, except in ort
      hogonal | 
 |  1227         // writing-mode, so this is equivalent to 'Start’. | 
 |  1228         return startOfRowForChild(child); | 
 |  1229  | 
 |  1230     case ItemPositionRight: | 
 |  1231         // orthogonal modes make property and inline axes to be parallel. | 
 |  1232         // FIXME: grid track sizing and positioning does not support orthogonal 
      modes yet. | 
 |  1233         if (hasOrthogonalWritingMode) | 
 |  1234             return endOfRowForChild(child); | 
 |  1235  | 
 |  1236         // self-align's axis is never parallel to the inline axis, except in ort
      hogonal | 
 |  1237         // writing-mode, so this is equivalent to 'Start'. | 
 |  1238         return startOfRowForChild(child); | 
 |  1239  | 
 |  1240     case ItemPositionCenter: | 
 |  1241         return centeredRowPositionForChild(child); | 
 |  1242         // Only used in flex layout, for other layout, it's equivalent to 'Start
      '. | 
 |  1243     case ItemPositionFlexStart: | 
 |  1244     case ItemPositionStart: | 
 |  1245         return startOfRowForChild(child); | 
 |  1246         // Only used in flex layout, for other layout, it's equivalent to 'End'. | 
 |  1247     case ItemPositionFlexEnd: | 
 |  1248     case ItemPositionEnd: | 
 |  1249         return endOfRowForChild(child); | 
 |  1250     case ItemPositionStretch: | 
 |  1251         // FIXME: Implement the Stretch value. For now, we always start align th
      e child. | 
 |  1252         return startOfRowForChild(child); | 
 |  1253     case ItemPositionBaseline: | 
 |  1254     case ItemPositionLastBaseline: | 
 |  1255         // FIXME: Implement the ItemPositionBaseline value. For now, we always s
      tart align the child. | 
 |  1256         return startOfRowForChild(child); | 
 |  1257     case ItemPositionAuto: | 
 |  1258         break; | 
 |  1259     } | 
 |  1260  | 
 |  1261     ASSERT_NOT_REACHED(); | 
 |  1262     return 0; | 
|  1156 } |  1263 } | 
|  1157  |  1264  | 
|  1158 LayoutPoint RenderGrid::findChildLogicalPosition(const RenderBox* child) const |  1265 LayoutPoint RenderGrid::findChildLogicalPosition(const RenderBox* child) const | 
|  1159 { |  1266 { | 
|  1160     return LayoutPoint(columnPositionForChild(child), rowPositionForChild(child)
      ); |  1267     return LayoutPoint(columnPositionForChild(child), rowPositionForChild(child)
      ); | 
|  1161 } |  1268 } | 
|  1162  |  1269  | 
|  1163 static GridSpan dirtiedGridAreas(const Vector<LayoutUnit>& coordinates, LayoutUn
      it start, LayoutUnit end) |  1270 static GridSpan dirtiedGridAreas(const Vector<LayoutUnit>& coordinates, LayoutUn
      it start, LayoutUnit end) | 
|  1164 { |  1271 { | 
|  1165     // This function does a binary search over the coordinates. |  1272     // This function does a binary search over the coordinates. | 
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1236     if (isOutOfFlowPositioned()) |  1343     if (isOutOfFlowPositioned()) | 
|  1237         return "RenderGrid (positioned)"; |  1344         return "RenderGrid (positioned)"; | 
|  1238     if (isAnonymous()) |  1345     if (isAnonymous()) | 
|  1239         return "RenderGrid (generated)"; |  1346         return "RenderGrid (generated)"; | 
|  1240     if (isRelPositioned()) |  1347     if (isRelPositioned()) | 
|  1241         return "RenderGrid (relative positioned)"; |  1348         return "RenderGrid (relative positioned)"; | 
|  1242     return "RenderGrid"; |  1349     return "RenderGrid"; | 
|  1243 } |  1350 } | 
|  1244  |  1351  | 
|  1245 } // namespace WebCore |  1352 } // namespace WebCore | 
| OLD | NEW |