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_macros.h" | 9 #include "core/layout/ng/ng_macros.h" |
10 #include "core/layout/ng/ng_physical_constraint_space.h" | 10 #include "core/layout/ng/ng_physical_constraint_space.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 NGLogicalSize PercentageResolutionSize() const; | 72 NGLogicalSize PercentageResolutionSize() const; |
73 | 73 |
74 // The available space size. | 74 // The available space size. |
75 // See: https://drafts.csswg.org/css-sizing/#available | 75 // See: https://drafts.csswg.org/css-sizing/#available |
76 NGLogicalSize AvailableSize() const; | 76 NGLogicalSize AvailableSize() const; |
77 | 77 |
78 // Offset relative to the root constraint space. | 78 // Offset relative to the root constraint space. |
79 NGLogicalOffset Offset() const { return offset_; } | 79 NGLogicalOffset Offset() const { return offset_; } |
80 void SetOffset(const NGLogicalOffset& offset) { offset_ = offset; } | 80 void SetOffset(const NGLogicalOffset& offset) { offset_ = offset; } |
81 | 81 |
| 82 // Returns the effective size of the constraint space. Equal to the |
| 83 // AvailableSize() for the root constraint space but derived constraint spaces |
| 84 // return the size of the layout opportunity. |
| 85 virtual NGLogicalSize Size() const { return size_; } |
| 86 void SetSize(const NGLogicalSize& size) { size_ = size; } |
| 87 |
82 // Whether the current constraint space is for the newly established | 88 // Whether the current constraint space is for the newly established |
83 // Formatting Context. | 89 // Formatting Context. |
84 bool IsNewFormattingContext() const; | 90 bool IsNewFormattingContext() const; |
85 | 91 |
86 // Whether exceeding the AvailableSize() triggers the presence of a scrollbar | 92 // Whether exceeding the AvailableSize() triggers the presence of a scrollbar |
87 // for the indicated direction. | 93 // for the indicated direction. |
88 // If exceeded the current layout should be aborted and invoked again with a | 94 // If exceeded the current layout should be aborted and invoked again with a |
89 // constraint space modified to reserve space for a scrollbar. | 95 // constraint space modified to reserve space for a scrollbar. |
90 bool InlineTriggersScrollbar() const; | 96 bool InlineTriggersScrollbar() const; |
91 bool BlockTriggersScrollbar() const; | 97 bool BlockTriggersScrollbar() const; |
(...skipping 13 matching lines...) Expand all Loading... |
105 // the shape of the fragment this will either modify the inline or block | 111 // the shape of the fragment this will either modify the inline or block |
106 // size, or add an exclusion. | 112 // size, or add an exclusion. |
107 void Subtract(const NGFragment*); | 113 void Subtract(const NGFragment*); |
108 | 114 |
109 NGLayoutOpportunityIterator* LayoutOpportunities( | 115 NGLayoutOpportunityIterator* LayoutOpportunities( |
110 unsigned clear = NGClearNone, | 116 unsigned clear = NGClearNone, |
111 bool for_inline_or_bfc = false); | 117 bool for_inline_or_bfc = false); |
112 | 118 |
113 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(physical_space_); } | 119 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(physical_space_); } |
114 | 120 |
| 121 // The setters for the NGConstraintSpace should only be used when constructing |
| 122 // a derived NGConstraintSpace. |
| 123 void SetOverflowTriggersScrollbar(bool inlineTriggers, bool blockTriggers); |
| 124 void SetFixedSize(bool inlineFixed, bool blockFixed); |
| 125 void SetFragmentationType(NGFragmentationType); |
| 126 void SetIsNewFormattingContext(bool is_new_fc); |
| 127 |
115 NGConstraintSpace* ChildSpace(const ComputedStyle* style) const; | 128 NGConstraintSpace* ChildSpace(const ComputedStyle* style) const; |
116 | 129 |
117 String ToString() const; | 130 String ToString() const; |
118 | 131 |
119 private: | 132 private: |
120 Member<NGPhysicalConstraintSpace> physical_space_; | 133 Member<NGPhysicalConstraintSpace> physical_space_; |
121 NGLogicalOffset offset_; | 134 NGLogicalOffset offset_; |
| 135 NGLogicalSize size_; |
122 unsigned writing_mode_ : 3; | 136 unsigned writing_mode_ : 3; |
123 unsigned direction_ : 1; | 137 unsigned direction_ : 1; |
124 }; | 138 }; |
125 | 139 |
126 inline std::ostream& operator<<(std::ostream& stream, | 140 inline std::ostream& operator<<(std::ostream& stream, |
127 const NGConstraintSpace& value) { | 141 const NGConstraintSpace& value) { |
128 return stream << value.ToString(); | 142 return stream << value.ToString(); |
129 } | 143 } |
130 | 144 |
131 } // namespace blink | 145 } // namespace blink |
132 | 146 |
133 #endif // NGConstraintSpace_h | 147 #endif // NGConstraintSpace_h |
OLD | NEW |