Title: [163277] trunk/Source/WebCore
Revision
163277
Author
akl...@apple.com
Date
2014-02-02 17:05:01 -0800 (Sun, 02 Feb 2014)

Log Message

SVGDocumentExtensions::resourcesCache() should return a reference.
<https://webkit.org/b/128087>

The SVGResourcesCache is always present when the Document is using
SVG extensions, so make this return a reference and propagate that
knowledge to the call site.

This gets rid of an assertion and some rickety looking ->'s.
Also converted a loop to use C++11 range for syntax.

Reviewed by Sam Weinig.

* rendering/svg/SVGResourcesCache.cpp:
(WebCore::resourcesCacheFromRenderer):
(WebCore::SVGResourcesCache::cachedResourcesForRenderObject):
(WebCore::SVGResourcesCache::clientStyleChanged):
(WebCore::SVGResourcesCache::clientWasAddedToTree):
(WebCore::SVGResourcesCache::clientWillBeRemovedFromTree):
(WebCore::SVGResourcesCache::clientDestroyed):
(WebCore::SVGResourcesCache::resourceDestroyed):
* svg/SVGDocumentExtensions.h:
(WebCore::SVGDocumentExtensions::resourcesCache):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (163276 => 163277)


--- trunk/Source/WebCore/ChangeLog	2014-02-03 01:03:48 UTC (rev 163276)
+++ trunk/Source/WebCore/ChangeLog	2014-02-03 01:05:01 UTC (rev 163277)
@@ -1,5 +1,30 @@
 2014-02-02  Andreas Kling  <akl...@apple.com>
 
+        SVGDocumentExtensions::resourcesCache() should return a reference.
+        <https://webkit.org/b/128087>
+
+        The SVGResourcesCache is always present when the Document is using
+        SVG extensions, so make this return a reference and propagate that
+        knowledge to the call site.
+
+        This gets rid of an assertion and some rickety looking ->'s.
+        Also converted a loop to use C++11 range for syntax.
+
+        Reviewed by Sam Weinig.
+
+        * rendering/svg/SVGResourcesCache.cpp:
+        (WebCore::resourcesCacheFromRenderer):
+        (WebCore::SVGResourcesCache::cachedResourcesForRenderObject):
+        (WebCore::SVGResourcesCache::clientStyleChanged):
+        (WebCore::SVGResourcesCache::clientWasAddedToTree):
+        (WebCore::SVGResourcesCache::clientWillBeRemovedFromTree):
+        (WebCore::SVGResourcesCache::clientDestroyed):
+        (WebCore::SVGResourcesCache::resourceDestroyed):
+        * svg/SVGDocumentExtensions.h:
+        (WebCore::SVGDocumentExtensions::resourcesCache):
+
+2014-02-02  Andreas Kling  <akl...@apple.com>
+
         RenderSVGInlineText::computeNewScaledFontForStyle() should take references.
         <https://webkit.org/b/128086>
 

Modified: trunk/Source/WebCore/rendering/svg/SVGResourcesCache.cpp (163276 => 163277)


--- trunk/Source/WebCore/rendering/svg/SVGResourcesCache.cpp	2014-02-03 01:03:48 UTC (rev 163276)
+++ trunk/Source/WebCore/rendering/svg/SVGResourcesCache.cpp	2014-02-03 01:05:01 UTC (rev 163277)
@@ -76,20 +76,16 @@
         (*it)->removeClient(&renderer);
 }
 
-static inline SVGResourcesCache* resourcesCacheFromRenderObject(const RenderObject& renderer)
+static inline SVGResourcesCache& resourcesCacheFromRenderer(const RenderObject& renderer)
 {
     SVGDocumentExtensions* extensions = renderer.document().accessSVGExtensions();
     ASSERT(extensions);
-
-    SVGResourcesCache* cache = extensions->resourcesCache();
-    ASSERT(cache);
-
-    return cache;
+    return extensions->resourcesCache();
 }
 
 SVGResources* SVGResourcesCache::cachedResourcesForRenderObject(const RenderObject& renderer)
 {
-    return resourcesCacheFromRenderObject(renderer)->m_cache.get(&renderer);
+    return resourcesCacheFromRenderer(renderer).m_cache.get(&renderer);
 }
 
 void SVGResourcesCache::clientLayoutChanged(RenderElement& renderer)
@@ -122,9 +118,9 @@
     // FIXME: Avoid passing in a useless StyleDifference, but instead compare oldStyle/newStyle to see which resources changed
     // to be able to selectively rebuild individual resources, instead of all of them.
     if (rendererCanHaveResources(renderer)) {
-        SVGResourcesCache* cache = resourcesCacheFromRenderObject(renderer);
-        cache->removeResourcesFromRenderer(renderer);
-        cache->addResourcesFromRenderer(renderer, newStyle);
+        auto& cache = resourcesCacheFromRenderer(renderer);
+        cache.removeResourcesFromRenderer(renderer);
+        cache.addResourcesFromRenderer(renderer, newStyle);
     }
 
     RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer, false);
@@ -143,8 +139,7 @@
     if (!rendererCanHaveResources(renderer))
         return;
     RenderElement& elementRenderer = toRenderElement(renderer);
-    SVGResourcesCache* cache = resourcesCacheFromRenderObject(elementRenderer);
-    cache->addResourcesFromRenderer(elementRenderer, elementRenderer.style());
+    resourcesCacheFromRenderer(elementRenderer).addResourcesFromRenderer(elementRenderer, elementRenderer.style());
 }
 
 void SVGResourcesCache::clientWillBeRemovedFromTree(RenderObject& renderer)
@@ -157,8 +152,7 @@
     if (!rendererCanHaveResources(renderer))
         return;
     RenderElement& elementRenderer = toRenderElement(renderer);
-    SVGResourcesCache* cache = resourcesCacheFromRenderObject(elementRenderer);
-    cache->removeResourcesFromRenderer(elementRenderer);
+    resourcesCacheFromRenderer(elementRenderer).removeResourcesFromRenderer(elementRenderer);
 }
 
 void SVGResourcesCache::clientDestroyed(RenderElement& renderer)
@@ -167,23 +161,22 @@
     if (resources)
         resources->removeClientFromCache(renderer);
 
-    SVGResourcesCache* cache = resourcesCacheFromRenderObject(renderer);
-    cache->removeResourcesFromRenderer(renderer);
+    resourcesCacheFromRenderer(renderer).removeResourcesFromRenderer(renderer);
 }
 
 void SVGResourcesCache::resourceDestroyed(RenderSVGResourceContainer& resource)
 {
-    SVGResourcesCache* cache = resourcesCacheFromRenderObject(resource);
+    auto& cache = resourcesCacheFromRenderer(resource);
 
     // The resource itself may have clients, that need to be notified.
-    cache->removeResourcesFromRenderer(resource);
+    cache.removeResourcesFromRenderer(resource);
 
-    for (auto it = cache->m_cache.begin(), end = cache->m_cache.end(); it != end; ++it) {
-        it->value->resourceDestroyed(resource);
+    for (auto& it : cache.m_cache) {
+        it.value->resourceDestroyed(resource);
 
         // Mark users of destroyed resources as pending resolution based on the id of the old resource.
         Element& resourceElement = resource.element();
-        Element* clientElement = toElement(it->key->node());
+        Element* clientElement = toElement(it.key->node());
         SVGDocumentExtensions* extensions = clientElement->document().accessSVGExtensions();
 
         extensions->addPendingResource(resourceElement.getIdAttribute(), clientElement);

Modified: trunk/Source/WebCore/svg/SVGDocumentExtensions.h (163276 => 163277)


--- trunk/Source/WebCore/svg/SVGDocumentExtensions.h	2014-02-03 01:03:48 UTC (rev 163276)
+++ trunk/Source/WebCore/svg/SVGDocumentExtensions.h	2014-02-03 01:05:01 UTC (rev 163277)
@@ -62,7 +62,7 @@
     void reportWarning(const String&);
     void reportError(const String&);
 
-    SVGResourcesCache* resourcesCache() const { return m_resourcesCache.get(); }
+    SVGResourcesCache& resourcesCache() { return *m_resourcesCache; }
 
     HashSet<SVGElement*>* setOfElementsReferencingTarget(SVGElement* referencedElement) const;
     void addElementReferencingTarget(SVGElement* referencingElement, SVGElement* referencedElement);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to