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 "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_normalFlowListDirty(true) | 59 , m_normalFlowListDirty(true) |
60 #if !ASSERT_DISABLED | 60 #if ASSERT_ENABLED |
61 , m_layerListMutationAllowed(true) | 61 , m_layerListMutationAllowed(true) |
62 , m_stackingParent(0) | 62 , m_stackingParent(0) |
63 #endif | 63 #endif |
64 { | 64 { |
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 RenderLayerStackingNode::~RenderLayerStackingNode() | 72 RenderLayerStackingNode::~RenderLayerStackingNode() |
73 { | 73 { |
74 #if !ASSERT_DISABLED | 74 #if ASSERT_ENABLED |
75 if (!renderer()->documentBeingDestroyed()) { | 75 if (!renderer()->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(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 ASSERT(renderer()->view()); | 93 ASSERT(renderer()->view()); |
94 return renderer()->view()->compositor(); | 94 return renderer()->view()->compositor(); |
95 } | 95 } |
96 | 96 |
97 void RenderLayerStackingNode::dirtyZOrderLists() | 97 void RenderLayerStackingNode::dirtyZOrderLists() |
98 { | 98 { |
99 ASSERT(m_layerListMutationAllowed); | 99 ASSERT(m_layerListMutationAllowed); |
100 ASSERT(isStackingContext()); | 100 ASSERT(isStackingContext()); |
101 | 101 |
102 #if !ASSERT_DISABLED | 102 #if ASSERT_ENABLED |
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 (!renderer()->documentBeingDestroyed()) |
113 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); | 113 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); |
114 } | 114 } |
115 | 115 |
116 void RenderLayerStackingNode::dirtyStackingContextZOrderLists() | 116 void RenderLayerStackingNode::dirtyStackingContextZOrderLists() |
117 { | 117 { |
118 if (RenderLayerStackingNode* stackingNode = ancestorStackingContextNode()) | 118 if (RenderLayerStackingNode* stackingNode = ancestorStackingContextNode()) |
119 stackingNode->dirtyZOrderLists(); | 119 stackingNode->dirtyZOrderLists(); |
120 } | 120 } |
121 | 121 |
122 void RenderLayerStackingNode::dirtyNormalFlowList() | 122 void RenderLayerStackingNode::dirtyNormalFlowList() |
123 { | 123 { |
124 ASSERT(m_layerListMutationAllowed); | 124 ASSERT(m_layerListMutationAllowed); |
125 | 125 |
126 #if !ASSERT_DISABLED | 126 #if ASSERT_ENABLED |
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 (!renderer()->documentBeingDestroyed()) |
135 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); | 135 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); |
136 } | 136 } |
(...skipping 24 matching lines...) Expand all Loading... |
161 if (childElement && childElement->isInTopLayer()) { | 161 if (childElement && childElement->isInTopLayer()) { |
162 RenderLayer* layer = toRenderLayerModelObject(child)->layer(); | 162 RenderLayer* layer = toRenderLayerModelObject(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<RenderLayerStackingNod
e*>); | 165 m_posZOrderList = adoptPtr(new Vector<RenderLayerStackingNod
e*>); |
166 m_posZOrderList->append(layer->stackingNode()); | 166 m_posZOrderList->append(layer->stackingNode()); |
167 } | 167 } |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 #if !ASSERT_DISABLED | 171 #if ASSERT_ENABLED |
172 updateStackingParentForZOrderLists(this); | 172 updateStackingParentForZOrderLists(this); |
173 #endif | 173 #endif |
174 | 174 |
175 m_zOrderListsDirty = false; | 175 m_zOrderListsDirty = false; |
176 } | 176 } |
177 | 177 |
178 void RenderLayerStackingNode::updateNormalFlowList() | 178 void RenderLayerStackingNode::updateNormalFlowList() |
179 { | 179 { |
180 if (!m_normalFlowListDirty) | 180 if (!m_normalFlowListDirty) |
181 return; | 181 return; |
182 | 182 |
183 ASSERT(m_layerListMutationAllowed); | 183 ASSERT(m_layerListMutationAllowed); |
184 | 184 |
185 for (RenderLayer* child = layer()->firstChild(); child; child = child->nextS
ibling()) { | 185 for (RenderLayer* child = layer()->firstChild(); child; child = child->nextS
ibling()) { |
186 if (child->stackingNode()->isNormalFlowOnly() && (!layer()->reflectionIn
fo() || layer()->reflectionInfo()->reflectionLayer() != child)) { | 186 if (child->stackingNode()->isNormalFlowOnly() && (!layer()->reflectionIn
fo() || layer()->reflectionInfo()->reflectionLayer() != child)) { |
187 if (!m_normalFlowList) | 187 if (!m_normalFlowList) |
188 m_normalFlowList = adoptPtr(new Vector<RenderLayerStackingNode*>
); | 188 m_normalFlowList = adoptPtr(new Vector<RenderLayerStackingNode*>
); |
189 m_normalFlowList->append(child->stackingNode()); | 189 m_normalFlowList->append(child->stackingNode()); |
190 } | 190 } |
191 } | 191 } |
192 | 192 |
193 #if !ASSERT_DISABLED | 193 #if ASSERT_ENABLED |
194 updateStackingParentForNormalFlowList(this); | 194 updateStackingParentForNormalFlowList(this); |
195 #endif | 195 #endif |
196 | 196 |
197 m_normalFlowListDirty = false; | 197 m_normalFlowListDirty = false; |
198 } | 198 } |
199 | 199 |
200 void RenderLayerStackingNode::collectLayers(OwnPtr<Vector<RenderLayerStackingNod
e*> >& posBuffer, OwnPtr<Vector<RenderLayerStackingNode*> >& negBuffer) | 200 void RenderLayerStackingNode::collectLayers(OwnPtr<Vector<RenderLayerStackingNod
e*> >& posBuffer, OwnPtr<Vector<RenderLayerStackingNode*> >& negBuffer) |
201 { | 201 { |
202 if (layer()->isInTopLayer()) | 202 if (layer()->isInTopLayer()) |
203 return; | 203 return; |
204 | 204 |
205 layer()->updateDescendantDependentFlags(); | 205 layer()->updateDescendantDependentFlags(); |
206 | 206 |
207 if (!isNormalFlowOnly()) { | 207 if (!isNormalFlowOnly()) { |
208 OwnPtr<Vector<RenderLayerStackingNode*> >& buffer = (zIndex() >= 0) ? po
sBuffer : negBuffer; | 208 OwnPtr<Vector<RenderLayerStackingNode*> >& buffer = (zIndex() >= 0) ? po
sBuffer : negBuffer; |
209 if (!buffer) | 209 if (!buffer) |
210 buffer = adoptPtr(new Vector<RenderLayerStackingNode*>); | 210 buffer = adoptPtr(new Vector<RenderLayerStackingNode*>); |
211 buffer->append(this); | 211 buffer->append(this); |
212 } | 212 } |
213 | 213 |
214 if (!isStackingContext()) { | 214 if (!isStackingContext()) { |
215 for (RenderLayer* child = layer()->firstChild(); child; child = child->n
extSibling()) { | 215 for (RenderLayer* child = layer()->firstChild(); child; child = child->n
extSibling()) { |
216 if (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflect
ionLayer() != child) | 216 if (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflect
ionLayer() != child) |
217 child->stackingNode()->collectLayers(posBuffer, negBuffer); | 217 child->stackingNode()->collectLayers(posBuffer, negBuffer); |
218 } | 218 } |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
222 #if !ASSERT_DISABLED | 222 #if ASSERT_ENABLED |
223 bool RenderLayerStackingNode::isInStackingParentZOrderLists() const | 223 bool RenderLayerStackingNode::isInStackingParentZOrderLists() const |
224 { | 224 { |
225 if (!m_stackingParent || m_stackingParent->zOrderListsDirty()) | 225 if (!m_stackingParent || m_stackingParent->zOrderListsDirty()) |
226 return false; | 226 return false; |
227 | 227 |
228 if (m_stackingParent->posZOrderList() && m_stackingParent->posZOrderList()->
find(this) != kNotFound) | 228 if (m_stackingParent->posZOrderList() && m_stackingParent->posZOrderList()->
find(this) != kNotFound) |
229 return true; | 229 return true; |
230 | 230 |
231 if (m_stackingParent->negZOrderList() && m_stackingParent->negZOrderList()->
find(this) != kNotFound) | 231 if (m_stackingParent->negZOrderList() && m_stackingParent->negZOrderList()->
find(this) != kNotFound) |
232 return true; | 232 return true; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 } | 322 } |
323 return 0; | 323 return 0; |
324 } | 324 } |
325 | 325 |
326 RenderLayerModelObject* RenderLayerStackingNode::renderer() const | 326 RenderLayerModelObject* RenderLayerStackingNode::renderer() const |
327 { | 327 { |
328 return m_layer->renderer(); | 328 return m_layer->renderer(); |
329 } | 329 } |
330 | 330 |
331 } // namespace WebCore | 331 } // namespace WebCore |
OLD | NEW |