Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerStackingNode.h

Issue 1798263002: Rename isTreatedAsOrStackingContext to isStacked (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix windows compile Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "wtf/OwnPtr.h" 51 #include "wtf/OwnPtr.h"
52 #include "wtf/Vector.h" 52 #include "wtf/Vector.h"
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 anything that is a stacking 61 // PaintLayerStackingNode represents a stacked element which is either a
62 // context or treated as a stacking context. 62 // stacking context (i.e. an element with non-auto z-index) or a positioned
63 // element with auto z-index which is treated as a stacking context but
64 // doesn't contain other stacked elements.
65 // See https://chromium.googlesource.com/chromium/src.git/+/master/third_party/W ebKit/Source/core/paint/README.md
66 // for more details of stacked elements.
63 // 67 //
64 // Stacking contexts are the basis for the CSS painting algorithm. The paint 68 // Stacked elements are the basis for the CSS painting algorithm. The paint
65 // order is determined by walking stacking contexts (or elements treated like a 69 // order is determined by walking stacked elements in an order defined by
66 // stacking context like positioned objects or floats) in an order defined by 70 // ‘z-index’. This walk is interleaved with non-stacked contents.
67 // ‘z-index’. This walk is interleaved with content that is not a stacking. 71 // 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 72 // http://www.w3.org/TR/CSS21/zindex.html
70 // See also PaintLayerPainter (in particular paintLayerContents) for 73 // See also PaintLayerPainter (in particular paintLayerContents) for
71 // our implementation of the walk. 74 // our implementation of the walk.
72 // 75 //
73 // Stacking contexts form a subtree over the layout tree. Ideally we would want 76 // Stacked elements 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 77 // 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 78 // issues with stale pointers so we rely on PaintLayer's tree
76 // structure. 79 // structure.
77 // 80 //
78 // This class's purpose is to represent a node in the stacking context tree 81 // This class's purpose is to represent a node in the stacked element tree
79 // (aka paint tree). It currently caches the z-order lists for painting and 82 // (aka paint tree). It currently caches the z-order lists for painting and
80 // hit-testing. 83 // hit-testing.
81 // 84 //
82 // To implement any z-order list iterations, use 85 // To implement any z-order list iterations, use
83 // PaintLayerStackingNodeIterator and 86 // PaintLayerStackingNodeIterator and
84 // PaintLayerStackingNodeReverseIterator. 87 // PaintLayerStackingNodeReverseIterator.
88 //
89 // Only a real stacking context can have non-empty z-order lists thus contain
90 // child nodes in the tree. The z-order lists of a positioned element with auto
91 // z-index are always empty (i.e. it's a leaf of the stacked element tree).
92 // A real stacking context can also be a leaf if it doesn't contain any stacked elements.
85 class CORE_EXPORT PaintLayerStackingNode { 93 class CORE_EXPORT PaintLayerStackingNode {
86 USING_FAST_MALLOC(PaintLayerStackingNode); 94 USING_FAST_MALLOC(PaintLayerStackingNode);
87 WTF_MAKE_NONCOPYABLE(PaintLayerStackingNode); 95 WTF_MAKE_NONCOPYABLE(PaintLayerStackingNode);
88 public: 96 public:
89 explicit PaintLayerStackingNode(PaintLayer*); 97 explicit PaintLayerStackingNode(PaintLayer*);
90 ~PaintLayerStackingNode(); 98 ~PaintLayerStackingNode();
91 99
92 int zIndex() const { return layoutObject()->style()->zIndex(); } 100 int zIndex() const { return layoutObject()->style()->zIndex(); }
93 101
94 bool isStackingContext() const { return layoutObject()->style()->isStackingC ontext(); } 102 bool isStackingContext() const { return layoutObject()->style()->isStackingC ontext(); }
95 103
104 // Whether the node is stacked. See documentation for the class about "stack ed".
105 // For now every PaintLayer has a PaintLayerStackingNode, even if the layer is not stacked
106 // (e.g. a scrollable layer which is statically positioned and is not a stac king context).
107 bool isStacked() const { return m_isStacked; }
108
96 // Update our normal and z-index lists. 109 // Update our normal and z-index lists.
97 void updateLayerListsIfNeeded(); 110 void updateLayerListsIfNeeded();
98 111
99 bool zOrderListsDirty() const { return m_zOrderListsDirty; } 112 bool zOrderListsDirty() const { return m_zOrderListsDirty; }
100 void dirtyZOrderLists(); 113 void dirtyZOrderLists();
101 void updateZOrderLists(); 114 void updateZOrderLists();
102 void clearZOrderLists(); 115 void clearZOrderLists();
103 void dirtyStackingContextZOrderLists(); 116 void dirtyStackingContextZOrderLists();
104 117
105 bool hasPositiveZOrderList() const { return posZOrderList() && posZOrderList ()->size(); } 118 bool hasPositiveZOrderList() const { return posZOrderList() && posZOrderList ()->size(); }
106 bool hasNegativeZOrderList() const { return negZOrderList() && negZOrderList ()->size(); } 119 bool hasNegativeZOrderList() const { return negZOrderList() && negZOrderList ()->size(); }
107 120
108 bool isTreatedAsOrStackingContext() const { return m_isTreatedAsOrStackingCo ntext; } 121 void styleDidChange(const ComputedStyle* oldStyle);
109 void updateIsTreatedAsStackingContext();
110
111 void updateStackingNodesAfterStyleChange(const ComputedStyle* oldStyle);
112 122
113 PaintLayerStackingNode* ancestorStackingContextNode() const; 123 PaintLayerStackingNode* ancestorStackingContextNode() const;
114 124
115 PaintLayer* layer() const { return m_layer; } 125 PaintLayer* layer() const { return m_layer; }
116 126
117 #if ENABLE(ASSERT) 127 #if ENABLE(ASSERT)
118 bool layerListMutationAllowed() const { return m_layerListMutationAllowed; } 128 bool layerListMutationAllowed() const { return m_layerListMutationAllowed; }
119 void setLayerListMutationAllowed(bool flag) { m_layerListMutationAllowed = f lag; } 129 void setLayerListMutationAllowed(bool flag) { m_layerListMutationAllowed = f lag; }
120 #endif 130 #endif
121 131
(...skipping 18 matching lines...) Expand all
140 150
141 void rebuildZOrderLists(); 151 void rebuildZOrderLists();
142 void collectLayers(OwnPtr<Vector<PaintLayerStackingNode*>>& posZOrderList, O wnPtr<Vector<PaintLayerStackingNode*>>& negZOrderList); 152 void collectLayers(OwnPtr<Vector<PaintLayerStackingNode*>>& posZOrderList, O wnPtr<Vector<PaintLayerStackingNode*>>& negZOrderList);
143 153
144 #if ENABLE(ASSERT) 154 #if ENABLE(ASSERT)
145 bool isInStackingParentZOrderLists() const; 155 bool isInStackingParentZOrderLists() const;
146 void updateStackingParentForZOrderLists(PaintLayerStackingNode* stackingPare nt); 156 void updateStackingParentForZOrderLists(PaintLayerStackingNode* stackingPare nt);
147 void setStackingParent(PaintLayerStackingNode* stackingParent) { m_stackingP arent = stackingParent; } 157 void setStackingParent(PaintLayerStackingNode* stackingParent) { m_stackingP arent = stackingParent; }
148 #endif 158 #endif
149 159
150 bool shouldBeTreatedAsOrStackingContext() const { return layoutObject()->sty le()->isTreatedAsOrStackingContext(); }
151
152 bool isDirtyStackingContext() const { return m_zOrderListsDirty && isStackin gContext(); } 160 bool isDirtyStackingContext() const { return m_zOrderListsDirty && isStackin gContext(); }
153 161
154 PaintLayerCompositor* compositor() const; 162 PaintLayerCompositor* compositor() const;
155 // We can't return a LayoutBox as LayoutInline can be a stacking context. 163 // We can't return a LayoutBox as LayoutInline can be a stacking context.
156 LayoutBoxModelObject* layoutObject() const; 164 LayoutBoxModelObject* layoutObject() const;
157 165
158 PaintLayer* m_layer; 166 PaintLayer* m_layer;
159 167
160 // m_posZOrderList holds a sorted list of all the descendant nodes within 168 // 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). 169 // 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 170 // m_negZOrderList holds descendants within our stacking context with
163 // negative z-indices. 171 // negative z-indices.
164 OwnPtr<Vector<PaintLayerStackingNode*>> m_posZOrderList; 172 OwnPtr<Vector<PaintLayerStackingNode*>> m_posZOrderList;
165 OwnPtr<Vector<PaintLayerStackingNode*>> m_negZOrderList; 173 OwnPtr<Vector<PaintLayerStackingNode*>> m_negZOrderList;
166 174
167 // This boolean caches whether the z-order lists above are dirty. 175 // 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 176 // It is only ever set for stacking contexts, as no other element can
169 // have z-order lists. 177 // have z-order lists.
170 unsigned m_zOrderListsDirty : 1; 178 bool m_zOrderListsDirty : 1;
171 179
172 // This attribute caches whether the element was a stacking context or 180 // This attribute caches whether the element was stacked. It's needed to che ck the
173 // was treated like a stacking context, so that we can do comparison against 181 // current stacked status (instead of the new stacked status determined by t he new
174 // it during style change (styleDidChange in particular), as we have lost 182 // style which has not been realized yet) when a layer is removed due to sty le change.
175 // the previous style information. 183 bool m_isStacked : 1;
176 unsigned m_isTreatedAsOrStackingContext: 1;
177 184
178 #if ENABLE(ASSERT) 185 #if ENABLE(ASSERT)
179 unsigned m_layerListMutationAllowed : 1; 186 bool m_layerListMutationAllowed : 1;
180 PaintLayerStackingNode* m_stackingParent; 187 PaintLayerStackingNode* m_stackingParent;
181 #endif 188 #endif
182 }; 189 };
183 190
184 inline void PaintLayerStackingNode::clearZOrderLists() 191 inline void PaintLayerStackingNode::clearZOrderLists()
185 { 192 {
186 ASSERT(!isStackingContext()); 193 ASSERT(!isStackingContext());
187 194
188 #if ENABLE(ASSERT) 195 #if ENABLE(ASSERT)
189 updateStackingParentForZOrderLists(0); 196 updateStackingParentForZOrderLists(0);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 231
225 private: 232 private:
226 PaintLayerStackingNode* m_stackingNode; 233 PaintLayerStackingNode* m_stackingNode;
227 bool m_previousMutationAllowedState; 234 bool m_previousMutationAllowedState;
228 }; 235 };
229 #endif 236 #endif
230 237
231 } // namespace blink 238 } // namespace blink
232 239
233 #endif // PaintLayerStackingNode_h 240 #endif // PaintLayerStackingNode_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.cpp ('k') | third_party/WebKit/Source/core/paint/PaintLayerStackingNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698