Start refactoring Filter code to reuse CachedSVGDocument for clipPath
authorkrit@webkit.org <krit@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Dec 2013 07:01:57 +0000 (07:01 +0000)
committerkrit@webkit.org <krit@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Dec 2013 07:01:57 +0000 (07:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=126069

Reviewed by Andreas Kling.

Smaller refactoring of the CSS filter style resolver code. Previously the code
requested the FilterOperations list from RenderStyle and compared the content
in this list with an internal map. Then the resource loading was triggered.
With the refactoring we do not request the list from RenderStyle anymore but
rely on the hash map data entirely.

* css/StyleResolver.cpp:
(WebCore::StyleResolver::loadPendingSVGDocuments):
* platform/graphics/filters/FilterOperation.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@160973 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/platform/graphics/filters/FilterOperation.h

index 13e44cc..1f495f7 100644 (file)
@@ -1,3 +1,20 @@
+2013-12-21  Dirk Schulze  <krit@webkit.org>
+
+        Start refactoring Filter code to reuse CachedSVGDocument for clipPath
+        https://bugs.webkit.org/show_bug.cgi?id=126069
+
+        Reviewed by Andreas Kling.
+
+        Smaller refactoring of the CSS filter style resolver code. Previously the code
+        requested the FilterOperations list from RenderStyle and compared the content
+        in this list with an internal map. Then the resource loading was triggered.
+        With the refactoring we do not request the list from RenderStyle anymore but
+        rely on the hash map data entirely.
+
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::loadPendingSVGDocuments):
+        * platform/graphics/filters/FilterOperation.h:
+
 2013-12-20  Andy Estes  <aestes@apple.com>
 
         [Mac] Soft-link WebContentAnalysis.framework
index 667707b..1a83347 100644 (file)
@@ -3418,22 +3418,18 @@ void StyleResolver::loadPendingSVGDocuments()
         return;
 
     CachedResourceLoader* cachedResourceLoader = state.document().cachedResourceLoader();
-    Vector<RefPtr<FilterOperation>>& filterOperations = state.style()->mutableFilter().operations();
-    for (unsigned i = 0; i < filterOperations.size(); ++i) {
-        RefPtr<FilterOperation> filterOperation = filterOperations.at(i);
-        if (filterOperation->type() == FilterOperation::REFERENCE) {
-            ReferenceFilterOperation* referenceFilter = static_cast<ReferenceFilterOperation*>(filterOperation.get());
-
-            WebKitCSSSVGDocumentValue* value = state.pendingSVGDocuments().get(referenceFilter);
-            if (!value)
-                continue;
-            CachedSVGDocument* cachedDocument = value->load(cachedResourceLoader);
-            if (!cachedDocument)
-                continue;
+    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.
-            referenceFilter->setCachedSVGDocumentReference(adoptPtr(new CachedSVGDocumentReference(cachedDocument)));
-        }
+        // Stash the CachedSVGDocument on the reference filter.
+        ReferenceFilterOperation& referenceFilter = *toReferenceFilterOperation(it->key);
+        referenceFilter.setCachedSVGDocumentReference(adoptPtr(new CachedSVGDocumentReference(cachedDocument)));
     }
     state.pendingSVGDocuments().clear();
 }
index b2c4632..13a4de0 100644 (file)
@@ -338,6 +338,11 @@ private:
     Color m_color;
 };
 
+#define FILTER_OPERATION_CASTS(ToValueTypeName, predicate) \
+    TYPE_CASTS_BASE(ToValueTypeName, FilterOperation, operation, operation->type() == FilterOperation::predicate, operation.type() == FilterOperation::predicate)
+
+FILTER_OPERATION_CASTS(ReferenceFilterOperation, REFERENCE)
+
 } // namespace WebCore
 
 #endif // ENABLE(CSS_FILTERS)