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 NGBlockLayoutAlgorithm_h | 5 #ifndef NGBlockLayoutAlgorithm_h |
6 #define NGBlockLayoutAlgorithm_h | 6 #define NGBlockLayoutAlgorithm_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/layout/ng/ng_block_node.h" | 9 #include "core/layout/ng/ng_block_node.h" |
10 #include "core/layout/ng/ng_layout_algorithm.h" | 10 #include "core/layout/ng/ng_layout_algorithm.h" |
11 #include "core/layout/ng/ng_units.h" | 11 #include "core/layout/ng/ng_units.h" |
12 #include "wtf/RefPtr.h" | 12 #include "wtf/RefPtr.h" |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
16 class ComputedStyle; | 16 class ComputedStyle; |
17 class NGBlockBreakToken; | 17 class NGBlockBreakToken; |
18 class NGBreakToken; | 18 class NGBreakToken; |
19 class NGColumnMapper; | 19 class NGColumnMapper; |
20 class NGConstraintSpace; | 20 class NGConstraintSpace; |
21 class NGConstraintSpaceBuilder; | 21 class NGConstraintSpaceBuilder; |
22 class NGBoxFragment; | 22 class NGBoxFragment; |
23 class NGFragmentBuilder; | 23 class NGFragmentBuilder; |
24 class NGOutOfFlowLayoutPart; | |
25 class NGPhysicalFragment; | 24 class NGPhysicalFragment; |
26 | 25 |
27 // A class for general block layout (e.g. a <div> with no special style). | 26 // A class for general block layout (e.g. a <div> with no special style). |
28 // Lays out the children in sequence. | 27 // Lays out the children in sequence. |
29 class CORE_EXPORT NGBlockLayoutAlgorithm : public NGLayoutAlgorithm { | 28 class CORE_EXPORT NGBlockLayoutAlgorithm : public NGLayoutAlgorithm { |
30 public: | 29 public: |
31 // Default constructor. | 30 // Default constructor. |
32 // @param style Style reference of the block that is being laid out. | 31 // @param style Style reference of the block that is being laid out. |
33 // @param first_child Our first child; the algorithm will use its NextSibling | 32 // @param first_child Our first child; the algorithm will use its NextSibling |
34 // method to access all the children. | 33 // method to access all the children. |
35 // @param space The constraint space which the algorithm should generate a | 34 // @param space The constraint space which the algorithm should generate a |
36 // fragment within. | 35 // fragment within. |
37 NGBlockLayoutAlgorithm(PassRefPtr<const ComputedStyle>, | 36 NGBlockLayoutAlgorithm(PassRefPtr<const ComputedStyle>, |
38 NGBlockNode* first_child, | 37 NGBlockNode* first_child, |
39 NGConstraintSpace* space, | 38 NGConstraintSpace* space, |
40 NGBreakToken* break_token = nullptr); | 39 NGBreakToken* break_token = nullptr); |
41 | 40 |
42 bool ComputeMinAndMaxContentSizes(MinAndMaxContentSizes*) override; | 41 bool ComputeMinAndMaxContentSizes(MinAndMaxContentSizes*) override; |
43 NGLayoutStatus Layout(NGPhysicalFragment*, | 42 NGLayoutStatus Layout(NGPhysicalFragment*, |
44 NGPhysicalFragment**, | 43 NGPhysicalFragment**, |
45 NGLayoutAlgorithm**) override; | 44 NGLayoutAlgorithm**) override; |
46 | 45 |
47 DECLARE_VIRTUAL_TRACE(); | 46 DECLARE_VIRTUAL_TRACE(); |
48 | 47 |
49 private: | 48 private: |
50 // Creates a new constraint space for the current child. | 49 // Creates a new constraint space for the current child. |
51 NGConstraintSpace* CreateConstraintSpaceForCurrentChild() const; | 50 NGConstraintSpace* CreateConstraintSpaceForCurrentChild() const; |
52 void FinishCurrentChildLayout(NGFragment* fragment); | 51 void FinishCurrentChildLayout(NGFragment* fragment); |
53 bool LayoutOutOfFlowChild(); | 52 HeapLinkedHashSet<WeakMember<NGBlockNode>> LayoutOutOfFlowChildren(); |
54 | 53 |
55 // Proceed to the next sibling that still needs layout. | 54 // Proceed to the next sibling that still needs layout. |
56 // | 55 // |
57 // @param child_fragment The newly created fragment for the current child. | 56 // @param child_fragment The newly created fragment for the current child. |
58 // @return true if we can continue to lay out, or false if we need to abort | 57 // @return true if we can continue to lay out, or false if we need to abort |
59 // due to a fragmentainer break. | 58 // due to a fragmentainer break. |
60 bool ProceedToNextUnfinishedSibling(NGPhysicalFragment* child_fragment); | 59 bool ProceedToNextUnfinishedSibling(NGPhysicalFragment* child_fragment); |
61 | 60 |
62 // Set a break token which contains enough information to be able to resume | 61 // Set a break token which contains enough information to be able to resume |
63 // layout in the next fragmentainer. | 62 // layout in the next fragmentainer. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 Member<NGConstraintSpace> constraint_space_; | 151 Member<NGConstraintSpace> constraint_space_; |
153 | 152 |
154 // The break token from which we are currently resuming layout. | 153 // The break token from which we are currently resuming layout. |
155 Member<NGBreakToken> break_token_; | 154 Member<NGBreakToken> break_token_; |
156 | 155 |
157 Member<NGFragmentBuilder> builder_; | 156 Member<NGFragmentBuilder> builder_; |
158 Member<NGConstraintSpaceBuilder> space_builder_; | 157 Member<NGConstraintSpaceBuilder> space_builder_; |
159 Member<NGConstraintSpace> space_for_current_child_; | 158 Member<NGConstraintSpace> space_for_current_child_; |
160 Member<NGBlockNode> current_child_; | 159 Member<NGBlockNode> current_child_; |
161 | 160 |
162 Member<NGOutOfFlowLayoutPart> out_of_flow_layout_; | |
163 HeapLinkedHashSet<WeakMember<NGBlockNode>> out_of_flow_candidates_; | |
164 Vector<NGStaticPosition> out_of_flow_candidate_positions_; | |
165 size_t out_of_flow_candidate_positions_index_; | |
166 | |
167 // Mapper from the fragmented flow coordinate space coordinates to visual | 161 // Mapper from the fragmented flow coordinate space coordinates to visual |
168 // coordinates. Only set on fragmentation context roots, such as multicol | 162 // coordinates. Only set on fragmentation context roots, such as multicol |
169 // containers. Keeps track of the current fragmentainer. | 163 // containers. Keeps track of the current fragmentainer. |
170 Member<NGColumnMapper> fragmentainer_mapper_; | 164 Member<NGColumnMapper> fragmentainer_mapper_; |
171 | 165 |
172 NGBoxStrut border_and_padding_; | 166 NGBoxStrut border_and_padding_; |
173 LayoutUnit content_size_; | 167 LayoutUnit content_size_; |
174 LayoutUnit max_inline_size_; | 168 LayoutUnit max_inline_size_; |
175 // MarginStrut for the previous child. | 169 // MarginStrut for the previous child. |
176 NGMarginStrut prev_child_margin_strut_; | 170 NGMarginStrut prev_child_margin_strut_; |
177 // Whether the block-start was set for the currently built | 171 // Whether the block-start was set for the currently built |
178 // fragment's margin strut. | 172 // fragment's margin strut. |
179 bool is_fragment_margin_strut_block_start_updated_ : 1; | 173 bool is_fragment_margin_strut_block_start_updated_ : 1; |
180 }; | 174 }; |
181 | 175 |
182 } // namespace blink | 176 } // namespace blink |
183 | 177 |
184 #endif // NGBlockLayoutAlgorithm_h | 178 #endif // NGBlockLayoutAlgorithm_h |
OLD | NEW |