Commit 3664c953 authored by Christian Biesinger's avatar Christian Biesinger Committed by Commit Bot

[layoutng] CalculateDefaultBlockSize can return too small values

It needs to return at least border_scrollbar_padding_, or else
this can lead to a DCHECK failure in ng_length_utils.cc

Found by running ScrollbarsTest.AutosizeAlmostRemovableScrollbar with
LayoutNG enabled.

R=ikilpatrick@chromium.org, mstensho@chromium.org

Change-Id: I9635ef98274bf573151756d19b3879fb6d33080a
Reviewed-on: https://chromium-review.googlesource.com/c/1330348Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607065}
parent a92288a8
...@@ -371,15 +371,15 @@ NGLogicalOffset NGBlockLayoutAlgorithm::CalculateLogicalOffset( ...@@ -371,15 +371,15 @@ NGLogicalOffset NGBlockLayoutAlgorithm::CalculateLogicalOffset(
scoped_refptr<NGLayoutResult> NGBlockLayoutAlgorithm::Layout() { scoped_refptr<NGLayoutResult> NGBlockLayoutAlgorithm::Layout() {
NGBoxStrut borders = ComputeBorders(ConstraintSpace(), Node()); NGBoxStrut borders = ComputeBorders(ConstraintSpace(), Node());
NGBoxStrut padding = ComputePadding(ConstraintSpace(), Style()); NGBoxStrut padding = ComputePadding(ConstraintSpace(), Style());
border_padding_ = borders + padding; border_padding_ = borders + padding;
NGLogicalSize border_box_size = CalculateBorderBoxSize(
ConstraintSpace(), Node(), CalculateDefaultBlockSize(), border_padding_);
NGBoxStrut scrollbars = Node().GetScrollbarSizes(); NGBoxStrut scrollbars = Node().GetScrollbarSizes();
border_scrollbar_padding_ = ConstraintSpace().IsAnonymous() border_scrollbar_padding_ = ConstraintSpace().IsAnonymous()
? NGBoxStrut() ? NGBoxStrut()
: border_padding_ + scrollbars; : border_padding_ + scrollbars;
NGLogicalSize border_box_size = CalculateBorderBoxSize(
ConstraintSpace(), Node(), CalculateDefaultBlockSize(), border_padding_);
child_available_size_ = child_available_size_ =
ShrinkAvailableSize(border_box_size, border_scrollbar_padding_); ShrinkAvailableSize(border_box_size, border_scrollbar_padding_);
...@@ -2299,7 +2299,8 @@ LayoutUnit NGBlockLayoutAlgorithm::CalculateDefaultBlockSize() { ...@@ -2299,7 +2299,8 @@ LayoutUnit NGBlockLayoutAlgorithm::CalculateDefaultBlockSize() {
if (Node().IsQuirkyAndFillsViewport()) { if (Node().IsQuirkyAndFillsViewport()) {
LayoutUnit block_size = ConstraintSpace().AvailableSize().block_size; LayoutUnit block_size = ConstraintSpace().AvailableSize().block_size;
block_size -= ComputeMarginsForSelf(ConstraintSpace(), Style()).BlockSum(); block_size -= ComputeMarginsForSelf(ConstraintSpace(), Style()).BlockSum();
return block_size.ClampNegativeToZero(); return std::max(block_size.ClampNegativeToZero(),
border_scrollbar_padding_.BlockSum());
} }
return NGSizeIndefinite; return NGSizeIndefinite;
} }
......
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