OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved. |
3 * Copyright (C) 2013 Intel Corporation. All rights reserved. | 3 * Copyright (C) 2013 Intel Corporation. All rights reserved. |
4 * | 4 * |
5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
6 * | 6 * |
7 * Other contributors: | 7 * Other contributors: |
8 * Robert O'Callahan <roc+@cs.cmu.edu> | 8 * Robert O'Callahan <roc+@cs.cmu.edu> |
9 * David Baron <dbaron@fas.harvard.edu> | 9 * David Baron <dbaron@fas.harvard.edu> |
10 * Christian Biesinger <cbiesinger@web.de> | 10 * Christian Biesinger <cbiesinger@web.de> |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 class PaintLayerCompositor; | 57 class PaintLayerCompositor; |
58 class ComputedStyle; | 58 class ComputedStyle; |
59 class LayoutBoxModelObject; | 59 class LayoutBoxModelObject; |
60 | 60 |
61 // PaintLayerStackingNode represents anything that is a stacking | 61 // PaintLayerStackingNode represents anything that is a stacking |
62 // context or treated as a stacking context. | 62 // context or treated as a stacking context. |
63 // | 63 // |
64 // Stacking contexts are the basis for the CSS painting algorithm. The paint | 64 // Stacking contexts are the basis for the CSS painting algorithm. The paint |
65 // order is determined by walking stacking contexts (or elements treated like a | 65 // order is determined by walking stacking contexts (or elements treated like a |
66 // stacking context like positioned objects or floats) in an order defined by | 66 // stacking context like positioned objects or floats) in an order defined by |
67 // ‘z-index’. This walk is interleaved with content that is not a stacking. | 67 // ‘z-index’. This walk is interleaved with content that is not a stacking |
68 // context. See CSS 2.1 appendix E for the actual algorithm | 68 // context. See CSS 2.1 appendix E for the actual algorithm |
69 // http://www.w3.org/TR/CSS21/zindex.html | 69 // http://www.w3.org/TR/CSS21/zindex.html |
70 // See also PaintLayerPainter (in particular paintLayerContents) for | 70 // See also PaintLayerPainter (in particular paintLayerContents) for |
71 // our implementation of the walk. | 71 // our implementation of the walk. |
72 // | 72 // |
73 // Stacking contexts form a subtree over the layout tree. Ideally we would want | 73 // Stacking contexts form a subtree over the layout tree. Ideally we would want |
74 // objects of this class to be a node in this tree but there are potential | 74 // objects of this class to be a node in this tree but there are potential |
75 // issues with stale pointers so we rely on PaintLayer's tree | 75 // issues with stale pointers so we rely on PaintLayer's tree |
76 // structure. | 76 // structure. |
77 // | 77 // |
(...skipping 20 matching lines...) Expand all Loading... | |
98 | 98 |
99 bool zOrderListsDirty() const { return m_zOrderListsDirty; } | 99 bool zOrderListsDirty() const { return m_zOrderListsDirty; } |
100 void dirtyZOrderLists(); | 100 void dirtyZOrderLists(); |
101 void updateZOrderLists(); | 101 void updateZOrderLists(); |
102 void clearZOrderLists(); | 102 void clearZOrderLists(); |
103 void dirtyStackingContextZOrderLists(); | 103 void dirtyStackingContextZOrderLists(); |
104 | 104 |
105 bool hasPositiveZOrderList() const { return posZOrderList() && posZOrderList ()->size(); } | 105 bool hasPositiveZOrderList() const { return posZOrderList() && posZOrderList ()->size(); } |
106 bool hasNegativeZOrderList() const { return negZOrderList() && negZOrderList ()->size(); } | 106 bool hasNegativeZOrderList() const { return negZOrderList() && negZOrderList ()->size(); } |
107 | 107 |
108 bool isTreatedAsOrStackingContext() const { return m_isTreatedAsOrStackingCo ntext; } | 108 bool isStacked() const { return m_isStacked; } |
109 void updateIsTreatedAsStackingContext(); | 109 void updateIsStacked(); |
110 | 110 |
111 void updateStackingNodesAfterStyleChange(const ComputedStyle* oldStyle); | 111 void updateStackingNodesAfterStyleChange(const ComputedStyle* oldStyle); |
112 | 112 |
113 PaintLayerStackingNode* ancestorStackingContextNode() const; | 113 PaintLayerStackingNode* ancestorStackingContextNode() const; |
114 | 114 |
115 PaintLayer* layer() const { return m_layer; } | 115 PaintLayer* layer() const { return m_layer; } |
116 | 116 |
117 #if ENABLE(ASSERT) | 117 #if ENABLE(ASSERT) |
118 bool layerListMutationAllowed() const { return m_layerListMutationAllowed; } | 118 bool layerListMutationAllowed() const { return m_layerListMutationAllowed; } |
119 void setLayerListMutationAllowed(bool flag) { m_layerListMutationAllowed = f lag; } | 119 void setLayerListMutationAllowed(bool flag) { m_layerListMutationAllowed = f lag; } |
120 #endif | 120 #endif |
121 | 121 |
122 // Stacking contexts and positioned elements[1] are stacked (sorted in negZO rderList | |
123 // and posZOrderList) in their enclosing stacking contexts. | |
124 // | |
125 // [1] According to CSS2.1, Appendix E.2.8 (https://www.w3.org/TR/CSS21/zind ex.html), | |
126 // positioned elements with 'z-index: auto' are "treated as if it created a new | |
127 // stacking context" and z-ordered together with other elements with 'z-inde x: 0'. | |
128 // The difference of them from normal stacking contexts is that they don't d etermine | |
129 // the stacking of the elements underneath them. | |
130 // (Note: There are also other elements treated as stacking context during p ainting, | |
131 // but not managed in stacks. See ObjectPainter::paintAllPhasesAtomically(). ) | |
pdr.
2016/03/16 02:22:53
Optional, may want to add a link to the markdown t
Xianzhu
2016/03/16 18:10:24
Done.
| |
132 static bool shouldStackObject(const LayoutObject& object) { return object.st yleRef().isStackingContext() || object.isPositioned(); } | |
133 | |
122 private: | 134 private: |
123 friend class PaintLayerStackingNodeIterator; | 135 friend class PaintLayerStackingNodeIterator; |
124 friend class PaintLayerStackingNodeReverseIterator; | 136 friend class PaintLayerStackingNodeReverseIterator; |
125 friend class LayoutTreeAsText; | 137 friend class LayoutTreeAsText; |
126 | 138 |
127 Vector<PaintLayerStackingNode*>* posZOrderList() const | 139 Vector<PaintLayerStackingNode*>* posZOrderList() const |
128 { | 140 { |
129 ASSERT(!m_zOrderListsDirty); | 141 ASSERT(!m_zOrderListsDirty); |
130 ASSERT(isStackingContext() || !m_posZOrderList); | 142 ASSERT(isStackingContext() || !m_posZOrderList); |
131 return m_posZOrderList.get(); | 143 return m_posZOrderList.get(); |
132 } | 144 } |
133 | 145 |
134 Vector<PaintLayerStackingNode*>* negZOrderList() const | 146 Vector<PaintLayerStackingNode*>* negZOrderList() const |
135 { | 147 { |
136 ASSERT(!m_zOrderListsDirty); | 148 ASSERT(!m_zOrderListsDirty); |
137 ASSERT(isStackingContext() || !m_negZOrderList); | 149 ASSERT(isStackingContext() || !m_negZOrderList); |
138 return m_negZOrderList.get(); | 150 return m_negZOrderList.get(); |
139 } | 151 } |
140 | 152 |
141 void rebuildZOrderLists(); | 153 void rebuildZOrderLists(); |
142 void collectLayers(OwnPtr<Vector<PaintLayerStackingNode*>>& posZOrderList, O wnPtr<Vector<PaintLayerStackingNode*>>& negZOrderList); | 154 void collectLayers(OwnPtr<Vector<PaintLayerStackingNode*>>& posZOrderList, O wnPtr<Vector<PaintLayerStackingNode*>>& negZOrderList); |
143 | 155 |
144 #if ENABLE(ASSERT) | 156 #if ENABLE(ASSERT) |
145 bool isInStackingParentZOrderLists() const; | 157 bool isInStackingParentZOrderLists() const; |
146 void updateStackingParentForZOrderLists(PaintLayerStackingNode* stackingPare nt); | 158 void updateStackingParentForZOrderLists(PaintLayerStackingNode* stackingPare nt); |
147 void setStackingParent(PaintLayerStackingNode* stackingParent) { m_stackingP arent = stackingParent; } | 159 void setStackingParent(PaintLayerStackingNode* stackingParent) { m_stackingP arent = stackingParent; } |
148 #endif | 160 #endif |
149 | 161 |
150 bool shouldBeTreatedAsOrStackingContext() const { return layoutObject()->sty le()->isTreatedAsOrStackingContext(); } | |
151 | |
152 bool isDirtyStackingContext() const { return m_zOrderListsDirty && isStackin gContext(); } | 162 bool isDirtyStackingContext() const { return m_zOrderListsDirty && isStackin gContext(); } |
153 | 163 |
154 PaintLayerCompositor* compositor() const; | 164 PaintLayerCompositor* compositor() const; |
155 // We can't return a LayoutBox as LayoutInline can be a stacking context. | 165 // We can't return a LayoutBox as LayoutInline can be a stacking context. |
156 LayoutBoxModelObject* layoutObject() const; | 166 LayoutBoxModelObject* layoutObject() const; |
157 | 167 |
158 PaintLayer* m_layer; | 168 PaintLayer* m_layer; |
159 | 169 |
160 // m_posZOrderList holds a sorted list of all the descendant nodes within | 170 // m_posZOrderList holds a sorted list of all the descendant nodes within |
161 // that have z-indices of 0 or greater (auto will count as 0). | 171 // that have z-indices of 0 (or is treated as 0 for positioned objects) or g reater. |
162 // m_negZOrderList holds descendants within our stacking context with | 172 // m_negZOrderList holds descendants within our stacking context with |
163 // negative z-indices. | 173 // negative z-indices. |
164 OwnPtr<Vector<PaintLayerStackingNode*>> m_posZOrderList; | 174 OwnPtr<Vector<PaintLayerStackingNode*>> m_posZOrderList; |
165 OwnPtr<Vector<PaintLayerStackingNode*>> m_negZOrderList; | 175 OwnPtr<Vector<PaintLayerStackingNode*>> m_negZOrderList; |
166 | 176 |
167 // This boolean caches whether the z-order lists above are dirty. | 177 // This boolean caches whether the z-order lists above are dirty. |
168 // It is only ever set for stacking contexts, as no other element can | 178 // It is only ever set for stacking contexts, as no other element can |
169 // have z-order lists. | 179 // have z-order lists. |
170 unsigned m_zOrderListsDirty : 1; | 180 unsigned m_zOrderListsDirty : 1; |
171 | 181 |
172 // This attribute caches whether the element was a stacking context or | 182 // This attribute caches whether the element was stacked, so that we can do comparison against |
173 // was treated like a stacking context, so that we can do comparison against | |
174 // it during style change (styleDidChange in particular), as we have lost | 183 // it during style change (styleDidChange in particular), as we have lost |
175 // the previous style information. | 184 // the previous style information. |
176 unsigned m_isTreatedAsOrStackingContext: 1; | 185 unsigned m_isStacked: 1; |
177 | 186 |
178 #if ENABLE(ASSERT) | 187 #if ENABLE(ASSERT) |
179 unsigned m_layerListMutationAllowed : 1; | 188 unsigned m_layerListMutationAllowed : 1; |
180 PaintLayerStackingNode* m_stackingParent; | 189 PaintLayerStackingNode* m_stackingParent; |
181 #endif | 190 #endif |
182 }; | 191 }; |
183 | 192 |
184 inline void PaintLayerStackingNode::clearZOrderLists() | 193 inline void PaintLayerStackingNode::clearZOrderLists() |
185 { | 194 { |
186 ASSERT(!isStackingContext()); | 195 ASSERT(!isStackingContext()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 | 233 |
225 private: | 234 private: |
226 PaintLayerStackingNode* m_stackingNode; | 235 PaintLayerStackingNode* m_stackingNode; |
227 bool m_previousMutationAllowedState; | 236 bool m_previousMutationAllowedState; |
228 }; | 237 }; |
229 #endif | 238 #endif |
230 | 239 |
231 } // namespace blink | 240 } // namespace blink |
232 | 241 |
233 #endif // PaintLayerStackingNode_h | 242 #endif // PaintLayerStackingNode_h |
OLD | NEW |