| 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 SubtreeLayoutScope layout_scope(*this); | 242 SubtreeLayoutScope layout_scope(*this); |
| 243 | 243 |
| 244 { | 244 { |
| 245 // LayoutState needs this deliberate scope to pop before updating scroll | 245 // LayoutState needs this deliberate scope to pop before updating scroll |
| 246 // information (which may trigger relayout). | 246 // information (which may trigger relayout). |
| 247 LayoutState state(*this); | 247 LayoutState state(*this); |
| 248 | 248 |
| 249 LayoutSize previous_size = Size(); | 249 LayoutSize previous_size = Size(); |
| 250 has_definite_logical_height_ = HasDefiniteLogicalHeight(); | 250 has_definite_logical_height_ = HasDefiniteLogicalHeight(); |
| 251 | 251 |
| 252 // We need to clear both own and containingBlock override sizes to | 252 // Grid's layout logic controls the grid item's override size, hence |
| 253 // ensure we get the same result when grid's intrinsic size is | 253 // we need to clear any override size set previously, so it doesn't |
| 254 // computed again in the updateLogicalWidth call bellow. | 254 // interfere in current layout execution. |
| 255 if (SizesLogicalWidthToFitContent(StyleRef().LogicalWidth()) || | 255 for (auto* child = FirstInFlowChildBox(); child; |
| 256 StyleRef().LogicalWidth().IsIntrinsicOrAuto()) { | 256 child = child->NextInFlowSiblingBox()) { |
| 257 for (auto* child = FirstInFlowChildBox(); child; | 257 child->ClearOverrideSize(); |
| 258 child = child->NextInFlowSiblingBox()) { | 258 if (!IsOrthogonalChild(*child) || |
| 259 if (!IsOrthogonalChild(*child)) | 259 (!SizesLogicalWidthToFitContent(StyleRef().LogicalWidth()) && |
| 260 continue; | 260 !StyleRef().LogicalWidth().IsIntrinsicOrAuto())) |
| 261 child->ClearOverrideSize(); | 261 continue; |
| 262 child->ClearContainingBlockOverrideSize(); | 262 // Additionally, we may need to clear containingBlock override sizes and |
| 263 child->ForceLayout(); | 263 // force a layout of the grid items to ensure we get the same result when |
| 264 } | 264 // grid's intrinsic size is computed again in the updateLogicalWidth call |
| 265 // bellow. |
| 266 child->ClearContainingBlockOverrideSize(); |
| 267 child->ForceLayout(); |
| 265 } | 268 } |
| 266 | 269 |
| 267 UpdateLogicalWidth(); | 270 UpdateLogicalWidth(); |
| 268 | 271 |
| 269 TextAutosizer::LayoutScope text_autosizer_layout_scope(this, &layout_scope); | 272 TextAutosizer::LayoutScope text_autosizer_layout_scope(this, &layout_scope); |
| 270 | 273 |
| 271 LayoutUnit available_space_for_columns = AvailableLogicalWidth(); | 274 LayoutUnit available_space_for_columns = AvailableLogicalWidth(); |
| 272 PlaceItemsOnGrid(grid_, available_space_for_columns); | 275 PlaceItemsOnGrid(grid_, available_space_for_columns); |
| 273 | 276 |
| 274 // 1- First, the track sizing algorithm is used to resolve the sizes of the | 277 // 1- First, the track sizing algorithm is used to resolve the sizes of the |
| (...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1569 const LayoutBox& child, | 1572 const LayoutBox& child, |
| 1570 GridTrackSizingDirection direction) const { | 1573 GridTrackSizingDirection direction) const { |
| 1571 return !IsOrthogonalChild(child) | 1574 return !IsOrthogonalChild(child) |
| 1572 ? direction | 1575 ? direction |
| 1573 : (direction == kForColumns ? kForRows : kForColumns); | 1576 : (direction == kForColumns ? kForRows : kForColumns); |
| 1574 } | 1577 } |
| 1575 | 1578 |
| 1576 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to | 1579 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to |
| 1577 // LayoutBox. | 1580 // LayoutBox. |
| 1578 void LayoutGrid::ApplyStretchAlignmentToChildIfNeeded(LayoutBox& child) { | 1581 void LayoutGrid::ApplyStretchAlignmentToChildIfNeeded(LayoutBox& child) { |
| 1579 // We clear height override values because we will decide now whether it's | |
| 1580 // allowed or not, evaluating the conditions which might have changed since | |
| 1581 // the old values were set. | |
| 1582 child.ClearOverrideLogicalContentHeight(); | |
| 1583 | |
| 1584 GridTrackSizingDirection child_block_direction = | 1582 GridTrackSizingDirection child_block_direction = |
| 1585 FlowAwareDirectionForChild(child, kForRows); | 1583 FlowAwareDirectionForChild(child, kForRows); |
| 1586 bool block_flow_is_column_axis = child_block_direction == kForRows; | 1584 bool block_flow_is_column_axis = child_block_direction == kForRows; |
| 1587 bool allowed_to_stretch_child_block_size = | 1585 bool allowed_to_stretch_child_block_size = |
| 1588 block_flow_is_column_axis ? AllowedToStretchChildAlongColumnAxis(child) | 1586 block_flow_is_column_axis ? AllowedToStretchChildAlongColumnAxis(child) |
| 1589 : AllowedToStretchChildAlongRowAxis(child); | 1587 : AllowedToStretchChildAlongRowAxis(child); |
| 1590 if (allowed_to_stretch_child_block_size) { | 1588 if (allowed_to_stretch_child_block_size) { |
| 1591 LayoutUnit stretched_logical_height = | 1589 LayoutUnit stretched_logical_height = |
| 1592 AvailableAlignmentSpaceForChildBeforeStretching( | 1590 AvailableAlignmentSpaceForChildBeforeStretching( |
| 1593 OverrideContainingBlockContentSizeForChild(child, | 1591 OverrideContainingBlockContentSizeForChild(child, |
| (...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2406 if (direction == kForRows) | 2404 if (direction == kForRows) |
| 2407 return grid.NumTracks(kForRows); | 2405 return grid.NumTracks(kForRows); |
| 2408 | 2406 |
| 2409 return grid.NumTracks(kForRows) | 2407 return grid.NumTracks(kForRows) |
| 2410 ? grid.NumTracks(kForColumns) | 2408 ? grid.NumTracks(kForColumns) |
| 2411 : GridPositionsResolver::ExplicitGridColumnCount( | 2409 : GridPositionsResolver::ExplicitGridColumnCount( |
| 2412 StyleRef(), grid.AutoRepeatTracks(kForColumns)); | 2410 StyleRef(), grid.AutoRepeatTracks(kForColumns)); |
| 2413 } | 2411 } |
| 2414 | 2412 |
| 2415 } // namespace blink | 2413 } // namespace blink |
| OLD | NEW |