Commit 76abb339 authored by Emil A Eklund's avatar Emil A Eklund Committed by Commit Bot

[LayoutNG] Move legacy tree population logic

Move the logic in NGInlineNode that populates the legacy layout tree out
of NGInlineNode and into the new NGInlineNodeLegacy class.

Bug: 591099
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: I7d228a1c9b1c28f301838336ecc1348eacb6e663
Reviewed-on: https://chromium-review.googlesource.com/898003Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Emil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533876}
parent 732dc6cb
...@@ -356,6 +356,8 @@ blink_core_sources("layout") { ...@@ -356,6 +356,8 @@ blink_core_sources("layout") {
"ng/inline/ng_inline_node.h", "ng/inline/ng_inline_node.h",
"ng/inline/ng_inline_node_data.cc", "ng/inline/ng_inline_node_data.cc",
"ng/inline/ng_inline_node_data.h", "ng/inline/ng_inline_node_data.h",
"ng/inline/ng_inline_node_legacy.cc",
"ng/inline/ng_inline_node_legacy.h",
"ng/inline/ng_line_box_fragment.cc", "ng/inline/ng_line_box_fragment.cc",
"ng/inline/ng_line_box_fragment.h", "ng/inline/ng_line_box_fragment.h",
"ng/inline/ng_line_box_fragment_builder.cc", "ng/inline/ng_line_box_fragment_builder.cc",
......
...@@ -28,6 +28,7 @@ using NGInlineItemsBuilder = ...@@ -28,6 +28,7 @@ using NGInlineItemsBuilder =
struct NGInlineNodeData; struct NGInlineNodeData;
class NGLayoutResult; class NGLayoutResult;
class NGOffsetMapping; class NGOffsetMapping;
class NGInlineNodeLegacy;
// Represents an anonymous block box to be laid out, that contains consecutive // Represents an anonymous block box to be laid out, that contains consecutive
// inline nodes and their descendants. // inline nodes and their descendants.
...@@ -53,10 +54,6 @@ class CORE_EXPORT NGInlineNode : public NGLayoutInputNode { ...@@ -53,10 +54,6 @@ class CORE_EXPORT NGInlineNode : public NGLayoutInputNode {
// opportunity, and max-content is when lines do not wrap at all. // opportunity, and max-content is when lines do not wrap at all.
MinMaxSize ComputeMinMaxSize(); MinMaxSize ComputeMinMaxSize();
// Copy fragment data of all lines to LayoutBlockFlow.
void CopyFragmentDataToLayoutBox(const NGConstraintSpace&,
const NGLayoutResult&);
// Instruct to re-compute |PrepareLayout| on the next layout. // Instruct to re-compute |PrepareLayout| on the next layout.
void InvalidatePrepareLayout(); void InvalidatePrepareLayout();
...@@ -69,7 +66,7 @@ class CORE_EXPORT NGInlineNode : public NGLayoutInputNode { ...@@ -69,7 +66,7 @@ class CORE_EXPORT NGInlineNode : public NGLayoutInputNode {
const Vector<NGInlineItem>& Items(bool is_first_line = false) const; const Vector<NGInlineItem>& Items(bool is_first_line = false) const;
NGInlineItemRange Items(unsigned start_index, unsigned end_index); NGInlineItemRange Items(unsigned start_index, unsigned end_index);
void GetLayoutTextOffsets(Vector<unsigned, 32>*); void GetLayoutTextOffsets(Vector<unsigned, 32>*) const;
// Returns the DOM to text content offset mapping of this block. If it is not // Returns the DOM to text content offset mapping of this block. If it is not
// computed before, compute and store it in NGInlineNodeData. // computed before, compute and store it in NGInlineNodeData.
...@@ -105,6 +102,7 @@ class CORE_EXPORT NGInlineNode : public NGLayoutInputNode { ...@@ -105,6 +102,7 @@ class CORE_EXPORT NGInlineNode : public NGLayoutInputNode {
const NGInlineNodeData& EnsureData(); const NGInlineNodeData& EnsureData();
friend class NGLineBreakerTest; friend class NGLineBreakerTest;
friend class NGInlineNodeLegacy;
}; };
inline void NGInlineNode::AssertOffset(unsigned index, unsigned offset) const { inline void NGInlineNode::AssertOffset(unsigned index, unsigned offset) const {
......
...@@ -29,6 +29,7 @@ struct CORE_EXPORT NGInlineNodeData { ...@@ -29,6 +29,7 @@ struct CORE_EXPORT NGInlineNodeData {
} }
friend class NGInlineNode; friend class NGInlineNode;
friend class NGInlineNodeLegacy;
friend class NGInlineNodeForTest; friend class NGInlineNodeForTest;
friend class NGOffsetMappingTest; friend class NGOffsetMappingTest;
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NGInlineNodeLegacy_h
#define NGInlineNodeLegacy_h
#include "core/CoreExport.h"
#include "core/layout/LayoutBlockFlow.h"
#include "core/layout/line/LineInfo.h"
#include "core/layout/line/RootInlineBox.h"
namespace blink {
class NGInlineNode;
// Helper class actiong as a bridge between LayoutNG inline nodes and legacy
// layout. Populates a LayoutBlockFlow with LayoutNG inline layout results.
class CORE_EXPORT NGInlineNodeLegacy {
public:
NGInlineNodeLegacy(const NGInlineNode& node) : inline_node_(node) {}
// Copy fragment data of all lines to LayoutBlockFlow.
void CopyFragmentDataToLayoutBox(const NGConstraintSpace&,
const NGLayoutResult&);
private:
const NGInlineNode& inline_node_;
};
} // namespace blink
#endif // NGInlineNodeLegacy_h
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "core/layout/LayoutTable.h" #include "core/layout/LayoutTable.h"
#include "core/layout/MinMaxSize.h" #include "core/layout/MinMaxSize.h"
#include "core/layout/ng/inline/ng_inline_node.h" #include "core/layout/ng/inline/ng_inline_node.h"
#include "core/layout/ng/inline/ng_inline_node_legacy.h"
#include "core/layout/ng/inline/ng_physical_line_box_fragment.h" #include "core/layout/ng/inline/ng_physical_line_box_fragment.h"
#include "core/layout/ng/layout_ng_block_flow.h" #include "core/layout/ng/layout_ng_block_flow.h"
#include "core/layout/ng/legacy_layout_tree_walking.h" #include "core/layout/ng/legacy_layout_tree_walking.h"
...@@ -186,10 +187,8 @@ scoped_refptr<NGLayoutResult> NGBlockNode::Layout( ...@@ -186,10 +187,8 @@ scoped_refptr<NGLayoutResult> NGBlockNode::Layout(
NGLayoutInputNode first_child = FirstChild(); NGLayoutInputNode first_child = FirstChild();
if (block_flow && first_child && first_child.IsInline()) { if (block_flow && first_child && first_child.IsInline()) {
if (!RuntimeEnabledFeatures::LayoutNGPaintFragmentsEnabled()) { if (!RuntimeEnabledFeatures::LayoutNGPaintFragmentsEnabled()) {
// TODO(ikilpatrick): Move line-box creation logic from NGInlineNodeLegacy(ToNGInlineNode(first_child))
// NGInlineNode::CopyFragmentDataToLayoutBox to NGBlockNode. .CopyFragmentDataToLayoutBox(constraint_space, *layout_result);
NGInlineNode node = ToNGInlineNode(first_child);
node.CopyFragmentDataToLayoutBox(constraint_space, *layout_result);
} else { } else {
CopyFragmentDataToLayoutBoxForInlineChildren( CopyFragmentDataToLayoutBoxForInlineChildren(
ToNGPhysicalBoxFragment(*layout_result->PhysicalFragment())); ToNGPhysicalBoxFragment(*layout_result->PhysicalFragment()));
......
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