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

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

Issue 2739683006: Use Opportunity Iterator to position text fragments in NGLineBuilder (Closed)
Patch Set: Created 3 years, 9 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 NGLineBuilder_h 5 #ifndef NGLineBuilder_h
6 #define NGLineBuilder_h 6 #define NGLineBuilder_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/layout/ng/geometry/ng_logical_offset.h" 9 #include "core/layout/ng/geometry/ng_logical_offset.h"
10 #include "core/layout/ng/ng_layout_opportunity_iterator.h"
10 #include "core/layout/ng/ng_physical_fragment.h" 11 #include "core/layout/ng/ng_physical_fragment.h"
11 #include "platform/fonts/FontBaseline.h" 12 #include "platform/fonts/FontBaseline.h"
12 #include "platform/heap/Handle.h" 13 #include "platform/heap/Handle.h"
13 #include "wtf/Vector.h" 14 #include "wtf/Vector.h"
14 15
15 namespace blink { 16 namespace blink {
16 17
17 class ComputedStyle; 18 class ComputedStyle;
18 class FontMetrics; 19 class FontMetrics;
19 class NGConstraintSpace; 20 class NGConstraintSpace;
20 class NGFragmentBuilder; 21 class NGFragmentBuilder;
21 class NGInlineNode; 22 class NGInlineNode;
22 class NGLayoutInlineItem; 23 class NGLayoutInlineItem;
23 24
24 // NGLineBuilder creates the fragment tree for a line. 25 // NGLineBuilder creates the fragment tree for a line.
25 // NGLineBuilder manages the current line as a range, |start| and |end|. 26 // NGLineBuilder manages the current line as a range, |start| and |end|.
26 // |end| can be extended multiple times before creating a line, usually until 27 // |end| can be extended multiple times before creating a line, usually until
27 // |!CanFitOnLine()|. 28 // |!CanFitOnLine()|.
28 // |SetBreakOpportunity| can mark the last confirmed offset that can fit. 29 // |SetBreakOpportunity| can mark the last confirmed offset that can fit.
29 class CORE_EXPORT NGLineBuilder final { 30 class CORE_EXPORT NGLineBuilder final {
30 STACK_ALLOCATED(); 31 STACK_ALLOCATED();
31 32
32 public: 33 public:
33 NGLineBuilder(NGInlineNode*, const NGConstraintSpace*); 34 NGLineBuilder(NGInlineNode*, NGConstraintSpace*);
34 35
35 const NGConstraintSpace& ConstraintSpace() const { 36 const NGConstraintSpace& ConstraintSpace() const {
36 return *constraint_space_; 37 return *constraint_space_;
37 } 38 }
38 39
39 LayoutUnit MaxInlineSize() const { return max_inline_size_; } 40 LayoutUnit MaxInlineSize() const { return max_inline_size_; }
40 41
41 // Returns if the current items fit on a line. 42 // Returns if the current items fit on a line.
42 bool CanFitOnLine() const; 43 bool CanFitOnLine() const;
43 44
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 82
82 // Create fragments for all lines created so far. 83 // Create fragments for all lines created so far.
83 void CreateFragments(NGFragmentBuilder*); 84 void CreateFragments(NGFragmentBuilder*);
84 85
85 // Copy fragment data of all lines created by this NGLineBuilder to 86 // Copy fragment data of all lines created by this NGLineBuilder to
86 // LayoutBlockFlow. 87 // LayoutBlockFlow.
87 // This must run after |CreateFragments()|, and after the fragments it created 88 // This must run after |CreateFragments()|, and after the fragments it created
88 // are placed. 89 // are placed.
89 void CopyFragmentDataToLayoutBlockFlow(); 90 void CopyFragmentDataToLayoutBlockFlow();
90 91
92 // Finds the next layout opportunity for the next text fragment.
93 void FindNextLayoutOpportunity();
94
91 private: 95 private:
92 struct LineItemChunk { 96 struct LineItemChunk {
93 unsigned index; 97 unsigned index;
94 unsigned start_offset; 98 unsigned start_offset;
95 unsigned end_offset; 99 unsigned end_offset;
96 LayoutUnit inline_size; 100 LayoutUnit inline_size;
97 }; 101 };
98 102
99 void BidiReorder(Vector<LineItemChunk, 32>*); 103 void BidiReorder(Vector<LineItemChunk, 32>*);
100 104
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 // Include |InlineItemMetrics| into the metrics for this line box. 137 // Include |InlineItemMetrics| into the metrics for this line box.
134 void UpdateMaxAscentAndDescent(const InlineItemMetrics&); 138 void UpdateMaxAscentAndDescent(const InlineItemMetrics&);
135 }; 139 };
136 140
137 void PlaceItems(const Vector<LineItemChunk, 32>&); 141 void PlaceItems(const Vector<LineItemChunk, 32>&);
138 void AccumulateUsedFonts(const NGLayoutInlineItem&, 142 void AccumulateUsedFonts(const NGLayoutInlineItem&,
139 const LineItemChunk&, 143 const LineItemChunk&,
140 LineBoxData*); 144 LineBoxData*);
141 145
142 Persistent<NGInlineNode> inline_box_; 146 Persistent<NGInlineNode> inline_box_;
143 const NGConstraintSpace* constraint_space_; // Not owned as STACK_ALLOCATED. 147 NGConstraintSpace* constraint_space_; // Not owned as STACK_ALLOCATED.
144 Vector<RefPtr<NGPhysicalFragment>, 32> fragments_; 148 Vector<RefPtr<NGPhysicalFragment>, 32> fragments_;
145 Vector<NGLogicalOffset, 32> offsets_; 149 Vector<NGLogicalOffset, 32> offsets_;
146 Vector<LineBoxData, 32> line_box_data_list_; 150 Vector<LineBoxData, 32> line_box_data_list_;
147 unsigned start_index_ = 0; 151 unsigned start_index_ = 0;
148 unsigned start_offset_ = 0; 152 unsigned start_offset_ = 0;
149 unsigned last_index_ = 0; 153 unsigned last_index_ = 0;
150 unsigned end_offset_ = 0; 154 unsigned end_offset_ = 0;
151 unsigned last_break_opportunity_index_ = 0; 155 unsigned last_break_opportunity_index_ = 0;
152 unsigned last_break_opportunity_offset_ = 0; 156 unsigned last_break_opportunity_offset_ = 0;
153 LayoutUnit end_position_; 157 LayoutUnit end_position_;
154 LayoutUnit last_break_opportunity_position_; 158 LayoutUnit last_break_opportunity_position_;
155 LayoutUnit content_size_; 159 LayoutUnit content_size_;
156 LayoutUnit max_inline_size_; 160 LayoutUnit max_inline_size_;
157 FontBaseline baseline_type_; 161 FontBaseline baseline_type_;
158 162
163 NGLogicalOffset bfc_offset_;
164 NGLogicalRect current_opportunity_;
165
159 #if DCHECK_IS_ON() 166 #if DCHECK_IS_ON()
160 unsigned is_bidi_reordered_ : 1; 167 unsigned is_bidi_reordered_ : 1;
161 #endif 168 #endif
162 }; 169 };
163 170
164 } // namespace blink 171 } // namespace blink
165 172
166 #endif // NGLineBuilder_h 173 #endif // NGLineBuilder_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698