<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[161967] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/161967">161967</a></dd>
<dt>Author</dt> <dd>krit@webkit.org</dd>
<dt>Date</dt> <dd>2014-01-14 07:58:22 -0800 (Tue, 14 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>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:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssStyleResolvercpp">trunk/Source/WebCore/css/StyleResolver.cpp</a></li>
<li><a href="#trunkSourceWebCorecssStyleResolverh">trunk/Source/WebCore/css/StyleResolver.h</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedSVGDocumentReferencecpp">trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedSVGDocumentReferenceh">trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsfiltersFilterOperationcpp">trunk/Source/WebCore/platform/graphics/filters/FilterOperation.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsfiltersFilterOperationh">trunk/Source/WebCore/platform/graphics/filters/FilterOperation.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (161966 => 161967)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2014-01-14  Dirk Schulze  &lt;krit@webkit.org&gt;
+
+        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:
+
</ins><span class="cx"> 2014-01-14  Mario Sanchez Prada  &lt;mario.prada@samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [ATK] AXChildrenChanged notification handling is a performance black hole
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.cpp (161966 => 161967)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -3429,19 +3429,8 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     CachedResourceLoader* cachedResourceLoader = state.document().cachedResourceLoader();
</span><del>-    for (auto it = state.pendingSVGDocuments().begin(), end = state.pendingSVGDocuments().end(); it != end; ++it) {
-        WebKitCSSSVGDocumentValue* value = it-&gt;value.get();
-        // FIXME: It is unclear why it should be null. Maybe an ASSERT instead?
-        if (!value)
-            continue;
-        CachedSVGDocument* cachedDocument = value-&gt;load(cachedResourceLoader);
-        if (!cachedDocument)
-            continue;
-
-        // Stash the CachedSVGDocument on the reference filter.
-        ReferenceFilterOperation&amp; referenceFilter = *toReferenceFilterOperation(it-&gt;key);
-        referenceFilter.setCachedSVGDocumentReference(adoptPtr(new CachedSVGDocumentReference(cachedDocument)));
-    }
</del><ins>+    for (auto pendingDocument : state.pendingSVGDocuments())
+        pendingDocument-&gt;load(cachedResourceLoader);
</ins><span class="cx">     state.pendingSVGDocuments().clear();
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="lines">@@ -3837,12 +3826,8 @@
</span><span class="cx">             URL url = m_state.document().completeURL(svgDocumentValue-&gt;url());
</span><span class="cx"> 
</span><span class="cx">             RefPtr&lt;ReferenceFilterOperation&gt; operation = ReferenceFilterOperation::create(svgDocumentValue-&gt;url(), url.fragmentIdentifier(), operationType);
</span><del>-            if (SVGURIReference::isExternalURIReference(svgDocumentValue-&gt;url(), m_state.document())) {
-                if (!svgDocumentValue-&gt;loadRequested())
-                    m_state.pendingSVGDocuments().set(operation.get(), svgDocumentValue);
-                else if (svgDocumentValue-&gt;cachedSVGDocument())
-                    operation-&gt;setCachedSVGDocumentReference(adoptPtr(new CachedSVGDocumentReference(svgDocumentValue-&gt;cachedSVGDocument())));
-            }
</del><ins>+            if (SVGURIReference::isExternalURIReference(svgDocumentValue-&gt;url(), m_state.document()))
+                m_state.pendingSVGDocuments().add(operation-&gt;createCachedSVGDocumentReference());
</ins><span class="cx">             operations.operations().append(operation);
</span><span class="cx"> #endif
</span><span class="cx">             continue;
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.h (161966 => 161967)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -379,7 +379,7 @@
</span><span class="cx"> public:
</span><span class="cx">     typedef HashMap&lt;CSSPropertyID, RefPtr&lt;CSSValue&gt;&gt; PendingImagePropertyMap;
</span><span class="cx"> #if ENABLE(CSS_FILTERS) &amp;&amp; ENABLE(SVG)
</span><del>-    typedef HashMap&lt;FilterOperation*, RefPtr&lt;WebKitCSSSVGDocumentValue&gt;&gt; PendingSVGDocumentMap;
</del><ins>+    typedef HashSet&lt;CachedSVGDocumentReference*&gt; PendingSVGDocumentSet;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     class State {
</span><span class="lines">@@ -432,7 +432,7 @@
</span><span class="cx">         bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisitedLinkStyle; }
</span><span class="cx">         PendingImagePropertyMap&amp; pendingImageProperties() { return m_pendingImageProperties; }
</span><span class="cx"> #if ENABLE(CSS_FILTERS) &amp;&amp; ENABLE(SVG)
</span><del>-        PendingSVGDocumentMap&amp; pendingSVGDocuments() { return m_pendingSVGDocuments; }
</del><ins>+        PendingSVGDocumentSet&amp; pendingSVGDocuments() { return m_pendingSVGDocuments; }
</ins><span class="cx"> #endif
</span><span class="cx"> #if ENABLE(CSS_SHADERS)
</span><span class="cx">         void setHasPendingShaders(bool hasPendingShaders) { m_hasPendingShaders = hasPendingShaders; }
</span><span class="lines">@@ -486,7 +486,7 @@
</span><span class="cx">         bool m_hasPendingShaders;
</span><span class="cx"> #endif
</span><span class="cx"> #if ENABLE(CSS_FILTERS) &amp;&amp; ENABLE(SVG)
</span><del>-        PendingSVGDocumentMap m_pendingSVGDocuments;
</del><ins>+        PendingSVGDocumentSet m_pendingSVGDocuments;
</ins><span class="cx"> #endif
</span><span class="cx">         CSSValue* m_lineHeightValue;
</span><span class="cx">         bool m_fontDirty;
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedSVGDocumentReferencecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.cpp (161966 => 161967)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -27,22 +27,40 @@
</span><span class="cx"> #include &quot;CachedSVGDocumentReference.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SVG) &amp;&amp; ENABLE(CSS_FILTERS)
</span><del>-
</del><ins>+#include &quot;CachedResourceHandle.h&quot;
+#include &quot;CachedResourceLoader.h&quot;
+#include &quot;CachedResourceRequest.h&quot;
+#include &quot;CachedResourceRequestInitiators.h&quot;
</ins><span class="cx"> #include &quot;CachedSVGDocument.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-CachedSVGDocumentReference::CachedSVGDocumentReference(CachedSVGDocument* document)
-    : m_document(document)
</del><ins>+CachedSVGDocumentReference::CachedSVGDocumentReference(const String&amp; url)
+    : m_url(url)
+    , m_document(0)
+    , m_loadRequested(false)
</ins><span class="cx"> {
</span><del>-    m_document-&gt;addClient(this);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CachedSVGDocumentReference::~CachedSVGDocumentReference()
</span><span class="cx"> {
</span><del>-    m_document-&gt;removeClient(this);
</del><ins>+    if (m_loadRequested)
+        m_document-&gt;removeClient(this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void CachedSVGDocumentReference::load(CachedResourceLoader* loader)
+{
+    ASSERT(loader);
+    if (m_loadRequested)
+        return;
+
+    CachedResourceRequest request(ResourceRequest(loader-&gt;document()-&gt;completeURL(m_url)));
+    request.setInitiator(cachedResourceRequestInitiators().css);
+    m_document = loader-&gt;requestSVGDocument(request);
+    m_document-&gt;addClient(this);
+    m_loadRequested = true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedSVGDocumentReferenceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.h (161966 => 161967)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -27,22 +27,30 @@
</span><span class="cx"> #define CachedSVGDocumentReference_h
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SVG) &amp;&amp; ENABLE(CSS_FILTERS)
</span><del>-
</del><span class="cx"> #include &quot;CachedResourceHandle.h&quot;
</span><span class="cx"> #include &quot;CachedSVGDocumentClient.h&quot;
</span><ins>+#include &lt;wtf/text/WTFString.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class CachedSVGDocument;
</span><ins>+class CachedResourceLoader;
</ins><span class="cx"> 
</span><span class="cx"> class CachedSVGDocumentReference : public CachedSVGDocumentClient {
</span><span class="cx"> public:
</span><del>-    CachedSVGDocumentReference(CachedSVGDocument*);
</del><ins>+    CachedSVGDocumentReference(const String&amp;);
+
</ins><span class="cx">     virtual ~CachedSVGDocumentReference();
</span><ins>+
+    void load(CachedResourceLoader*);
+    bool loadRequested() const { return m_loadRequested; }
+
</ins><span class="cx">     CachedSVGDocument* document() { return m_document.get(); }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    String m_url;
</ins><span class="cx">     CachedResourceHandle&lt;CachedSVGDocument&gt; m_document;
</span><ins>+    bool m_loadRequested;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfiltersFilterOperationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/filters/FilterOperation.cpp (161966 => 161967)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -48,9 +48,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SVG)
</span><del>-void ReferenceFilterOperation::setCachedSVGDocumentReference(PassOwnPtr&lt;CachedSVGDocumentReference&gt; cachedSVGDocumentReference)
</del><ins>+CachedSVGDocumentReference* ReferenceFilterOperation::createCachedSVGDocumentReference()
</ins><span class="cx"> {
</span><del>-    m_cachedSVGDocumentReference = cachedSVGDocumentReference;
</del><ins>+    m_cachedSVGDocumentReference = std::make_unique&lt;CachedSVGDocumentReference&gt;(m_url);
+    return m_cachedSVGDocumentReference.get();
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfiltersFilterOperationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/filters/FilterOperation.h (161966 => 161967)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -166,7 +166,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SVG)
</span><span class="cx">     CachedSVGDocumentReference* cachedSVGDocumentReference() const { return m_cachedSVGDocumentReference.get(); }
</span><del>-    void setCachedSVGDocumentReference(PassOwnPtr&lt;CachedSVGDocumentReference&gt;);
</del><ins>+    CachedSVGDocumentReference* createCachedSVGDocumentReference();
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     FilterEffect* filterEffect() const { return m_filterEffect.get(); }
</span><span class="lines">@@ -186,7 +186,7 @@
</span><span class="cx">     String m_url;
</span><span class="cx">     String m_fragment;
</span><span class="cx"> #if ENABLE(SVG)
</span><del>-    OwnPtr&lt;CachedSVGDocumentReference&gt; m_cachedSVGDocumentReference;
</del><ins>+    std::unique_ptr&lt;CachedSVGDocumentReference&gt; m_cachedSVGDocumentReference;
</ins><span class="cx"> #endif
</span><span class="cx">     RefPtr&lt;FilterEffect&gt; m_filterEffect;
</span><span class="cx"> };
</span></span></pre>
</div>
</div>

</body>
</html>