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 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1256 LayoutUnit column_breadth = LayoutUnit(); | 1256 LayoutUnit column_breadth = LayoutUnit(); |
1257 OffsetAndBreadthForPositionedChild(*child, kForColumns, column_offset, | 1257 OffsetAndBreadthForPositionedChild(*child, kForColumns, column_offset, |
1258 column_breadth); | 1258 column_breadth); |
1259 LayoutUnit row_offset = LayoutUnit(); | 1259 LayoutUnit row_offset = LayoutUnit(); |
1260 LayoutUnit row_breadth = LayoutUnit(); | 1260 LayoutUnit row_breadth = LayoutUnit(); |
1261 OffsetAndBreadthForPositionedChild(*child, kForRows, row_offset, | 1261 OffsetAndBreadthForPositionedChild(*child, kForRows, row_offset, |
1262 row_breadth); | 1262 row_breadth); |
1263 | 1263 |
1264 child->SetOverrideContainingBlockContentLogicalWidth(column_breadth); | 1264 child->SetOverrideContainingBlockContentLogicalWidth(column_breadth); |
1265 child->SetOverrideContainingBlockContentLogicalHeight(row_breadth); | 1265 child->SetOverrideContainingBlockContentLogicalHeight(row_breadth); |
1266 child->SetExtraInlineOffset(column_offset); | |
1267 child->SetExtraBlockOffset(row_offset); | |
1268 | 1266 |
1269 if (child->Parent() == this) { | 1267 child->SetX(LayoutUnit()); |
1270 PaintLayer* child_layer = child->Layer(); | 1268 child->SetY(LayoutUnit()); |
svillar
2017/05/08 11:18:10
Why do we need this?
Manuel Rego
2017/05/08 13:29:44
Actually this is a leftover from a previous versio
| |
1271 child_layer->SetStaticInlinePosition(BorderStart() + column_offset); | 1269 |
1272 child_layer->SetStaticBlockPosition(BorderBefore() + row_offset); | 1270 // Mark for layout as we're resetting the position before and we relay in |
1273 } | 1271 // generic layout logic for positioned items in order to get the offsets |
1272 // properly resolved. | |
1273 SubtreeLayoutScope layout_scope(*child); | |
1274 layout_scope.SetChildNeedsLayout(child); | |
svillar
2017/05/08 11:18:10
Why are you using a SubtreeLayoutScope here? Would
Manuel Rego
2017/05/08 13:29:44
I just copied it from LayoutBlock::LayoutPositione
| |
1274 | 1275 |
1275 LayoutPositionedObject(child, relayout_children, info); | 1276 LayoutPositionedObject(child, relayout_children, info); |
1277 | |
1278 child->SetLogicalLocation(LayoutPoint(child->LogicalLeft() + column_offset, | |
1279 child->LogicalTop() + row_offset)); | |
1276 } | 1280 } |
1277 } | 1281 } |
1278 | 1282 |
1279 void LayoutGrid::OffsetAndBreadthForPositionedChild( | 1283 void LayoutGrid::OffsetAndBreadthForPositionedChild( |
1280 const LayoutBox& child, | 1284 const LayoutBox& child, |
1281 GridTrackSizingDirection direction, | 1285 GridTrackSizingDirection direction, |
1282 LayoutUnit& offset, | 1286 LayoutUnit& offset, |
1283 LayoutUnit& breadth) { | 1287 LayoutUnit& breadth) { |
1284 DCHECK(!IsOrthogonalChild(child)); | 1288 DCHECK(!IsOrthogonalChild(child)); |
1285 bool is_for_columns = direction == kForColumns; | 1289 bool is_for_columns = direction == kForColumns; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1357 DCHECK(!grid_.NeedsItemsPlacement()); | 1361 DCHECK(!grid_.NeedsItemsPlacement()); |
1358 end -= GuttersSize(grid_, direction, end_line - 1, 2, | 1362 end -= GuttersSize(grid_, direction, end_line - 1, 2, |
1359 available_size_for_gutters); | 1363 available_size_for_gutters); |
1360 end -= is_for_columns ? offset_between_columns_ : offset_between_rows_; | 1364 end -= is_for_columns ? offset_between_columns_ : offset_between_rows_; |
1361 } | 1365 } |
1362 } | 1366 } |
1363 | 1367 |
1364 breadth = std::max(end - start, LayoutUnit()); | 1368 breadth = std::max(end - start, LayoutUnit()); |
1365 offset = start; | 1369 offset = start; |
1366 | 1370 |
1367 if (is_for_columns && !StyleRef().IsLeftToRightDirection() && | 1371 if (is_for_columns && !StyleRef().IsLeftToRightDirection()) { |
1368 !child.StyleRef().HasStaticInlinePosition( | 1372 // We always want to calculate the static position from the left |
1369 child.IsHorizontalWritingMode())) { | |
1370 // If the child doesn't have a static inline position (i.e. "left" and/or | |
1371 // "right" aren't "auto", we need to calculate the offset from the left | |
1372 // (even if we're in RTL). | 1373 // (even if we're in RTL). |
1373 if (end_is_auto) { | 1374 if (end_is_auto) { |
1374 offset = LayoutUnit(); | 1375 offset = LayoutUnit(); |
1375 } else { | 1376 } else { |
1376 offset = TranslateRTLCoordinate(column_positions_[end_line]) - | 1377 offset = TranslateRTLCoordinate(column_positions_[end_line]) - |
1377 BorderLogicalLeft(); | 1378 BorderLogicalLeft(); |
1378 | 1379 |
1379 if (end_line > 0 && end_line < last_line) { | 1380 if (end_line > 0 && end_line < last_line) { |
1380 DCHECK(!grid_.NeedsItemsPlacement()); | 1381 DCHECK(!grid_.NeedsItemsPlacement()); |
1381 offset += GuttersSize(grid_, direction, end_line - 1, 2, | 1382 offset += GuttersSize(grid_, direction, end_line - 1, 2, |
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2404 if (direction == kForRows) | 2405 if (direction == kForRows) |
2405 return grid.NumTracks(kForRows); | 2406 return grid.NumTracks(kForRows); |
2406 | 2407 |
2407 return grid.NumTracks(kForRows) | 2408 return grid.NumTracks(kForRows) |
2408 ? grid.NumTracks(kForColumns) | 2409 ? grid.NumTracks(kForColumns) |
2409 : GridPositionsResolver::ExplicitGridColumnCount( | 2410 : GridPositionsResolver::ExplicitGridColumnCount( |
2410 StyleRef(), grid.AutoRepeatTracks(kForColumns)); | 2411 StyleRef(), grid.AutoRepeatTracks(kForColumns)); |
2411 } | 2412 } |
2412 | 2413 |
2413 } // namespace blink | 2414 } // namespace blink |
OLD | NEW |