| 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/paint/DeprecatedPaintLayer.h" | 49 #include "core/paint/DeprecatedPaintLayer.h" |
| 50 #include "public/platform/Platform.h" | 50 #include "public/platform/Platform.h" |
| 51 | 51 |
| 52 namespace blink { | 52 namespace blink { |
| 53 | 53 |
| 54 // FIXME: This should not require DeprecatedPaintLayer. There is currently a cyc
le where | 54 // 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 | 55 // in order to determine if we shoulBeTreatedAsStackingContextForPainting() we h
ave to ask the paint |
| 56 // layer about some of its state. | 56 // layer about some of its state. |
| 57 DeprecatedPaintLayerStackingNode::DeprecatedPaintLayerStackingNode(DeprecatedPai
ntLayer* layer) | 57 DeprecatedPaintLayerStackingNode::DeprecatedPaintLayerStackingNode(DeprecatedPai
ntLayer* layer) |
| 58 : m_layer(layer) | 58 : m_layer(layer) |
| 59 , m_normalFlowListDirty(true) | |
| 60 #if ENABLE(ASSERT) | 59 #if ENABLE(ASSERT) |
| 61 , m_layerListMutationAllowed(true) | 60 , m_layerListMutationAllowed(true) |
| 62 , m_stackingParent(0) | 61 , m_stackingParent(0) |
| 63 #endif | 62 #endif |
| 64 { | 63 { |
| 65 m_isTreatedAsStackingContextForPainting = shouldBeTreatedAsStackingContextFo
rPainting(); | 64 m_isTreatedAsStackingContextForPainting = shouldBeTreatedAsStackingContextFo
rPainting(); |
| 66 | 65 |
| 67 // Non-stacking contexts should have empty z-order lists. As this is already
the case, | 66 // 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. | 67 // there is no need to dirty / recompute these lists. |
| 69 m_zOrderListsDirty = isStackingContext(); | 68 m_zOrderListsDirty = isStackingContext(); |
| 70 } | 69 } |
| 71 | 70 |
| 72 DeprecatedPaintLayerStackingNode::~DeprecatedPaintLayerStackingNode() | 71 DeprecatedPaintLayerStackingNode::~DeprecatedPaintLayerStackingNode() |
| 73 { | 72 { |
| 74 #if ENABLE(ASSERT) | 73 #if ENABLE(ASSERT) |
| 75 if (!layoutObject()->documentBeingDestroyed()) { | 74 if (!layoutObject()->documentBeingDestroyed()) { |
| 76 ASSERT(!isInStackingParentZOrderLists()); | 75 ASSERT(!isInStackingParentZOrderLists()); |
| 77 ASSERT(!isInStackingParentNormalFlowList()); | |
| 78 | 76 |
| 79 updateStackingParentForZOrderLists(0); | 77 updateStackingParentForZOrderLists(0); |
| 80 updateStackingParentForNormalFlowList(0); | |
| 81 } | 78 } |
| 82 #endif | 79 #endif |
| 83 } | 80 } |
| 84 | 81 |
| 85 // Helper for the sorting of layers by z-index. | 82 // Helper for the sorting of layers by z-index. |
| 86 static inline bool compareZIndex(DeprecatedPaintLayerStackingNode* first, Deprec
atedPaintLayerStackingNode* second) | 83 static inline bool compareZIndex(DeprecatedPaintLayerStackingNode* first, Deprec
atedPaintLayerStackingNode* second) |
| 87 { | 84 { |
| 88 return first->zIndex() < second->zIndex(); | 85 return first->zIndex() < second->zIndex(); |
| 89 } | 86 } |
| 90 | 87 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 112 if (!layoutObject()->documentBeingDestroyed()) | 109 if (!layoutObject()->documentBeingDestroyed()) |
| 113 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); | 110 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); |
| 114 } | 111 } |
| 115 | 112 |
| 116 void DeprecatedPaintLayerStackingNode::dirtyStackingContextZOrderLists() | 113 void DeprecatedPaintLayerStackingNode::dirtyStackingContextZOrderLists() |
| 117 { | 114 { |
| 118 if (DeprecatedPaintLayerStackingNode* stackingNode = ancestorStackingContext
Node()) | 115 if (DeprecatedPaintLayerStackingNode* stackingNode = ancestorStackingContext
Node()) |
| 119 stackingNode->dirtyZOrderLists(); | 116 stackingNode->dirtyZOrderLists(); |
| 120 } | 117 } |
| 121 | 118 |
| 122 void DeprecatedPaintLayerStackingNode::dirtyNormalFlowList() | |
| 123 { | |
| 124 ASSERT(m_layerListMutationAllowed); | |
| 125 | |
| 126 #if ENABLE(ASSERT) | |
| 127 updateStackingParentForNormalFlowList(0); | |
| 128 #endif | |
| 129 | |
| 130 if (m_normalFlowList) | |
| 131 m_normalFlowList->clear(); | |
| 132 m_normalFlowListDirty = true; | |
| 133 | |
| 134 if (!layoutObject()->documentBeingDestroyed()) | |
| 135 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); | |
| 136 } | |
| 137 | |
| 138 void DeprecatedPaintLayerStackingNode::rebuildZOrderLists() | 119 void DeprecatedPaintLayerStackingNode::rebuildZOrderLists() |
| 139 { | 120 { |
| 140 ASSERT(m_layerListMutationAllowed); | 121 ASSERT(m_layerListMutationAllowed); |
| 141 ASSERT(isDirtyStackingContext()); | 122 ASSERT(isDirtyStackingContext()); |
| 142 | 123 |
| 143 for (DeprecatedPaintLayer* child = layer()->firstChild(); child; child = chi
ld->nextSibling()) { | 124 for (DeprecatedPaintLayer* child = layer()->firstChild(); child; child = chi
ld->nextSibling()) { |
| 144 if (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflectionL
ayer() != child) | 125 if (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflectionL
ayer() != child) |
| 145 child->stackingNode()->collectLayers(m_posZOrderList, m_negZOrderLis
t); | 126 child->stackingNode()->collectLayers(m_posZOrderList, m_negZOrderLis
t); |
| 146 } | 127 } |
| 147 | 128 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 168 } | 149 } |
| 169 } | 150 } |
| 170 | 151 |
| 171 #if ENABLE(ASSERT) | 152 #if ENABLE(ASSERT) |
| 172 updateStackingParentForZOrderLists(this); | 153 updateStackingParentForZOrderLists(this); |
| 173 #endif | 154 #endif |
| 174 | 155 |
| 175 m_zOrderListsDirty = false; | 156 m_zOrderListsDirty = false; |
| 176 } | 157 } |
| 177 | 158 |
| 178 void DeprecatedPaintLayerStackingNode::updateNormalFlowList() | |
| 179 { | |
| 180 if (!m_normalFlowListDirty) | |
| 181 return; | |
| 182 | |
| 183 ASSERT(m_layerListMutationAllowed); | |
| 184 | |
| 185 for (DeprecatedPaintLayer* child = layer()->firstChild(); child; child = chi
ld->nextSibling()) { | |
| 186 if (!child->stackingNode()->isTreatedAsStackingContextForPainting() && (
!layer()->reflectionInfo() || layer()->reflectionInfo()->reflectionLayer() != ch
ild)) { | |
| 187 if (!m_normalFlowList) | |
| 188 m_normalFlowList = adoptPtr(new Vector<DeprecatedPaintLayerStack
ingNode*>); | |
| 189 m_normalFlowList->append(child->stackingNode()); | |
| 190 } | |
| 191 } | |
| 192 | |
| 193 #if ENABLE(ASSERT) | |
| 194 updateStackingParentForNormalFlowList(this); | |
| 195 #endif | |
| 196 | |
| 197 m_normalFlowListDirty = false; | |
| 198 } | |
| 199 | |
| 200 void DeprecatedPaintLayerStackingNode::collectLayers(OwnPtr<Vector<DeprecatedPai
ntLayerStackingNode*>>& posBuffer, OwnPtr<Vector<DeprecatedPaintLayerStackingNod
e*>>& negBuffer) | 159 void DeprecatedPaintLayerStackingNode::collectLayers(OwnPtr<Vector<DeprecatedPai
ntLayerStackingNode*>>& posBuffer, OwnPtr<Vector<DeprecatedPaintLayerStackingNod
e*>>& negBuffer) |
| 201 { | 160 { |
| 202 if (layer()->isInTopLayer()) | 161 if (layer()->isInTopLayer()) |
| 203 return; | 162 return; |
| 204 | 163 |
| 205 if (isTreatedAsStackingContextForPainting()) { | 164 if (isTreatedAsStackingContextForPainting()) { |
| 206 OwnPtr<Vector<DeprecatedPaintLayerStackingNode*>>& buffer = (zIndex() >=
0) ? posBuffer : negBuffer; | 165 OwnPtr<Vector<DeprecatedPaintLayerStackingNode*>>& buffer = (zIndex() >=
0) ? posBuffer : negBuffer; |
| 207 if (!buffer) | 166 if (!buffer) |
| 208 buffer = adoptPtr(new Vector<DeprecatedPaintLayerStackingNode*>); | 167 buffer = adoptPtr(new Vector<DeprecatedPaintLayerStackingNode*>); |
| 209 buffer->append(this); | 168 buffer->append(this); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 225 | 184 |
| 226 if (m_stackingParent->posZOrderList() && m_stackingParent->posZOrderList()->
find(this) != kNotFound) | 185 if (m_stackingParent->posZOrderList() && m_stackingParent->posZOrderList()->
find(this) != kNotFound) |
| 227 return true; | 186 return true; |
| 228 | 187 |
| 229 if (m_stackingParent->negZOrderList() && m_stackingParent->negZOrderList()->
find(this) != kNotFound) | 188 if (m_stackingParent->negZOrderList() && m_stackingParent->negZOrderList()->
find(this) != kNotFound) |
| 230 return true; | 189 return true; |
| 231 | 190 |
| 232 return false; | 191 return false; |
| 233 } | 192 } |
| 234 | 193 |
| 235 bool DeprecatedPaintLayerStackingNode::isInStackingParentNormalFlowList() const | |
| 236 { | |
| 237 if (!m_stackingParent || m_stackingParent->normalFlowListDirty()) | |
| 238 return false; | |
| 239 | |
| 240 return (m_stackingParent->normalFlowList() && m_stackingParent->normalFlowLi
st()->find(this) != kNotFound); | |
| 241 } | |
| 242 | |
| 243 void DeprecatedPaintLayerStackingNode::updateStackingParentForZOrderLists(Deprec
atedPaintLayerStackingNode* stackingParent) | 194 void DeprecatedPaintLayerStackingNode::updateStackingParentForZOrderLists(Deprec
atedPaintLayerStackingNode* stackingParent) |
| 244 { | 195 { |
| 245 if (m_posZOrderList) { | 196 if (m_posZOrderList) { |
| 246 for (size_t i = 0; i < m_posZOrderList->size(); ++i) | 197 for (size_t i = 0; i < m_posZOrderList->size(); ++i) |
| 247 m_posZOrderList->at(i)->setStackingParent(stackingParent); | 198 m_posZOrderList->at(i)->setStackingParent(stackingParent); |
| 248 } | 199 } |
| 249 | 200 |
| 250 if (m_negZOrderList) { | 201 if (m_negZOrderList) { |
| 251 for (size_t i = 0; i < m_negZOrderList->size(); ++i) | 202 for (size_t i = 0; i < m_negZOrderList->size(); ++i) |
| 252 m_negZOrderList->at(i)->setStackingParent(stackingParent); | 203 m_negZOrderList->at(i)->setStackingParent(stackingParent); |
| 253 } | 204 } |
| 254 } | 205 } |
| 255 | 206 |
| 256 void DeprecatedPaintLayerStackingNode::updateStackingParentForNormalFlowList(Dep
recatedPaintLayerStackingNode* stackingParent) | |
| 257 { | |
| 258 if (m_normalFlowList) { | |
| 259 for (size_t i = 0; i < m_normalFlowList->size(); ++i) | |
| 260 m_normalFlowList->at(i)->setStackingParent(stackingParent); | |
| 261 } | |
| 262 } | |
| 263 #endif | 207 #endif |
| 264 | 208 |
| 265 void DeprecatedPaintLayerStackingNode::updateLayerListsIfNeeded() | 209 void DeprecatedPaintLayerStackingNode::updateLayerListsIfNeeded() |
| 266 { | 210 { |
| 267 updateZOrderLists(); | 211 updateZOrderLists(); |
| 268 updateNormalFlowList(); | |
| 269 | 212 |
| 270 if (!layer()->reflectionInfo()) | 213 if (!layer()->reflectionInfo()) |
| 271 return; | 214 return; |
| 272 | 215 |
| 273 DeprecatedPaintLayer* reflectionLayer = layer()->reflectionInfo()->reflectio
nLayer(); | 216 DeprecatedPaintLayer* reflectionLayer = layer()->reflectionInfo()->reflectio
nLayer(); |
| 274 reflectionLayer->stackingNode()->updateZOrderLists(); | 217 reflectionLayer->stackingNode()->updateZOrderLists(); |
| 275 reflectionLayer->stackingNode()->updateNormalFlowList(); | |
| 276 } | 218 } |
| 277 | 219 |
| 278 void DeprecatedPaintLayerStackingNode::updateStackingNodesAfterStyleChange(const
ComputedStyle* oldStyle) | 220 void DeprecatedPaintLayerStackingNode::updateStackingNodesAfterStyleChange(const
ComputedStyle* oldStyle) |
| 279 { | 221 { |
| 280 bool wasStackingContext = oldStyle ? !oldStyle->hasAutoZIndex() : false; | 222 bool wasStackingContext = oldStyle ? !oldStyle->hasAutoZIndex() : false; |
| 281 int oldZIndex = oldStyle ? oldStyle->zIndex() : 0; | 223 int oldZIndex = oldStyle ? oldStyle->zIndex() : 0; |
| 282 | 224 |
| 283 bool isStackingContext = this->isStackingContext(); | 225 bool isStackingContext = this->isStackingContext(); |
| 284 if (isStackingContext == wasStackingContext && oldZIndex == zIndex()) | 226 if (isStackingContext == wasStackingContext && oldZIndex == zIndex()) |
| 285 return; | 227 return; |
| 286 | 228 |
| 287 dirtyStackingContextZOrderLists(); | 229 dirtyStackingContextZOrderLists(); |
| 288 | 230 |
| 289 if (isStackingContext) | 231 if (isStackingContext) |
| 290 dirtyZOrderLists(); | 232 dirtyZOrderLists(); |
| 291 else | 233 else |
| 292 clearZOrderLists(); | 234 clearZOrderLists(); |
| 293 } | 235 } |
| 294 | 236 |
| 295 void DeprecatedPaintLayerStackingNode::updateIsTreatedAsStackingContextForPainti
ng() | 237 void DeprecatedPaintLayerStackingNode::updateIsTreatedAsStackingContextForPainti
ng() |
| 296 { | 238 { |
| 297 bool isTreatedAsStackingContextForPainting = shouldBeTreatedAsStackingContex
tForPainting(); | 239 bool isTreatedAsStackingContextForPainting = shouldBeTreatedAsStackingContex
tForPainting(); |
| 298 if (isTreatedAsStackingContextForPainting == this->isTreatedAsStackingContex
tForPainting()) | 240 if (isTreatedAsStackingContextForPainting == this->isTreatedAsStackingContex
tForPainting()) |
| 299 return; | 241 return; |
| 300 | 242 |
| 301 m_isTreatedAsStackingContextForPainting = isTreatedAsStackingContextForPaint
ing; | 243 m_isTreatedAsStackingContextForPainting = isTreatedAsStackingContextForPaint
ing; |
| 302 if (DeprecatedPaintLayer* p = layer()->parent()) | 244 if (!layoutObject()->documentBeingDestroyed() && !layer()->isRootLayer()) |
| 303 p->stackingNode()->dirtyNormalFlowList(); | 245 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); |
| 304 dirtyStackingContextZOrderLists(); | 246 dirtyStackingContextZOrderLists(); |
| 305 } | 247 } |
| 306 | 248 |
| 307 DeprecatedPaintLayerStackingNode* DeprecatedPaintLayerStackingNode::ancestorStac
kingContextNode() const | 249 DeprecatedPaintLayerStackingNode* DeprecatedPaintLayerStackingNode::ancestorStac
kingContextNode() const |
| 308 { | 250 { |
| 309 for (DeprecatedPaintLayer* ancestor = layer()->parent(); ancestor; ancestor
= ancestor->parent()) { | 251 for (DeprecatedPaintLayer* ancestor = layer()->parent(); ancestor; ancestor
= ancestor->parent()) { |
| 310 DeprecatedPaintLayerStackingNode* stackingNode = ancestor->stackingNode(
); | 252 DeprecatedPaintLayerStackingNode* stackingNode = ancestor->stackingNode(
); |
| 311 if (stackingNode->isStackingContext()) | 253 if (stackingNode->isStackingContext()) |
| 312 return stackingNode; | 254 return stackingNode; |
| 313 } | 255 } |
| 314 return 0; | 256 return 0; |
| 315 } | 257 } |
| 316 | 258 |
| 317 LayoutBoxModelObject* DeprecatedPaintLayerStackingNode::layoutObject() const | 259 LayoutBoxModelObject* DeprecatedPaintLayerStackingNode::layoutObject() const |
| 318 { | 260 { |
| 319 return m_layer->layoutObject(); | 261 return m_layer->layoutObject(); |
| 320 } | 262 } |
| 321 | 263 |
| 322 } // namespace blink | 264 } // namespace blink |
| OLD | NEW |