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 "platform/LayoutUnit.h" | 9 #include "core/layout/ng/ng_units.h" |
10 #include "wtf/DoublyLinkedList.h" | 10 #include "wtf/DoublyLinkedList.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 class NGConstraintSpace; | 14 class NGConstraintSpace; |
15 class NGDerivedConstraintSpace; | 15 class NGDerivedConstraintSpace; |
16 class NGExclusion; | 16 class NGExclusion; |
17 class NGFragment; | 17 class NGFragment; |
18 class NGLayoutOpportunityIterator; | 18 class NGLayoutOpportunityIterator; |
19 class LayoutBox; | 19 class LayoutBox; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 enum NGDirection { LeftToRight = 0, RightToLeft = 1 }; | 51 enum NGDirection { LeftToRight = 0, RightToLeft = 1 }; |
52 | 52 |
53 class NGExclusion { | 53 class NGExclusion { |
54 public: | 54 public: |
55 NGExclusion(); | 55 NGExclusion(); |
56 ~NGExclusion() {} | 56 ~NGExclusion() {} |
57 }; | 57 }; |
58 | 58 |
59 class CORE_EXPORT NGConstraintSpace { | 59 class CORE_EXPORT NGConstraintSpace { |
60 public: | 60 public: |
61 NGConstraintSpace(LayoutUnit inlineContainerSize, | 61 NGConstraintSpace(NGLogicalSize container_size); |
62 LayoutUnit blockContainerSize); | 62 virtual ~NGConstraintSpace() {} |
63 ~NGConstraintSpace() {} | |
64 | 63 |
65 // Constructs Layout NG constraint space from legacy layout object. | 64 // Constructs Layout NG constraint space from legacy layout object. |
66 static NGConstraintSpace fromLayoutObject(const LayoutBox&); | 65 static NGConstraintSpace fromLayoutObject(const LayoutBox&); |
67 | 66 |
68 void addExclusion(const NGExclusion, unsigned options = 0); | 67 void addExclusion(const NGExclusion, unsigned options = 0); |
69 void setOverflowTriggersScrollbar(bool inlineTriggers, bool blockTriggers); | 68 void setOverflowTriggersScrollbar(bool inlineTriggers, bool blockTriggers); |
70 void setFixedSize(bool inlineFixed, bool blockFixed); | 69 void setFixedSize(bool inlineFixed, bool blockFixed); |
71 void setFragmentationType(NGFragmentationType); | 70 void setFragmentationType(NGFragmentationType); |
72 | 71 |
73 // Size of the container in each direction. Used for the following | 72 // Size of the container. Used for the following three cases: |
74 // three cases: | |
75 // 1) Percentage resolution. | 73 // 1) Percentage resolution. |
76 // 2) Resolving absolute positions of children. | 74 // 2) Resolving absolute positions of children. |
77 // 3) Defining the threashold that triggers the presence of a scrollbar. Only | 75 // 3) Defining the threashold that triggers the presence of a scrollbar. Only |
78 // applies if the corresponding scrollbarTrigger flag has been set for the | 76 // applies if the corresponding scrollbarTrigger flag has been set for the |
79 // direction. | 77 // direction. |
80 LayoutUnit inlineContainerSize() const { return m_inlineContainerSize; } | 78 NGLogicalSize ContainerSize() const { return container_size_; } |
81 LayoutUnit blockContainerSize() const { return m_blockContainerSize; } | 79 |
| 80 // Returns the effective size of the constraint space. Defaults to |
| 81 // ContainerSize() for the root constraint space but derived constraint spaces |
| 82 // overrides it to return the size of the layout opportunity. |
| 83 virtual NGLogicalSize Size() const { return ContainerSize(); } |
82 | 84 |
83 // Whether exceeding the containerSize triggers the presence of a scrollbar | 85 // Whether exceeding the containerSize triggers the presence of a scrollbar |
84 // for the indicated direction. | 86 // for the indicated direction. |
85 // If exceeded the current layout should be aborted and invoked again with a | 87 // If exceeded the current layout should be aborted and invoked again with a |
86 // constraint space modified to reserve space for a scrollbar. | 88 // constraint space modified to reserve space for a scrollbar. |
87 bool inlineTriggersScrollbar() const { return m_inlineTriggersScrollbar; } | 89 bool inlineTriggersScrollbar() const { return m_inlineTriggersScrollbar; } |
88 bool blockTriggersScrollbar() const { return m_blockTriggersScrollbar; } | 90 bool blockTriggersScrollbar() const { return m_blockTriggersScrollbar; } |
89 | 91 |
90 // Some layout modes “stretch” their children to a fixed size (e.g. flex, | 92 // Some layout modes “stretch” their children to a fixed size (e.g. flex, |
91 // grid). These flags represented whether a layout needs to produce a | 93 // grid). These flags represented whether a layout needs to produce a |
(...skipping 13 matching lines...) Expand all Loading... |
105 NGLayoutOpportunityIterator layoutOpportunities( | 107 NGLayoutOpportunityIterator layoutOpportunities( |
106 unsigned clear = NGClearNone, | 108 unsigned clear = NGClearNone, |
107 NGExclusionFlowType avoid = ExcludeNone) const; | 109 NGExclusionFlowType avoid = ExcludeNone) const; |
108 | 110 |
109 // Modifies constraint space to account for a placed fragment. Depending on | 111 // Modifies constraint space to account for a placed fragment. Depending on |
110 // the shape of the fragment this will either modify the inline or block | 112 // the shape of the fragment this will either modify the inline or block |
111 // size, or add an exclusion. | 113 // size, or add an exclusion. |
112 void subtract(const NGFragment); | 114 void subtract(const NGFragment); |
113 | 115 |
114 private: | 116 private: |
115 LayoutUnit m_inlineContainerSize; | 117 NGLogicalSize container_size_; |
116 LayoutUnit m_blockContainerSize; | |
117 | 118 |
118 unsigned m_fixedInlineSize : 1; | 119 unsigned m_fixedInlineSize : 1; |
119 unsigned m_fixedBlockSize : 1; | 120 unsigned m_fixedBlockSize : 1; |
120 unsigned m_inlineTriggersScrollbar : 1; | 121 unsigned m_inlineTriggersScrollbar : 1; |
121 unsigned m_blockTriggersScrollbar : 1; | 122 unsigned m_blockTriggersScrollbar : 1; |
122 unsigned m_blockFragmentationType : 2; | 123 unsigned m_blockFragmentationType : 2; |
123 | 124 |
124 DoublyLinkedList<const NGExclusion> m_exclusions; | 125 DoublyLinkedList<const NGExclusion> m_exclusions; |
125 }; | 126 }; |
126 | 127 |
127 class CORE_EXPORT NGLayoutOpportunityIterator final { | 128 class CORE_EXPORT NGLayoutOpportunityIterator final { |
128 public: | 129 public: |
129 NGLayoutOpportunityIterator(const NGConstraintSpace* space, | 130 NGLayoutOpportunityIterator(const NGConstraintSpace* space, |
130 unsigned clear, | 131 unsigned clear, |
131 NGExclusionFlowType avoid) | 132 NGExclusionFlowType avoid) |
132 : m_constraintSpace(space), m_clear(clear), m_avoid(avoid) {} | 133 : m_constraintSpace(space), m_clear(clear), m_avoid(avoid) {} |
133 ~NGLayoutOpportunityIterator() {} | 134 ~NGLayoutOpportunityIterator() {} |
134 | 135 |
135 const NGDerivedConstraintSpace* next(); | 136 const NGDerivedConstraintSpace* next(); |
136 | 137 |
137 private: | 138 private: |
138 const NGConstraintSpace* m_constraintSpace; | 139 const NGConstraintSpace* m_constraintSpace; |
139 unsigned m_clear; | 140 unsigned m_clear; |
140 NGExclusionFlowType m_avoid; | 141 NGExclusionFlowType m_avoid; |
141 }; | 142 }; |
142 | 143 |
143 } // namespace blink | 144 } // namespace blink |
144 | 145 |
145 #endif // NGConstraintSpace_h | 146 #endif // NGConstraintSpace_h |
OLD | NEW |