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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/layout/svg/LayoutSVGResourceContainer.h ('k') | Source/core/layout/svg/SVGResources.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/svg/LayoutSVGResourceContainer.cpp
diff --git a/Source/core/layout/svg/LayoutSVGResourceContainer.cpp b/Source/core/layout/svg/LayoutSVGResourceContainer.cpp
index 35ac287f07d068fe010c527b914d6865a438a8e8..c0366122d6e3f407adbbaca50e2da5219130eac7 100644
--- a/Source/core/layout/svg/LayoutSVGResourceContainer.cpp
+++ b/Source/core/layout/svg/LayoutSVGResourceContainer.cpp
@@ -31,7 +31,7 @@
namespace blink {
-static inline SVGDocumentExtensions& svgExtensionsFromElement(SVGElement* element)
+static inline SVGDocumentExtensions& svgExtensionsFromElement(Element* element)
{
ASSERT(element);
return element->document().accessSVGExtensions();
@@ -68,7 +68,11 @@ void LayoutSVGResourceContainer::layout()
void LayoutSVGResourceContainer::willBeDestroyed()
{
- SVGResourcesCache::resourceDestroyed(this);
+ // Detach all clients referring to this resource. If the resource itself is
+ // a client, it will be detached from any such resources by the call to
+ // LayoutSVGHiddenContainer::willBeDestroyed() below.
+ detachAllClients();
+
LayoutSVGHiddenContainer::willBeDestroyed();
if (m_registered)
svgExtensionsFromElement(element()).removeResource(m_id);
@@ -84,6 +88,23 @@ void LayoutSVGResourceContainer::styleDidChange(StyleDifference diff, const Comp
}
}
+void LayoutSVGResourceContainer::detachAllClients()
+{
+ for (auto* client : m_clients) {
+ // Unlink the resource from the client's SVGResources. (The actual
+ // removal will be signaled after processing all the clients.)
+ SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(client);
+ ASSERT(resources); // Or else the client wouldn't be in the list in the first place.
+ resources->resourceDestroyed(this);
+
+ // Add a pending resolution based on the id of the old resource.
+ Element* clientElement = toElement(client->node());
+ svgExtensionsFromElement(clientElement).addPendingResource(m_id, clientElement);
+ }
+
+ removeAllClientsFromCache();
+}
+
void LayoutSVGResourceContainer::idChanged()
{
// Invalidate all our current clients.
« 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