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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 | 226 |
227 SubtreeLayoutScope layout_scope(*this); | 227 SubtreeLayoutScope layout_scope(*this); |
228 | 228 |
229 { | 229 { |
230 // LayoutState needs this deliberate scope to pop before updating scroll | 230 // LayoutState needs this deliberate scope to pop before updating scroll |
231 // information (which may trigger relayout). | 231 // information (which may trigger relayout). |
232 LayoutState state(*this); | 232 LayoutState state(*this); |
233 | 233 |
234 LayoutSize previous_size = Size(); | 234 LayoutSize previous_size = Size(); |
235 | 235 |
236 // We need to clear both own and containingBlock override sizes to | 236 // Grid's layout logic controls the grid item's override size, so |
237 // ensure we get the same result when grid's intrinsic size is | 237 // we need to clear any override size set previously, so it doesn't |
238 // computed again in the updateLogicalWidth call bellow. | 238 // interfere in current layout execution. |
Manuel Rego
2017/04/28 09:51:16
Thanks for the new comment!
Nit: the two "so" sou
| |
239 if (SizesLogicalWidthToFitContent(StyleRef().LogicalWidth()) || | 239 for (auto* child = FirstInFlowChildBox(); child; |
240 StyleRef().LogicalWidth().IsIntrinsicOrAuto()) { | 240 child = child->NextInFlowSiblingBox()) { |
241 for (auto* child = FirstInFlowChildBox(); child; | 241 child->ClearOverrideSize(); |
242 child = child->NextInFlowSiblingBox()) { | 242 if (!IsOrthogonalChild(*child) || |
243 if (!IsOrthogonalChild(*child)) | 243 (!SizesLogicalWidthToFitContent(StyleRef().LogicalWidth()) && |
244 continue; | 244 !StyleRef().LogicalWidth().IsIntrinsicOrAuto())) |
245 child->ClearOverrideSize(); | 245 continue; |
246 child->ClearContainingBlockOverrideSize(); | 246 // Additionally, we may need to clear containingBlock override sizes and |
247 child->ForceLayout(); | 247 // force a layout of the grid items to ensure we get the same result when |
248 } | 248 // grid's intrinsic size is computed again in the updateLogicalWidth call |
249 // bellow. | |
250 child->ClearContainingBlockOverrideSize(); | |
251 child->ForceLayout(); | |
svillar
2017/04/28 15:33:31
I know this forced layout was already there in ord
| |
249 } | 252 } |
250 | 253 |
251 UpdateLogicalWidth(); | 254 UpdateLogicalWidth(); |
252 has_definite_logical_height_ = HasDefiniteLogicalHeight(); | 255 has_definite_logical_height_ = HasDefiniteLogicalHeight(); |
253 | 256 |
254 TextAutosizer::LayoutScope text_autosizer_layout_scope(this, &layout_scope); | 257 TextAutosizer::LayoutScope text_autosizer_layout_scope(this, &layout_scope); |
255 | 258 |
256 PlaceItemsOnGrid(grid_, kTrackSizing); | 259 PlaceItemsOnGrid(grid_, kTrackSizing); |
257 | 260 |
258 // 1- First, the track sizing algorithm is used to resolve the sizes of the | 261 // 1- First, the track sizing algorithm is used to resolve the sizes of the |
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1520 const LayoutBox& child, | 1523 const LayoutBox& child, |
1521 GridTrackSizingDirection direction) const { | 1524 GridTrackSizingDirection direction) const { |
1522 return !IsOrthogonalChild(child) | 1525 return !IsOrthogonalChild(child) |
1523 ? direction | 1526 ? direction |
1524 : (direction == kForColumns ? kForRows : kForColumns); | 1527 : (direction == kForColumns ? kForRows : kForColumns); |
1525 } | 1528 } |
1526 | 1529 |
1527 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to | 1530 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to |
1528 // LayoutBox. | 1531 // LayoutBox. |
1529 void LayoutGrid::ApplyStretchAlignmentToChildIfNeeded(LayoutBox& child) { | 1532 void LayoutGrid::ApplyStretchAlignmentToChildIfNeeded(LayoutBox& child) { |
1530 // We clear height override values because we will decide now whether it's | |
1531 // allowed or not, evaluating the conditions which might have changed since | |
1532 // the old values were set. | |
1533 child.ClearOverrideLogicalContentHeight(); | |
1534 | |
1535 GridTrackSizingDirection child_block_direction = | 1533 GridTrackSizingDirection child_block_direction = |
1536 FlowAwareDirectionForChild(child, kForRows); | 1534 FlowAwareDirectionForChild(child, kForRows); |
1537 bool block_flow_is_column_axis = child_block_direction == kForRows; | 1535 bool block_flow_is_column_axis = child_block_direction == kForRows; |
1538 bool allowed_to_stretch_child_block_size = | 1536 bool allowed_to_stretch_child_block_size = |
1539 block_flow_is_column_axis ? AllowedToStretchChildAlongColumnAxis(child) | 1537 block_flow_is_column_axis ? AllowedToStretchChildAlongColumnAxis(child) |
1540 : AllowedToStretchChildAlongRowAxis(child); | 1538 : AllowedToStretchChildAlongRowAxis(child); |
1541 if (allowed_to_stretch_child_block_size) { | 1539 if (allowed_to_stretch_child_block_size) { |
1542 LayoutUnit stretched_logical_height = | 1540 LayoutUnit stretched_logical_height = |
1543 AvailableAlignmentSpaceForChildBeforeStretching( | 1541 AvailableAlignmentSpaceForChildBeforeStretching( |
1544 OverrideContainingBlockContentSizeForChild(child, | 1542 OverrideContainingBlockContentSizeForChild(child, |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2357 if (direction == kForRows) | 2355 if (direction == kForRows) |
2358 return grid.NumTracks(kForRows); | 2356 return grid.NumTracks(kForRows); |
2359 | 2357 |
2360 return grid.NumTracks(kForRows) | 2358 return grid.NumTracks(kForRows) |
2361 ? grid.NumTracks(kForColumns) | 2359 ? grid.NumTracks(kForColumns) |
2362 : GridPositionsResolver::ExplicitGridColumnCount( | 2360 : GridPositionsResolver::ExplicitGridColumnCount( |
2363 StyleRef(), grid.AutoRepeatTracks(kForColumns)); | 2361 StyleRef(), grid.AutoRepeatTracks(kForColumns)); |
2364 } | 2362 } |
2365 | 2363 |
2366 } // namespace blink | 2364 } // namespace blink |
OLD | NEW |