| OLD | NEW |
| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "core/rendering/compositing/RenderLayerCompositor.h" | 49 #include "core/rendering/compositing/RenderLayerCompositor.h" |
| 50 #include "public/platform/Platform.h" | 50 #include "public/platform/Platform.h" |
| 51 | 51 |
| 52 namespace WebCore { | 52 namespace WebCore { |
| 53 | 53 |
| 54 // FIXME: This should not require RenderLayer. There is currently a cycle where | 54 // FIXME: This should not require RenderLayer. There is currently a cycle where |
| 55 // in order to determine if we shoulBeNormalFlowOnly() we have to ask the render | 55 // in order to determine if we shoulBeNormalFlowOnly() we have to ask the render |
| 56 // layer about some of its state. | 56 // layer about some of its state. |
| 57 RenderLayerStackingNode::RenderLayerStackingNode(RenderLayer* layer) | 57 RenderLayerStackingNode::RenderLayerStackingNode(RenderLayer* layer) |
| 58 : m_layer(layer) | 58 : m_layer(layer) |
| 59 , m_descendantsAreContiguousInStackingOrder(false) | |
| 60 , m_descendantsAreContiguousInStackingOrderDirty(true) | |
| 61 , m_normalFlowListDirty(true) | 59 , m_normalFlowListDirty(true) |
| 62 #if !ASSERT_DISABLED | 60 #if !ASSERT_DISABLED |
| 63 , m_layerListMutationAllowed(true) | 61 , m_layerListMutationAllowed(true) |
| 64 , m_stackingParent(0) | 62 , m_stackingParent(0) |
| 65 #endif | 63 #endif |
| 66 { | 64 { |
| 67 m_isNormalFlowOnly = shouldBeNormalFlowOnly(); | 65 m_isNormalFlowOnly = shouldBeNormalFlowOnly(); |
| 68 | 66 |
| 69 // Non-stacking contexts should have empty z-order lists. As this is already
the case, | 67 // Non-stacking contexts should have empty z-order lists. As this is already
the case, |
| 70 // there is no need to dirty / recompute these lists. | 68 // there is no need to dirty / recompute these lists. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 85 } | 83 } |
| 86 | 84 |
| 87 // Helper for the sorting of layers by z-index. | 85 // Helper for the sorting of layers by z-index. |
| 88 static inline bool compareZIndex(RenderLayerStackingNode* first, RenderLayerStac
kingNode* second) | 86 static inline bool compareZIndex(RenderLayerStackingNode* first, RenderLayerStac
kingNode* second) |
| 89 { | 87 { |
| 90 return first->zIndex() < second->zIndex(); | 88 return first->zIndex() < second->zIndex(); |
| 91 } | 89 } |
| 92 | 90 |
| 93 RenderLayerCompositor* RenderLayerStackingNode::compositor() const | 91 RenderLayerCompositor* RenderLayerStackingNode::compositor() const |
| 94 { | 92 { |
| 95 if (!renderer()->view()) | 93 ASSERT(renderer()->view()); |
| 96 return 0; | |
| 97 return renderer()->view()->compositor(); | 94 return renderer()->view()->compositor(); |
| 98 } | 95 } |
| 99 | 96 |
| 100 void RenderLayerStackingNode::dirtyZOrderLists() | 97 void RenderLayerStackingNode::dirtyZOrderLists() |
| 101 { | 98 { |
| 102 ASSERT(m_layerListMutationAllowed); | 99 ASSERT(m_layerListMutationAllowed); |
| 103 ASSERT(isStackingContext()); | 100 ASSERT(isStackingContext()); |
| 104 | 101 |
| 105 #if !ASSERT_DISABLED | 102 #if !ASSERT_DISABLED |
| 106 updateStackingParentForZOrderLists(0); | 103 updateStackingParentForZOrderLists(0); |
| 107 #endif | 104 #endif |
| 108 | 105 |
| 109 if (m_posZOrderList) | 106 if (m_posZOrderList) |
| 110 m_posZOrderList->clear(); | 107 m_posZOrderList->clear(); |
| 111 if (m_negZOrderList) | 108 if (m_negZOrderList) |
| 112 m_negZOrderList->clear(); | 109 m_negZOrderList->clear(); |
| 113 m_zOrderListsDirty = true; | 110 m_zOrderListsDirty = true; |
| 114 | 111 |
| 115 m_descendantsAreContiguousInStackingOrderDirty = true; | |
| 116 | |
| 117 if (!renderer()->documentBeingDestroyed()) | 112 if (!renderer()->documentBeingDestroyed()) |
| 118 compositor()->setCompositingLayersNeedRebuild(); | 113 compositor()->setCompositingLayersNeedRebuild(); |
| 119 } | 114 } |
| 120 | 115 |
| 121 void RenderLayerStackingNode::dirtyStackingContextZOrderLists() | 116 void RenderLayerStackingNode::dirtyStackingContextZOrderLists() |
| 122 { | 117 { |
| 123 RenderLayerStackingNode* stackingContextNode = ancestorStackingContextNode()
; | 118 if (RenderLayerStackingNode* stackingNode = ancestorStackingContextNode()) |
| 124 if (stackingContextNode) | |
| 125 stackingContextNode->dirtyZOrderLists(); | |
| 126 | |
| 127 RenderLayerStackingNode* stackingNode = ancestorStackingNode(); | |
| 128 if (stackingNode && stackingNode != stackingContextNode) | |
| 129 stackingNode->dirtyZOrderLists(); | 119 stackingNode->dirtyZOrderLists(); |
| 130 } | 120 } |
| 131 | 121 |
| 132 void RenderLayerStackingNode::dirtyNormalFlowList() | 122 void RenderLayerStackingNode::dirtyNormalFlowList() |
| 133 { | 123 { |
| 134 ASSERT(m_layerListMutationAllowed); | 124 ASSERT(m_layerListMutationAllowed); |
| 135 | 125 |
| 136 #if !ASSERT_DISABLED | 126 #if !ASSERT_DISABLED |
| 137 updateStackingParentForNormalFlowList(0); | 127 updateStackingParentForNormalFlowList(0); |
| 138 #endif | 128 #endif |
| 139 | 129 |
| 140 if (m_normalFlowList) | 130 if (m_normalFlowList) |
| 141 m_normalFlowList->clear(); | 131 m_normalFlowList->clear(); |
| 142 m_normalFlowListDirty = true; | 132 m_normalFlowListDirty = true; |
| 143 | 133 |
| 144 if (!renderer()->documentBeingDestroyed()) { | 134 if (!renderer()->documentBeingDestroyed()) |
| 145 compositor()->setCompositingLayersNeedRebuild(); | 135 compositor()->setCompositingLayersNeedRebuild(); |
| 146 } | |
| 147 } | 136 } |
| 148 | 137 |
| 149 void RenderLayerStackingNode::rebuildZOrderLists() | 138 void RenderLayerStackingNode::rebuildZOrderLists() |
| 150 { | 139 { |
| 151 ASSERT(m_layerListMutationAllowed); | 140 ASSERT(m_layerListMutationAllowed); |
| 152 ASSERT(isDirtyStackingContext()); | 141 ASSERT(isDirtyStackingContext()); |
| 153 | 142 |
| 154 for (RenderLayer* child = layer()->firstChild(); child; child = child->nextS
ibling()) { | 143 for (RenderLayer* child = layer()->firstChild(); child; child = child->nextS
ibling()) { |
| 155 if (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflectionL
ayer() != child) | 144 if (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflectionL
ayer() != child) |
| 156 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 Loading... |
| 296 reflectionLayer->stackingNode()->updateZOrderLists(); | 285 reflectionLayer->stackingNode()->updateZOrderLists(); |
| 297 reflectionLayer->stackingNode()->updateNormalFlowList(); | 286 reflectionLayer->stackingNode()->updateNormalFlowList(); |
| 298 } | 287 } |
| 299 | 288 |
| 300 void RenderLayerStackingNode::updateStackingNodesAfterStyleChange(const RenderSt
yle* oldStyle) | 289 void RenderLayerStackingNode::updateStackingNodesAfterStyleChange(const RenderSt
yle* oldStyle) |
| 301 { | 290 { |
| 302 bool wasStackingContext = oldStyle ? !oldStyle->hasAutoZIndex() : false; | 291 bool wasStackingContext = oldStyle ? !oldStyle->hasAutoZIndex() : false; |
| 303 EVisibility oldVisibility = oldStyle ? oldStyle->visibility() : VISIBLE; | 292 EVisibility oldVisibility = oldStyle ? oldStyle->visibility() : VISIBLE; |
| 304 int oldZIndex = oldStyle ? oldStyle->zIndex() : 0; | 293 int oldZIndex = oldStyle ? oldStyle->zIndex() : 0; |
| 305 | 294 |
| 306 // 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 |
| 307 // likely be folded along with the rest. | 296 // likely be folded along with the rest. |
| 308 bool isStackingContext = this->isStackingContext(); | 297 bool isStackingContext = this->isStackingContext(); |
| 309 if (isStackingContext == wasStackingContext && oldVisibility == renderer()->
style()->visibility() && oldZIndex == zIndex()) | 298 if (isStackingContext == wasStackingContext && oldVisibility == renderer()->
style()->visibility() && oldZIndex == zIndex()) |
| 310 return; | 299 return; |
| 311 | 300 |
| 312 dirtyStackingContextZOrderLists(); | 301 dirtyStackingContextZOrderLists(); |
| 313 | 302 |
| 314 if (isStackingContext) | 303 if (isStackingContext) |
| 315 dirtyZOrderLists(); | 304 dirtyZOrderLists(); |
| 316 else | 305 else |
| 317 clearZOrderLists(); | 306 clearZOrderLists(); |
| 318 } | 307 } |
| 319 | 308 |
| 320 bool RenderLayerStackingNode::shouldBeNormalFlowOnly() const | 309 bool RenderLayerStackingNode::shouldBeNormalFlowOnly() const |
| 321 { | 310 { |
| 322 const bool couldBeNormalFlow = renderer()->hasOverflowClip() | 311 return !isStackingContext() && !renderer()->isPositioned(); |
| 323 || renderer()->hasReflection() | |
| 324 || renderer()->hasMask() | |
| 325 || renderer()->isCanvas() | |
| 326 || renderer()->isVideo() | |
| 327 || renderer()->isEmbeddedObject() | |
| 328 || renderer()->isRenderIFrame() | |
| 329 || (renderer()->style()->specifiesColumns() && !layer()->isRootLayer()); | |
| 330 const bool preventsElementFromBeingNormalFlow = renderer()->isPositioned() | |
| 331 || renderer()->hasTransform() | |
| 332 || renderer()->hasClipPath() | |
| 333 || renderer()->hasFilter() | |
| 334 || renderer()->hasBlendMode() | |
| 335 || layer()->isTransparent(); | |
| 336 | |
| 337 return couldBeNormalFlow && !preventsElementFromBeingNormalFlow; | |
| 338 } | 312 } |
| 339 | 313 |
| 340 void RenderLayerStackingNode::updateIsNormalFlowOnly() | 314 void RenderLayerStackingNode::updateIsNormalFlowOnly() |
| 341 { | 315 { |
| 342 bool isNormalFlowOnly = shouldBeNormalFlowOnly(); | 316 bool isNormalFlowOnly = shouldBeNormalFlowOnly(); |
| 343 if (isNormalFlowOnly == this->isNormalFlowOnly()) | 317 if (isNormalFlowOnly == this->isNormalFlowOnly()) |
| 344 return; | 318 return; |
| 345 | 319 |
| 346 m_isNormalFlowOnly = isNormalFlowOnly; | 320 m_isNormalFlowOnly = isNormalFlowOnly; |
| 347 if (RenderLayer* p = layer()->parent()) | 321 if (RenderLayer* p = layer()->parent()) |
| 348 p->stackingNode()->dirtyNormalFlowList(); | 322 p->stackingNode()->dirtyNormalFlowList(); |
| 349 dirtyStackingContextZOrderLists(); | 323 dirtyStackingContextZOrderLists(); |
| 350 } | 324 } |
| 351 | 325 |
| 352 RenderLayerStackingNode* RenderLayerStackingNode::ancestorStackingContextNode()
const | 326 RenderLayerStackingNode* RenderLayerStackingNode::ancestorStackingContextNode()
const |
| 353 { | 327 { |
| 354 RenderLayer* ancestor = layer()->parent(); | 328 for (RenderLayer* ancestor = layer()->parent(); ancestor; ancestor = ancesto
r->parent()) { |
| 355 while (ancestor && !ancestor->stackingNode()->isStackingContext()) | 329 RenderLayerStackingNode* stackingNode = ancestor->stackingNode(); |
| 356 ancestor = ancestor->parent(); | 330 if (stackingNode->isStackingContext()) |
| 357 if (ancestor) | 331 return stackingNode; |
| 358 return ancestor->stackingNode(); | 332 } |
| 359 return 0; | 333 return 0; |
| 360 } | 334 } |
| 361 | 335 |
| 362 RenderLayerStackingNode* RenderLayerStackingNode::ancestorStackingNode() const | |
| 363 { | |
| 364 RenderLayer* ancestor = layer()->parent(); | |
| 365 while (ancestor && !ancestor->stackingNode()->isStackingContext()) | |
| 366 ancestor = ancestor->parent(); | |
| 367 if (ancestor) | |
| 368 return ancestor->stackingNode(); | |
| 369 return 0; | |
| 370 } | |
| 371 | |
| 372 RenderLayerModelObject* RenderLayerStackingNode::renderer() const | 336 RenderLayerModelObject* RenderLayerStackingNode::renderer() const |
| 373 { | 337 { |
| 374 return m_layer->renderer(); | 338 return m_layer->renderer(); |
| 375 } | 339 } |
| 376 | 340 |
| 377 } // namespace WebCore | 341 } // namespace WebCore |
| OLD | NEW |