Commit 092113c3 authored by Manuel Rego Casasnovas's avatar Manuel Rego Casasnovas Committed by Commit Bot

[css-grid] Initialize OverrideContainingBlock size for grid items

This patch removes the grid logic from
LayoutBox::ContainingBlockLogicalWidth|HeightForContent().
Instead it initializes the OverrideContainingBlock size to zero
in LayoutGrid::UpdateBlockLayout().

For grid items we don't want to use the grid container size
(which would be the regular containing block size),
so we want to use the overridden value.
And while we don't have such value, it's better we use zero
(so percentages are not resolved against the wrong thing).

This change is covered by existent tests.

Change-Id: If6a96abe7148203a2cdb9ffb2b9dd487239f7aae
Reviewed-on: https://chromium-review.googlesource.com/989734
Commit-Queue: Manuel Rego Casasnovas <rego@igalia.com>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarSergio Villar <svillar@igalia.com>
Cr-Commit-Position: refs/heads/master@{#549461}
parent cc28fa94
...@@ -2073,12 +2073,6 @@ LayoutUnit LayoutBox::ContainingBlockLogicalWidthForContent() const { ...@@ -2073,12 +2073,6 @@ LayoutUnit LayoutBox::ContainingBlockLogicalWidthForContent() const {
if (HasOverrideContainingBlockLogicalWidth()) if (HasOverrideContainingBlockLogicalWidth())
return OverrideContainingBlockContentLogicalWidth(); return OverrideContainingBlockContentLogicalWidth();
// TODO(rego): Probably this should be done directly in
// HasOverrideContainingBlockLogicalWidth(), but that would imply more changes
// in other parts of the code so leaving it for a follow-up patch.
if (IsGridItem())
return LayoutUnit();
LayoutBlock* cb = ContainingBlock(); LayoutBlock* cb = ContainingBlock();
if (IsOutOfFlowPositioned()) if (IsOutOfFlowPositioned())
return cb->ClientLogicalWidth(); return cb->ClientLogicalWidth();
...@@ -2090,12 +2084,6 @@ LayoutUnit LayoutBox::ContainingBlockLogicalHeightForContent( ...@@ -2090,12 +2084,6 @@ LayoutUnit LayoutBox::ContainingBlockLogicalHeightForContent(
if (HasOverrideContainingBlockLogicalHeight()) if (HasOverrideContainingBlockLogicalHeight())
return OverrideContainingBlockContentLogicalHeight(); return OverrideContainingBlockContentLogicalHeight();
// TODO(rego): Probably this should be done directly in
// HasOverrideContainingBlockLogicalHeight(), but that would imply more
// changes in other parts of the code so leaving it for a follow-up patch.
if (IsGridItem())
return LayoutUnit();
LayoutBlock* cb = ContainingBlock(); LayoutBlock* cb = ContainingBlock();
return cb->AvailableLogicalHeight(height_type); return cb->AvailableLogicalHeight(height_type);
} }
......
...@@ -323,8 +323,11 @@ void LayoutGrid::UpdateBlockLayout(bool relayout_children) { ...@@ -323,8 +323,11 @@ void LayoutGrid::UpdateBlockLayout(bool relayout_children) {
// we need to clear any override size set previously, so it doesn't // we need to clear any override size set previously, so it doesn't
// interfere in current layout execution. // interfere in current layout execution.
for (auto* child = FirstInFlowChildBox(); child; for (auto* child = FirstInFlowChildBox(); child;
child = child->NextInFlowSiblingBox()) child = child->NextInFlowSiblingBox()) {
child->ClearOverrideSize(); child->ClearOverrideSize();
child->SetOverrideContainingBlockContentLogicalWidth(LayoutUnit());
child->SetOverrideContainingBlockContentLogicalHeight(LayoutUnit());
}
UpdateLogicalWidth(); UpdateLogicalWidth();
...@@ -1182,23 +1185,14 @@ void LayoutGrid::LayoutGridItems() { ...@@ -1182,23 +1185,14 @@ void LayoutGrid::LayoutGridItems() {
// Because the grid area cannot be styled, we don't need to adjust // Because the grid area cannot be styled, we don't need to adjust
// the grid breadth to account for 'box-sizing'. // the grid breadth to account for 'box-sizing'.
LayoutUnit old_override_containing_block_content_logical_width =
child->HasOverrideContainingBlockLogicalWidth()
? child->OverrideContainingBlockContentLogicalWidth()
: LayoutUnit();
LayoutUnit old_override_containing_block_content_logical_height =
child->HasOverrideContainingBlockLogicalHeight()
? child->OverrideContainingBlockContentLogicalHeight()
: LayoutUnit();
LayoutUnit override_containing_block_content_logical_width = LayoutUnit override_containing_block_content_logical_width =
GridAreaBreadthForChildIncludingAlignmentOffsets(*child, kForColumns); GridAreaBreadthForChildIncludingAlignmentOffsets(*child, kForColumns);
LayoutUnit override_containing_block_content_logical_height = LayoutUnit override_containing_block_content_logical_height =
GridAreaBreadthForChildIncludingAlignmentOffsets(*child, kForRows); GridAreaBreadthForChildIncludingAlignmentOffsets(*child, kForRows);
if (old_override_containing_block_content_logical_width != if (child->OverrideContainingBlockContentLogicalWidth() !=
override_containing_block_content_logical_width || override_containing_block_content_logical_width ||
(old_override_containing_block_content_logical_height != (child->OverrideContainingBlockContentLogicalHeight() !=
override_containing_block_content_logical_height && override_containing_block_content_logical_height &&
child->HasRelativeLogicalHeight())) child->HasRelativeLogicalHeight()))
child->SetNeedsLayout(LayoutInvalidationReason::kGridChanged); child->SetNeedsLayout(LayoutInvalidationReason::kGridChanged);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment