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

Unified Diff: third_party/WebKit/Source/core/layout/svg/SVGResourcesCache.cpp

Issue 2824823003: DOM-based SVG resource tracking (Closed)
Patch Set: Update baselines Created 3 years, 7 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
Index: third_party/WebKit/Source/core/layout/svg/SVGResourcesCache.cpp
diff --git a/third_party/WebKit/Source/core/layout/svg/SVGResourcesCache.cpp b/third_party/WebKit/Source/core/layout/svg/SVGResourcesCache.cpp
index dc9cdff976402988c24be236fe841681199c2aaf..d0a4d7d881c4b72d254c3c915d5fd9be6f1973c1 100644
--- a/third_party/WebKit/Source/core/layout/svg/SVGResourcesCache.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/SVGResourcesCache.cpp
@@ -70,8 +70,13 @@ void SVGResourcesCache::RemoveResourcesFromLayoutObject(LayoutObject* object) {
HashSet<LayoutSVGResourceContainer*> resource_set;
resources->BuildSetOfResources(resource_set);
+ bool did_empty_client_set = false;
for (auto* resource_container : resource_set)
- resource_container->RemoveClient(object);
+ did_empty_client_set |= resource_container->RemoveClient(object);
+
+ // Remove any registrations that became empty after the above.
+ if (did_empty_client_set)
+ SVGResources::RemoveUnreferencedResources(*object);
}
static inline SVGResourcesCache& ResourcesCache(Document& document) {
@@ -150,6 +155,26 @@ void SVGResourcesCache::ClientStyleChanged(LayoutObject* layout_object,
layout_object, needs_layout);
}
+void SVGResourcesCache::ResourceReferenceChanged(LayoutObject& layout_object) {
+ DCHECK(layout_object.IsSVG());
+ DCHECK(layout_object.GetNode());
+ DCHECK(layout_object.GetNode()->IsSVGElement());
+
+ if (!layout_object.Parent())
+ return;
+
+ // Only LayoutObjects that can actually have resources should be pending and
+ // hence be able to call this method.
+ DCHECK(LayoutObjectCanHaveResources(&layout_object));
+
+ SVGResourcesCache& cache = ResourcesCache(layout_object.GetDocument());
+ cache.RemoveResourcesFromLayoutObject(&layout_object);
+ cache.AddResourcesFromLayoutObject(&layout_object, layout_object.StyleRef());
+
+ LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(
+ &layout_object, true);
+}
+
void SVGResourcesCache::ClientWasAddedToTree(LayoutObject* layout_object,
const ComputedStyle& new_style) {
if (!layout_object->GetNode())
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/SVGResourcesCache.h ('k') | third_party/WebKit/Source/core/svg/SVGClipPathElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698