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

Side by Side Diff: Source/core/paint/DeprecatedPaintLayerStackingNode.cpp

Issue 1199413006: Switch DPLStackingNode to use LayoutBoxModelObject (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Removed extra 'make' Created 5 years, 6 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
« no previous file with comments | « Source/core/paint/DeprecatedPaintLayerStackingNode.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 26 matching lines...) Expand all
37 * version of this file under the LGPL, indicate your decision by 37 * version of this file under the LGPL, indicate your decision by
38 * deletingthe provisions above and replace them with the notice and 38 * deletingthe provisions above and replace them with the notice and
39 * other provisions required by the MPL or the GPL, as the case may be. 39 * other provisions required by the MPL or the GPL, as the case may be.
40 * If you do not delete the provisions above, a recipient may use your 40 * If you do not delete the provisions above, a recipient may use your
41 * version of this file under any of the LGPL, the MPL or the GPL. 41 * version of this file under any of the LGPL, the MPL or the GPL.
42 */ 42 */
43 43
44 #include "config.h" 44 #include "config.h"
45 #include "core/paint/DeprecatedPaintLayerStackingNode.h" 45 #include "core/paint/DeprecatedPaintLayerStackingNode.h"
46 46
47 #include "core/dom/Node.h"
47 #include "core/layout/LayoutView.h" 48 #include "core/layout/LayoutView.h"
48 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" 49 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h"
49 #include "core/paint/DeprecatedPaintLayer.h" 50 #include "core/paint/DeprecatedPaintLayer.h"
50 #include "public/platform/Platform.h" 51 #include "public/platform/Platform.h"
51 52
52 namespace blink { 53 namespace blink {
53 54
54 // FIXME: This should not require DeprecatedPaintLayer. There is currently a cyc le where 55 // FIXME: This should not require DeprecatedPaintLayer. There is currently a cyc le where
55 // in order to determine if we shoulBeTreatedAsStackingContextForPainting() we h ave to ask the paint 56 // in order to determine if we shoulBeTreatedAsStackingContextForPainting() we h ave to ask the paint
56 // layer about some of its state. 57 // layer about some of its state.
57 DeprecatedPaintLayerStackingNode::DeprecatedPaintLayerStackingNode(DeprecatedPai ntLayer* layer) 58 DeprecatedPaintLayerStackingNode::DeprecatedPaintLayerStackingNode(LayoutBoxMode lObject& layoutObject)
58 : m_layer(layer) 59 : m_layoutObject(layoutObject)
59 , m_normalFlowListDirty(true) 60 , m_normalFlowListDirty(true)
60 #if ENABLE(ASSERT) 61 #if ENABLE(ASSERT)
61 , m_layerListMutationAllowed(true) 62 , m_layerListMutationAllowed(true)
62 , m_stackingParent(0) 63 , m_stackingParent(0)
63 #endif 64 #endif
64 { 65 {
65 m_isTreatedAsStackingContextForPainting = shouldBeTreatedAsStackingContextFo rPainting(); 66 m_isTreatedAsStackingContextForPainting = shouldBeTreatedAsStackingContextFo rPainting();
66 67
67 // Non-stacking contexts should have empty z-order lists. As this is already the case, 68 // Non-stacking contexts should have empty z-order lists. As this is already the case,
68 // there is no need to dirty / recompute these lists. 69 // there is no need to dirty / recompute these lists.
69 m_zOrderListsDirty = isStackingContext(); 70 m_zOrderListsDirty = isStackingContext();
70 } 71 }
71 72
72 DeprecatedPaintLayerStackingNode::~DeprecatedPaintLayerStackingNode() 73 DeprecatedPaintLayerStackingNode::~DeprecatedPaintLayerStackingNode()
73 { 74 {
74 #if ENABLE(ASSERT) 75 #if ENABLE(ASSERT)
75 if (!layoutObject()->documentBeingDestroyed()) { 76 if (!layoutObject().documentBeingDestroyed()) {
76 ASSERT(!isInStackingParentZOrderLists()); 77 ASSERT(!isInStackingParentZOrderLists());
77 ASSERT(!isInStackingParentNormalFlowList()); 78 ASSERT(!isInStackingParentNormalFlowList());
78 79
79 updateStackingParentForZOrderLists(0); 80 updateStackingParentForZOrderLists(0);
80 updateStackingParentForNormalFlowList(0); 81 updateStackingParentForNormalFlowList(0);
81 } 82 }
82 #endif 83 #endif
83 } 84 }
84 85
85 // Helper for the sorting of layers by z-index. 86 // Helper for the sorting of layers by z-index.
86 static inline bool compareZIndex(DeprecatedPaintLayerStackingNode* first, Deprec atedPaintLayerStackingNode* second) 87 static inline bool compareZIndex(DeprecatedPaintLayerStackingNode* first, Deprec atedPaintLayerStackingNode* second)
87 { 88 {
88 return first->zIndex() < second->zIndex(); 89 return first->zIndex() < second->zIndex();
89 } 90 }
90 91
91 DeprecatedPaintLayerCompositor* DeprecatedPaintLayerStackingNode::compositor() c onst 92 DeprecatedPaintLayerCompositor* DeprecatedPaintLayerStackingNode::compositor() c onst
92 { 93 {
93 ASSERT(layoutObject()->view()); 94 ASSERT(layoutObject().view());
94 return layoutObject()->view()->compositor(); 95 return layoutObject().view()->compositor();
95 } 96 }
96 97
97 void DeprecatedPaintLayerStackingNode::dirtyZOrderLists() 98 void DeprecatedPaintLayerStackingNode::dirtyZOrderLists()
98 { 99 {
99 ASSERT(m_layerListMutationAllowed); 100 ASSERT(m_layerListMutationAllowed);
100 ASSERT(isStackingContext()); 101 ASSERT(isStackingContext());
101 102
102 #if ENABLE(ASSERT) 103 #if ENABLE(ASSERT)
103 updateStackingParentForZOrderLists(0); 104 updateStackingParentForZOrderLists(0);
104 #endif 105 #endif
105 106
106 if (m_posZOrderList) 107 if (m_posZOrderList)
107 m_posZOrderList->clear(); 108 m_posZOrderList->clear();
108 if (m_negZOrderList) 109 if (m_negZOrderList)
109 m_negZOrderList->clear(); 110 m_negZOrderList->clear();
110 m_zOrderListsDirty = true; 111 m_zOrderListsDirty = true;
111 112
112 if (!layoutObject()->documentBeingDestroyed()) 113 if (!layoutObject().documentBeingDestroyed())
113 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); 114 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree);
114 } 115 }
115 116
116 void DeprecatedPaintLayerStackingNode::dirtyStackingContextZOrderLists() 117 void DeprecatedPaintLayerStackingNode::dirtyStackingContextZOrderLists()
117 { 118 {
118 if (DeprecatedPaintLayerStackingNode* stackingNode = ancestorStackingContext Node()) 119 if (DeprecatedPaintLayerStackingNode* stackingNode = ancestorStackingContext Node())
119 stackingNode->dirtyZOrderLists(); 120 stackingNode->dirtyZOrderLists();
120 } 121 }
121 122
122 void DeprecatedPaintLayerStackingNode::dirtyNormalFlowList() 123 void DeprecatedPaintLayerStackingNode::dirtyNormalFlowList()
123 { 124 {
124 ASSERT(m_layerListMutationAllowed); 125 ASSERT(m_layerListMutationAllowed);
125 126
126 #if ENABLE(ASSERT) 127 #if ENABLE(ASSERT)
127 updateStackingParentForNormalFlowList(0); 128 updateStackingParentForNormalFlowList(0);
128 #endif 129 #endif
129 130
130 if (m_normalFlowList) 131 if (m_normalFlowList)
131 m_normalFlowList->clear(); 132 m_normalFlowList->clear();
132 m_normalFlowListDirty = true; 133 m_normalFlowListDirty = true;
133 134
134 if (!layoutObject()->documentBeingDestroyed()) 135 if (!layoutObject().documentBeingDestroyed())
135 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); 136 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree);
136 } 137 }
137 138
139 static bool isInTopLayer(const LayoutObject& layoutObject)
140 {
141 const Node* node = layoutObject.node();
142 return node && node->isElementNode() && toElement(node)->isInTopLayer();
143 }
144
138 void DeprecatedPaintLayerStackingNode::rebuildZOrderLists() 145 void DeprecatedPaintLayerStackingNode::rebuildZOrderLists()
139 { 146 {
140 ASSERT(m_layerListMutationAllowed); 147 ASSERT(m_layerListMutationAllowed);
141 ASSERT(isDirtyStackingContext()); 148 ASSERT(isDirtyStackingContext());
142 149
143 for (DeprecatedPaintLayer* child = layer()->firstChild(); child; child = chi ld->nextSibling()) { 150 for (LayoutObject* descendant = layoutObject().slowFirstChild(); descendant; ) {
144 if (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflectionL ayer() != child) 151 if (isInTopLayer(*descendant)) {
145 child->stackingNode()->collectLayers(m_posZOrderList, m_negZOrderLis t); 152 // Top layer objects are handled below.
153 descendant = descendant->nextInPreOrderAfterChildren(&layoutObject() );
154 continue;
155 }
156
157 // FIXME: Some non-LayoutBoxModeObject can have position != static and t hus would be treated like
158 // stacking context. However we can't store them in the lists unless the y have a DeprecatedPaintLayer.
159 if (descendant->styleRef().isTreatedAsStackingContextForPainting() && de scendant->hasLayer()) {
160 OwnPtr<Vector<DeprecatedPaintLayerStackingNode*>>& buffer = (descend ant->style()->zIndex() >= 0) ? m_posZOrderList : m_negZOrderList;
161 if (!buffer)
162 buffer = adoptPtr(new Vector<DeprecatedPaintLayerStackingNode*>) ;
163 buffer->append(toLayoutBoxModelObject(descendant)->layer()->stacking Node());
164 }
165
166 if (descendant->styleRef().isStackingContext()) {
167 // We found a stacking context, just continue walking the other subt rees.
168 // They will collect their own descendant stacking contexts.
169 descendant = descendant->nextInPreOrderAfterChildren(&layoutObject() );
170 } else {
171 // Not stacking context, continue deeper.
172 descendant = descendant->nextInPreOrder(&layoutObject());
173 }
146 } 174 }
147 175
148 // Sort the two lists. 176 // Sort the two lists.
149 if (m_posZOrderList) 177 if (m_posZOrderList)
150 std::stable_sort(m_posZOrderList->begin(), m_posZOrderList->end(), compa reZIndex); 178 std::stable_sort(m_posZOrderList->begin(), m_posZOrderList->end(), compa reZIndex);
151 179
152 if (m_negZOrderList) 180 if (m_negZOrderList)
153 std::stable_sort(m_negZOrderList->begin(), m_negZOrderList->end(), compa reZIndex); 181 std::stable_sort(m_negZOrderList->begin(), m_negZOrderList->end(), compa reZIndex);
154 182
155 // Append layers for top layer elements after normal layer collection, to en sure they are on top regardless of z-indexes. 183 // Append stacking contexts for top layer elements after normal layer collec tion, to ensure they are on top regardless of z-indexes.
156 // The layoutObjects of top layer elements are children of the view, sorted in top layer stacking order. 184 // The layoutObjects of top layer elements are children of the view, sorted in top layer stacking order.
157 if (layer()->isRootLayer()) { 185 if (layoutObject().isLayoutView()) {
158 LayoutView* view = layoutObject()->view(); 186 LayoutView& view = toLayoutView(layoutObject());
159 for (LayoutObject* child = view->firstChild(); child; child = child->nex tSibling()) { 187 for (LayoutObject* child = view.firstChild(); child; child = child->next Sibling()) {
160 Element* childElement = (child->node() && child->node()->isElementNo de()) ? toElement(child->node()) : 0; 188 if (!isInTopLayer(*child))
161 if (childElement && childElement->isInTopLayer()) { 189 continue;
162 DeprecatedPaintLayer* layer = toLayoutBoxModelObject(child)->lay er(); 190
163 // Create the buffer if it doesn't exist yet. 191 // Create the buffer if it doesn't exist yet.
164 if (!m_posZOrderList) 192 if (!m_posZOrderList)
165 m_posZOrderList = adoptPtr(new Vector<DeprecatedPaintLayerSt ackingNode*>); 193 m_posZOrderList = adoptPtr(new Vector<DeprecatedPaintLayerStacki ngNode*>);
166 m_posZOrderList->append(layer->stackingNode()); 194 ASSERT(child->style()->isStackingContext());
167 } 195 m_posZOrderList->append(toLayoutBoxModelObject(child)->layer()->stac kingNode());
168 } 196 }
169 } 197 }
170 198
171 #if ENABLE(ASSERT) 199 #if ENABLE(ASSERT)
172 updateStackingParentForZOrderLists(this); 200 updateStackingParentForZOrderLists(this);
173 #endif 201 #endif
174 202
175 m_zOrderListsDirty = false; 203 m_zOrderListsDirty = false;
176 } 204 }
177 205
(...skipping 12 matching lines...) Expand all
190 } 218 }
191 } 219 }
192 220
193 #if ENABLE(ASSERT) 221 #if ENABLE(ASSERT)
194 updateStackingParentForNormalFlowList(this); 222 updateStackingParentForNormalFlowList(this);
195 #endif 223 #endif
196 224
197 m_normalFlowListDirty = false; 225 m_normalFlowListDirty = false;
198 } 226 }
199 227
200 void DeprecatedPaintLayerStackingNode::collectLayers(OwnPtr<Vector<DeprecatedPai ntLayerStackingNode*>>& posBuffer, OwnPtr<Vector<DeprecatedPaintLayerStackingNod e*>>& negBuffer)
201 {
202 if (layer()->isInTopLayer())
203 return;
204
205 if (isTreatedAsStackingContextForPainting()) {
206 OwnPtr<Vector<DeprecatedPaintLayerStackingNode*>>& buffer = (zIndex() >= 0) ? posBuffer : negBuffer;
207 if (!buffer)
208 buffer = adoptPtr(new Vector<DeprecatedPaintLayerStackingNode*>);
209 buffer->append(this);
210 }
211
212 if (!isStackingContext()) {
213 for (DeprecatedPaintLayer* child = layer()->firstChild(); child; child = child->nextSibling()) {
214 if (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflect ionLayer() != child)
215 child->stackingNode()->collectLayers(posBuffer, negBuffer);
216 }
217 }
218 }
219
220 #if ENABLE(ASSERT) 228 #if ENABLE(ASSERT)
221 bool DeprecatedPaintLayerStackingNode::isInStackingParentZOrderLists() const 229 bool DeprecatedPaintLayerStackingNode::isInStackingParentZOrderLists() const
222 { 230 {
223 if (!m_stackingParent || m_stackingParent->zOrderListsDirty()) 231 if (!m_stackingParent || m_stackingParent->zOrderListsDirty())
224 return false; 232 return false;
225 233
226 if (m_stackingParent->posZOrderList() && m_stackingParent->posZOrderList()-> find(this) != kNotFound) 234 if (m_stackingParent->posZOrderList() && m_stackingParent->posZOrderList()-> find(this) != kNotFound)
227 return true; 235 return true;
228 236
229 if (m_stackingParent->negZOrderList() && m_stackingParent->negZOrderList()-> find(this) != kNotFound) 237 if (m_stackingParent->negZOrderList() && m_stackingParent->negZOrderList()-> find(this) != kNotFound)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 DeprecatedPaintLayerStackingNode* DeprecatedPaintLayerStackingNode::ancestorStac kingContextNode() const 315 DeprecatedPaintLayerStackingNode* DeprecatedPaintLayerStackingNode::ancestorStac kingContextNode() const
308 { 316 {
309 for (DeprecatedPaintLayer* ancestor = layer()->parent(); ancestor; ancestor = ancestor->parent()) { 317 for (DeprecatedPaintLayer* ancestor = layer()->parent(); ancestor; ancestor = ancestor->parent()) {
310 DeprecatedPaintLayerStackingNode* stackingNode = ancestor->stackingNode( ); 318 DeprecatedPaintLayerStackingNode* stackingNode = ancestor->stackingNode( );
311 if (stackingNode->isStackingContext()) 319 if (stackingNode->isStackingContext())
312 return stackingNode; 320 return stackingNode;
313 } 321 }
314 return 0; 322 return 0;
315 } 323 }
316 324
317 LayoutBoxModelObject* DeprecatedPaintLayerStackingNode::layoutObject() const 325 DeprecatedPaintLayer* DeprecatedPaintLayerStackingNode::layer() const
318 { 326 {
319 return m_layer->layoutObject(); 327 return layoutObject().layer();
320 } 328 }
321 329
322 } // namespace blink 330 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/DeprecatedPaintLayerStackingNode.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698