OLD | NEW |
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 NGFragmentBuilder_h | 5 #ifndef NGFragmentBuilder_h |
6 #define NGFragmentBuilder_h | 6 #define NGFragmentBuilder_h |
7 | 7 |
8 #include "core/layout/ng/geometry/ng_static_position.h" | 8 #include "core/layout/ng/geometry/ng_static_position.h" |
9 #include "core/layout/ng/inline/ng_baseline.h" | 9 #include "core/layout/ng/inline/ng_baseline.h" |
10 #include "core/layout/ng/inline/ng_physical_text_fragment.h" | 10 #include "core/layout/ng/inline/ng_physical_text_fragment.h" |
11 #include "core/layout/ng/ng_break_token.h" | 11 #include "core/layout/ng/ng_break_token.h" |
12 #include "core/layout/ng/ng_constraint_space.h" | 12 #include "core/layout/ng/ng_constraint_space.h" |
| 13 #include "core/layout/ng/ng_layout_result.h" |
13 #include "core/layout/ng/ng_out_of_flow_positioned_descendant.h" | 14 #include "core/layout/ng/ng_out_of_flow_positioned_descendant.h" |
14 #include "core/layout/ng/ng_physical_fragment.h" | 15 #include "core/layout/ng/ng_physical_fragment.h" |
15 #include "core/layout/ng/ng_positioned_float.h" | 16 #include "core/layout/ng/ng_positioned_float.h" |
16 #include "core/layout/ng/ng_unpositioned_float.h" | 17 #include "core/layout/ng/ng_unpositioned_float.h" |
17 #include "platform/wtf/Allocator.h" | 18 #include "platform/wtf/Allocator.h" |
18 | 19 |
19 namespace blink { | 20 namespace blink { |
20 | 21 |
21 class NGLayoutResult; | |
22 | |
23 class CORE_EXPORT NGFragmentBuilder final { | 22 class CORE_EXPORT NGFragmentBuilder final { |
24 DISALLOW_NEW(); | 23 DISALLOW_NEW(); |
25 | 24 |
26 public: | 25 public: |
27 NGFragmentBuilder(NGPhysicalFragment::NGFragmentType, NGLayoutInputNode); | 26 NGFragmentBuilder(NGPhysicalFragment::NGFragmentType, NGLayoutInputNode); |
28 | 27 |
29 // Build a fragment for LayoutObject without NGLayoutInputNode. LayoutInline | 28 // Build a fragment for LayoutObject without NGLayoutInputNode. LayoutInline |
30 // has NGInlineItem but does not have corresponding NGLayoutInputNode. | 29 // has NGInlineItem but does not have corresponding NGLayoutInputNode. |
31 NGFragmentBuilder(NGPhysicalFragment::NGFragmentType, LayoutObject*); | 30 NGFragmentBuilder(NGPhysicalFragment::NGFragmentType, LayoutObject*); |
32 | 31 |
(...skipping 11 matching lines...) Expand all Loading... |
44 NGFragmentBuilder& SetBlockOverflow(LayoutUnit); | 43 NGFragmentBuilder& SetBlockOverflow(LayoutUnit); |
45 | 44 |
46 NGFragmentBuilder& AddChild(RefPtr<NGLayoutResult>, const NGLogicalOffset&); | 45 NGFragmentBuilder& AddChild(RefPtr<NGLayoutResult>, const NGLogicalOffset&); |
47 NGFragmentBuilder& AddChild(RefPtr<NGPhysicalFragment>, | 46 NGFragmentBuilder& AddChild(RefPtr<NGPhysicalFragment>, |
48 const NGLogicalOffset&); | 47 const NGLogicalOffset&); |
49 | 48 |
50 NGFragmentBuilder& AddPositionedFloat(NGPositionedFloat); | 49 NGFragmentBuilder& AddPositionedFloat(NGPositionedFloat); |
51 | 50 |
52 NGFragmentBuilder& SetBfcOffset(const NGLogicalOffset& offset); | 51 NGFragmentBuilder& SetBfcOffset(const NGLogicalOffset& offset); |
53 | 52 |
54 NGFragmentBuilder& AddUnpositionedFloat( | |
55 RefPtr<NGUnpositionedFloat> unpositioned_float); | |
56 | |
57 // Builder has non-trivial out-of-flow descendant methods. | 53 // Builder has non-trivial out-of-flow descendant methods. |
58 // These methods are building blocks for implementation of | 54 // These methods are building blocks for implementation of |
59 // out-of-flow descendants by layout algorithms. | 55 // out-of-flow descendants by layout algorithms. |
60 // | 56 // |
61 // They are intended to be used by layout algorithm like this: | 57 // They are intended to be used by layout algorithm like this: |
62 // | 58 // |
63 // Part 1: layout algorithm positions in-flow children. | 59 // Part 1: layout algorithm positions in-flow children. |
64 // out-of-flow children, and out-of-flow descendants of fragments | 60 // out-of-flow children, and out-of-flow descendants of fragments |
65 // are stored inside builder. | 61 // are stored inside builder. |
66 // | 62 // |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 end_margin_strut_ = from; | 97 end_margin_strut_ = from; |
102 return *this; | 98 return *this; |
103 } | 99 } |
104 | 100 |
105 // Offsets are not supposed to be set during fragment construction, so we | 101 // Offsets are not supposed to be set during fragment construction, so we |
106 // do not provide a setter here. | 102 // do not provide a setter here. |
107 | 103 |
108 // Creates the fragment. Can only be called once. | 104 // Creates the fragment. Can only be called once. |
109 RefPtr<NGLayoutResult> ToBoxFragment(); | 105 RefPtr<NGLayoutResult> ToBoxFragment(); |
110 | 106 |
111 Vector<RefPtr<NGPhysicalFragment>>& MutableChildren() { return children_; } | 107 RefPtr<NGLayoutResult> Abort(NGLayoutResult::NGLayoutResultStatus); |
112 | 108 |
113 Vector<NGLogicalOffset>& MutableOffsets() { return offsets_; } | 109 Vector<NGLogicalOffset>& MutableOffsets() { return offsets_; } |
114 | 110 |
115 // Mutable list of floats that need to be positioned. | 111 void SwapUnpositionedFloats( |
116 Vector<RefPtr<NGUnpositionedFloat>>& MutableUnpositionedFloats() { | 112 Vector<RefPtr<NGUnpositionedFloat>>* unpositioned_floats) { |
117 return unpositioned_floats_; | 113 unpositioned_floats_.swap(*unpositioned_floats); |
118 } | |
119 | |
120 // List of floats that need to be positioned. | |
121 const Vector<RefPtr<NGUnpositionedFloat>>& UnpositionedFloats() const { | |
122 return unpositioned_floats_; | |
123 } | 114 } |
124 | 115 |
125 const WTF::Optional<NGLogicalOffset>& BfcOffset() const { | 116 const WTF::Optional<NGLogicalOffset>& BfcOffset() const { |
126 return bfc_offset_; | 117 return bfc_offset_; |
127 } | 118 } |
128 | 119 |
129 const Vector<RefPtr<NGPhysicalFragment>>& Children() const { | 120 const Vector<RefPtr<NGPhysicalFragment>>& Children() const { |
130 return children_; | 121 return children_; |
131 } | 122 } |
132 | 123 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 NGMarginStrut end_margin_strut_; | 185 NGMarginStrut end_margin_strut_; |
195 | 186 |
196 Vector<NGBaseline> baselines_; | 187 Vector<NGBaseline> baselines_; |
197 | 188 |
198 NGBorderEdges border_edges_; | 189 NGBorderEdges border_edges_; |
199 }; | 190 }; |
200 | 191 |
201 } // namespace blink | 192 } // namespace blink |
202 | 193 |
203 #endif // NGFragmentBuilder | 194 #endif // NGFragmentBuilder |
OLD | NEW |