Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.h

Issue 2836293004: [LayoutNG] Move NGInlineNode data to NGInlineNodeData. (Closed)
Patch Set: rebase. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NGInlineNode_h 5 #ifndef NGInlineNode_h
6 #define NGInlineNode_h 6 #define NGInlineNode_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/layout/LayoutBlockFlow.h"
10 #include "core/layout/ng/inline/ng_inline_item.h" 9 #include "core/layout/ng/inline/ng_inline_item.h"
10 #include "core/layout/ng/inline/ng_inline_node_data.h"
11 #include "core/layout/ng/layout_ng_block_flow.h"
11 #include "core/layout/ng/ng_layout_input_node.h" 12 #include "core/layout/ng/ng_layout_input_node.h"
12 #include "platform/heap/Handle.h" 13 #include "platform/heap/Handle.h"
13 #include "platform/wtf/text/WTFString.h" 14 #include "platform/wtf/text/WTFString.h"
14 15
15 namespace blink { 16 namespace blink {
16 17
17 class ComputedStyle; 18 class ComputedStyle;
18 class LayoutBlockFlow; 19 class LayoutBlockFlow;
20 class LayoutNGBlockFlow;
19 class LayoutObject; 21 class LayoutObject;
20 struct MinMaxContentSize; 22 struct MinMaxContentSize;
21 class NGConstraintSpace; 23 class NGConstraintSpace;
22 class NGInlineItem; 24 class NGInlineItem;
23 class NGInlineItemRange; 25 class NGInlineItemRange;
24 class NGInlineItemsBuilder; 26 class NGInlineItemsBuilder;
25 class NGLayoutResult; 27 class NGLayoutResult;
26 28
27 // Represents an anonymous block box to be laid out, that contains consecutive 29 // Represents an anonymous block box to be laid out, that contains consecutive
28 // inline nodes and their descendants. 30 // inline nodes and their descendants.
29 class CORE_EXPORT NGInlineNode : public NGLayoutInputNode { 31 class CORE_EXPORT NGInlineNode : public NGLayoutInputNode {
30 public: 32 public:
31 NGInlineNode(LayoutObject* start_inline, LayoutBlockFlow*); 33 NGInlineNode(LayoutObject* start_inline, LayoutNGBlockFlow*);
32 ~NGInlineNode() override; 34 ~NGInlineNode() override;
33 35
34 LayoutBlockFlow* GetLayoutBlockFlow() const { return block_; } 36 LayoutBlockFlow* GetLayoutBlockFlow() const { return block_; }
35 const ComputedStyle& Style() const override { return block_->StyleRef(); } 37 const ComputedStyle& Style() const override { return block_->StyleRef(); }
36 NGLayoutInputNode* NextSibling() override; 38 NGLayoutInputNode* NextSibling() override;
37 39
38 RefPtr<NGLayoutResult> Layout(NGConstraintSpace*, NGBreakToken*) override; 40 RefPtr<NGLayoutResult> Layout(NGConstraintSpace*, NGBreakToken*) override;
39 LayoutObject* GetLayoutObject() override; 41 LayoutObject* GetLayoutObject() override;
40 42
41 // Computes the value of min-content and max-content for this anonymous block 43 // Computes the value of min-content and max-content for this anonymous block
42 // box. min-content is the inline size when lines wrap at every break 44 // box. min-content is the inline size when lines wrap at every break
43 // opportunity, and max-content is when lines do not wrap at all. 45 // opportunity, and max-content is when lines do not wrap at all.
44 MinMaxContentSize ComputeMinMaxContentSize() override; 46 MinMaxContentSize ComputeMinMaxContentSize() override;
45 47
46 // Copy fragment data of all lines to LayoutBlockFlow. 48 // Copy fragment data of all lines to LayoutBlockFlow.
47 void CopyFragmentDataToLayoutBox(const NGConstraintSpace&, NGLayoutResult*); 49 void CopyFragmentDataToLayoutBox(const NGConstraintSpace&, NGLayoutResult*);
48 50
49 // Instruct to re-compute |PrepareLayout| on the next layout. 51 // Instruct to re-compute |PrepareLayout| on the next layout.
50 void InvalidatePrepareLayout(); 52 void InvalidatePrepareLayout();
51 53
52 const String& Text() const { return text_content_; } 54 const String& Text() const { return Data().text_content_; }
53 StringView Text(unsigned start_offset, unsigned end_offset) const { 55 StringView Text(unsigned start_offset, unsigned end_offset) const {
54 return StringView(text_content_, start_offset, end_offset - start_offset); 56 return StringView(Data().text_content_, start_offset,
57 end_offset - start_offset);
55 } 58 }
56 59
57 Vector<NGInlineItem>& Items() { return items_; } 60 const Vector<NGInlineItem>& Items() const { return Data().items_; }
58 const Vector<NGInlineItem>& Items() const { return items_; }
59 NGInlineItemRange Items(unsigned start_index, unsigned end_index); 61 NGInlineItemRange Items(unsigned start_index, unsigned end_index);
60 62
61 void GetLayoutTextOffsets(Vector<unsigned, 32>*); 63 void GetLayoutTextOffsets(Vector<unsigned, 32>*);
62 64
63 bool IsBidiEnabled() const { return is_bidi_enabled_; } 65 bool IsBidiEnabled() const { return Data().is_bidi_enabled_; }
64 66
65 void AssertOffset(unsigned index, unsigned offset) const; 67 void AssertOffset(unsigned index, unsigned offset) const;
66 void AssertEndOffset(unsigned index, unsigned offset) const; 68 void AssertEndOffset(unsigned index, unsigned offset) const;
67 69
68 DECLARE_VIRTUAL_TRACE(); 70 DECLARE_VIRTUAL_TRACE();
69 71
70 protected: 72 protected:
71 NGInlineNode(); // This constructor is only for testing. 73 NGInlineNode(); // This constructor is only for testing.
72 74
73 // Prepare inline and text content for layout. Must be called before 75 // Prepare inline and text content for layout. Must be called before
74 // calling the Layout method. 76 // calling the Layout method.
75 void PrepareLayout(); 77 void PrepareLayout();
76 bool IsPrepareLayoutFinished() const { return !text_content_.IsNull(); } 78 bool IsPrepareLayoutFinished() const { return !Text().IsNull(); }
77 79
78 void CollectInlines(LayoutObject* start, LayoutBlockFlow*); 80 void CollectInlines(LayoutObject* start, LayoutBlockFlow*);
79 LayoutObject* CollectInlines(LayoutObject* start, 81 LayoutObject* CollectInlines(LayoutObject* start,
80 LayoutBlockFlow*, 82 LayoutBlockFlow*,
81 NGInlineItemsBuilder*); 83 NGInlineItemsBuilder*);
82 void SegmentText(); 84 void SegmentText();
83 void ShapeText(); 85 void ShapeText();
84 86
87 NGInlineNodeData& MutableData() { return block_->GetNGInlineNodeData(); }
88 const NGInlineNodeData& Data() const { return block_->GetNGInlineNodeData(); }
89
85 LayoutObject* start_inline_; 90 LayoutObject* start_inline_;
86 LayoutBlockFlow* block_; 91 LayoutNGBlockFlow* block_;
87 Member<NGLayoutInputNode> next_sibling_; 92 Member<NGLayoutInputNode> next_sibling_;
88
89 // Text content for all inline items represented by a single NGInlineNode
90 // instance. Encoded either as UTF-16 or latin-1 depending on content.
91 String text_content_;
92 Vector<NGInlineItem> items_;
93
94 // TODO(kojii): This should move to somewhere else when we move PrepareLayout
95 // to the correct place.
96 bool is_bidi_enabled_ = false;
97 }; 93 };
98 94
99 inline void NGInlineNode::AssertOffset(unsigned index, unsigned offset) const { 95 inline void NGInlineNode::AssertOffset(unsigned index, unsigned offset) const {
100 items_[index].AssertOffset(offset); 96 Data().items_[index].AssertOffset(offset);
101 } 97 }
102 98
103 inline void NGInlineNode::AssertEndOffset(unsigned index, 99 inline void NGInlineNode::AssertEndOffset(unsigned index,
104 unsigned offset) const { 100 unsigned offset) const {
105 items_[index].AssertEndOffset(offset); 101 Data().items_[index].AssertEndOffset(offset);
106 } 102 }
107 103
108 DEFINE_TYPE_CASTS(NGInlineNode, 104 DEFINE_TYPE_CASTS(NGInlineNode,
109 NGLayoutInputNode, 105 NGLayoutInputNode,
110 node, 106 node,
111 node->IsInline(), 107 node->IsInline(),
112 node.IsInline()); 108 node.IsInline());
113 109
114 } // namespace blink 110 } // namespace blink
115 111
116 #endif // NGInlineNode_h 112 #endif // NGInlineNode_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/BUILD.gn ('k') | third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698