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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutGrid.cpp

Issue 2832783003: [css-grid] Clearing the override height before layout (Closed)
Patch Set: Added test and some optimizations. Created 3 years, 8 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
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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // We need to clear both own and containingBlock override sizes to
237 // ensure we get the same result when grid's intrinsic size is 237 // ensure we get the same result when grid's intrinsic size is
238 // computed again in the updateLogicalWidth call bellow. 238 // computed again in the updateLogicalWidth call bellow.
239 if (SizesLogicalWidthToFitContent(StyleRef().LogicalWidth()) || 239 bool isContentSizedGrid =
240 StyleRef().LogicalWidth().IsIntrinsicOrAuto()) { 240 SizesLogicalWidthToFitContent(StyleRef().LogicalWidth()) ||
241 for (auto* child = FirstInFlowChildBox(); child; 241 StyleRef().LogicalWidth().IsIntrinsicOrAuto();
242 child = child->NextInFlowSiblingBox()) { 242 for (auto* child = FirstInFlowChildBox(); child;
243 if (!IsOrthogonalChild(*child)) 243 child = child->NextInFlowSiblingBox()) {
244 continue; 244 child->ClearOverrideSize();
245 child->ClearOverrideSize(); 245 if (!isContentSizedGrid || !IsOrthogonalChild(*child))
246 child->ClearContainingBlockOverrideSize(); 246 continue;
247 child->ForceLayout(); 247 child->ClearContainingBlockOverrideSize();
248 } 248 child->ForceLayout();
249 } 249 }
250 250
251 UpdateLogicalWidth(); 251 UpdateLogicalWidth();
252 has_definite_logical_height_ = HasDefiniteLogicalHeight(); 252 has_definite_logical_height_ = HasDefiniteLogicalHeight();
253 253
254 TextAutosizer::LayoutScope text_autosizer_layout_scope(this, &layout_scope); 254 TextAutosizer::LayoutScope text_autosizer_layout_scope(this, &layout_scope);
255 255
256 PlaceItemsOnGrid(grid_, kTrackSizing); 256 PlaceItemsOnGrid(grid_, kTrackSizing);
257 257
258 // 1- First, the track sizing algorithm is used to resolve the sizes of the 258 // 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
1520 const LayoutBox& child, 1520 const LayoutBox& child,
1521 GridTrackSizingDirection direction) const { 1521 GridTrackSizingDirection direction) const {
1522 return !IsOrthogonalChild(child) 1522 return !IsOrthogonalChild(child)
1523 ? direction 1523 ? direction
1524 : (direction == kForColumns ? kForRows : kForColumns); 1524 : (direction == kForColumns ? kForRows : kForColumns);
1525 } 1525 }
1526 1526
1527 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to 1527 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to
1528 // LayoutBox. 1528 // LayoutBox.
1529 void LayoutGrid::ApplyStretchAlignmentToChildIfNeeded(LayoutBox& child) { 1529 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 = 1530 GridTrackSizingDirection child_block_direction =
1536 FlowAwareDirectionForChild(child, kForRows); 1531 FlowAwareDirectionForChild(child, kForRows);
1537 bool block_flow_is_column_axis = child_block_direction == kForRows; 1532 bool block_flow_is_column_axis = child_block_direction == kForRows;
1538 bool allowed_to_stretch_child_block_size = 1533 bool allowed_to_stretch_child_block_size =
1539 block_flow_is_column_axis ? AllowedToStretchChildAlongColumnAxis(child) 1534 block_flow_is_column_axis ? AllowedToStretchChildAlongColumnAxis(child)
1540 : AllowedToStretchChildAlongRowAxis(child); 1535 : AllowedToStretchChildAlongRowAxis(child);
1541 if (allowed_to_stretch_child_block_size) { 1536 if (allowed_to_stretch_child_block_size) {
1542 LayoutUnit stretched_logical_height = 1537 LayoutUnit stretched_logical_height =
1543 AvailableAlignmentSpaceForChildBeforeStretching( 1538 AvailableAlignmentSpaceForChildBeforeStretching(
1544 OverrideContainingBlockContentSizeForChild(child, 1539 OverrideContainingBlockContentSizeForChild(child,
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
2357 if (direction == kForRows) 2352 if (direction == kForRows)
2358 return grid.NumTracks(kForRows); 2353 return grid.NumTracks(kForRows);
2359 2354
2360 return grid.NumTracks(kForRows) 2355 return grid.NumTracks(kForRows)
2361 ? grid.NumTracks(kForColumns) 2356 ? grid.NumTracks(kForColumns)
2362 : GridPositionsResolver::ExplicitGridColumnCount( 2357 : GridPositionsResolver::ExplicitGridColumnCount(
2363 StyleRef(), grid.AutoRepeatTracks(kForColumns)); 2358 StyleRef(), grid.AutoRepeatTracks(kForColumns));
2364 } 2359 }
2365 2360
2366 } // namespace blink 2361 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698