Title: [161967] trunk/Source/WebCore
Revision
161967
Author
[email protected]
Date
2014-01-14 07:58:22 -0800 (Tue, 14 Jan 2014)

Log Message

Make CachedSVGDocument independent of CSS Filters
https://bugs.webkit.org/show_bug.cgi?id=126133

Reviewed by Antti Koivisto.

Clean-up the pendingSVGDocuments code in StyleResolver.
CachedSVGDocumentReference is responsible for requesting the
SVG document instead of WebKitCSSSVGDocumentValue.
CachedSVGDocumentReference can be used by other SVG resource like
clip-path and mask now so that these may load external resources
as well.
WebKitCSSSVGDocumentValue does not provide any further value
and will be removed in the next patch.

Refactoring, no new test cases.

* css/StyleResolver.cpp:
(WebCore::StyleResolver::loadPendingSVGDocuments):
(WebCore::StyleResolver::createFilterOperations):
* css/StyleResolver.h: Replace Map with a Set.
(WebCore::StyleResolver::State::pendingSVGDocuments): Use the Set from now on.
* loader/cache/CachedSVGDocumentReference.cpp:
(WebCore::CachedSVGDocumentReference::CachedSVGDocumentReference):
(WebCore::CachedSVGDocumentReference::~CachedSVGDocumentReference):
(WebCore::CachedSVGDocumentReference::load):
* loader/cache/CachedSVGDocumentReference.h: Is responsible for
    requesting the SVG document.
(WebCore::CachedSVGDocumentReference::create):
(WebCore::CachedSVGDocumentReference::loadRequested):
* platform/graphics/filters/FilterOperation.cpp:
(WebCore::ReferenceFilterOperation::createCachedSVGDocumentReference):
* platform/graphics/filters/FilterOperation.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (161966 => 161967)


--- trunk/Source/WebCore/ChangeLog	2014-01-14 15:45:32 UTC (rev 161966)
+++ trunk/Source/WebCore/ChangeLog	2014-01-14 15:58:22 UTC (rev 161967)
@@ -1,3 +1,38 @@
+2014-01-14  Dirk Schulze  <[email protected]>
+
+        Make CachedSVGDocument independent of CSS Filters
+        https://bugs.webkit.org/show_bug.cgi?id=126133
+
+        Reviewed by Antti Koivisto.
+
+        Clean-up the pendingSVGDocuments code in StyleResolver.
+        CachedSVGDocumentReference is responsible for requesting the
+        SVG document instead of WebKitCSSSVGDocumentValue.
+        CachedSVGDocumentReference can be used by other SVG resource like
+        clip-path and mask now so that these may load external resources
+        as well.
+        WebKitCSSSVGDocumentValue does not provide any further value
+        and will be removed in the next patch.
+
+        Refactoring, no new test cases.
+
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::loadPendingSVGDocuments):
+        (WebCore::StyleResolver::createFilterOperations):
+        * css/StyleResolver.h: Replace Map with a Set.
+        (WebCore::StyleResolver::State::pendingSVGDocuments): Use the Set from now on.
+        * loader/cache/CachedSVGDocumentReference.cpp:
+        (WebCore::CachedSVGDocumentReference::CachedSVGDocumentReference):
+        (WebCore::CachedSVGDocumentReference::~CachedSVGDocumentReference):
+        (WebCore::CachedSVGDocumentReference::load):
+        * loader/cache/CachedSVGDocumentReference.h: Is responsible for 
+            requesting the SVG document.
+        (WebCore::CachedSVGDocumentReference::create):
+        (WebCore::CachedSVGDocumentReference::loadRequested):
+        * platform/graphics/filters/FilterOperation.cpp:
+        (WebCore::ReferenceFilterOperation::createCachedSVGDocumentReference):
+        * platform/graphics/filters/FilterOperation.h:
+
 2014-01-14  Mario Sanchez Prada  <[email protected]>
 
         [ATK] AXChildrenChanged notification handling is a performance black hole

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (161966 => 161967)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2014-01-14 15:45:32 UTC (rev 161966)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2014-01-14 15:58:22 UTC (rev 161967)
@@ -3429,19 +3429,8 @@
         return;
 
     CachedResourceLoader* cachedResourceLoader = state.document().cachedResourceLoader();
-    for (auto it = state.pendingSVGDocuments().begin(), end = state.pendingSVGDocuments().end(); it != end; ++it) {
-        WebKitCSSSVGDocumentValue* value = it->value.get();
-        // FIXME: It is unclear why it should be null. Maybe an ASSERT instead?
-        if (!value)
-            continue;
-        CachedSVGDocument* cachedDocument = value->load(cachedResourceLoader);
-        if (!cachedDocument)
-            continue;
-
-        // Stash the CachedSVGDocument on the reference filter.
-        ReferenceFilterOperation& referenceFilter = *toReferenceFilterOperation(it->key);
-        referenceFilter.setCachedSVGDocumentReference(adoptPtr(new CachedSVGDocumentReference(cachedDocument)));
-    }
+    for (auto pendingDocument : state.pendingSVGDocuments())
+        pendingDocument->load(cachedResourceLoader);
     state.pendingSVGDocuments().clear();
 }
 #endif
@@ -3837,12 +3826,8 @@
             URL url = ""
 
             RefPtr<ReferenceFilterOperation> operation = ReferenceFilterOperation::create(svgDocumentValue->url(), url.fragmentIdentifier(), operationType);
-            if (SVGURIReference::isExternalURIReference(svgDocumentValue->url(), m_state.document())) {
-                if (!svgDocumentValue->loadRequested())
-                    m_state.pendingSVGDocuments().set(operation.get(), svgDocumentValue);
-                else if (svgDocumentValue->cachedSVGDocument())
-                    operation->setCachedSVGDocumentReference(adoptPtr(new CachedSVGDocumentReference(svgDocumentValue->cachedSVGDocument())));
-            }
+            if (SVGURIReference::isExternalURIReference(svgDocumentValue->url(), m_state.document()))
+                m_state.pendingSVGDocuments().add(operation->createCachedSVGDocumentReference());
             operations.operations().append(operation);
 #endif
             continue;

Modified: trunk/Source/WebCore/css/StyleResolver.h (161966 => 161967)


--- trunk/Source/WebCore/css/StyleResolver.h	2014-01-14 15:45:32 UTC (rev 161966)
+++ trunk/Source/WebCore/css/StyleResolver.h	2014-01-14 15:58:22 UTC (rev 161967)
@@ -379,7 +379,7 @@
 public:
     typedef HashMap<CSSPropertyID, RefPtr<CSSValue>> PendingImagePropertyMap;
 #if ENABLE(CSS_FILTERS) && ENABLE(SVG)
-    typedef HashMap<FilterOperation*, RefPtr<WebKitCSSSVGDocumentValue>> PendingSVGDocumentMap;
+    typedef HashSet<CachedSVGDocumentReference*> PendingSVGDocumentSet;
 #endif
 
     class State {
@@ -432,7 +432,7 @@
         bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisitedLinkStyle; }
         PendingImagePropertyMap& pendingImageProperties() { return m_pendingImageProperties; }
 #if ENABLE(CSS_FILTERS) && ENABLE(SVG)
-        PendingSVGDocumentMap& pendingSVGDocuments() { return m_pendingSVGDocuments; }
+        PendingSVGDocumentSet& pendingSVGDocuments() { return m_pendingSVGDocuments; }
 #endif
 #if ENABLE(CSS_SHADERS)
         void setHasPendingShaders(bool hasPendingShaders) { m_hasPendingShaders = hasPendingShaders; }
@@ -486,7 +486,7 @@
         bool m_hasPendingShaders;
 #endif
 #if ENABLE(CSS_FILTERS) && ENABLE(SVG)
-        PendingSVGDocumentMap m_pendingSVGDocuments;
+        PendingSVGDocumentSet m_pendingSVGDocuments;
 #endif
         CSSValue* m_lineHeightValue;
         bool m_fontDirty;

Modified: trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.cpp (161966 => 161967)


--- trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.cpp	2014-01-14 15:45:32 UTC (rev 161966)
+++ trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.cpp	2014-01-14 15:58:22 UTC (rev 161967)
@@ -27,22 +27,40 @@
 #include "CachedSVGDocumentReference.h"
 
 #if ENABLE(SVG) && ENABLE(CSS_FILTERS)
-
+#include "CachedResourceHandle.h"
+#include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
+#include "CachedResourceRequestInitiators.h"
 #include "CachedSVGDocument.h"
 
 namespace WebCore {
 
-CachedSVGDocumentReference::CachedSVGDocumentReference(CachedSVGDocument* document)
-    : m_document(document)
+CachedSVGDocumentReference::CachedSVGDocumentReference(const String& url)
+    : m_url(url)
+    , m_document(0)
+    , m_loadRequested(false)
 {
-    m_document->addClient(this);
 }
 
 CachedSVGDocumentReference::~CachedSVGDocumentReference()
 {
-    m_document->removeClient(this);
+    if (m_loadRequested)
+        m_document->removeClient(this);
 }
 
+void CachedSVGDocumentReference::load(CachedResourceLoader* loader)
+{
+    ASSERT(loader);
+    if (m_loadRequested)
+        return;
+
+    CachedResourceRequest request(ResourceRequest(loader->document()->completeURL(m_url)));
+    request.setInitiator(cachedResourceRequestInitiators().css);
+    m_document = loader->requestSVGDocument(request);
+    m_document->addClient(this);
+    m_loadRequested = true;
 }
 
+}
+
 #endif

Modified: trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.h (161966 => 161967)


--- trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.h	2014-01-14 15:45:32 UTC (rev 161966)
+++ trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.h	2014-01-14 15:58:22 UTC (rev 161967)
@@ -27,22 +27,30 @@
 #define CachedSVGDocumentReference_h
 
 #if ENABLE(SVG) && ENABLE(CSS_FILTERS)
-
 #include "CachedResourceHandle.h"
 #include "CachedSVGDocumentClient.h"
+#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
 class CachedSVGDocument;
+class CachedResourceLoader;
 
 class CachedSVGDocumentReference : public CachedSVGDocumentClient {
 public:
-    CachedSVGDocumentReference(CachedSVGDocument*);
+    CachedSVGDocumentReference(const String&);
+
     virtual ~CachedSVGDocumentReference();
+
+    void load(CachedResourceLoader*);
+    bool loadRequested() const { return m_loadRequested; }
+
     CachedSVGDocument* document() { return m_document.get(); }
 
 private:
+    String m_url;
     CachedResourceHandle<CachedSVGDocument> m_document;
+    bool m_loadRequested;
 };
 
 };

Modified: trunk/Source/WebCore/platform/graphics/filters/FilterOperation.cpp (161966 => 161967)


--- trunk/Source/WebCore/platform/graphics/filters/FilterOperation.cpp	2014-01-14 15:45:32 UTC (rev 161966)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterOperation.cpp	2014-01-14 15:58:22 UTC (rev 161967)
@@ -48,9 +48,10 @@
 }
 
 #if ENABLE(SVG)
-void ReferenceFilterOperation::setCachedSVGDocumentReference(PassOwnPtr<CachedSVGDocumentReference> cachedSVGDocumentReference)
+CachedSVGDocumentReference* ReferenceFilterOperation::createCachedSVGDocumentReference()
 {
-    m_cachedSVGDocumentReference = cachedSVGDocumentReference;
+    m_cachedSVGDocumentReference = std::make_unique<CachedSVGDocumentReference>(m_url);
+    return m_cachedSVGDocumentReference.get();
 }
 #endif
 

Modified: trunk/Source/WebCore/platform/graphics/filters/FilterOperation.h (161966 => 161967)


--- trunk/Source/WebCore/platform/graphics/filters/FilterOperation.h	2014-01-14 15:45:32 UTC (rev 161966)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterOperation.h	2014-01-14 15:58:22 UTC (rev 161967)
@@ -166,7 +166,7 @@
 
 #if ENABLE(SVG)
     CachedSVGDocumentReference* cachedSVGDocumentReference() const { return m_cachedSVGDocumentReference.get(); }
-    void setCachedSVGDocumentReference(PassOwnPtr<CachedSVGDocumentReference>);
+    CachedSVGDocumentReference* createCachedSVGDocumentReference();
 #endif
 
     FilterEffect* filterEffect() const { return m_filterEffect.get(); }
@@ -186,7 +186,7 @@
     String m_url;
     String m_fragment;
 #if ENABLE(SVG)
-    OwnPtr<CachedSVGDocumentReference> m_cachedSVGDocumentReference;
+    std::unique_ptr<CachedSVGDocumentReference> m_cachedSVGDocumentReference;
 #endif
     RefPtr<FilterEffect> m_filterEffect;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to