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 MinAndMaxState ComputeMinAndMaxContentSizes(MinAndMaxContentSizes*) override; | 40 MinAndMaxState ComputeMinAndMaxContentSizes(MinAndMaxContentSizes*) override; |
40 NGLayoutStatus Layout(NGPhysicalFragmentBase*, | 41 NGLayoutStatus Layout(NGPhysicalFragmentBase*, |
41 NGPhysicalFragmentBase**, | 42 NGPhysicalFragmentBase**, |
42 NGLayoutAlgorithm**) override; | 43 NGLayoutAlgorithm**) override; |
43 | 44 |
44 DECLARE_VIRTUAL_TRACE(); | 45 DECLARE_VIRTUAL_TRACE(); |
45 | 46 |
46 private: | 47 private: |
47 // Creates a new constraint space for the current child. | 48 // Creates a new constraint space for the current child. |
48 NGConstraintSpace* CreateConstraintSpaceForCurrentChild() const; | 49 NGConstraintSpace* CreateConstraintSpaceForCurrentChild() const; |
49 void FinishCurrentChildLayout(NGFragmentBase* fragment); | 50 void FinishCurrentChildLayout(NGFragmentBase* fragment); |
| 51 bool LayoutOutOfFlowChild(); |
50 | 52 |
51 // Computes collapsed margins for 2 adjoining blocks and updates the resultant | 53 // Computes collapsed margins for 2 adjoining blocks and updates the resultant |
52 // fragment's MarginStrut if needed. | 54 // fragment's MarginStrut if needed. |
53 // See https://www.w3.org/TR/CSS2/box.html#collapsing-margins | 55 // See https://www.w3.org/TR/CSS2/box.html#collapsing-margins |
54 // | 56 // |
55 // @param child_margins Margins information for the current child. | 57 // @param child_margins Margins information for the current child. |
56 // @param fragment Current child's fragment. | 58 // @param fragment Current child's fragment. |
57 // @return NGBoxStrut with margins block start/end. | 59 // @return NGBoxStrut with margins block start/end. |
58 NGBoxStrut CollapseMargins(const NGBoxStrut& child_margins, | 60 NGBoxStrut CollapseMargins(const NGBoxStrut& child_margins, |
59 const NGFragment& fragment); | 61 const NGFragment& fragment); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 const NGConstraintSpace& ConstraintSpace() const { | 98 const NGConstraintSpace& ConstraintSpace() const { |
97 return *constraint_space_; | 99 return *constraint_space_; |
98 } | 100 } |
99 | 101 |
100 const ComputedStyle& Style() const { return *style_; } | 102 const ComputedStyle& Style() const { return *style_; } |
101 | 103 |
102 enum LayoutState { | 104 enum LayoutState { |
103 kStateInit, | 105 kStateInit, |
104 kStatePrepareForChildLayout, | 106 kStatePrepareForChildLayout, |
105 kStateChildLayout, | 107 kStateChildLayout, |
| 108 kStateOutOfFlowLayout, |
106 kStateFinalize | 109 kStateFinalize |
107 }; | 110 }; |
108 LayoutState layout_state_; | 111 LayoutState layout_state_; |
109 LayoutState compute_minmax_state_; | 112 LayoutState compute_minmax_state_; |
110 | 113 |
111 RefPtr<const ComputedStyle> style_; | 114 RefPtr<const ComputedStyle> style_; |
112 | 115 |
113 Member<NGBlockNode> first_child_; | 116 Member<NGBlockNode> first_child_; |
114 Member<NGConstraintSpace> constraint_space_; | 117 Member<NGConstraintSpace> constraint_space_; |
115 Member<NGBreakToken> break_token_; | 118 Member<NGBreakToken> break_token_; |
116 Member<NGFragmentBuilder> builder_; | 119 Member<NGFragmentBuilder> builder_; |
117 Member<NGConstraintSpaceBuilder> space_builder_; | 120 Member<NGConstraintSpaceBuilder> space_builder_; |
118 Member<NGConstraintSpace> space_for_current_child_; | 121 Member<NGConstraintSpace> space_for_current_child_; |
119 Member<NGBlockNode> current_child_; | 122 Member<NGBlockNode> current_child_; |
120 Member<NGBlockNode> current_minmax_child_; | 123 Member<NGBlockNode> current_minmax_child_; |
121 MinAndMaxContentSizes pending_minmax_sizes_; | 124 MinAndMaxContentSizes pending_minmax_sizes_; |
122 | 125 |
| 126 Member<NGOutOfFlowLayoutPart> out_of_flow_layout_; |
| 127 HeapLinkedHashSet<WeakMember<NGBlockNode>> out_of_flow_candidates_; |
| 128 Vector<NGStaticPosition> out_of_flow_candidate_positions_; |
| 129 size_t out_of_flow_candidate_positions_index_; |
| 130 |
123 NGBoxStrut border_and_padding_; | 131 NGBoxStrut border_and_padding_; |
124 LayoutUnit content_size_; | 132 LayoutUnit content_size_; |
125 LayoutUnit max_inline_size_; | 133 LayoutUnit max_inline_size_; |
126 // MarginStrut for the previous child. | 134 // MarginStrut for the previous child. |
127 NGMarginStrut prev_child_margin_strut_; | 135 NGMarginStrut prev_child_margin_strut_; |
128 // Whether the block-start was set for the currently built | 136 // Whether the block-start was set for the currently built |
129 // fragment's margin strut. | 137 // fragment's margin strut. |
130 bool is_fragment_margin_strut_block_start_updated_ : 1; | 138 bool is_fragment_margin_strut_block_start_updated_ : 1; |
131 }; | 139 }; |
132 | 140 |
133 } // namespace blink | 141 } // namespace blink |
134 | 142 |
135 #endif // NGBlockLayoutAlgorithm_h | 143 #endif // NGBlockLayoutAlgorithm_h |
OLD | NEW |