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 b2a4e9c9823631c9a19ca61b6efccea001f6bba5..dc9cdff976402988c24be236fe841681199c2aaf 100644 |
--- a/third_party/WebKit/Source/core/layout/svg/SVGResourcesCache.cpp |
+++ b/third_party/WebKit/Source/core/layout/svg/SVGResourcesCache.cpp |
@@ -186,4 +186,24 @@ void SVGResourcesCache::ClientDestroyed(LayoutObject* layout_object) { |
cache.RemoveResourcesFromLayoutObject(layout_object); |
} |
+SVGResourcesCache::TemporaryStyleScope::TemporaryStyleScope( |
+ LayoutObject& layout_object, |
+ const ComputedStyle& style, |
+ const ComputedStyle& temporary_style) |
+ : layout_object_(layout_object), |
+ original_style_(style), |
+ styles_are_equal_(style == temporary_style) { |
+ SwitchTo(temporary_style); |
+} |
+ |
+void SVGResourcesCache::TemporaryStyleScope::SwitchTo( |
+ const ComputedStyle& style) { |
+ DCHECK(LayoutObjectCanHaveResources(&layout_object_)); |
+ if (styles_are_equal_) |
+ return; |
+ SVGResourcesCache& cache = ResourcesCache(layout_object_.GetDocument()); |
+ cache.RemoveResourcesFromLayoutObject(&layout_object_); |
+ cache.AddResourcesFromLayoutObject(&layout_object_, style); |
+} |
+ |
} // namespace blink |