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