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 NGBreakToken; | 17 class NGBreakToken; |
18 class NGConstraintSpace; | 18 class NGConstraintSpace; |
19 class NGConstraintSpaceBuilder; | 19 class NGConstraintSpaceBuilder; |
20 class NGFragment; | 20 class NGFragment; |
21 class NGFragmentBuilder; | 21 class NGFragmentBuilder; |
| 22 class NGOutOfFlowLayoutPart; |
22 class NGPhysicalFragmentBase; | 23 class NGPhysicalFragmentBase; |
23 | 24 |
24 // A class for general block layout (e.g. a <div> with no special style). | 25 // A class for general block layout (e.g. a <div> with no special style). |
25 // Lays out the children in sequence. | 26 // Lays out the children in sequence. |
26 class CORE_EXPORT NGBlockLayoutAlgorithm : public NGLayoutAlgorithm { | 27 class CORE_EXPORT NGBlockLayoutAlgorithm : public NGLayoutAlgorithm { |
27 public: | 28 public: |
28 // Default constructor. | 29 // Default constructor. |
29 // @param style Style reference of the block that is being laid out. | 30 // @param style Style reference of the block that is being laid out. |
30 // @param first_child Our first child; the algorithm will use its NextSibling | 31 // @param first_child Our first child; the algorithm will use its NextSibling |
31 // method to access all the children. | 32 // method to access all the children. |
32 // @param space The constraint space which the algorithm should generate a | 33 // @param space The constraint space which the algorithm should generate a |
33 // fragment within. | 34 // fragment within. |
34 NGBlockLayoutAlgorithm(PassRefPtr<const ComputedStyle>, | 35 NGBlockLayoutAlgorithm(PassRefPtr<const ComputedStyle>, |
35 NGBlockNode* first_child, | 36 NGBlockNode* first_child, |
36 NGConstraintSpace* space, | 37 NGConstraintSpace* space, |
37 NGBreakToken* break_token = nullptr); | 38 NGBreakToken* break_token = nullptr); |
38 | 39 |
39 NGLayoutStatus Layout(NGPhysicalFragmentBase*, | 40 NGLayoutStatus Layout(NGPhysicalFragmentBase*, |
40 NGPhysicalFragmentBase**, | 41 NGPhysicalFragmentBase**, |
41 NGLayoutAlgorithm**) override; | 42 NGLayoutAlgorithm**) override; |
42 | 43 |
43 DECLARE_VIRTUAL_TRACE(); | 44 DECLARE_VIRTUAL_TRACE(); |
44 | 45 |
45 private: | 46 private: |
46 // Creates a new constraint space for the current child. | 47 // Creates a new constraint space for the current child. |
47 NGConstraintSpace* CreateConstraintSpaceForCurrentChild() const; | 48 NGConstraintSpace* CreateConstraintSpaceForCurrentChild() const; |
48 void FinishCurrentChildLayout(NGFragmentBase* fragment); | 49 void FinishCurrentChildLayout(NGFragmentBase* fragment); |
| 50 bool LayoutOutOfFlowChild(); |
49 | 51 |
50 // Computes collapsed margins for 2 adjoining blocks and updates the resultant | 52 // Computes collapsed margins for 2 adjoining blocks and updates the resultant |
51 // fragment's MarginStrut if needed. | 53 // fragment's MarginStrut if needed. |
52 // See https://www.w3.org/TR/CSS2/box.html#collapsing-margins | 54 // See https://www.w3.org/TR/CSS2/box.html#collapsing-margins |
53 // | 55 // |
54 // @param child_margins Margins information for the current child. | 56 // @param child_margins Margins information for the current child. |
55 // @param fragment Current child's fragment. | 57 // @param fragment Current child's fragment. |
56 // @return NGBoxStrut with margins block start/end. | 58 // @return NGBoxStrut with margins block start/end. |
57 NGBoxStrut CollapseMargins(const NGBoxStrut& child_margins, | 59 NGBoxStrut CollapseMargins(const NGBoxStrut& child_margins, |
58 const NGFragment& fragment); | 60 const NGFragment& fragment); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 const NGConstraintSpace& ConstraintSpace() const { | 97 const NGConstraintSpace& ConstraintSpace() const { |
96 return *constraint_space_; | 98 return *constraint_space_; |
97 } | 99 } |
98 | 100 |
99 const ComputedStyle& Style() const { return *style_; } | 101 const ComputedStyle& Style() const { return *style_; } |
100 | 102 |
101 enum State { | 103 enum State { |
102 kStateInit, | 104 kStateInit, |
103 kStatePrepareForChildLayout, | 105 kStatePrepareForChildLayout, |
104 kStateChildLayout, | 106 kStateChildLayout, |
| 107 kStateOutOfFlowLayout, |
105 kStateFinalize | 108 kStateFinalize |
106 }; | 109 }; |
107 State state_; | 110 State state_; |
108 | 111 |
109 RefPtr<const ComputedStyle> style_; | 112 RefPtr<const ComputedStyle> style_; |
110 | 113 |
111 Member<NGBlockNode> first_child_; | 114 Member<NGBlockNode> first_child_; |
112 Member<NGConstraintSpace> constraint_space_; | 115 Member<NGConstraintSpace> constraint_space_; |
113 Member<NGBreakToken> break_token_; | 116 Member<NGBreakToken> break_token_; |
114 Member<NGFragmentBuilder> builder_; | 117 Member<NGFragmentBuilder> builder_; |
115 Member<NGConstraintSpaceBuilder> space_builder_; | 118 Member<NGConstraintSpaceBuilder> space_builder_; |
116 Member<NGConstraintSpace> space_for_current_child_; | 119 Member<NGConstraintSpace> space_for_current_child_; |
117 Member<NGBlockNode> current_child_; | 120 Member<NGBlockNode> current_child_; |
118 | 121 |
| 122 Member<NGOutOfFlowLayoutPart> out_of_flow_layout_; |
| 123 HeapLinkedHashSet<WeakMember<NGBlockNode>> out_of_flow_candidates_; |
| 124 Vector<NGStaticPosition> out_of_flow_candidate_positions_; |
| 125 size_t out_of_flow_candidate_positions_index_; |
| 126 |
119 NGBoxStrut border_and_padding_; | 127 NGBoxStrut border_and_padding_; |
120 LayoutUnit content_size_; | 128 LayoutUnit content_size_; |
121 LayoutUnit max_inline_size_; | 129 LayoutUnit max_inline_size_; |
122 // MarginStrut for the previous child. | 130 // MarginStrut for the previous child. |
123 NGMarginStrut prev_child_margin_strut_; | 131 NGMarginStrut prev_child_margin_strut_; |
124 // Whether the block-start was set for the currently built | 132 // Whether the block-start was set for the currently built |
125 // fragment's margin strut. | 133 // fragment's margin strut. |
126 bool is_fragment_margin_strut_block_start_updated_ : 1; | 134 bool is_fragment_margin_strut_block_start_updated_ : 1; |
127 }; | 135 }; |
128 | 136 |
129 } // namespace blink | 137 } // namespace blink |
130 | 138 |
131 #endif // NGBlockLayoutAlgorithm_h | 139 #endif // NGBlockLayoutAlgorithm_h |
OLD | NEW |