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 NGConstraintSpace_h | 5 #ifndef NGConstraintSpace_h |
6 #define NGConstraintSpace_h | 6 #define NGConstraintSpace_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/layout/ng/geometry/ng_logical_offset.h" | 9 #include "core/layout/ng/geometry/ng_logical_offset.h" |
10 #include "core/layout/ng/geometry/ng_logical_size.h" | 10 #include "core/layout/ng/geometry/ng_logical_size.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 } | 87 } |
88 | 88 |
89 bool IsBlockDirectionTriggersScrollbar() const { | 89 bool IsBlockDirectionTriggersScrollbar() const { |
90 return is_block_direction_triggers_scrollbar_; | 90 return is_block_direction_triggers_scrollbar_; |
91 } | 91 } |
92 | 92 |
93 // Some layout modes “stretch” their children to a fixed size (e.g. flex, | 93 // Some layout modes “stretch” their children to a fixed size (e.g. flex, |
94 // grid). These flags represented whether a layout needs to produce a | 94 // grid). These flags represented whether a layout needs to produce a |
95 // fragment that satisfies a fixed constraint in the inline and block | 95 // fragment that satisfies a fixed constraint in the inline and block |
96 // direction respectively. | 96 // direction respectively. |
| 97 // |
97 // If these flags are true, the AvailableSize() is interpreted as the fixed | 98 // If these flags are true, the AvailableSize() is interpreted as the fixed |
98 // border-box size of this box in the respective dimension. | 99 // border-box size of this box in the respective dimension. |
99 bool IsFixedSizeInline() const { return is_fixed_size_inline_; } | 100 bool IsFixedSizeInline() const { return is_fixed_size_inline_; } |
100 | 101 |
101 bool IsFixedSizeBlock() const { return is_fixed_size_block_; } | 102 bool IsFixedSizeBlock() const { return is_fixed_size_block_; } |
102 | 103 |
103 // Whether an auto inline-size should be interpreted as shrink-to-fit | 104 // Whether an auto inline-size should be interpreted as shrink-to-fit |
104 // (ie. fit-content). This is used for inline-block, floats, etc. | 105 // (ie. fit-content). This is used for inline-block, floats, etc. |
105 bool IsShrinkToFit() const { return is_shrink_to_fit_; } | 106 bool IsShrinkToFit() const { return is_shrink_to_fit_; } |
106 | 107 |
107 // If specified a layout should produce a Fragment which fragments at the | 108 // If specified a layout should produce a Fragment which fragments at the |
108 // blockSize if possible. | 109 // blockSize if possible. |
109 NGFragmentationType BlockFragmentationType() const; | 110 NGFragmentationType BlockFragmentationType() const; |
110 | 111 |
111 // Return true if this contraint space participates in a fragmentation | 112 // Return true if this contraint space participates in a fragmentation |
112 // context. | 113 // context. |
113 bool HasBlockFragmentation() const { | 114 bool HasBlockFragmentation() const { |
114 return BlockFragmentationType() != kFragmentNone; | 115 return BlockFragmentationType() != kFragmentNone; |
115 } | 116 } |
116 | 117 |
117 NGMarginStrut MarginStrut() const { return margin_strut_; } | 118 NGMarginStrut MarginStrut() const { return margin_strut_; } |
118 | 119 |
| 120 // The BfcOffset is where the MarginStrut is placed within the block |
| 121 // formatting context. |
| 122 // |
| 123 // The current layout or a descendant layout may "resolve" the BFC offset, |
| 124 // i.e. decide where the current fragment should be placed within the BFC. |
| 125 // |
| 126 // This is done by: |
| 127 // bfc_block_offset = |
| 128 // space.BfcOffset().block_offset + space.MarginStrut().Sum(); |
| 129 // |
| 130 // The BFC offset can get "resolved" in many circumstances (including, but |
| 131 // not limited to): |
| 132 // - block_start border or padding in the current layout. |
| 133 // - Text content, atomic inlines, (see NGLineBreaker). |
| 134 // - The current layout having a block_size. |
119 NGLogicalOffset BfcOffset() const { return bfc_offset_; } | 135 NGLogicalOffset BfcOffset() const { return bfc_offset_; } |
120 | 136 |
| 137 // If present, and the current layout hasn't resolved its BFC offset yet (see |
| 138 // BfcOffset), the layout should position all of its unpositioned floats at |
| 139 // this offset. |
| 140 // |
| 141 // This value should be propogated to child layouts if the current layout |
| 142 // hasn't resolved its BFC offset yet. |
| 143 // |
| 144 // This value is calculated *after* an initial pass of the tree, this value |
| 145 // should only be present during the second pass. |
| 146 WTF::Optional<NGLogicalOffset> FloatsBfcOffset() const { |
| 147 return floats_bfc_offset_; |
| 148 } |
| 149 |
121 Vector<RefPtr<NGUnpositionedFloat>>& UnpositionedFloats() { | 150 Vector<RefPtr<NGUnpositionedFloat>>& UnpositionedFloats() { |
122 return unpositioned_floats_; | 151 return unpositioned_floats_; |
123 } | 152 } |
124 | 153 |
125 WTF::Optional<LayoutUnit> ClearanceOffset() const { | 154 WTF::Optional<LayoutUnit> ClearanceOffset() const { |
126 return clearance_offset_; | 155 return clearance_offset_; |
127 } | 156 } |
128 | 157 |
129 bool operator==(const NGConstraintSpace&) const; | 158 bool operator==(const NGConstraintSpace&) const; |
130 bool operator!=(const NGConstraintSpace&) const; | 159 bool operator!=(const NGConstraintSpace&) const; |
(...skipping 12 matching lines...) Expand all Loading... |
143 bool is_fixed_size_inline, | 172 bool is_fixed_size_inline, |
144 bool is_fixed_size_block, | 173 bool is_fixed_size_block, |
145 bool is_shrink_to_fit, | 174 bool is_shrink_to_fit, |
146 bool is_inline_direction_triggers_scrollbar, | 175 bool is_inline_direction_triggers_scrollbar, |
147 bool is_block_direction_triggers_scrollbar, | 176 bool is_block_direction_triggers_scrollbar, |
148 NGFragmentationType block_direction_fragmentation_type, | 177 NGFragmentationType block_direction_fragmentation_type, |
149 bool is_new_fc, | 178 bool is_new_fc, |
150 bool is_anonymous, | 179 bool is_anonymous, |
151 const NGMarginStrut& margin_strut, | 180 const NGMarginStrut& margin_strut, |
152 const NGLogicalOffset& bfc_offset, | 181 const NGLogicalOffset& bfc_offset, |
| 182 const WTF::Optional<NGLogicalOffset>& floats_bfc_offset, |
153 const std::shared_ptr<NGExclusions>& exclusions, | 183 const std::shared_ptr<NGExclusions>& exclusions, |
154 Vector<RefPtr<NGUnpositionedFloat>>& unpositioned_floats, | 184 Vector<RefPtr<NGUnpositionedFloat>>& unpositioned_floats, |
155 const WTF::Optional<LayoutUnit>& clearance_offset); | 185 const WTF::Optional<LayoutUnit>& clearance_offset); |
156 | 186 |
157 NGPhysicalSize InitialContainingBlockSize() const { | 187 NGPhysicalSize InitialContainingBlockSize() const { |
158 return initial_containing_block_size_; | 188 return initial_containing_block_size_; |
159 } | 189 } |
160 | 190 |
161 NGLogicalSize available_size_; | 191 NGLogicalSize available_size_; |
162 NGLogicalSize percentage_resolution_size_; | 192 NGLogicalSize percentage_resolution_size_; |
(...skipping 15 matching lines...) Expand all Loading... |
178 // formatting Context | 208 // formatting Context |
179 unsigned is_new_fc_ : 1; | 209 unsigned is_new_fc_ : 1; |
180 | 210 |
181 unsigned is_anonymous_ : 1; | 211 unsigned is_anonymous_ : 1; |
182 | 212 |
183 unsigned writing_mode_ : 3; | 213 unsigned writing_mode_ : 3; |
184 unsigned direction_ : 1; | 214 unsigned direction_ : 1; |
185 | 215 |
186 NGMarginStrut margin_strut_; | 216 NGMarginStrut margin_strut_; |
187 NGLogicalOffset bfc_offset_; | 217 NGLogicalOffset bfc_offset_; |
| 218 WTF::Optional<NGLogicalOffset> floats_bfc_offset_; |
| 219 |
188 const std::shared_ptr<NGExclusions> exclusions_; | 220 const std::shared_ptr<NGExclusions> exclusions_; |
189 WTF::Optional<LayoutUnit> clearance_offset_; | 221 WTF::Optional<LayoutUnit> clearance_offset_; |
190 Vector<RefPtr<NGUnpositionedFloat>> unpositioned_floats_; | 222 Vector<RefPtr<NGUnpositionedFloat>> unpositioned_floats_; |
191 }; | 223 }; |
192 | 224 |
193 inline std::ostream& operator<<(std::ostream& stream, | 225 inline std::ostream& operator<<(std::ostream& stream, |
194 const NGConstraintSpace& value) { | 226 const NGConstraintSpace& value) { |
195 return stream << value.ToString(); | 227 return stream << value.ToString(); |
196 } | 228 } |
197 | 229 |
198 } // namespace blink | 230 } // namespace blink |
199 | 231 |
200 #endif // NGConstraintSpace_h | 232 #endif // NGConstraintSpace_h |
OLD | NEW |