Chromium Code Reviews| 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_physical_constraint_space.h" | 9 #include "core/layout/ng/ng_physical_constraint_space.h" |
| 10 #include "core/layout/ng/ng_writing_mode.h" | 10 #include "core/layout/ng/ng_writing_mode.h" |
| 11 #include "platform/heap/Handle.h" | 11 #include "platform/heap/Handle.h" |
| 12 #include "wtf/text/WTFString.h" | 12 #include "wtf/text/WTFString.h" |
| 13 #include "wtf/Vector.h" | 13 #include "wtf/Vector.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 class LayoutBox; | 17 class LayoutBox; |
| 18 class NGFragment; | 18 class NGFragment; |
| 19 class NGLayoutOpportunityIterator; | 19 class NGLayoutOpportunityIterator; |
| 20 | 20 |
| 21 // The NGConstraintSpace represents a set of constraints and available space | 21 // The NGConstraintSpace represents a set of constraints and available space |
| 22 // which a layout algorithm may produce a NGFragment within. It is a view on | 22 // which a layout algorithm may produce a NGFragment within. It is a view on |
| 23 // top of a NGPhysicalConstraintSpace and provides accessor methods in the | 23 // top of a NGPhysicalConstraintSpace and provides accessor methods in the |
| 24 // logical coordinate system defined by the writing mode given. | 24 // logical coordinate system defined by the writing mode given. |
| 25 class CORE_EXPORT NGConstraintSpace final | 25 class CORE_EXPORT NGConstraintSpace final |
| 26 : public GarbageCollected<NGConstraintSpace> { | 26 : public GarbageCollectedFinalized<NGConstraintSpace> { |
| 27 public: | 27 public: |
| 28 // Constructs a constraint space with a new backing NGPhysicalConstraintSpace. | 28 // Constructs a constraint space with a new backing NGPhysicalConstraintSpace. |
| 29 // The size will be used for both for the physical constraint space's | 29 // The size will be used for both for the physical constraint space's |
| 30 // container size and this constraint space's Size(). | 30 // container size and this constraint space's Size(). |
| 31 NGConstraintSpace(NGWritingMode, NGDirection, NGLogicalSize); | 31 NGConstraintSpace(NGWritingMode, NGDirection, NGLogicalSize); |
| 32 | 32 |
| 33 // Constructs a constraint space based on an existing backing | 33 // Constructs a constraint space based on an existing backing |
| 34 // NGPhysicalConstraintSpace. Sets this constraint space's size to the | 34 // NGPhysicalConstraintSpace. Sets this constraint space's size to the |
| 35 // physical constraint space's container size, converted to logical | 35 // physical constraint space's container size, converted to logical |
| 36 // coordinates. | 36 // coordinates. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 54 // to use as the basis to find layout opportunities for children. | 54 // to use as the basis to find layout opportunities for children. |
| 55 NGConstraintSpace(NGWritingMode, | 55 NGConstraintSpace(NGWritingMode, |
| 56 NGDirection, | 56 NGDirection, |
| 57 const NGConstraintSpace& other, | 57 const NGConstraintSpace& other, |
| 58 NGLogicalSize); | 58 NGLogicalSize); |
| 59 | 59 |
| 60 // This should live on NGBox or another layout bridge and probably take a root | 60 // This should live on NGBox or another layout bridge and probably take a root |
| 61 // NGConstraintSpace or a NGPhysicalConstraintSpace. | 61 // NGConstraintSpace or a NGPhysicalConstraintSpace. |
| 62 static NGConstraintSpace* CreateFromLayoutObject(const LayoutBox&); | 62 static NGConstraintSpace* CreateFromLayoutObject(const LayoutBox&); |
| 63 | 63 |
| 64 NGPhysicalConstraintSpace* PhysicalSpace() const { return physical_space_; } | 64 NGPhysicalConstraintSpace const& PhysicalSpace() const { |
| 65 return physical_space_; | |
| 66 } | |
| 65 | 67 |
| 66 NGDirection Direction() const { return static_cast<NGDirection>(direction_); } | 68 NGDirection Direction() const { return static_cast<NGDirection>(direction_); } |
| 67 | 69 |
| 68 NGWritingMode WritingMode() const { | 70 NGWritingMode WritingMode() const { |
| 69 return static_cast<NGWritingMode>(writing_mode_); | 71 return static_cast<NGWritingMode>(writing_mode_); |
| 70 } | 72 } |
| 71 | 73 |
| 72 // Size of the container. Used for the following three cases: | 74 // Size of the container. Used for the following three cases: |
| 73 // 1) Percentage resolution. | 75 // 1) Percentage resolution. |
| 74 // 2) Resolving absolute positions of children. | 76 // 2) Resolving absolute positions of children. |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 105 | 107 |
| 106 // Modifies constraint space to account for a placed fragment. Depending on | 108 // Modifies constraint space to account for a placed fragment. Depending on |
| 107 // the shape of the fragment this will either modify the inline or block | 109 // the shape of the fragment this will either modify the inline or block |
| 108 // size, or add an exclusion. | 110 // size, or add an exclusion. |
| 109 void Subtract(const NGFragment*); | 111 void Subtract(const NGFragment*); |
| 110 | 112 |
| 111 NGLayoutOpportunityIterator* LayoutOpportunities( | 113 NGLayoutOpportunityIterator* LayoutOpportunities( |
| 112 unsigned clear = NGClearNone, | 114 unsigned clear = NGClearNone, |
| 113 bool for_inline_or_bfc = false); | 115 bool for_inline_or_bfc = false); |
| 114 | 116 |
| 115 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(physical_space_); } | |
| 116 | |
| 117 // The setters for the NGConstraintSpace should only be used when constructing | 117 // The setters for the NGConstraintSpace should only be used when constructing |
| 118 // a derived NGConstraintSpace. | 118 // a derived NGConstraintSpace. |
| 119 void SetOverflowTriggersScrollbar(bool inlineTriggers, bool blockTriggers); | 119 void SetOverflowTriggersScrollbar(bool inlineTriggers, bool blockTriggers); |
| 120 void SetFixedSize(bool inlineFixed, bool blockFixed); | 120 void SetFixedSize(bool inlineFixed, bool blockFixed); |
| 121 void SetFragmentationType(NGFragmentationType); | 121 void SetFragmentationType(NGFragmentationType); |
| 122 | 122 |
| 123 String ToString() const; | 123 String ToString() const; |
| 124 | 124 |
| 125 DEFINE_INLINE_TRACE(){}; | |
|
cbiesinger
2016/09/26 17:17:55
no semicolon here. shouldn't there be a space befo
| |
| 126 | |
| 125 private: | 127 private: |
| 126 Member<NGPhysicalConstraintSpace> physical_space_; | 128 NGPhysicalConstraintSpace physical_space_; |
| 127 NGLogicalOffset offset_; | 129 NGLogicalOffset offset_; |
| 128 NGLogicalSize size_; | 130 NGLogicalSize size_; |
| 129 unsigned writing_mode_ : 3; | 131 unsigned writing_mode_ : 3; |
| 130 unsigned direction_ : 1; | 132 unsigned direction_ : 1; |
| 131 }; | 133 }; |
| 132 | 134 |
| 133 inline std::ostream& operator<<(std::ostream& stream, | 135 inline std::ostream& operator<<(std::ostream& stream, |
| 134 const NGConstraintSpace& value) { | 136 const NGConstraintSpace& value) { |
| 135 return stream << value.ToString(); | 137 return stream << value.ToString(); |
| 136 } | 138 } |
| 137 | 139 |
| 138 } // namespace blink | 140 } // namespace blink |
| 139 | 141 |
| 140 #endif // NGConstraintSpace_h | 142 #endif // NGConstraintSpace_h |
| OLD | NEW |