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/ng_units.h" | 9 #include "core/layout/ng/ng_units.h" |
10 #include "core/layout/ng/ng_writing_mode.h" | 10 #include "core/layout/ng/ng_writing_mode.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 } | 87 } |
88 | 88 |
89 // Some layout modes “stretch” their children to a fixed size (e.g. flex, | 89 // Some layout modes “stretch” their children to a fixed size (e.g. flex, |
90 // grid). These flags represented whether a layout needs to produce a | 90 // grid). These flags represented whether a layout needs to produce a |
91 // fragment that satisfies a fixed constraint in the inline and block | 91 // fragment that satisfies a fixed constraint in the inline and block |
92 // direction respectively. | 92 // direction respectively. |
93 bool IsFixedSizeInline() const { return is_fixed_size_inline_; } | 93 bool IsFixedSizeInline() const { return is_fixed_size_inline_; } |
94 | 94 |
95 bool IsFixedSizeBlock() const { return is_fixed_size_block_; } | 95 bool IsFixedSizeBlock() const { return is_fixed_size_block_; } |
96 | 96 |
| 97 // Whether an auto inline-size should be interpreted as shrink-to-fit |
| 98 // (ie. fit-content). This is used for inline-block, floats, etc. |
| 99 bool IsShrinkToFit() const { return is_shrink_to_fit_; } |
| 100 |
97 // If specified a layout should produce a Fragment which fragments at the | 101 // If specified a layout should produce a Fragment which fragments at the |
98 // blockSize if possible. | 102 // blockSize if possible. |
99 NGFragmentationType BlockFragmentationType() const; | 103 NGFragmentationType BlockFragmentationType() const; |
100 | 104 |
101 // Modifies constraint space to account for a placed fragment. Depending on | 105 // Modifies constraint space to account for a placed fragment. Depending on |
102 // the shape of the fragment this will either modify the inline or block | 106 // the shape of the fragment this will either modify the inline or block |
103 // size, or add an exclusion. | 107 // size, or add an exclusion. |
104 void Subtract(const NGFragment*); | 108 void Subtract(const NGFragment*); |
105 | 109 |
106 NGLayoutOpportunityIterator* LayoutOpportunities( | 110 NGLayoutOpportunityIterator* LayoutOpportunities( |
107 unsigned clear = kNGClearNone, | 111 unsigned clear = kNGClearNone, |
108 bool for_inline_or_bfc = false); | 112 bool for_inline_or_bfc = false); |
109 | 113 |
110 DEFINE_INLINE_VIRTUAL_TRACE() {} | 114 DEFINE_INLINE_VIRTUAL_TRACE() {} |
111 | 115 |
112 String ToString() const; | 116 String ToString() const; |
113 | 117 |
114 private: | 118 private: |
115 friend class NGConstraintSpaceBuilder; | 119 friend class NGConstraintSpaceBuilder; |
116 // Default constructor. | 120 // Default constructor. |
117 NGConstraintSpace(NGWritingMode, | 121 NGConstraintSpace(NGWritingMode, |
118 TextDirection, | 122 TextDirection, |
119 NGLogicalSize available_size, | 123 NGLogicalSize available_size, |
120 NGLogicalSize percentage_resolution_size, | 124 NGLogicalSize percentage_resolution_size, |
121 bool is_fixed_size_inline, | 125 bool is_fixed_size_inline, |
122 bool is_fixed_size_block, | 126 bool is_fixed_size_block, |
| 127 bool is_shrink_to_fit, |
123 bool is_inline_direction_triggers_scrollbar, | 128 bool is_inline_direction_triggers_scrollbar, |
124 bool is_block_direction_triggers_scrollbar, | 129 bool is_block_direction_triggers_scrollbar, |
125 NGFragmentationType block_direction_fragmentation_type, | 130 NGFragmentationType block_direction_fragmentation_type, |
126 bool is_new_fc, | 131 bool is_new_fc, |
127 const std::shared_ptr<NGExclusions>& exclusions_); | 132 const std::shared_ptr<NGExclusions>& exclusions_); |
128 | 133 |
129 NGLogicalSize available_size_; | 134 NGLogicalSize available_size_; |
130 NGLogicalSize percentage_resolution_size_; | 135 NGLogicalSize percentage_resolution_size_; |
131 | 136 |
132 unsigned is_fixed_size_inline_ : 1; | 137 unsigned is_fixed_size_inline_ : 1; |
133 unsigned is_fixed_size_block_ : 1; | 138 unsigned is_fixed_size_block_ : 1; |
134 | 139 |
| 140 unsigned is_shrink_to_fit_ : 1; |
| 141 |
135 unsigned is_inline_direction_triggers_scrollbar_ : 1; | 142 unsigned is_inline_direction_triggers_scrollbar_ : 1; |
136 unsigned is_block_direction_triggers_scrollbar_ : 1; | 143 unsigned is_block_direction_triggers_scrollbar_ : 1; |
137 | 144 |
138 unsigned block_direction_fragmentation_type_ : 2; | 145 unsigned block_direction_fragmentation_type_ : 2; |
139 | 146 |
140 // Whether the current constraint space is for the newly established | 147 // Whether the current constraint space is for the newly established |
141 // formatting Context | 148 // formatting Context |
142 unsigned is_new_fc_ : 1; | 149 unsigned is_new_fc_ : 1; |
143 | 150 |
144 NGLogicalOffset offset_; | 151 NGLogicalOffset offset_; |
145 unsigned writing_mode_ : 3; | 152 unsigned writing_mode_ : 3; |
146 unsigned direction_ : 1; | 153 unsigned direction_ : 1; |
147 | 154 |
148 const std::shared_ptr<NGExclusions> exclusions_; | 155 const std::shared_ptr<NGExclusions> exclusions_; |
149 }; | 156 }; |
150 | 157 |
151 inline std::ostream& operator<<(std::ostream& stream, | 158 inline std::ostream& operator<<(std::ostream& stream, |
152 const NGConstraintSpace& value) { | 159 const NGConstraintSpace& value) { |
153 return stream << value.ToString(); | 160 return stream << value.ToString(); |
154 } | 161 } |
155 | 162 |
156 } // namespace blink | 163 } // namespace blink |
157 | 164 |
158 #endif // NGConstraintSpace_h | 165 #endif // NGConstraintSpace_h |
OLD | NEW |