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/LayoutBox.h" | 9 #include "core/layout/LayoutBox.h" |
10 #include "core/layout/ng/ng_physical_constraint_space.h" | 10 #include "core/layout/ng/ng_physical_constraint_space.h" |
11 #include "core/layout/ng/ng_writing_mode.h" | 11 #include "core/layout/ng/ng_writing_mode.h" |
12 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
13 #include "wtf/text/WTFString.h" | 13 #include "wtf/text/WTFString.h" |
14 #include "wtf/Vector.h" | |
14 | 15 |
15 namespace blink { | 16 namespace blink { |
16 | 17 |
17 class LayoutBox; | 18 class LayoutBox; |
18 class NGDerivedConstraintSpace; | 19 class NGDerivedConstraintSpace; |
19 class NGFragment; | 20 class NGFragment; |
20 class NGLayoutOpportunityIterator; | 21 class NGLayoutOpportunityIterator; |
21 | 22 |
22 // The NGConstraintSpace represents a set of constraints and available space | 23 // The NGConstraintSpace represents a set of constraints and available space |
23 // which a layout algorithm may produce a NGFragment within. It is a view on | 24 // which a layout algorithm may produce a NGFragment within. It is a view on |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 | 92 |
92 // If specified a layout should produce a Fragment which fragments at the | 93 // If specified a layout should produce a Fragment which fragments at the |
93 // blockSize if possible. | 94 // blockSize if possible. |
94 NGFragmentationType BlockFragmentationType() const; | 95 NGFragmentationType BlockFragmentationType() const; |
95 | 96 |
96 // Modifies constraint space to account for a placed fragment. Depending on | 97 // Modifies constraint space to account for a placed fragment. Depending on |
97 // the shape of the fragment this will either modify the inline or block | 98 // the shape of the fragment this will either modify the inline or block |
98 // size, or add an exclusion. | 99 // size, or add an exclusion. |
99 void Subtract(const NGFragment*); | 100 void Subtract(const NGFragment*); |
100 | 101 |
101 NGLayoutOpportunityIterator LayoutOpportunities( | 102 NGLayoutOpportunityIterator* LayoutOpportunities( |
102 unsigned clear = NGClearNone, | 103 unsigned clear = NGClearNone, |
103 bool for_inline_or_bfc = false); | 104 bool for_inline_or_bfc = false); |
104 | 105 |
105 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(physical_space_); } | 106 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(physical_space_); } |
106 | 107 |
107 // The setters for the NGConstraintSpace should only be used when constructing | 108 // The setters for the NGConstraintSpace should only be used when constructing |
108 // a derived NGConstraintSpace. | 109 // a derived NGConstraintSpace. |
109 void SetOverflowTriggersScrollbar(bool inlineTriggers, bool blockTriggers); | 110 void SetOverflowTriggersScrollbar(bool inlineTriggers, bool blockTriggers); |
110 void SetFixedSize(bool inlineFixed, bool blockFixed); | 111 void SetFixedSize(bool inlineFixed, bool blockFixed); |
111 void SetFragmentationType(NGFragmentationType); | 112 void SetFragmentationType(NGFragmentationType); |
112 | 113 |
113 String toString() const; | 114 String toString() const; |
114 | 115 |
115 private: | 116 private: |
116 Member<NGPhysicalConstraintSpace> physical_space_; | 117 Member<NGPhysicalConstraintSpace> physical_space_; |
117 NGLogicalOffset offset_; | 118 NGLogicalOffset offset_; |
118 NGLogicalSize size_; | 119 NGLogicalSize size_; |
119 unsigned writing_mode_ : 3; | 120 unsigned writing_mode_ : 3; |
120 }; | 121 }; |
121 | 122 |
122 class CORE_EXPORT NGLayoutOpportunityIterator final { | 123 class CORE_EXPORT NGLayoutOpportunityIterator final |
124 : public GarbageCollectedFinalized<NGLayoutOpportunityIterator> { | |
123 public: | 125 public: |
124 NGLayoutOpportunityIterator(NGConstraintSpace* space, | 126 NGLayoutOpportunityIterator(NGConstraintSpace* space, |
125 unsigned clear, | 127 unsigned clear, |
126 bool for_inline_or_bfc) | 128 bool for_inline_or_bfc); |
127 : constraint_space_(space), | |
128 clear_(clear), | |
129 for_inline_or_bfc_(for_inline_or_bfc) {} | |
130 ~NGLayoutOpportunityIterator() {} | 129 ~NGLayoutOpportunityIterator() {} |
131 | 130 |
132 NGConstraintSpace* Next(); | 131 NGConstraintSpace* Next(); |
133 | 132 |
133 DEFINE_INLINE_VIRTUAL_TRACE() { | |
134 visitor->trace(constraint_space_); | |
135 visitor->trace(current_opportunities_); | |
136 } | |
137 | |
134 private: | 138 private: |
135 Persistent<NGConstraintSpace> constraint_space_; | 139 void computeForExclusion(unsigned index); |
140 LayoutUnit heightForOpportunity(LayoutUnit left, | |
141 LayoutUnit top, | |
142 LayoutUnit right, | |
143 LayoutUnit bottom); | |
144 void addLayoutOpportunity(LayoutUnit left, | |
145 LayoutUnit top, | |
146 LayoutUnit right, | |
147 LayoutUnit bottom); | |
148 | |
149 Member<NGConstraintSpace> constraint_space_; | |
136 unsigned clear_; | 150 unsigned clear_; |
137 bool for_inline_or_bfc_; | 151 bool for_inline_or_bfc_; |
152 Vector<NGExclusion> filtered_exclusions_; | |
153 HeapVector<Member<NGConstraintSpace>> current_opportunities_; | |
154 unsigned current_exclusion_; | |
ikilpatrick
2016/09/06 23:09:40
current_exclusion_idx_ ? up to you.
eae
2016/09/06 23:30:53
I like that, changed.
| |
138 }; | 155 }; |
139 | 156 |
140 inline std::ostream& operator<<(std::ostream& stream, | 157 inline std::ostream& operator<<(std::ostream& stream, |
141 const NGConstraintSpace& value) { | 158 const NGConstraintSpace& value) { |
142 return stream << value.toString(); | 159 return stream << value.toString(); |
143 } | 160 } |
144 | 161 |
145 } // namespace blink | 162 } // namespace blink |
146 | 163 |
147 #endif // NGConstraintSpace_h | 164 #endif // NGConstraintSpace_h |
OLD | NEW |