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

[LayoutNG] Move PrepareLayout to NGBlockNode::FirstChild

This isn't ideal, but it does make things faster.

A few more tests pass (don't timeout) only 1-2 additional failure.
So a net win?

Bug: 635619
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: Id95bdd4ebcfd2534dbbf07b50a730c9961349713
Reviewed-on: https://chromium-review.googlesource.com/726846
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#510224}
parent f5db82f1
......@@ -4009,7 +4009,7 @@ crbug.com/591099 fast/css/invalidation-errors-3.html [ Failure ]
crbug.com/591099 fast/css/invalidation-errors.html [ Failure ]
crbug.com/591099 fast/css/invalidation/fieldset-disabled.html [ Failure ]
crbug.com/591099 fast/css/invalidation/valid-invalid-pseudo.html [ Failure ]
crbug.com/591099 fast/css/large-numbers.html [ Failure Timeout ]
crbug.com/591099 fast/css/large-numbers.html [ Crash Failure ]
crbug.com/591099 fast/css/last-child-pseudo-class.html [ Failure ]
crbug.com/591099 fast/css/last-child-style-sharing.html [ Failure ]
crbug.com/591099 fast/css/last-of-type-pseudo-class.html [ Failure ]
......
......@@ -542,10 +542,6 @@ void NGInlineNode::ShapeTextForFirstLineIfNeeded() {
RefPtr<NGLayoutResult> NGInlineNode::Layout(
const NGConstraintSpace& constraint_space,
NGBreakToken* break_token) {
// TODO(kojii): Invalidate PrepareLayout() more efficiently.
InvalidatePrepareLayout();
PrepareLayout();
NGInlineLayoutAlgorithm algorithm(*this, constraint_space,
ToNGInlineBreakToken(break_token));
RefPtr<NGLayoutResult> result = algorithm.Layout();
......@@ -600,10 +596,6 @@ static LayoutUnit ComputeContentSize(NGInlineNode node,
}
MinMaxSize NGInlineNode::ComputeMinMaxSize() {
// TODO(kojii): Invalidate PrepareLayout() more efficiently.
InvalidatePrepareLayout();
PrepareLayout();
// Run line breaking with 0 and indefinite available width.
// TODO(kojii): There are several ways to make this more efficient and faster
......@@ -628,9 +620,6 @@ MinMaxSize NGInlineNode::ComputeMinMaxSize() {
}
NGLayoutInputNode NGInlineNode::NextSibling() {
// TODO(kojii): Invalidate PrepareLayout() more efficiently.
InvalidatePrepareLayout();
PrepareLayout();
return NGBlockNode(Data().next_sibling_);
}
......
......@@ -55,6 +55,10 @@ class CORE_EXPORT NGInlineNode : public NGLayoutInputNode {
// Instruct to re-compute |PrepareLayout| on the next layout.
void InvalidatePrepareLayout();
// Prepare inline and text content for layout. Must be called before
// calling the Layout method.
void PrepareLayout();
const String& Text() const { return Data().text_content_; }
StringView Text(unsigned start_offset, unsigned end_offset) const {
return StringView(Data().text_content_, start_offset,
......@@ -83,9 +87,6 @@ class CORE_EXPORT NGInlineNode : public NGLayoutInputNode {
String ToString() const;
protected:
// Prepare inline and text content for layout. Must be called before
// calling the Layout method.
void PrepareLayout();
bool IsPrepareLayoutFinished() const { return !Text().IsNull(); }
void CollectInlines();
......
......@@ -330,6 +330,7 @@ TEST_F(NGInlineNodeTest, MinMaxSize) {
LoadAhem();
SetupHtml("t", "<div id=t style='font:10px Ahem'>AB CDEF</div>");
NGInlineNodeForTest node = CreateInlineNode();
node.PrepareLayout();
MinMaxSize sizes = node.ComputeMinMaxSize();
EXPECT_EQ(40, sizes.min_size);
EXPECT_EQ(70, sizes.max_size);
......@@ -339,6 +340,7 @@ TEST_F(NGInlineNodeTest, MinMaxSizeElementBoundary) {
LoadAhem();
SetupHtml("t", "<div id=t style='font:10px Ahem'>A B<span>C D</span></div>");
NGInlineNodeForTest node = CreateInlineNode();
node.PrepareLayout();
MinMaxSize sizes = node.ComputeMinMaxSize();
// |min_content| should be the width of "BC" because there is an element
// boundary between "B" and "C" but no break opportunities.
......
......@@ -109,7 +109,7 @@ class CORE_EXPORT NGPhysicalTextFragment final : public NGPhysicalFragment {
private:
// The text of NGInlineNode; i.e., of a parent block. The text for this
// fragment is a substring(start_offset_, end_offset_) of this string.
const String& text_;
const String text_;
// Deprecating, ItemIndexDeprecated().
unsigned item_index_;
......
......@@ -250,8 +250,13 @@ NGLayoutInputNode NGBlockNode::FirstChild() {
auto* child = GetLayoutObjectForFirstChildNode(block);
if (!child)
return nullptr;
if (AreNGBlockFlowChildrenInline(block))
return NGInlineNode(block);
if (AreNGBlockFlowChildrenInline(block)) {
// TODO(kojii): Invalidate PrepareLayout() more efficiently.
NGInlineNode node(block);
node.InvalidatePrepareLayout();
node.PrepareLayout();
return node;
}
return NGBlockNode(ToLayoutBox(child));
}
......
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