Commit 3b8c952b authored by Christian Biesinger's avatar Christian Biesinger Committed by Commit Bot

[layoutng] Cache min/max content size in ComputeInlineSizeForFragment

This also required fixing the relayout when the scrollbar changes, which fixes
css3/flexbox/scrollbars-auto.html (and avoids breaking two tests in
external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/flexbox)

Bug: 635619

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng;luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I790f0524b029a3c2340b6b9715c5b3529c75357f
Reviewed-on: https://chromium-review.googlesource.com/1162657
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582464}
parent fb68785c
......@@ -68,7 +68,6 @@ crbug.com/591099 css3/flexbox/bug646288.html [ Failure ]
crbug.com/591099 css3/flexbox/flex-flow-margins-auto-size.html [ Failure ]
crbug.com/591099 css3/flexbox/intrinsic-width-orthogonal-writing-mode.html [ Failure ]
crbug.com/591099 css3/flexbox/line-wrapping.html [ Failure ]
crbug.com/591099 css3/flexbox/scrollbars-auto.html [ Failure ]
crbug.com/714962 css3/masking/clip-path-reference-box-inline.html [ Failure ]
crbug.com/591099 editing/selection/paint-hyphen.html [ Pass ]
crbug.com/591099 external/wpt/2dcontext/drawing-images-to-the-canvas/drawimage_html_image_11.html [ Pass ]
......
......@@ -29,6 +29,7 @@
#include "third_party/blink/renderer/core/layout/ng/ng_page_layout_algorithm.h"
#include "third_party/blink/renderer/core/layout/shapes/shape_outside_info.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/text/writing_mode.h"
......@@ -241,8 +242,20 @@ scoped_refptr<NGLayoutResult> NGBlockNode::Layout(
box_->ComputePreferredLogicalWidths();
}
bool preferred_logical_widths_were_dirty =
box_->PreferredLogicalWidthsDirty();
layout_result = LayoutWithAlgorithm(*this, constraint_space, break_token,
/* ignored */ nullptr);
if (!preferred_logical_widths_were_dirty &&
box_->PreferredLogicalWidthsDirty()) {
// The only thing that should dirty preferred widths at this point is the
// addition of overflow:auto scrollbars in a descendant. To avoid a
// potential infinite loop, run layout again with auto scrollbars frozen in
// their current state.
PaintLayerScrollableArea::FreezeScrollbarsScope freeze_scrollbars;
layout_result = LayoutWithAlgorithm(*this, constraint_space, break_token,
/* ignored */ nullptr);
}
if (block_flow) {
block_flow->SetCachedLayoutResult(constraint_space, break_token,
layout_result);
......
......@@ -430,6 +430,10 @@ LayoutUnit ComputeInlineSizeForFragment(const NGConstraintSpace& space,
} else {
min_and_max = node.ComputeMinMaxSize(space.GetWritingMode(),
MinMaxSizeInput(), &space);
// Cache these computed values
MinMaxSize contribution = ComputeMinAndMaxContentContribution(
style.GetWritingMode(), style, min_and_max);
box->SetPreferredLogicalWidthsFromNG(contribution);
}
}
......
......@@ -957,46 +957,47 @@ void PaintLayerScrollableArea::UpdateAfterLayout() {
GetLayoutBox()->GetDocument().SetAnnotatedRegionsDirty(true);
// Our proprietary overflow: overlay value doesn't trigger a layout.
// If the box is managed by LayoutNG, don't go here. We don't want to
// re-enter the NG layout algorithm for this box from here.
if (((horizontal_scrollbar_should_change &&
GetLayoutBox()->StyleRef().OverflowX() != EOverflow::kOverlay) ||
(vertical_scrollbar_should_change &&
GetLayoutBox()->StyleRef().OverflowY() != EOverflow::kOverlay)) &&
!IsManagedByLayoutNG(*GetLayoutBox())) {
GetLayoutBox()->StyleRef().OverflowY() != EOverflow::kOverlay))) {
if ((vertical_scrollbar_should_change &&
GetLayoutBox()->IsHorizontalWritingMode()) ||
(horizontal_scrollbar_should_change &&
!GetLayoutBox()->IsHorizontalWritingMode())) {
GetLayoutBox()->SetPreferredLogicalWidthsDirty();
}
if (PreventRelayoutScope::RelayoutIsPrevented()) {
// We're not doing re-layout right now, but we still want to
// add the scrollbar to the logical width now, to facilitate parent
// layout.
GetLayoutBox()->UpdateLogicalWidth();
PreventRelayoutScope::SetBoxNeedsLayout(*this, had_horizontal_scrollbar,
had_vertical_scrollbar);
} else {
in_overflow_relayout_ = true;
SubtreeLayoutScope layout_scope(*GetLayoutBox());
layout_scope.SetNeedsLayout(
GetLayoutBox(), LayoutInvalidationReason::kScrollbarChanged);
if (GetLayoutBox()->IsLayoutBlock()) {
LayoutBlock* block = ToLayoutBlock(GetLayoutBox());
block->ScrollbarsChanged(horizontal_scrollbar_should_change,
vertical_scrollbar_should_change);
block->UpdateBlockLayout(true);
// If the box is managed by LayoutNG, don't go here. We don't want to
// re-enter the NG layout algorithm for this box from here.
if (!IsManagedByLayoutNG(*GetLayoutBox())) {
if (PreventRelayoutScope::RelayoutIsPrevented()) {
// We're not doing re-layout right now, but we still want to
// add the scrollbar to the logical width now, to facilitate parent
// layout.
GetLayoutBox()->UpdateLogicalWidth();
PreventRelayoutScope::SetBoxNeedsLayout(
*this, had_horizontal_scrollbar, had_vertical_scrollbar);
} else {
GetLayoutBox()->UpdateLayout();
in_overflow_relayout_ = true;
SubtreeLayoutScope layout_scope(*GetLayoutBox());
layout_scope.SetNeedsLayout(
GetLayoutBox(), LayoutInvalidationReason::kScrollbarChanged);
if (GetLayoutBox()->IsLayoutBlock()) {
LayoutBlock* block = ToLayoutBlock(GetLayoutBox());
block->ScrollbarsChanged(horizontal_scrollbar_should_change,
vertical_scrollbar_should_change);
block->UpdateBlockLayout(true);
} else {
GetLayoutBox()->UpdateLayout();
}
in_overflow_relayout_ = false;
scrollbar_manager_.DestroyDetachedScrollbars();
}
LayoutObject* parent = GetLayoutBox()->Parent();
if (parent && parent->IsFlexibleBox()) {
ToLayoutFlexibleBox(parent)->ClearCachedMainSizeForChild(
*GetLayoutBox());
}
in_overflow_relayout_ = false;
scrollbar_manager_.DestroyDetachedScrollbars();
}
LayoutObject* parent = GetLayoutBox()->Parent();
if (parent && parent->IsFlexibleBox()) {
ToLayoutFlexibleBox(parent)->ClearCachedMainSizeForChild(
*GetLayoutBox());
}
}
}
......
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