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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #include "config.h" | 20 #include "config.h" |
21 #include "core/rendering/svg/RenderSVGResourceContainer.h" | 21 #include "core/rendering/svg/RenderSVGResourceContainer.h" |
22 | 22 |
23 #include "core/rendering/RenderLayer.h" | 23 #include "core/rendering/RenderLayer.h" |
| 24 #include "core/rendering/svg/RenderSVGResourceClipper.h" |
| 25 #include "core/rendering/svg/RenderSVGResourceFilter.h" |
| 26 #include "core/rendering/svg/RenderSVGResourceMasker.h" |
| 27 #include "core/rendering/svg/SVGResources.h" |
24 #include "core/rendering/svg/SVGResourcesCache.h" | 28 #include "core/rendering/svg/SVGResourcesCache.h" |
25 | 29 |
26 #include "wtf/TemporaryChange.h" | 30 #include "wtf/TemporaryChange.h" |
27 | 31 |
28 namespace blink { | 32 namespace blink { |
29 | 33 |
30 static inline SVGDocumentExtensions& svgExtensionsFromElement(SVGElement* elemen
t) | 34 static inline SVGDocumentExtensions& svgExtensionsFromElement(SVGElement* elemen
t) |
31 { | 35 { |
32 ASSERT(element); | 36 ASSERT(element); |
33 return element->document().accessSVGExtensions(); | 37 return element->document().accessSVGExtensions(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 for (HashSet<RenderObject*>::iterator it = m_clients.begin(); it != end; ++i
t) { | 114 for (HashSet<RenderObject*>::iterator it = m_clients.begin(); it != end; ++i
t) { |
111 RenderObject* client = *it; | 115 RenderObject* client = *it; |
112 if (client->isSVGResourceContainer()) { | 116 if (client->isSVGResourceContainer()) { |
113 toRenderSVGResourceContainer(client)->removeAllClientsFromCache(mark
ForInvalidation); | 117 toRenderSVGResourceContainer(client)->removeAllClientsFromCache(mark
ForInvalidation); |
114 continue; | 118 continue; |
115 } | 119 } |
116 | 120 |
117 if (markForInvalidation) | 121 if (markForInvalidation) |
118 markClientForInvalidation(client, mode); | 122 markClientForInvalidation(client, mode); |
119 | 123 |
120 RenderSVGResource::markForLayoutAndParentResourceInvalidation(client, ne
edsLayout); | 124 RenderSVGResourceContainer::markForLayoutAndParentResourceInvalidation(c
lient, needsLayout); |
121 } | 125 } |
122 | 126 |
123 markAllClientLayersForInvalidation(); | 127 markAllClientLayersForInvalidation(); |
124 | 128 |
125 m_isInvalidating = false; | 129 m_isInvalidating = false; |
126 } | 130 } |
127 | 131 |
128 void RenderSVGResourceContainer::markAllClientLayersForInvalidation() | 132 void RenderSVGResourceContainer::markAllClientLayersForInvalidation() |
129 { | 133 { |
130 HashSet<RenderLayer*>::iterator layerEnd = m_clientLayers.end(); | 134 HashSet<RenderLayer*>::iterator layerEnd = m_clientLayers.end(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 if (!renderer) | 223 if (!renderer) |
220 continue; | 224 continue; |
221 | 225 |
222 StyleDifference diff; | 226 StyleDifference diff; |
223 diff.setNeedsFullLayout(); | 227 diff.setNeedsFullLayout(); |
224 SVGResourcesCache::clientStyleChanged(renderer, diff, renderer->style())
; | 228 SVGResourcesCache::clientStyleChanged(renderer, diff, renderer->style())
; |
225 renderer->setNeedsLayoutAndFullPaintInvalidation(); | 229 renderer->setNeedsLayoutAndFullPaintInvalidation(); |
226 } | 230 } |
227 } | 231 } |
228 | 232 |
| 233 static inline void removeFromCacheAndInvalidateDependencies(RenderObject* object
, bool needsLayout) |
| 234 { |
| 235 ASSERT(object); |
| 236 if (SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObj
ect(object)) { |
| 237 if (RenderSVGResourceFilter* filter = resources->filter()) |
| 238 filter->removeClientFromCache(object); |
| 239 |
| 240 if (RenderSVGResourceMasker* masker = resources->masker()) |
| 241 masker->removeClientFromCache(object); |
| 242 |
| 243 if (RenderSVGResourceClipper* clipper = resources->clipper()) |
| 244 clipper->removeClientFromCache(object); |
| 245 } |
| 246 |
| 247 if (!object->node() || !object->node()->isSVGElement()) |
| 248 return; |
| 249 SVGElementSet* dependencies = toSVGElement(object->node())->setOfIncomingRef
erences(); |
| 250 if (!dependencies) |
| 251 return; |
| 252 |
| 253 // We allow cycles in SVGDocumentExtensions reference sets in order to avoid
expensive |
| 254 // reference graph adjustments on changes, so we need to break possible cycl
es here. |
| 255 // This strong reference is safe, as it is guaranteed that this set will be
emptied |
| 256 // at the end of recursion. |
| 257 typedef WillBeHeapHashSet<RawPtrWillBeMember<SVGElement> > SVGElementSet; |
| 258 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<SVGElementSet>, invalidatingDepen
dencies, (adoptPtrWillBeNoop(new SVGElementSet))); |
| 259 |
| 260 SVGElementSet::iterator end = dependencies->end(); |
| 261 for (SVGElementSet::iterator it = dependencies->begin(); it != end; ++it) { |
| 262 if (RenderObject* renderer = (*it)->renderer()) { |
| 263 if (UNLIKELY(!invalidatingDependencies->add(*it).isNewEntry)) { |
| 264 // Reference cycle: we are in process of invalidating this depen
dant. |
| 265 continue; |
| 266 } |
| 267 |
| 268 RenderSVGResourceContainer::markForLayoutAndParentResourceInvalidati
on(renderer, needsLayout); |
| 269 invalidatingDependencies->remove(*it); |
| 270 } |
| 271 } |
| 272 } |
| 273 |
| 274 void RenderSVGResourceContainer::markForLayoutAndParentResourceInvalidation(Rend
erObject* object, bool needsLayout) |
| 275 { |
| 276 ASSERT(object); |
| 277 ASSERT(object->node()); |
| 278 |
| 279 if (needsLayout && !object->documentBeingDestroyed()) |
| 280 object->setNeedsLayoutAndFullPaintInvalidation(); |
| 281 |
| 282 removeFromCacheAndInvalidateDependencies(object, needsLayout); |
| 283 |
| 284 // Invalidate resources in ancestor chain, if needed. |
| 285 RenderObject* current = object->parent(); |
| 286 while (current) { |
| 287 removeFromCacheAndInvalidateDependencies(current, needsLayout); |
| 288 |
| 289 if (current->isSVGResourceContainer()) { |
| 290 // This will process the rest of the ancestors. |
| 291 toRenderSVGResourceContainer(current)->removeAllClientsFromCache(); |
| 292 break; |
| 293 } |
| 294 |
| 295 current = current->parent(); |
| 296 } |
| 297 } |
| 298 |
229 } | 299 } |
OLD | NEW |