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/ng_constraint_space.h" | 8 #include "core/layout/ng/ng_constraint_space.h" |
9 #include "core/layout/ng/ng_floating_object.h" | 9 #include "core/layout/ng/ng_floating_object.h" |
10 #include "core/layout/ng/ng_physical_fragment.h" | 10 #include "core/layout/ng/ng_physical_fragment.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 NGFragmentBuilder& SetBlockSize(LayoutUnit); | 31 NGFragmentBuilder& SetBlockSize(LayoutUnit); |
32 NGLogicalSize Size() const { return size_; } | 32 NGLogicalSize Size() const { return size_; } |
33 | 33 |
34 NGFragmentBuilder& SetInlineOverflow(LayoutUnit); | 34 NGFragmentBuilder& SetInlineOverflow(LayoutUnit); |
35 NGFragmentBuilder& SetBlockOverflow(LayoutUnit); | 35 NGFragmentBuilder& SetBlockOverflow(LayoutUnit); |
36 | 36 |
37 NGFragmentBuilder& AddChild(NGFragment*, const NGLogicalOffset&); | 37 NGFragmentBuilder& AddChild(NGFragment*, const NGLogicalOffset&); |
38 NGFragmentBuilder& AddFloatingObject(NGFloatingObject*, | 38 NGFragmentBuilder& AddFloatingObject(NGFloatingObject*, |
39 const NGLogicalOffset&); | 39 const NGLogicalOffset&); |
40 | 40 |
| 41 NGFragmentBuilder& SetBfcOffset(const NGLogicalOffset& offset); |
| 42 |
| 43 NGFragmentBuilder& AddUnpositionedFloat(NGFloatingObject* floating_object); |
| 44 |
41 // Builder has non-trivial out-of-flow descendant methods. | 45 // Builder has non-trivial out-of-flow descendant methods. |
42 // These methods are building blocks for implementation of | 46 // These methods are building blocks for implementation of |
43 // out-of-flow descendants by layout algorithms. | 47 // out-of-flow descendants by layout algorithms. |
44 // | 48 // |
45 // They are intended to be used by layout algorithm like this: | 49 // They are intended to be used by layout algorithm like this: |
46 // | 50 // |
47 // Part 1: layout algorithm positions in-flow children. | 51 // Part 1: layout algorithm positions in-flow children. |
48 // out-of-flow children, and out-of-flow descendants of fragments | 52 // out-of-flow children, and out-of-flow descendants of fragments |
49 // are stored inside builder. | 53 // are stored inside builder. |
50 // | 54 // |
(...skipping 13 matching lines...) Expand all Loading... |
64 // | 68 // |
65 // See layout part for builder interaction. | 69 // See layout part for builder interaction. |
66 NGFragmentBuilder& AddOutOfFlowChildCandidate(NGBlockNode*, NGLogicalOffset); | 70 NGFragmentBuilder& AddOutOfFlowChildCandidate(NGBlockNode*, NGLogicalOffset); |
67 | 71 |
68 void GetAndClearOutOfFlowDescendantCandidates(WeakBoxList*, | 72 void GetAndClearOutOfFlowDescendantCandidates(WeakBoxList*, |
69 Vector<NGStaticPosition>*); | 73 Vector<NGStaticPosition>*); |
70 | 74 |
71 NGFragmentBuilder& AddOutOfFlowDescendant(NGBlockNode*, | 75 NGFragmentBuilder& AddOutOfFlowDescendant(NGBlockNode*, |
72 const NGStaticPosition&); | 76 const NGStaticPosition&); |
73 | 77 |
74 NGFragmentBuilder& AddUnpositionedFloat(NGFloatingObject* floating_object); | |
75 | |
76 void SetBreakToken(NGBreakToken* token) { | 78 void SetBreakToken(NGBreakToken* token) { |
77 DCHECK(!break_token_); | 79 DCHECK(!break_token_); |
78 break_token_ = token; | 80 break_token_ = token; |
79 } | 81 } |
80 bool HasBreakToken() const { return break_token_; } | 82 bool HasBreakToken() const { return break_token_; } |
81 | 83 |
82 // Sets MarginStrut for the resultant fragment. | 84 NGFragmentBuilder& SetEndMarginStrut(const NGMarginStrut& from) { |
83 NGFragmentBuilder& SetMarginStrutBlockStart( | 85 end_margin_strut_ = from; |
84 const NGDeprecatedMarginStrut& from); | 86 return *this; |
85 NGFragmentBuilder& SetMarginStrutBlockEnd( | 87 } |
86 const NGDeprecatedMarginStrut& from); | |
87 | 88 |
88 // Offsets are not supposed to be set during fragment construction, so we | 89 // Offsets are not supposed to be set during fragment construction, so we |
89 // do not provide a setter here. | 90 // do not provide a setter here. |
90 | 91 |
91 // Creates the fragment. Can only be called once. | 92 // Creates the fragment. Can only be called once. |
92 NGPhysicalBoxFragment* ToBoxFragment(); | 93 NGPhysicalBoxFragment* ToBoxFragment(); |
93 NGPhysicalTextFragment* ToTextFragment(NGInlineNode*, | 94 NGPhysicalTextFragment* ToTextFragment(NGInlineNode*, |
94 unsigned start_index, | 95 unsigned start_index, |
95 unsigned end_index); | 96 unsigned end_index); |
96 | 97 |
| 98 // Mutable list of floats that need to be positioned. |
| 99 HeapVector<Member<NGFloatingObject>>& MutableUnpositionedFloats() { |
| 100 return unpositioned_floats_; |
| 101 } |
| 102 |
97 // List of floats that need to be positioned. | 103 // List of floats that need to be positioned. |
98 HeapVector<Member<NGFloatingObject>>& UnpositionedFloats() { | 104 const HeapVector<Member<NGFloatingObject>>& UnpositionedFloats() const { |
99 return unpositioned_floats_; | 105 return unpositioned_floats_; |
100 } | 106 } |
101 | 107 |
| 108 const WTF::Optional<NGLogicalOffset>& BfcOffset() const { |
| 109 return bfc_offset_; |
| 110 } |
| 111 |
102 DECLARE_VIRTUAL_TRACE(); | 112 DECLARE_VIRTUAL_TRACE(); |
103 | 113 |
104 private: | |
105 // Out-of-flow descendant placement information. | 114 // Out-of-flow descendant placement information. |
106 // The generated fragment must compute NGStaticPosition for all | 115 // The generated fragment must compute NGStaticPosition for all |
107 // out-of-flow descendants. | 116 // out-of-flow descendants. |
108 // The resulting NGStaticPosition gets derived from: | 117 // The resulting NGStaticPosition gets derived from: |
109 // 1. The offset of fragment's child. | 118 // 1. The offset of fragment's child. |
110 // 2. The static position of descendant wrt child. | 119 // 2. The static position of descendant wrt child. |
111 // | 120 // |
112 // A child can be: | 121 // A child can be: |
113 // 1. A descendant itself. In this case, descendant position is (0,0). | 122 // 1. A descendant itself. In this case, descendant position is (0,0). |
114 // 2. A fragment containing a descendant. | 123 // 2. A fragment containing a descendant. |
115 // | 124 // |
116 // child_offset is stored as NGLogicalOffset because physical offset cannot | 125 // child_offset is stored as NGLogicalOffset because physical offset cannot |
117 // be computed until we know fragment's size. | 126 // be computed until we know fragment's size. |
118 struct OutOfFlowPlacement { | 127 struct OutOfFlowPlacement { |
119 NGLogicalOffset child_offset; | 128 NGLogicalOffset child_offset; |
120 NGStaticPosition descendant_position; | 129 NGStaticPosition descendant_position; |
121 }; | 130 }; |
122 | 131 |
123 NGPhysicalFragment::NGFragmentType type_; | 132 NGPhysicalFragment::NGFragmentType type_; |
124 NGWritingMode writing_mode_; | 133 NGWritingMode writing_mode_; |
125 TextDirection direction_; | 134 TextDirection direction_; |
126 | 135 |
127 LayoutObject* layout_object_; | 136 LayoutObject* layout_object_; |
128 | 137 |
129 NGLogicalSize size_; | 138 NGLogicalSize size_; |
130 NGLogicalSize overflow_; | 139 NGLogicalSize overflow_; |
131 | 140 |
132 NGDeprecatedMarginStrut margin_strut_; | |
133 | |
134 HeapVector<Member<NGPhysicalFragment>> children_; | 141 HeapVector<Member<NGPhysicalFragment>> children_; |
135 Vector<NGLogicalOffset> offsets_; | 142 Vector<NGLogicalOffset> offsets_; |
136 | 143 |
137 WeakBoxList out_of_flow_descendant_candidates_; | 144 WeakBoxList out_of_flow_descendant_candidates_; |
138 Vector<OutOfFlowPlacement> out_of_flow_candidate_placements_; | 145 Vector<OutOfFlowPlacement> out_of_flow_candidate_placements_; |
139 | 146 |
140 WeakBoxList out_of_flow_descendants_; | 147 WeakBoxList out_of_flow_descendants_; |
141 Vector<NGStaticPosition> out_of_flow_positions_; | 148 Vector<NGStaticPosition> out_of_flow_positions_; |
142 | 149 |
143 // Floats that need to be positioned by the next in-flow fragment that can | 150 // Floats that need to be positioned by the next in-flow fragment that can |
144 // determine its block position in space. | 151 // determine its block position in space. |
145 HeapVector<Member<NGFloatingObject>> unpositioned_floats_; | 152 HeapVector<Member<NGFloatingObject>> unpositioned_floats_; |
146 | 153 |
147 Vector<NGLogicalOffset> floating_object_offsets_; | 154 Vector<NGLogicalOffset> floating_object_offsets_; |
148 HeapVector<Member<NGFloatingObject>> positioned_floats_; | 155 HeapVector<Member<NGFloatingObject>> positioned_floats_; |
149 | 156 |
150 Member<NGBreakToken> break_token_; | 157 Member<NGBreakToken> break_token_; |
| 158 |
| 159 WTF::Optional<NGLogicalOffset> bfc_offset_; |
| 160 NGMarginStrut end_margin_strut_; |
151 }; | 161 }; |
152 | 162 |
153 } // namespace blink | 163 } // namespace blink |
154 | 164 |
155 #endif // NGFragmentBuilder | 165 #endif // NGFragmentBuilder |
OLD | NEW |