Commit a048ad56 authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

[FlexNG] Add TextAutosizer::NGLayoutScope to the flex layout algorithm.

Fixes: fast/text-autosizing/cluster-inline-grid-flex-box.html

We weren't applying any of the text-autosizing logic. This adds the
correct scope so we can apply it.

Bug: 845235
Change-Id: Ie7496043f80959bad342a4fe7f8876a8a8eeb7b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037859
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739060}
parent 477d8d41
......@@ -31,7 +31,6 @@
#include "third_party/blink/renderer/core/layout/ng/ng_positioned_float.h"
#include "third_party/blink/renderer/core/layout/ng/ng_space_utils.h"
#include "third_party/blink/renderer/core/layout/ng/ng_unpositioned_float.h"
#include "third_party/blink/renderer/core/layout/text_autosizer.h"
#include "third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
......@@ -538,12 +537,6 @@ inline scoped_refptr<const NGLayoutResult> NGBlockLayoutAlgorithm::Layout(
if (node_.IsQuirkyContainer())
previous_inflow_position.margin_strut.is_quirky_container_start = true;
// Before we descend into children (but after we have determined our inline
// size), give the autosizer an opportunity to adjust the font size on the
// children.
TextAutosizer::NGLayoutScope text_autosizer_layout_scope(
Node(), border_box_size.inline_size);
// Try to reuse line box fragments from cached fragments if possible.
// When possible, this adds fragments to |container_builder_| and update
// |previous_inflow_position| and |BreakToken()|.
......
......@@ -45,6 +45,7 @@
#include "third_party/blink/renderer/core/layout/ng/ng_simplified_layout_algorithm.h"
#include "third_party/blink/renderer/core/layout/ng/ng_space_utils.h"
#include "third_party/blink/renderer/core/layout/shapes/shape_outside_info.h"
#include "third_party/blink/renderer/core/layout/text_autosizer.h"
#include "third_party/blink/renderer/core/mathml/mathml_element.h"
#include "third_party/blink/renderer/core/mathml/mathml_space_element.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
......@@ -346,6 +347,9 @@ scoped_refptr<const NGLayoutResult> NGBlockNode::Layout(
CalculateInitialFragmentGeometry(constraint_space, *this);
}
TextAutosizer::NGLayoutScope text_autosizer_layout_scope(
box_, fragment_geometry->border_box_size.inline_size);
PrepareForLayout();
NGLayoutAlgorithmParams params(*this, *fragment_geometry, constraint_space,
......
......@@ -52,7 +52,6 @@
#include "third_party/blink/renderer/core/layout/layout_table_cell.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/layout/ng/list/layout_ng_list_item.h"
#include "third_party/blink/renderer/core/layout/ng/ng_block_node.h"
#include "third_party/blink/renderer/core/layout/style_retain_scope.h"
#include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/page.h"
......@@ -1440,17 +1439,17 @@ TextAutosizer::DeferUpdatePageInfo::DeferUpdatePageInfo(Page* page)
}
}
TextAutosizer::NGLayoutScope::NGLayoutScope(const NGBlockNode& node,
TextAutosizer::NGLayoutScope::NGLayoutScope(LayoutBox* box,
LayoutUnit inline_size)
: text_autosizer_(node.GetLayoutBox()->GetDocument().GetTextAutosizer()),
block_(To<LayoutBlockFlow>(node.GetLayoutBox())) {
: text_autosizer_(box->GetDocument().GetTextAutosizer()), box_(box) {
// Bail if:
// - Text autosizing isn't enabled.
// - If the chid isn't a LayoutBlock.
// - If the child is a LayoutNGListMarker. (They are super-small blocks, and
// using them to determine if we should autosize the text will typically
// false, overriding whatever its parent has already correctly determined).
if (!text_autosizer_ || !text_autosizer_->ShouldHandleLayout() ||
block_->IsLayoutNGListMarker()) {
// Bail if text autosizing isn't enabled, but also if this is a
// IsLayoutNGListMarker. They are super-small blocks, and using them to
// determine if we should autosize the text will typically always yield
// false, overriding whatever its parent (typically the list item) has
// already correctly determined.
box_->IsLayoutNGListMarker() || !box_->IsLayoutBlock()) {
text_autosizer_ = nullptr;
return;
}
......@@ -1459,14 +1458,14 @@ TextAutosizer::NGLayoutScope::NGLayoutScope(const NGBlockNode& node,
// know the inline size of the block. So set it. LayoutNG normally writes back
// to the legacy tree *after* layout, but this one must be set before, at
// least if the autosizer is enabled.
block_->SetLogicalWidth(inline_size);
box_->SetLogicalWidth(inline_size);
text_autosizer_->BeginLayout(block_, nullptr);
text_autosizer_->BeginLayout(To<LayoutBlock>(box_), nullptr);
}
TextAutosizer::NGLayoutScope::~NGLayoutScope() {
if (text_autosizer_)
text_autosizer_->EndLayout(block_);
text_autosizer_->EndLayout(To<LayoutBlock>(box_));
}
TextAutosizer::DeferUpdatePageInfo::~DeferUpdatePageInfo() {
......
......@@ -47,11 +47,11 @@ class Document;
class Frame;
class IntSize;
class LayoutBlock;
class LayoutBox;
class LayoutNGTableInterface;
class LayoutObject;
class LayoutText;
class LocalFrame;
class NGBlockNode;
class Page;
class SubtreeLayoutScope;
......@@ -105,12 +105,12 @@ class CORE_EXPORT TextAutosizer final : public GarbageCollected<TextAutosizer> {
STACK_ALLOCATED();
public:
explicit NGLayoutScope(const NGBlockNode& node, LayoutUnit inline_size);
explicit NGLayoutScope(LayoutBox*, LayoutUnit inline_size);
~NGLayoutScope();
protected:
TextAutosizer* text_autosizer_;
LayoutBlock* block_;
LayoutBox* box_;
};
class CORE_EXPORT DeferUpdatePageInfo {
......
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