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> |
11 * Randall Jesup <rjesup@wgate.com> | 11 * Randall Jesup <rjesup@wgate.com> |
12 * Roland Mainz <roland.mainz@informatik.med.uni-giessen.de> | 12 * Roland Mainz <roland.mainz@informatik.med.uni-giessen.de> |
13 * Josh Soref <timeless@mac.com> | 13 * Josh Soref <timeless@mac.com> |
14 * Boris Zbarsky <bzbarsky@mit.edu> | 14 * Boris Zbarsky <bzbarsky@mit.edu> |
15 * | 15 * |
16 * This library is free software; you can redistribute it and/or | 16 * This library is free software; you can redistribute it and/or |
17 * modify it under the terms of the GNU Lesser General Public | 17 * modify it under the terms of the GNU Lesser General Public |
18 * License as published by the Free Software Foundation; either | 18 * License as published by the Free Software Foundation; either |
19 * version 2.1 of the License, or (at your option) any later version. | 19 * version 2.1 of the License, or (at your option) any later version. |
20 * | 20 * |
21 * This library is distributed in the hope that it will be useful, | 21 * This library is distributed in the hope that it will be useful, |
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
24 * Lesser General Public License for more details. | 24 * Lesser General Public License for more details. |
25 * | 25 * |
26 * You should have received a copy of the GNU Lesser General Public | 26 * You should have received a copy of the GNU Lesser General Public |
27 * License along with this library; if not, write to the Free Software | 27 * License along with this library; if not, write to the Free Software |
28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 US
A | 28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
29 * | 29 * |
30 * Alternatively, the contents of this file may be used under the terms | 30 * Alternatively, the contents of this file may be used under the terms |
31 * of either the Mozilla Public License Version 1.1, found at | 31 * of either the Mozilla Public License Version 1.1, found at |
32 * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public | 32 * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public |
33 * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html | 33 * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html |
34 * (the "GPL"), in which case the provisions of the MPL or the GPL are | 34 * (the "GPL"), in which case the provisions of the MPL or the GPL are |
35 * applicable instead of those above. If you wish to allow use of your | 35 * applicable instead of those above. If you wish to allow use of your |
36 * version of this file only under the terms of one of those two | 36 * version of this file only under the terms of one of those two |
37 * licenses (the MPL or the GPL) and not to allow others to use your | 37 * licenses (the MPL or the GPL) and not to allow others to use your |
38 * version of this file under the LGPL, indicate your decision by | 38 * version of this file under the LGPL, indicate your decision by |
(...skipping 14 matching lines...) Expand all Loading... |
53 | 53 |
54 namespace blink { | 54 namespace blink { |
55 | 55 |
56 class PaintLayer; | 56 class PaintLayer; |
57 class PaintLayerCompositor; | 57 class PaintLayerCompositor; |
58 class ComputedStyle; | 58 class ComputedStyle; |
59 class LayoutBoxModelObject; | 59 class LayoutBoxModelObject; |
60 | 60 |
61 // PaintLayerStackingNode represents a stacked element which is either a | 61 // PaintLayerStackingNode represents a stacked element which is either a |
62 // stacking context or a positioned element. | 62 // stacking context or a positioned element. |
63 // See https://chromium.googlesource.com/chromium/src.git/+/master/third_party/W
ebKit/Source/core/paint/README.md | 63 // See |
| 64 // https://chromium.googlesource.com/chromium/src.git/+/master/third_party/WebKi
t/Source/core/paint/README.md |
64 // for more details of stacked elements. | 65 // for more details of stacked elements. |
65 // | 66 // |
66 // Stacked elements are the basis for the CSS painting algorithm. The paint | 67 // Stacked elements are the basis for the CSS painting algorithm. The paint |
67 // order is determined by walking stacked elements in an order defined by | 68 // order is determined by walking stacked elements in an order defined by |
68 // ‘z-index’. This walk is interleaved with non-stacked contents. | 69 // ‘z-index’. This walk is interleaved with non-stacked contents. |
69 // See CSS 2.1 appendix E for the actual algorithm | 70 // See CSS 2.1 appendix E for the actual algorithm |
70 // http://www.w3.org/TR/CSS21/zindex.html | 71 // http://www.w3.org/TR/CSS21/zindex.html |
71 // See also PaintLayerPainter (in particular paintLayerContents) for | 72 // See also PaintLayerPainter (in particular paintLayerContents) for |
72 // our implementation of the walk. | 73 // our implementation of the walk. |
73 // | 74 // |
74 // Stacked elements form a subtree over the layout tree. Ideally we would want | 75 // Stacked elements form a subtree over the layout tree. Ideally we would want |
75 // objects of this class to be a node in this tree but there are potential | 76 // objects of this class to be a node in this tree but there are potential |
76 // issues with stale pointers so we rely on PaintLayer's tree | 77 // issues with stale pointers so we rely on PaintLayer's tree |
77 // structure. | 78 // structure. |
78 // | 79 // |
79 // This class's purpose is to represent a node in the stacked element tree | 80 // This class's purpose is to represent a node in the stacked element tree |
80 // (aka paint tree). It currently caches the z-order lists for painting and | 81 // (aka paint tree). It currently caches the z-order lists for painting and |
81 // hit-testing. | 82 // hit-testing. |
82 // | 83 // |
83 // To implement any z-order list iterations, use | 84 // To implement any z-order list iterations, use |
84 // PaintLayerStackingNodeIterator and | 85 // PaintLayerStackingNodeIterator and |
85 // PaintLayerStackingNodeReverseIterator. | 86 // PaintLayerStackingNodeReverseIterator. |
86 // | 87 // |
87 // Only a real stacking context can have non-empty z-order lists thus contain | 88 // Only a real stacking context can have non-empty z-order lists thus contain |
88 // child nodes in the tree. The z-order lists of a positioned element with auto | 89 // child nodes in the tree. The z-order lists of a positioned element with auto |
89 // z-index are always empty (i.e. it's a leaf of the stacked element tree). | 90 // z-index are always empty (i.e. it's a leaf of the stacked element tree). |
90 // A real stacking context can also be a leaf if it doesn't contain any stacked
elements. | 91 // A real stacking context can also be a leaf if it doesn't contain any stacked |
| 92 // elements. |
91 class CORE_EXPORT PaintLayerStackingNode { | 93 class CORE_EXPORT PaintLayerStackingNode { |
92 USING_FAST_MALLOC(PaintLayerStackingNode); | 94 USING_FAST_MALLOC(PaintLayerStackingNode); |
93 WTF_MAKE_NONCOPYABLE(PaintLayerStackingNode); | 95 WTF_MAKE_NONCOPYABLE(PaintLayerStackingNode); |
94 | 96 |
95 public: | 97 public: |
96 explicit PaintLayerStackingNode(PaintLayer*); | 98 explicit PaintLayerStackingNode(PaintLayer*); |
97 ~PaintLayerStackingNode(); | 99 ~PaintLayerStackingNode(); |
98 | 100 |
99 int zIndex() const { return layoutObject()->style()->zIndex(); } | 101 int zIndex() const { return layoutObject()->style()->zIndex(); } |
100 | 102 |
101 bool isStackingContext() const { | 103 bool isStackingContext() const { |
102 return layoutObject()->style()->isStackingContext(); | 104 return layoutObject()->style()->isStackingContext(); |
103 } | 105 } |
104 | 106 |
105 // Whether the node is stacked. See documentation for the class about "stacked
". | 107 // Whether the node is stacked. See documentation for the class about |
106 // For now every PaintLayer has a PaintLayerStackingNode, even if the layer is
not stacked | 108 // "stacked". For now every PaintLayer has a PaintLayerStackingNode, even if |
107 // (e.g. a scrollable layer which is statically positioned and is not a stacki
ng context). | 109 // the layer is not stacked (e.g. a scrollable layer which is statically |
| 110 // positioned and is not a stacking context). |
108 bool isStacked() const { return m_isStacked; } | 111 bool isStacked() const { return m_isStacked; } |
109 | 112 |
110 // Update our normal and z-index lists. | 113 // Update our normal and z-index lists. |
111 void updateLayerListsIfNeeded(); | 114 void updateLayerListsIfNeeded(); |
112 | 115 |
113 bool zOrderListsDirty() const { return m_zOrderListsDirty; } | 116 bool zOrderListsDirty() const { return m_zOrderListsDirty; } |
114 void dirtyZOrderLists(); | 117 void dirtyZOrderLists(); |
115 void updateZOrderLists(); | 118 void updateZOrderLists(); |
116 void clearZOrderLists(); | 119 void clearZOrderLists(); |
117 void dirtyStackingContextZOrderLists(); | 120 void dirtyStackingContextZOrderLists(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 return m_zOrderListsDirty && isStackingContext(); | 174 return m_zOrderListsDirty && isStackingContext(); |
172 } | 175 } |
173 | 176 |
174 PaintLayerCompositor* compositor() const; | 177 PaintLayerCompositor* compositor() const; |
175 // We can't return a LayoutBox as LayoutInline can be a stacking context. | 178 // We can't return a LayoutBox as LayoutInline can be a stacking context. |
176 LayoutBoxModelObject* layoutObject() const; | 179 LayoutBoxModelObject* layoutObject() const; |
177 | 180 |
178 PaintLayer* m_layer; | 181 PaintLayer* m_layer; |
179 | 182 |
180 // m_posZOrderList holds a sorted list of all the descendant nodes within | 183 // m_posZOrderList holds a sorted list of all the descendant nodes within |
181 // that have z-indices of 0 (or is treated as 0 for positioned objects) or gre
ater. | 184 // that have z-indices of 0 (or is treated as 0 for positioned objects) or |
| 185 // greater. |
| 186 std::unique_ptr<Vector<PaintLayerStackingNode*>> m_posZOrderList; |
182 // m_negZOrderList holds descendants within our stacking context with | 187 // m_negZOrderList holds descendants within our stacking context with |
183 // negative z-indices. | 188 // negative z-indices. |
184 std::unique_ptr<Vector<PaintLayerStackingNode*>> m_posZOrderList; | |
185 std::unique_ptr<Vector<PaintLayerStackingNode*>> m_negZOrderList; | 189 std::unique_ptr<Vector<PaintLayerStackingNode*>> m_negZOrderList; |
186 | 190 |
187 // This boolean caches whether the z-order lists above are dirty. | 191 // This boolean caches whether the z-order lists above are dirty. |
188 // It is only ever set for stacking contexts, as no other element can | 192 // It is only ever set for stacking contexts, as no other element can |
189 // have z-order lists. | 193 // have z-order lists. |
190 bool m_zOrderListsDirty : 1; | 194 bool m_zOrderListsDirty : 1; |
191 | 195 |
192 // This attribute caches whether the element was stacked. It's needed to check
the | 196 // This attribute caches whether the element was stacked. It's needed to check |
193 // current stacked status (instead of the new stacked status determined by the
new | 197 // the current stacked status (instead of the new stacked status determined by |
194 // style which has not been realized yet) when a layer is removed due to style
change. | 198 // the new style which has not been realized yet) when a layer is removed due |
| 199 // to style change. |
195 bool m_isStacked : 1; | 200 bool m_isStacked : 1; |
196 | 201 |
197 #if ENABLE(ASSERT) | 202 #if ENABLE(ASSERT) |
198 bool m_layerListMutationAllowed : 1; | 203 bool m_layerListMutationAllowed : 1; |
199 PaintLayerStackingNode* m_stackingParent; | 204 PaintLayerStackingNode* m_stackingParent; |
200 #endif | 205 #endif |
201 }; | 206 }; |
202 | 207 |
203 inline void PaintLayerStackingNode::clearZOrderLists() { | 208 inline void PaintLayerStackingNode::clearZOrderLists() { |
204 ASSERT(!isStackingContext()); | 209 ASSERT(!isStackingContext()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 245 |
241 private: | 246 private: |
242 PaintLayerStackingNode* m_stackingNode; | 247 PaintLayerStackingNode* m_stackingNode; |
243 bool m_previousMutationAllowedState; | 248 bool m_previousMutationAllowedState; |
244 }; | 249 }; |
245 #endif | 250 #endif |
246 | 251 |
247 } // namespace blink | 252 } // namespace blink |
248 | 253 |
249 #endif // PaintLayerStackingNode_h | 254 #endif // PaintLayerStackingNode_h |
OLD | NEW |