| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 m_isNormalFlowOnly = shouldBeNormalFlowOnly(); | 65 m_isNormalFlowOnly = shouldBeNormalFlowOnly(); |
| 66 | 66 |
| 67 // 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, |
| 68 // there is no need to dirty / recompute these lists. | 68 // there is no need to dirty / recompute these lists. |
| 69 m_zOrderListsDirty = isStackingContext(); | 69 m_zOrderListsDirty = isStackingContext(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 LayerStackingNode::~LayerStackingNode() | 72 LayerStackingNode::~LayerStackingNode() |
| 73 { | 73 { |
| 74 #if ENABLE(ASSERT) | 74 #if ENABLE(ASSERT) |
| 75 if (!renderer()->documentBeingDestroyed()) { | 75 if (!layoutObject()->documentBeingDestroyed()) { |
| 76 ASSERT(!isInStackingParentZOrderLists()); | 76 ASSERT(!isInStackingParentZOrderLists()); |
| 77 ASSERT(!isInStackingParentNormalFlowList()); | 77 ASSERT(!isInStackingParentNormalFlowList()); |
| 78 | 78 |
| 79 updateStackingParentForZOrderLists(0); | 79 updateStackingParentForZOrderLists(0); |
| 80 updateStackingParentForNormalFlowList(0); | 80 updateStackingParentForNormalFlowList(0); |
| 81 } | 81 } |
| 82 #endif | 82 #endif |
| 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(LayerStackingNode* first, LayerStackingNode* se
cond) | 86 static inline bool compareZIndex(LayerStackingNode* first, LayerStackingNode* se
cond) |
| 87 { | 87 { |
| 88 return first->zIndex() < second->zIndex(); | 88 return first->zIndex() < second->zIndex(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 LayerCompositor* LayerStackingNode::compositor() const | 91 LayerCompositor* LayerStackingNode::compositor() const |
| 92 { | 92 { |
| 93 ASSERT(renderer()->view()); | 93 ASSERT(layoutObject()->view()); |
| 94 return renderer()->view()->compositor(); | 94 return layoutObject()->view()->compositor(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void LayerStackingNode::dirtyZOrderLists() | 97 void LayerStackingNode::dirtyZOrderLists() |
| 98 { | 98 { |
| 99 ASSERT(m_layerListMutationAllowed); | 99 ASSERT(m_layerListMutationAllowed); |
| 100 ASSERT(isStackingContext()); | 100 ASSERT(isStackingContext()); |
| 101 | 101 |
| 102 #if ENABLE(ASSERT) | 102 #if ENABLE(ASSERT) |
| 103 updateStackingParentForZOrderLists(0); | 103 updateStackingParentForZOrderLists(0); |
| 104 #endif | 104 #endif |
| 105 | 105 |
| 106 if (m_posZOrderList) | 106 if (m_posZOrderList) |
| 107 m_posZOrderList->clear(); | 107 m_posZOrderList->clear(); |
| 108 if (m_negZOrderList) | 108 if (m_negZOrderList) |
| 109 m_negZOrderList->clear(); | 109 m_negZOrderList->clear(); |
| 110 m_zOrderListsDirty = true; | 110 m_zOrderListsDirty = true; |
| 111 | 111 |
| 112 if (!renderer()->documentBeingDestroyed()) | 112 if (!layoutObject()->documentBeingDestroyed()) |
| 113 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); | 113 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void LayerStackingNode::dirtyStackingContextZOrderLists() | 116 void LayerStackingNode::dirtyStackingContextZOrderLists() |
| 117 { | 117 { |
| 118 if (LayerStackingNode* stackingNode = ancestorStackingContextNode()) | 118 if (LayerStackingNode* stackingNode = ancestorStackingContextNode()) |
| 119 stackingNode->dirtyZOrderLists(); | 119 stackingNode->dirtyZOrderLists(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void LayerStackingNode::dirtyNormalFlowList() | 122 void LayerStackingNode::dirtyNormalFlowList() |
| 123 { | 123 { |
| 124 ASSERT(m_layerListMutationAllowed); | 124 ASSERT(m_layerListMutationAllowed); |
| 125 | 125 |
| 126 #if ENABLE(ASSERT) | 126 #if ENABLE(ASSERT) |
| 127 updateStackingParentForNormalFlowList(0); | 127 updateStackingParentForNormalFlowList(0); |
| 128 #endif | 128 #endif |
| 129 | 129 |
| 130 if (m_normalFlowList) | 130 if (m_normalFlowList) |
| 131 m_normalFlowList->clear(); | 131 m_normalFlowList->clear(); |
| 132 m_normalFlowListDirty = true; | 132 m_normalFlowListDirty = true; |
| 133 | 133 |
| 134 if (!renderer()->documentBeingDestroyed()) | 134 if (!layoutObject()->documentBeingDestroyed()) |
| 135 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); | 135 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void LayerStackingNode::rebuildZOrderLists() | 138 void LayerStackingNode::rebuildZOrderLists() |
| 139 { | 139 { |
| 140 ASSERT(m_layerListMutationAllowed); | 140 ASSERT(m_layerListMutationAllowed); |
| 141 ASSERT(isDirtyStackingContext()); | 141 ASSERT(isDirtyStackingContext()); |
| 142 | 142 |
| 143 for (Layer* child = layer()->firstChild(); child; child = child->nextSibling
()) { | 143 for (Layer* child = layer()->firstChild(); child; child = child->nextSibling
()) { |
| 144 if (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflectionL
ayer() != child) | 144 if (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflectionL
ayer() != child) |
| 145 child->stackingNode()->collectLayers(m_posZOrderList, m_negZOrderLis
t); | 145 child->stackingNode()->collectLayers(m_posZOrderList, m_negZOrderLis
t); |
| 146 } | 146 } |
| 147 | 147 |
| 148 // Sort the two lists. | 148 // Sort the two lists. |
| 149 if (m_posZOrderList) | 149 if (m_posZOrderList) |
| 150 std::stable_sort(m_posZOrderList->begin(), m_posZOrderList->end(), compa
reZIndex); | 150 std::stable_sort(m_posZOrderList->begin(), m_posZOrderList->end(), compa
reZIndex); |
| 151 | 151 |
| 152 if (m_negZOrderList) | 152 if (m_negZOrderList) |
| 153 std::stable_sort(m_negZOrderList->begin(), m_negZOrderList->end(), compa
reZIndex); | 153 std::stable_sort(m_negZOrderList->begin(), m_negZOrderList->end(), compa
reZIndex); |
| 154 | 154 |
| 155 // Append layers for top layer elements after normal layer collection, to en
sure they are on top regardless of z-indexes. | 155 // Append layers for top layer elements after normal layer collection, to en
sure they are on top regardless of z-indexes. |
| 156 // The renderers of top layer elements are children of the view, sorted in t
op layer stacking order. | 156 // The renderers of top layer elements are children of the view, sorted in t
op layer stacking order. |
| 157 if (layer()->isRootLayer()) { | 157 if (layer()->isRootLayer()) { |
| 158 LayoutView* view = renderer()->view(); | 158 LayoutView* view = layoutObject()->view(); |
| 159 for (LayoutObject* child = view->firstChild(); child; child = child->nex
tSibling()) { | 159 for (LayoutObject* child = view->firstChild(); child; child = child->nex
tSibling()) { |
| 160 Element* childElement = (child->node() && child->node()->isElementNo
de()) ? toElement(child->node()) : 0; | 160 Element* childElement = (child->node() && child->node()->isElementNo
de()) ? toElement(child->node()) : 0; |
| 161 if (childElement && childElement->isInTopLayer()) { | 161 if (childElement && childElement->isInTopLayer()) { |
| 162 Layer* layer = toLayoutBoxModelObject(child)->layer(); | 162 Layer* layer = toLayoutBoxModelObject(child)->layer(); |
| 163 // Create the buffer if it doesn't exist yet. | 163 // Create the buffer if it doesn't exist yet. |
| 164 if (!m_posZOrderList) | 164 if (!m_posZOrderList) |
| 165 m_posZOrderList = adoptPtr(new Vector<LayerStackingNode*>); | 165 m_posZOrderList = adoptPtr(new Vector<LayerStackingNode*>); |
| 166 m_posZOrderList->append(layer->stackingNode()); | 166 m_posZOrderList->append(layer->stackingNode()); |
| 167 } | 167 } |
| 168 } | 168 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 if (isStackingContext) | 289 if (isStackingContext) |
| 290 dirtyZOrderLists(); | 290 dirtyZOrderLists(); |
| 291 else | 291 else |
| 292 clearZOrderLists(); | 292 clearZOrderLists(); |
| 293 } | 293 } |
| 294 | 294 |
| 295 // FIXME: Rename shouldBeNormalFlowOnly to something more accurate now that CSS | 295 // FIXME: Rename shouldBeNormalFlowOnly to something more accurate now that CSS |
| 296 // 2.1 defines the term "normal flow". | 296 // 2.1 defines the term "normal flow". |
| 297 bool LayerStackingNode::shouldBeNormalFlowOnly() const | 297 bool LayerStackingNode::shouldBeNormalFlowOnly() const |
| 298 { | 298 { |
| 299 return !isStackingContext() && !renderer()->isPositioned(); | 299 return !isStackingContext() && !layoutObject()->isPositioned(); |
| 300 } | 300 } |
| 301 | 301 |
| 302 void LayerStackingNode::updateIsNormalFlowOnly() | 302 void LayerStackingNode::updateIsNormalFlowOnly() |
| 303 { | 303 { |
| 304 bool isNormalFlowOnly = shouldBeNormalFlowOnly(); | 304 bool isNormalFlowOnly = shouldBeNormalFlowOnly(); |
| 305 if (isNormalFlowOnly == this->isNormalFlowOnly()) | 305 if (isNormalFlowOnly == this->isNormalFlowOnly()) |
| 306 return; | 306 return; |
| 307 | 307 |
| 308 m_isNormalFlowOnly = isNormalFlowOnly; | 308 m_isNormalFlowOnly = isNormalFlowOnly; |
| 309 if (Layer* p = layer()->parent()) | 309 if (Layer* p = layer()->parent()) |
| 310 p->stackingNode()->dirtyNormalFlowList(); | 310 p->stackingNode()->dirtyNormalFlowList(); |
| 311 dirtyStackingContextZOrderLists(); | 311 dirtyStackingContextZOrderLists(); |
| 312 } | 312 } |
| 313 | 313 |
| 314 LayerStackingNode* LayerStackingNode::ancestorStackingContextNode() const | 314 LayerStackingNode* LayerStackingNode::ancestorStackingContextNode() const |
| 315 { | 315 { |
| 316 for (Layer* ancestor = layer()->parent(); ancestor; ancestor = ancestor->par
ent()) { | 316 for (Layer* ancestor = layer()->parent(); ancestor; ancestor = ancestor->par
ent()) { |
| 317 LayerStackingNode* stackingNode = ancestor->stackingNode(); | 317 LayerStackingNode* stackingNode = ancestor->stackingNode(); |
| 318 if (stackingNode->isStackingContext()) | 318 if (stackingNode->isStackingContext()) |
| 319 return stackingNode; | 319 return stackingNode; |
| 320 } | 320 } |
| 321 return 0; | 321 return 0; |
| 322 } | 322 } |
| 323 | 323 |
| 324 LayoutBoxModelObject* LayerStackingNode::renderer() const | 324 LayoutBoxModelObject* LayerStackingNode::layoutObject() const |
| 325 { | 325 { |
| 326 return m_layer->renderer(); | 326 return m_layer->layoutObject(); |
| 327 } | 327 } |
| 328 | 328 |
| 329 } // namespace blink | 329 } // namespace blink |
| OLD | NEW |