Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(980)

Side by Side Diff: Source/core/layout/svg/LayoutSVGResourceContainer.cpp

Issue 1302713003: Don't register excessive pending SVG resources (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 13 matching lines...) Expand all
24 #include "core/layout/svg/LayoutSVGResourceFilter.h" 24 #include "core/layout/svg/LayoutSVGResourceFilter.h"
25 #include "core/layout/svg/LayoutSVGResourceMasker.h" 25 #include "core/layout/svg/LayoutSVGResourceMasker.h"
26 #include "core/layout/svg/SVGResources.h" 26 #include "core/layout/svg/SVGResources.h"
27 #include "core/layout/svg/SVGResourcesCache.h" 27 #include "core/layout/svg/SVGResourcesCache.h"
28 #include "core/paint/DeprecatedPaintLayer.h" 28 #include "core/paint/DeprecatedPaintLayer.h"
29 29
30 #include "wtf/TemporaryChange.h" 30 #include "wtf/TemporaryChange.h"
31 31
32 namespace blink { 32 namespace blink {
33 33
34 static inline SVGDocumentExtensions& svgExtensionsFromElement(SVGElement* elemen t) 34 static inline SVGDocumentExtensions& svgExtensionsFromElement(Element* element)
35 { 35 {
36 ASSERT(element); 36 ASSERT(element);
37 return element->document().accessSVGExtensions(); 37 return element->document().accessSVGExtensions();
38 } 38 }
39 39
40 LayoutSVGResourceContainer::LayoutSVGResourceContainer(SVGElement* node) 40 LayoutSVGResourceContainer::LayoutSVGResourceContainer(SVGElement* node)
41 : LayoutSVGHiddenContainer(node) 41 : LayoutSVGHiddenContainer(node)
42 , m_isInLayout(false) 42 , m_isInLayout(false)
43 , m_id(node->getIdAttribute()) 43 , m_id(node->getIdAttribute())
44 , m_invalidationMask(0) 44 , m_invalidationMask(0)
(...skipping 16 matching lines...) Expand all
61 61
62 TemporaryChange<bool> inLayoutChange(m_isInLayout, true); 62 TemporaryChange<bool> inLayoutChange(m_isInLayout, true);
63 63
64 LayoutSVGHiddenContainer::layout(); 64 LayoutSVGHiddenContainer::layout();
65 65
66 clearInvalidationMask(); 66 clearInvalidationMask();
67 } 67 }
68 68
69 void LayoutSVGResourceContainer::willBeDestroyed() 69 void LayoutSVGResourceContainer::willBeDestroyed()
70 { 70 {
71 SVGResourcesCache::resourceDestroyed(this); 71 // Detach all clients referring to this resource. If the resource itself is
72 // a client, it will be detached from any such resources by the call to
73 // LayoutSVGHiddenContainer::willBeDestroyed() below.
74 detachAllClients();
75
72 LayoutSVGHiddenContainer::willBeDestroyed(); 76 LayoutSVGHiddenContainer::willBeDestroyed();
73 if (m_registered) 77 if (m_registered)
74 svgExtensionsFromElement(element()).removeResource(m_id); 78 svgExtensionsFromElement(element()).removeResource(m_id);
75 } 79 }
76 80
77 void LayoutSVGResourceContainer::styleDidChange(StyleDifference diff, const Comp utedStyle* oldStyle) 81 void LayoutSVGResourceContainer::styleDidChange(StyleDifference diff, const Comp utedStyle* oldStyle)
78 { 82 {
79 LayoutSVGHiddenContainer::styleDidChange(diff, oldStyle); 83 LayoutSVGHiddenContainer::styleDidChange(diff, oldStyle);
80 84
81 if (!m_registered) { 85 if (!m_registered) {
82 m_registered = true; 86 m_registered = true;
83 registerResource(); 87 registerResource();
84 } 88 }
85 } 89 }
86 90
91 void LayoutSVGResourceContainer::detachAllClients()
92 {
93 for (auto* client : m_clients) {
94 // Unlink the resource from the client's SVGResources. (The actual
95 // removal will be signaled after processing all the clients.)
96 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObj ect(client);
97 ASSERT(resources); // Or else the client wouldn't be in the list in the first place.
98 resources->resourceDestroyed(this);
99
100 // Add a pending resolution based on the id of the old resource.
101 Element* clientElement = toElement(client->node());
102 svgExtensionsFromElement(clientElement).addPendingResource(m_id, clientE lement);
103 }
104
105 removeAllClientsFromCache();
106 }
107
87 void LayoutSVGResourceContainer::idChanged() 108 void LayoutSVGResourceContainer::idChanged()
88 { 109 {
89 // Invalidate all our current clients. 110 // Invalidate all our current clients.
90 removeAllClientsFromCache(); 111 removeAllClientsFromCache();
91 112
92 // Remove old id, that is guaranteed to be present in cache. 113 // Remove old id, that is guaranteed to be present in cache.
93 SVGDocumentExtensions& extensions = svgExtensionsFromElement(element()); 114 SVGDocumentExtensions& extensions = svgExtensionsFromElement(element());
94 extensions.removeResource(m_id); 115 extensions.removeResource(m_id);
95 m_id = element()->getIdAttribute(); 116 m_id = element()->getIdAttribute();
96 117
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 // This will process the rest of the ancestors. 314 // This will process the rest of the ancestors.
294 toLayoutSVGResourceContainer(current)->removeAllClientsFromCache(); 315 toLayoutSVGResourceContainer(current)->removeAllClientsFromCache();
295 break; 316 break;
296 } 317 }
297 318
298 current = current->parent(); 319 current = current->parent();
299 } 320 }
300 } 321 }
301 322
302 } 323 }
OLDNEW
« no previous file with comments | « Source/core/layout/svg/LayoutSVGResourceContainer.h ('k') | Source/core/layout/svg/SVGResources.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698