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

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

Issue 2782603003: Add NGColumnLayoutAlgorithm skeleton implementation. (Closed)
Patch Set: update TestExpectations Created 3 years, 8 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 NGInlineLayoutAlgorithm_h 5 #ifndef NGInlineLayoutAlgorithm_h
6 #define NGInlineLayoutAlgorithm_h 6 #define NGInlineLayoutAlgorithm_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_constraint_space_builder.h" 10 #include "core/layout/ng/ng_constraint_space_builder.h"
11 #include "core/layout/ng/ng_fragment_builder.h" 11 #include "core/layout/ng/ng_fragment_builder.h"
12 #include "core/layout/ng/ng_inline_break_token.h"
12 #include "core/layout/ng/ng_layout_algorithm.h" 13 #include "core/layout/ng/ng_layout_algorithm.h"
13 #include "core/layout/ng/ng_line_height_metrics.h" 14 #include "core/layout/ng/ng_line_height_metrics.h"
14 #include "platform/fonts/FontBaseline.h" 15 #include "platform/fonts/FontBaseline.h"
15 #include "platform/heap/Handle.h" 16 #include "platform/heap/Handle.h"
16 #include "wtf/Vector.h" 17 #include "wtf/Vector.h"
17 18
18 namespace blink { 19 namespace blink {
19 20
20 class NGConstraintSpace; 21 class NGConstraintSpace;
21 class NGInlineBreakToken; 22 class NGInlineBreakToken;
22 class NGInlineNode; 23 class NGInlineNode;
23 class NGLayoutInlineItem; 24 class NGLayoutInlineItem;
24 class NGLineBoxFragmentBuilder; 25 class NGLineBoxFragmentBuilder;
25 class NGTextFragmentBuilder; 26 class NGTextFragmentBuilder;
26 27
27 // A class for inline layout (e.g. a <span> with no special style). 28 // A class for inline layout (e.g. a <span> with no special style).
28 // 29 //
29 // Uses NGLineBreaker to find break opportunities, and let it call back to 30 // Uses NGLineBreaker to find break opportunities, and let it call back to
30 // construct linebox fragments and its wrapper box fragment. 31 // construct linebox fragments and its wrapper box fragment.
31 // 32 //
32 // From a line breaker, this class manages the current line as a range, |start| 33 // From a line breaker, this class manages the current line as a range, |start|
33 // and |end|. |end| can be extended multiple times before creating a line, 34 // and |end|. |end| can be extended multiple times before creating a line,
34 // usually until |!CanFitOnLine()|. |SetBreakOpportunity| can mark the last 35 // usually until |!CanFitOnLine()|. |SetBreakOpportunity| can mark the last
35 // confirmed offset that can fit. 36 // confirmed offset that can fit.
36 class CORE_EXPORT NGInlineLayoutAlgorithm final : public NGLayoutAlgorithm { 37 class CORE_EXPORT NGInlineLayoutAlgorithm final
38 : public NGLayoutAlgorithm<NGInlineNode, NGInlineBreakToken> {
37 public: 39 public:
38 NGInlineLayoutAlgorithm(NGInlineNode*, 40 NGInlineLayoutAlgorithm(NGInlineNode*,
39 NGConstraintSpace*, 41 NGConstraintSpace*,
40 NGInlineBreakToken* = nullptr); 42 NGInlineBreakToken* = nullptr);
41 43
42 const NGConstraintSpace& ConstraintSpace() const {
43 return *constraint_space_;
44 }
45
46 LayoutUnit MaxInlineSize() const { return max_inline_size_; } 44 LayoutUnit MaxInlineSize() const { return max_inline_size_; }
47 45
48 // Returns if the current items fit on a line. 46 // Returns if the current items fit on a line.
49 bool CanFitOnLine() const; 47 bool CanFitOnLine() const;
50 48
51 // Returns if there were any items. 49 // Returns if there were any items.
52 bool HasItems() const; 50 bool HasItems() const;
53 51
54 // Set the end offset. 52 // Set the end offset.
55 void SetEnd(unsigned end_offset); 53 void SetEnd(unsigned end_offset);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 const LineItemChunk&, 134 const LineItemChunk&,
137 NGLineBoxFragmentBuilder*); 135 NGLineBoxFragmentBuilder*);
138 LayoutUnit PlaceAtomicInline(const NGLayoutInlineItem&, 136 LayoutUnit PlaceAtomicInline(const NGLayoutInlineItem&,
139 LayoutUnit estimated_baseline, 137 LayoutUnit estimated_baseline,
140 NGLineBoxFragmentBuilder*, 138 NGLineBoxFragmentBuilder*,
141 NGTextFragmentBuilder*); 139 NGTextFragmentBuilder*);
142 140
143 // Finds the next layout opportunity for the next text fragment. 141 // Finds the next layout opportunity for the next text fragment.
144 void FindNextLayoutOpportunity(); 142 void FindNextLayoutOpportunity();
145 143
146 Persistent<NGInlineNode> inline_box_;
147 NGConstraintSpace* constraint_space_; // Not owned as STACK_ALLOCATED.
148 Vector<RefPtr<NGLayoutResult>, 32> layout_results_; 144 Vector<RefPtr<NGLayoutResult>, 32> layout_results_;
149 unsigned start_index_ = 0; 145 unsigned start_index_ = 0;
150 unsigned start_offset_ = 0; 146 unsigned start_offset_ = 0;
151 unsigned last_index_ = 0; 147 unsigned last_index_ = 0;
152 unsigned end_offset_ = 0; 148 unsigned end_offset_ = 0;
153 unsigned last_break_opportunity_index_ = 0; 149 unsigned last_break_opportunity_index_ = 0;
154 unsigned last_break_opportunity_offset_ = 0; 150 unsigned last_break_opportunity_offset_ = 0;
155 LayoutUnit end_position_; 151 LayoutUnit end_position_;
156 LayoutUnit last_break_opportunity_position_; 152 LayoutUnit last_break_opportunity_position_;
157 LayoutUnit content_size_; 153 LayoutUnit content_size_;
158 LayoutUnit max_inline_size_; 154 LayoutUnit max_inline_size_;
159 NGFragmentBuilder container_builder_; 155 NGFragmentBuilder container_builder_;
160 FontBaseline baseline_type_ = FontBaseline::AlphabeticBaseline; 156 FontBaseline baseline_type_ = FontBaseline::AlphabeticBaseline;
161 157
162 NGLogicalOffset bfc_offset_; 158 NGLogicalOffset bfc_offset_;
163 NGLogicalRect current_opportunity_; 159 NGLogicalRect current_opportunity_;
164 160
165 unsigned is_horizontal_writing_mode_ : 1; 161 unsigned is_horizontal_writing_mode_ : 1;
166 162
167 NGConstraintSpaceBuilder space_builder_; 163 NGConstraintSpaceBuilder space_builder_;
168 #if DCHECK_IS_ON() 164 #if DCHECK_IS_ON()
169 unsigned is_bidi_reordered_ : 1; 165 unsigned is_bidi_reordered_ : 1;
170 #endif 166 #endif
171 }; 167 };
172 168
173 } // namespace blink 169 } // namespace blink
174 170
175 #endif // NGInlineLayoutAlgorithm_h 171 #endif // NGInlineLayoutAlgorithm_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698