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

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

Issue 301233008: Shave some yaks in RenderLayerStackingNode (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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/rendering/RenderLayerStackingNode.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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 // Helper for the sorting of layers by z-index. 85 // Helper for the sorting of layers by z-index.
86 static inline bool compareZIndex(RenderLayerStackingNode* first, RenderLayerStac kingNode* second) 86 static inline bool compareZIndex(RenderLayerStackingNode* first, RenderLayerStac kingNode* second)
87 { 87 {
88 return first->zIndex() < second->zIndex(); 88 return first->zIndex() < second->zIndex();
89 } 89 }
90 90
91 RenderLayerCompositor* RenderLayerStackingNode::compositor() const 91 RenderLayerCompositor* RenderLayerStackingNode::compositor() const
92 { 92 {
93 if (!renderer()->view()) 93 ASSERT(renderer()->view());
94 return 0;
95 return renderer()->view()->compositor(); 94 return renderer()->view()->compositor();
96 } 95 }
97 96
98 void RenderLayerStackingNode::dirtyZOrderLists() 97 void RenderLayerStackingNode::dirtyZOrderLists()
99 { 98 {
100 ASSERT(m_layerListMutationAllowed); 99 ASSERT(m_layerListMutationAllowed);
101 ASSERT(isStackingContext()); 100 ASSERT(isStackingContext());
102 101
103 #if !ASSERT_DISABLED 102 #if !ASSERT_DISABLED
104 updateStackingParentForZOrderLists(0); 103 updateStackingParentForZOrderLists(0);
105 #endif 104 #endif
106 105
107 if (m_posZOrderList) 106 if (m_posZOrderList)
108 m_posZOrderList->clear(); 107 m_posZOrderList->clear();
109 if (m_negZOrderList) 108 if (m_negZOrderList)
110 m_negZOrderList->clear(); 109 m_negZOrderList->clear();
111 m_zOrderListsDirty = true; 110 m_zOrderListsDirty = true;
112 111
113 if (!renderer()->documentBeingDestroyed()) 112 if (!renderer()->documentBeingDestroyed())
114 compositor()->setCompositingLayersNeedRebuild(); 113 compositor()->setCompositingLayersNeedRebuild();
115 } 114 }
116 115
117 void RenderLayerStackingNode::dirtyStackingContextZOrderLists() 116 void RenderLayerStackingNode::dirtyStackingContextZOrderLists()
118 { 117 {
119 RenderLayerStackingNode* stackingContextNode = ancestorStackingContextNode() ; 118 if (RenderLayerStackingNode* stackingNode = ancestorStackingContextNode())
120 if (stackingContextNode)
121 stackingContextNode->dirtyZOrderLists();
122
123 RenderLayerStackingNode* stackingNode = ancestorStackingNode();
124 if (stackingNode && stackingNode != stackingContextNode)
125 stackingNode->dirtyZOrderLists(); 119 stackingNode->dirtyZOrderLists();
126 } 120 }
127 121
128 void RenderLayerStackingNode::dirtyNormalFlowList() 122 void RenderLayerStackingNode::dirtyNormalFlowList()
129 { 123 {
130 ASSERT(m_layerListMutationAllowed); 124 ASSERT(m_layerListMutationAllowed);
131 125
132 #if !ASSERT_DISABLED 126 #if !ASSERT_DISABLED
133 updateStackingParentForNormalFlowList(0); 127 updateStackingParentForNormalFlowList(0);
134 #endif 128 #endif
135 129
136 if (m_normalFlowList) 130 if (m_normalFlowList)
137 m_normalFlowList->clear(); 131 m_normalFlowList->clear();
138 m_normalFlowListDirty = true; 132 m_normalFlowListDirty = true;
139 133
140 if (!renderer()->documentBeingDestroyed()) { 134 if (!renderer()->documentBeingDestroyed())
141 compositor()->setCompositingLayersNeedRebuild(); 135 compositor()->setCompositingLayersNeedRebuild();
142 }
143 } 136 }
144 137
145 void RenderLayerStackingNode::rebuildZOrderLists() 138 void RenderLayerStackingNode::rebuildZOrderLists()
146 { 139 {
147 ASSERT(m_layerListMutationAllowed); 140 ASSERT(m_layerListMutationAllowed);
148 ASSERT(isDirtyStackingContext()); 141 ASSERT(isDirtyStackingContext());
149 142
150 for (RenderLayer* child = layer()->firstChild(); child; child = child->nextS ibling()) { 143 for (RenderLayer* child = layer()->firstChild(); child; child = child->nextS ibling()) {
151 if (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflectionL ayer() != child) 144 if (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflectionL ayer() != child)
152 child->stackingNode()->collectLayers(m_posZOrderList, m_negZOrderLis t); 145 child->stackingNode()->collectLayers(m_posZOrderList, m_negZOrderLis t);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 reflectionLayer->stackingNode()->updateZOrderLists(); 285 reflectionLayer->stackingNode()->updateZOrderLists();
293 reflectionLayer->stackingNode()->updateNormalFlowList(); 286 reflectionLayer->stackingNode()->updateNormalFlowList();
294 } 287 }
295 288
296 void RenderLayerStackingNode::updateStackingNodesAfterStyleChange(const RenderSt yle* oldStyle) 289 void RenderLayerStackingNode::updateStackingNodesAfterStyleChange(const RenderSt yle* oldStyle)
297 { 290 {
298 bool wasStackingContext = oldStyle ? !oldStyle->hasAutoZIndex() : false; 291 bool wasStackingContext = oldStyle ? !oldStyle->hasAutoZIndex() : false;
299 EVisibility oldVisibility = oldStyle ? oldStyle->visibility() : VISIBLE; 292 EVisibility oldVisibility = oldStyle ? oldStyle->visibility() : VISIBLE;
300 int oldZIndex = oldStyle ? oldStyle->zIndex() : 0; 293 int oldZIndex = oldStyle ? oldStyle->zIndex() : 0;
301 294
302 // FIXME: RenderLayer already handles visibility changes through our visibli ty dirty bits. This logic could 295 // FIXME: RenderLayer already handles visibility changes through our visibil ity dirty bits. This logic could
303 // likely be folded along with the rest. 296 // likely be folded along with the rest.
304 bool isStackingContext = this->isStackingContext(); 297 bool isStackingContext = this->isStackingContext();
305 if (isStackingContext == wasStackingContext && oldVisibility == renderer()-> style()->visibility() && oldZIndex == zIndex()) 298 if (isStackingContext == wasStackingContext && oldVisibility == renderer()-> style()->visibility() && oldZIndex == zIndex())
306 return; 299 return;
307 300
308 dirtyStackingContextZOrderLists(); 301 dirtyStackingContextZOrderLists();
309 302
310 if (isStackingContext) 303 if (isStackingContext)
311 dirtyZOrderLists(); 304 dirtyZOrderLists();
312 else 305 else
313 clearZOrderLists(); 306 clearZOrderLists();
314 } 307 }
315 308
316 bool RenderLayerStackingNode::shouldBeNormalFlowOnly() const 309 bool RenderLayerStackingNode::shouldBeNormalFlowOnly() const
317 { 310 {
318 const bool couldBeNormalFlow = renderer()->hasOverflowClip() 311 RenderLayerModelObject* renderer = this->renderer();
319 || renderer()->hasReflection() 312
320 || renderer()->hasMask() 313 const bool couldBeNormalFlow = renderer->hasOverflowClip()
321 || renderer()->isCanvas() 314 || renderer->hasReflection()
322 || renderer()->isVideo() 315 || renderer->hasMask()
323 || renderer()->isEmbeddedObject() 316 || renderer->isCanvas()
324 || renderer()->isRenderIFrame() 317 || renderer->isVideo()
325 || (renderer()->style()->specifiesColumns() && !layer()->isRootLayer()); 318 || renderer->isEmbeddedObject()
326 const bool preventsElementFromBeingNormalFlow = renderer()->isPositioned() 319 || renderer->isRenderIFrame()
327 || renderer()->hasTransform() 320 || (renderer->style()->specifiesColumns() && !layer()->isRootLayer());
328 || renderer()->hasClipPath() 321
329 || renderer()->hasFilter() 322 const bool preventsElementFromBeingNormalFlow = renderer->isPositioned()
330 || renderer()->hasBlendMode() 323 || renderer->hasTransform()
324 || renderer->hasClipPath()
325 || renderer->hasFilter()
326 || renderer->hasBlendMode()
331 || layer()->isTransparent(); 327 || layer()->isTransparent();
332 328
333 return couldBeNormalFlow && !preventsElementFromBeingNormalFlow; 329 return couldBeNormalFlow && !preventsElementFromBeingNormalFlow;
334 } 330 }
335 331
336 void RenderLayerStackingNode::updateIsNormalFlowOnly() 332 void RenderLayerStackingNode::updateIsNormalFlowOnly()
337 { 333 {
338 bool isNormalFlowOnly = shouldBeNormalFlowOnly(); 334 bool isNormalFlowOnly = shouldBeNormalFlowOnly();
339 if (isNormalFlowOnly == this->isNormalFlowOnly()) 335 if (isNormalFlowOnly == this->isNormalFlowOnly())
340 return; 336 return;
341 337
342 m_isNormalFlowOnly = isNormalFlowOnly; 338 m_isNormalFlowOnly = isNormalFlowOnly;
343 if (RenderLayer* p = layer()->parent()) 339 if (RenderLayer* p = layer()->parent())
344 p->stackingNode()->dirtyNormalFlowList(); 340 p->stackingNode()->dirtyNormalFlowList();
345 dirtyStackingContextZOrderLists(); 341 dirtyStackingContextZOrderLists();
346 } 342 }
347 343
348 RenderLayerStackingNode* RenderLayerStackingNode::ancestorStackingContextNode() const 344 RenderLayerStackingNode* RenderLayerStackingNode::ancestorStackingContextNode() const
349 { 345 {
350 RenderLayer* ancestor = layer()->parent(); 346 for (RenderLayer* ancestor = layer()->parent(); ancestor; ancestor = ancesto r->parent()) {
351 while (ancestor && !ancestor->stackingNode()->isStackingContext()) 347 RenderLayerStackingNode* stackingNode = ancestor->stackingNode();
352 ancestor = ancestor->parent(); 348 if (stackingNode->isStackingContext())
353 if (ancestor) 349 return stackingNode;
354 return ancestor->stackingNode(); 350 }
355 return 0; 351 return 0;
356 } 352 }
357 353
358 RenderLayerStackingNode* RenderLayerStackingNode::ancestorStackingNode() const
359 {
360 RenderLayer* ancestor = layer()->parent();
361 while (ancestor && !ancestor->stackingNode()->isStackingContext())
362 ancestor = ancestor->parent();
363 if (ancestor)
364 return ancestor->stackingNode();
365 return 0;
366 }
367
368 RenderLayerModelObject* RenderLayerStackingNode::renderer() const 354 RenderLayerModelObject* RenderLayerStackingNode::renderer() const
369 { 355 {
370 return m_layer->renderer(); 356 return m_layer->renderer();
371 } 357 }
372 358
373 } // namespace WebCore 359 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderLayerStackingNode.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698