Commit 2093cb98 authored by Christian Biesinger's avatar Christian Biesinger Committed by Commit Bot

[layoutng] Re-introduce optimization

This implements a previously skipped optimization in a different
way for flexbox with NG children.

Adding css3/flexbox/bug646288.html to expectations because it seems like
that passed by accident; it does not use percentages.

Bug: 839661

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: I910b18f24d9d7a27d25f2d9bbd00bc585a3c5516
Reviewed-on: https://chromium-review.googlesource.com/1051005
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557353}
parent 6b389690
...@@ -157,6 +157,7 @@ crbug.com/591099 css3/filters/effect-brightness-clamping.html [ Failure ] ...@@ -157,6 +157,7 @@ crbug.com/591099 css3/filters/effect-brightness-clamping.html [ Failure ]
crbug.com/591099 css3/filters/effect-brightness.html [ Failure ] crbug.com/591099 css3/filters/effect-brightness.html [ Failure ]
crbug.com/714962 css3/filters/effect-reference-zoom-hw.html [ Failure ] crbug.com/714962 css3/filters/effect-reference-zoom-hw.html [ Failure ]
crbug.com/591099 css3/filters/multiple-references-id-mutate-crash-2.html [ Crash ] crbug.com/591099 css3/filters/multiple-references-id-mutate-crash-2.html [ Crash ]
crbug.com/591099 css3/flexbox/bug646288.html [ Failure ]
crbug.com/591099 css3/flexbox/bug669714.html [ Failure ] crbug.com/591099 css3/flexbox/bug669714.html [ Failure ]
crbug.com/591099 css3/flexbox/flex-flow-border.html [ Failure ] crbug.com/591099 css3/flexbox/flex-flow-border.html [ Failure ]
crbug.com/591099 css3/flexbox/flex-flow-margins-auto-size.html [ Failure ] crbug.com/591099 css3/flexbox/flex-flow-margins-auto-size.html [ Failure ]
......
...@@ -2514,6 +2514,10 @@ scoped_refptr<NGLayoutResult> LayoutBlockFlow::CachedLayoutResult( ...@@ -2514,6 +2514,10 @@ scoped_refptr<NGLayoutResult> LayoutBlockFlow::CachedLayoutResult(
return nullptr; return nullptr;
} }
const NGConstraintSpace* LayoutBlockFlow::CachedConstraintSpace() const {
return nullptr;
}
scoped_refptr<NGLayoutResult> LayoutBlockFlow::CachedLayoutResultForTesting() { scoped_refptr<NGLayoutResult> LayoutBlockFlow::CachedLayoutResultForTesting() {
return nullptr; return nullptr;
} }
......
...@@ -458,6 +458,7 @@ class CORE_EXPORT LayoutBlockFlow : public LayoutBlock { ...@@ -458,6 +458,7 @@ class CORE_EXPORT LayoutBlockFlow : public LayoutBlock {
virtual scoped_refptr<NGLayoutResult> CachedLayoutResult( virtual scoped_refptr<NGLayoutResult> CachedLayoutResult(
const NGConstraintSpace&, const NGConstraintSpace&,
NGBreakToken*) const; NGBreakToken*) const;
virtual const NGConstraintSpace* CachedConstraintSpace() const;
virtual scoped_refptr<NGLayoutResult> CachedLayoutResultForTesting(); virtual scoped_refptr<NGLayoutResult> CachedLayoutResultForTesting();
virtual void SetCachedLayoutResult(const NGConstraintSpace&, virtual void SetCachedLayoutResult(const NGConstraintSpace&,
NGBreakToken*, NGBreakToken*,
......
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#include "third_party/blink/renderer/core/layout/layout_state.h" #include "third_party/blink/renderer/core/layout/layout_state.h"
#include "third_party/blink/renderer/core/layout/layout_view.h" #include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/layout/min_max_size.h" #include "third_party/blink/renderer/core/layout/min_max_size.h"
#include "third_party/blink/renderer/core/layout/ng/layout_ng_mixin.h"
#include "third_party/blink/renderer/core/layout/ng/ng_constraint_space.h"
#include "third_party/blink/renderer/core/layout/text_autosizer.h" #include "third_party/blink/renderer/core/layout/text_autosizer.h"
#include "third_party/blink/renderer/core/paint/block_painter.h" #include "third_party/blink/renderer/core/paint/block_painter.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h" #include "third_party/blink/renderer/core/paint/paint_layer.h"
...@@ -825,6 +827,30 @@ void LayoutFlexibleBox::ClearCachedMainSizeForChild(const LayoutBox& child) { ...@@ -825,6 +827,30 @@ void LayoutFlexibleBox::ClearCachedMainSizeForChild(const LayoutBox& child) {
intrinsic_size_along_main_axis_.erase(&child); intrinsic_size_along_main_axis_.erase(&child);
} }
bool LayoutFlexibleBox::ShouldForceLayoutForNGChild(
const LayoutBlockFlow& child) const {
// If the last layout was done with a different override size,
// or different definite-ness, we need to force-relayout so
// that percentage sizes are resolved correctly.
const NGConstraintSpace* old_space = child.CachedConstraintSpace();
if (!old_space)
return true;
if (old_space->IsFixedSizeInline() != child.HasOverrideLogicalWidth())
return true;
if (old_space->IsFixedSizeBlock() != child.HasOverrideLogicalHeight())
return true;
if (old_space->FixedSizeBlockIsDefinite() !=
UseOverrideLogicalHeightForPerentageResolution(child))
return true;
if (child.HasOverrideLogicalWidth() &&
old_space->AvailableSize().inline_size != child.OverrideLogicalWidth())
return true;
if (child.HasOverrideLogicalHeight() &&
old_space->AvailableSize().block_size != child.OverrideLogicalHeight())
return true;
return false;
}
DISABLE_CFI_PERF DISABLE_CFI_PERF
LayoutUnit LayoutFlexibleBox::ComputeInnerFlexBaseSizeForChild( LayoutUnit LayoutFlexibleBox::ComputeInnerFlexBaseSizeForChild(
LayoutBox& child, LayoutBox& child,
...@@ -1464,12 +1490,10 @@ void LayoutFlexibleBox::LayoutLineItems(FlexLine* current_line, ...@@ -1464,12 +1490,10 @@ void LayoutFlexibleBox::LayoutLineItems(FlexLine* current_line,
} }
// We may have already forced relayout for orthogonal flowing children in // We may have already forced relayout for orthogonal flowing children in
// computeInnerFlexBaseSizeForChild. // computeInnerFlexBaseSizeForChild.
// TODO(crbug.com/839661): LayoutNG does not correctly set
// HasPercentHeightDescendants(), so we need to bypass this optimization
// for now.
bool force_child_relayout = bool force_child_relayout =
relayout_children && !relaid_out_children_.Contains(child); relayout_children && !relaid_out_children_.Contains(child);
if (RuntimeEnabledFeatures::LayoutNGEnabled() || if ((child->IsLayoutNGMixin() &&
ShouldForceLayoutForNGChild(ToLayoutBlockFlow(*child))) ||
(child->IsLayoutBlock() && (child->IsLayoutBlock() &&
ToLayoutBlock(*child).HasPercentHeightDescendants())) { ToLayoutBlock(*child).HasPercentHeightDescendants())) {
// Have to force another relayout even though the child is sized // Have to force another relayout even though the child is sized
......
...@@ -158,6 +158,7 @@ class CORE_EXPORT LayoutFlexibleBox : public LayoutBlock { ...@@ -158,6 +158,7 @@ class CORE_EXPORT LayoutFlexibleBox : public LayoutBlock {
EOverflow MainAxisOverflowForChild(const LayoutBox& child) const; EOverflow MainAxisOverflowForChild(const LayoutBox& child) const;
EOverflow CrossAxisOverflowForChild(const LayoutBox& child) const; EOverflow CrossAxisOverflowForChild(const LayoutBox& child) const;
void CacheChildMainSize(const LayoutBox& child); void CacheChildMainSize(const LayoutBox& child);
bool ShouldForceLayoutForNGChild(const LayoutBlockFlow& child) const;
void LayoutFlexItems(bool relayout_children, SubtreeLayoutScope&); void LayoutFlexItems(bool relayout_children, SubtreeLayoutScope&);
LayoutUnit AutoMarginOffsetInMainAxis(const Vector<FlexItem>&, LayoutUnit AutoMarginOffsetInMainAxis(const Vector<FlexItem>&,
......
...@@ -167,6 +167,11 @@ scoped_refptr<NGLayoutResult> LayoutNGMixin<Base>::CachedLayoutResult( ...@@ -167,6 +167,11 @@ scoped_refptr<NGLayoutResult> LayoutNGMixin<Base>::CachedLayoutResult(
return cached_result_->CloneWithoutOffset(); return cached_result_->CloneWithoutOffset();
} }
template <typename Base>
const NGConstraintSpace* LayoutNGMixin<Base>::CachedConstraintSpace() const {
return cached_constraint_space_.get();
}
template <typename Base> template <typename Base>
void LayoutNGMixin<Base>::SetCachedLayoutResult( void LayoutNGMixin<Base>::SetCachedLayoutResult(
const NGConstraintSpace& constraint_space, const NGConstraintSpace& constraint_space,
......
...@@ -58,6 +58,7 @@ class CORE_TEMPLATE_CLASS_EXPORT LayoutNGMixin : public Base { ...@@ -58,6 +58,7 @@ class CORE_TEMPLATE_CLASS_EXPORT LayoutNGMixin : public Base {
scoped_refptr<NGLayoutResult> CachedLayoutResult( scoped_refptr<NGLayoutResult> CachedLayoutResult(
const NGConstraintSpace&, const NGConstraintSpace&,
NGBreakToken*) const override; NGBreakToken*) const override;
const NGConstraintSpace* CachedConstraintSpace() const override;
void SetCachedLayoutResult(const NGConstraintSpace&, void SetCachedLayoutResult(const NGConstraintSpace&,
NGBreakToken*, NGBreakToken*,
......
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