OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 LayoutSVGHiddenContainer::willBeDestroyed(); | 76 LayoutSVGHiddenContainer::willBeDestroyed(); |
77 if (m_registered) | 77 if (m_registered) |
78 svgTreeScopeResourcesFromElement(element()).removeResource(m_id); | 78 svgTreeScopeResourcesFromElement(element()).removeResource(m_id); |
79 } | 79 } |
80 | 80 |
81 void LayoutSVGResourceContainer::styleDidChange(StyleDifference diff, | 81 void LayoutSVGResourceContainer::styleDidChange(StyleDifference diff, |
82 const ComputedStyle* oldStyle) { | 82 const ComputedStyle* oldStyle) { |
83 LayoutSVGHiddenContainer::styleDidChange(diff, oldStyle); | 83 LayoutSVGHiddenContainer::styleDidChange(diff, oldStyle); |
84 | 84 |
85 if (!m_registered) { | 85 if (m_registered) |
86 m_registered = true; | 86 return; |
87 registerResource(); | 87 m_registered = true; |
88 } | 88 svgTreeScopeResourcesFromElement(element()).updateResource(m_id, this); |
89 } | 89 } |
90 | 90 |
91 void LayoutSVGResourceContainer::detachAllClients() { | 91 void LayoutSVGResourceContainer::detachAllClients() { |
92 for (auto* client : m_clients) { | 92 for (auto* client : m_clients) { |
93 // Unlink the resource from the client's SVGResources. (The actual | 93 // Unlink the resource from the client's SVGResources. (The actual |
94 // removal will be signaled after processing all the clients.) | 94 // removal will be signaled after processing all the clients.) |
95 SVGResources* resources = | 95 SVGResources* resources = |
96 SVGResourcesCache::cachedResourcesForLayoutObject(client); | 96 SVGResourcesCache::cachedResourcesForLayoutObject(client); |
97 // Or else the client wouldn't be in the list in the first place. | 97 // Or else the client wouldn't be in the list in the first place. |
98 DCHECK(resources); | 98 DCHECK(resources); |
(...skipping 10 matching lines...) Expand all Loading... |
109 | 109 |
110 void LayoutSVGResourceContainer::idChanged() { | 110 void LayoutSVGResourceContainer::idChanged() { |
111 // Invalidate all our current clients. | 111 // Invalidate all our current clients. |
112 removeAllClientsFromCache(); | 112 removeAllClientsFromCache(); |
113 | 113 |
114 // Remove old id, that is guaranteed to be present in cache. | 114 // Remove old id, that is guaranteed to be present in cache. |
115 SVGTreeScopeResources& treeScopeResources = | 115 SVGTreeScopeResources& treeScopeResources = |
116 svgTreeScopeResourcesFromElement(element()); | 116 svgTreeScopeResourcesFromElement(element()); |
117 treeScopeResources.removeResource(m_id); | 117 treeScopeResources.removeResource(m_id); |
118 m_id = element()->getIdAttribute(); | 118 m_id = element()->getIdAttribute(); |
119 | 119 treeScopeResources.updateResource(m_id, this); |
120 registerResource(); | |
121 } | 120 } |
122 | 121 |
123 void LayoutSVGResourceContainer::markAllClientsForInvalidation( | 122 void LayoutSVGResourceContainer::markAllClientsForInvalidation( |
124 InvalidationMode mode) { | 123 InvalidationMode mode) { |
125 if (m_isInvalidating) | 124 if (m_isInvalidating) |
126 return; | 125 return; |
127 SVGElementProxySet* proxySet = elementProxySet(); | 126 SVGElementProxySet* proxySet = elementProxySet(); |
128 if (m_clients.isEmpty() && (!proxySet || proxySet->isEmpty())) | 127 if (m_clients.isEmpty() && (!proxySet || proxySet->isEmpty())) |
129 return; | 128 return; |
130 if (m_invalidationMask & mode) | 129 if (m_invalidationMask & mode) |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 return; | 201 return; |
203 | 202 |
204 setNeedsLayoutAndFullPaintInvalidation( | 203 setNeedsLayoutAndFullPaintInvalidation( |
205 LayoutInvalidationReason::SvgResourceInvalidated, MarkContainerChain, | 204 LayoutInvalidationReason::SvgResourceInvalidated, MarkContainerChain, |
206 layoutScope); | 205 layoutScope); |
207 | 206 |
208 if (everHadLayout()) | 207 if (everHadLayout()) |
209 removeAllClientsFromCache(); | 208 removeAllClientsFromCache(); |
210 } | 209 } |
211 | 210 |
212 void LayoutSVGResourceContainer::registerResource() { | |
213 SVGTreeScopeResources& treeScopeResources = | |
214 svgTreeScopeResourcesFromElement(element()); | |
215 if (!treeScopeResources.hasPendingResource(m_id)) { | |
216 treeScopeResources.addResource(m_id, this); | |
217 return; | |
218 } | |
219 | |
220 SVGTreeScopeResources::SVGPendingElements* clients( | |
221 treeScopeResources.removePendingResource(m_id)); | |
222 | |
223 // Cache us with the new id. | |
224 treeScopeResources.addResource(m_id, this); | |
225 | |
226 // Update cached resources of pending clients. | |
227 for (const auto& pendingClient : *clients) { | |
228 DCHECK(pendingClient->hasPendingResources()); | |
229 treeScopeResources.clearHasPendingResourcesIfPossible(pendingClient); | |
230 LayoutObject* layoutObject = pendingClient->layoutObject(); | |
231 if (!layoutObject) | |
232 continue; | |
233 DCHECK(layoutObject->isSVG()); | |
234 | |
235 StyleDifference diff; | |
236 diff.setNeedsFullLayout(); | |
237 SVGResourcesCache::clientStyleChanged(layoutObject, diff, | |
238 layoutObject->styleRef()); | |
239 layoutObject->setNeedsLayoutAndFullPaintInvalidation( | |
240 LayoutInvalidationReason::SvgResourceInvalidated); | |
241 } | |
242 } | |
243 | |
244 static inline void removeFromCacheAndInvalidateDependencies( | 211 static inline void removeFromCacheAndInvalidateDependencies( |
245 LayoutObject* object, | 212 LayoutObject* object, |
246 bool needsLayout) { | 213 bool needsLayout) { |
247 ASSERT(object); | 214 ASSERT(object); |
248 if (SVGResources* resources = | 215 if (SVGResources* resources = |
249 SVGResourcesCache::cachedResourcesForLayoutObject(object)) { | 216 SVGResourcesCache::cachedResourcesForLayoutObject(object)) { |
250 resources->removeClientFromCacheAffectingObjectBounds(object); | 217 resources->removeClientFromCacheAffectingObjectBounds(object); |
251 } | 218 } |
252 | 219 |
253 if (!object->node() || !object->node()->isSVGElement()) | 220 if (!object->node() || !object->node()->isSVGElement()) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 // This will process the rest of the ancestors. | 268 // This will process the rest of the ancestors. |
302 toLayoutSVGResourceContainer(current)->removeAllClientsFromCache(); | 269 toLayoutSVGResourceContainer(current)->removeAllClientsFromCache(); |
303 break; | 270 break; |
304 } | 271 } |
305 | 272 |
306 current = current->parent(); | 273 current = current->parent(); |
307 } | 274 } |
308 } | 275 } |
309 | 276 |
310 } // namespace blink | 277 } // namespace blink |
OLD | NEW |