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

Side by Side Diff: Source/core/rendering/RenderLayerStackingNode.h

Issue 898783003: Move rendering/RenderLayer* to layout/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Intel Corporation. All rights reserved.
4 *
5 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
6 *
7 * Other contributors:
8 * Robert O'Callahan <roc+@cs.cmu.edu>
9 * David Baron <dbaron@fas.harvard.edu>
10 * Christian Biesinger <cbiesinger@web.de>
11 * Randall Jesup <rjesup@wgate.com>
12 * Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
13 * Josh Soref <timeless@mac.com>
14 * Boris Zbarsky <bzbarsky@mit.edu>
15 *
16 * This library is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public
18 * License as published by the Free Software Foundation; either
19 * version 2.1 of the License, or (at your option) any later version.
20 *
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
25 *
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
28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 US A
29 *
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
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
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
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
38 * version of this file under the LGPL, indicate your decision by
39 * deletingthe provisions above and replace them with the notice and
40 * other provisions required by the MPL or the GPL, as the case may be.
41 * If you do not delete the provisions above, a recipient may use your
42 * version of this file under any of the LGPL, the MPL or the GPL.
43 */
44
45 #ifndef RenderLayerStackingNode_h
46 #define RenderLayerStackingNode_h
47
48 #include "core/rendering/RenderLayerModelObject.h"
49 #include "wtf/Noncopyable.h"
50 #include "wtf/OwnPtr.h"
51 #include "wtf/Vector.h"
52
53 namespace blink {
54
55 class RenderLayer;
56 class RenderLayerCompositor;
57 class RenderStyle;
58
59 class RenderLayerStackingNode {
60 WTF_MAKE_NONCOPYABLE(RenderLayerStackingNode);
61 public:
62 explicit RenderLayerStackingNode(RenderLayer*);
63 ~RenderLayerStackingNode();
64
65 int zIndex() const { return renderer()->style()->zIndex(); }
66
67 // A stacking context is a layer that has a non-auto z-index.
68 bool isStackingContext() const { return !renderer()->style()->hasAutoZIndex( ); }
69
70 // Update our normal and z-index lists.
71 void updateLayerListsIfNeeded();
72
73 bool zOrderListsDirty() const { return m_zOrderListsDirty; }
74 void dirtyZOrderLists();
75 void updateZOrderLists();
76 void clearZOrderLists();
77 void dirtyStackingContextZOrderLists();
78
79 bool hasPositiveZOrderList() const { return posZOrderList() && posZOrderList ()->size(); }
80 bool hasNegativeZOrderList() const { return negZOrderList() && negZOrderList ()->size(); }
81
82 // FIXME: should check for dirtiness here?
83 bool isNormalFlowOnly() const { return m_isNormalFlowOnly; }
84 void updateIsNormalFlowOnly();
85 bool normalFlowListDirty() const { return m_normalFlowListDirty; }
86 void dirtyNormalFlowList();
87
88 void updateStackingNodesAfterStyleChange(const RenderStyle* oldStyle);
89
90 RenderLayerStackingNode* ancestorStackingContextNode() const;
91
92 RenderLayer* layer() const { return m_layer; }
93
94 #if ENABLE(ASSERT)
95 bool layerListMutationAllowed() const { return m_layerListMutationAllowed; }
96 void setLayerListMutationAllowed(bool flag) { m_layerListMutationAllowed = f lag; }
97 #endif
98
99 private:
100 friend class RenderLayerStackingNodeIterator;
101 friend class RenderLayerStackingNodeReverseIterator;
102 friend class LayoutTreeAsText;
103
104 Vector<RenderLayerStackingNode*>* posZOrderList() const
105 {
106 ASSERT(!m_zOrderListsDirty);
107 ASSERT(isStackingContext() || !m_posZOrderList);
108 return m_posZOrderList.get();
109 }
110
111 Vector<RenderLayerStackingNode*>* normalFlowList() const
112 {
113 ASSERT(!m_normalFlowListDirty);
114 return m_normalFlowList.get();
115 }
116
117 Vector<RenderLayerStackingNode*>* negZOrderList() const
118 {
119 ASSERT(!m_zOrderListsDirty);
120 ASSERT(isStackingContext() || !m_negZOrderList);
121 return m_negZOrderList.get();
122 }
123
124 void rebuildZOrderLists();
125 void collectLayers(OwnPtr<Vector<RenderLayerStackingNode*> >& posZOrderList, OwnPtr<Vector<RenderLayerStackingNode*> >& negZOrderList);
126
127 #if ENABLE(ASSERT)
128 bool isInStackingParentZOrderLists() const;
129 bool isInStackingParentNormalFlowList() const;
130 void updateStackingParentForZOrderLists(RenderLayerStackingNode* stackingPar ent);
131 void updateStackingParentForNormalFlowList(RenderLayerStackingNode* stacking Parent);
132 void setStackingParent(RenderLayerStackingNode* stackingParent) { m_stacking Parent = stackingParent; }
133 #endif
134
135 bool shouldBeNormalFlowOnly() const;
136
137 void updateNormalFlowList();
138
139 bool isDirtyStackingContext() const { return m_zOrderListsDirty && isStackin gContext(); }
140
141 RenderLayerCompositor* compositor() const;
142 // FIXME: Investigate changing this to Renderbox.
143 RenderLayerModelObject* renderer() const;
144
145 RenderLayer* m_layer;
146
147 // m_posZOrderList holds a sorted list of all the descendant nodes within
148 // that have z-indices of 0 or greater (auto will count as 0).
149 // m_negZOrderList holds descendants within our stacking context with
150 // negative z-indices.
151 OwnPtr<Vector<RenderLayerStackingNode*> > m_posZOrderList;
152 OwnPtr<Vector<RenderLayerStackingNode*> > m_negZOrderList;
153
154 // This list contains child nodes that cannot create stacking contexts.
155 OwnPtr<Vector<RenderLayerStackingNode*> > m_normalFlowList;
156
157 unsigned m_zOrderListsDirty : 1;
158 unsigned m_normalFlowListDirty: 1;
159 unsigned m_isNormalFlowOnly : 1;
160
161 #if ENABLE(ASSERT)
162 unsigned m_layerListMutationAllowed : 1;
163 RenderLayerStackingNode* m_stackingParent;
164 #endif
165 };
166
167 inline void RenderLayerStackingNode::clearZOrderLists()
168 {
169 ASSERT(!isStackingContext());
170
171 #if ENABLE(ASSERT)
172 updateStackingParentForZOrderLists(0);
173 #endif
174
175 m_posZOrderList.clear();
176 m_negZOrderList.clear();
177 }
178
179 inline void RenderLayerStackingNode::updateZOrderLists()
180 {
181 if (!m_zOrderListsDirty)
182 return;
183
184 if (!isStackingContext()) {
185 clearZOrderLists();
186 m_zOrderListsDirty = false;
187 return;
188 }
189
190 rebuildZOrderLists();
191 }
192
193 #if ENABLE(ASSERT)
194 class LayerListMutationDetector {
195 public:
196 explicit LayerListMutationDetector(RenderLayerStackingNode* stackingNode)
197 : m_stackingNode(stackingNode)
198 , m_previousMutationAllowedState(stackingNode->layerListMutationAllowed( ))
199 {
200 m_stackingNode->setLayerListMutationAllowed(false);
201 }
202
203 ~LayerListMutationDetector()
204 {
205 m_stackingNode->setLayerListMutationAllowed(m_previousMutationAllowedSta te);
206 }
207
208 private:
209 RenderLayerStackingNode* m_stackingNode;
210 bool m_previousMutationAllowedState;
211 };
212 #endif
213
214 } // namespace blink
215
216 #endif // RenderLayerStackingNode_h
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderLayerScrollableArea.cpp ('k') | Source/core/rendering/RenderLayerStackingNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698