- Revision
- 132528
- Author
- [email protected]
- Date
- 2012-10-25 13:42:03 -0700 (Thu, 25 Oct 2012)
Log Message
Source/WebCore: Change ReferenceFilterOperations to reference (own) the data passed to
them.
https://bugs.webkit.org/show_bug.cgi?id=97715
Reviewed by Nate Chapin.
Covered by css3/filters/reference-filter-update-after-remove.html
* css/CachedSVGDocumentReference.h: Added.
(CachedSVGDocumentReference):
New class which holds a CachedResourceHandle<CachedSVGDocument>, but
can be placed in ReferenceFilterOperation's Data. It also calls
addClient() / removeClient(), in order to keep the CachedSVGDocument
alive until the FilterEffectRenderer can get it.
(WebCore::CachedSVGDocumentReference::CachedSVGDocumentReference):
(WebCore::CachedSVGDocumentReference::~CachedSVGDocumentReference):
(WebCore::CachedSVGDocumentReference::document):
Accessor for the underlying document.
* css/StyleResolver.cpp:
(WebCore::StyleResolver::loadPendingSVGDocuments):
Wrap the CachedSVGDocument handle in a CachedSVGDocumentReference, and
transfer ownership to the ReferenceFilterOperation.
(WebCore::StyleResolver::createFilterOperations):
Same as above.
* platform/graphics/filters/FilterOperation.h:
(Data):
New base class for generic data which can be deleted polymorphically.
(WebCore::FilterOperation::ReferenceFilterOperation::data):
(WebCore::FilterOperation::ReferenceFilterOperation::setData):
Use the above-mentioned Data class, instead of a void *.
(WebCore::FilterOperation::ReferenceFilterOperation::ReferenceFilterOperation):
Don't initialize data to null; OwnPtr will do that for us.
* rendering/FilterEffectRenderer.cpp:
(WebCore::FilterEffectRenderer::buildReferenceFilter):
Extract the cached SVG document from the reference data.
* rendering/RenderLayerFilterInfo.cpp:
(WebCore::RenderLayerFilterInfo::updateReferenceFilterClients):
Extract the cached SVG document from the reference data.
LayoutTests: Add new layout test for reference filters.
https://bugs.webkit.org/show_bug.cgi?id=97715
Reviewed by Nate Chapin.
* css3/filters/reference-filter-update-after-remove-expected.txt: Added.
* css3/filters/reference-filter-update-after-remove.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (132527 => 132528)
--- trunk/LayoutTests/ChangeLog 2012-10-25 20:39:32 UTC (rev 132527)
+++ trunk/LayoutTests/ChangeLog 2012-10-25 20:42:03 UTC (rev 132528)
@@ -1,3 +1,13 @@
+2012-10-25 Stephen White <[email protected]>
+
+ Add new layout test for reference filters.
+ https://bugs.webkit.org/show_bug.cgi?id=97715
+
+ Reviewed by Nate Chapin.
+
+ * css3/filters/reference-filter-update-after-remove-expected.txt: Added.
+ * css3/filters/reference-filter-update-after-remove.html: Added.
+
2012-10-25 Simon Fraser <[email protected]>
Incorrect tile size in the slow scrolling case
Added: trunk/LayoutTests/css3/filters/reference-filter-update-after-remove-expected.txt (0 => 132528)
--- trunk/LayoutTests/css3/filters/reference-filter-update-after-remove-expected.txt (rev 0)
+++ trunk/LayoutTests/css3/filters/reference-filter-update-after-remove-expected.txt 2012-10-25 20:42:03 UTC (rev 132528)
@@ -0,0 +1 @@
+If you can read this, the test passed.
Added: trunk/LayoutTests/css3/filters/reference-filter-update-after-remove.html (0 => 132528)
--- trunk/LayoutTests/css3/filters/reference-filter-update-after-remove.html (rev 0)
+++ trunk/LayoutTests/css3/filters/reference-filter-update-after-remove.html 2012-10-25 20:42:03 UTC (rev 132528)
@@ -0,0 +1,35 @@
+<script>
+internals.settings.setCSSVariablesEnabled(true);
+</script>
+<style>
+body {
+ -webkit-var-a: url(1);
+ -webkit-filter: -webkit-var(a);
+}
+body::first-letter {
+ cursor: inherit;
+}
+</style>
+<script>
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText(false);
+}
+function init() {
+ var docElement = document.documentElement;
+ rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
+ docElement.appendChild(rect);
+ text = document.createTextNode("If you can read this, the test passed.");
+ docElement.appendChild(text);
+ setTimeout("edit();", 20);
+}
+document.addEventListener("DOMContentLoaded", init, false);
+function edit() {
+ document.designMode = "on";
+ r = document.createRange();
+ r.selectNodeContents(rect);
+ window.getSelection().addRange(r);
+ window.getSelection().deleteFromDocument();
+ if (window.testRunner) testRunner.notifyDone();
+}
+</script>
Modified: trunk/Source/WebCore/ChangeLog (132527 => 132528)
--- trunk/Source/WebCore/ChangeLog 2012-10-25 20:39:32 UTC (rev 132527)
+++ trunk/Source/WebCore/ChangeLog 2012-10-25 20:42:03 UTC (rev 132528)
@@ -1,3 +1,44 @@
+2012-10-25 Stephen White <[email protected]>
+
+ Change ReferenceFilterOperations to reference (own) the data passed to
+ them.
+ https://bugs.webkit.org/show_bug.cgi?id=97715
+
+ Reviewed by Nate Chapin.
+
+ Covered by css3/filters/reference-filter-update-after-remove.html
+
+ * css/CachedSVGDocumentReference.h: Added.
+ (CachedSVGDocumentReference):
+ New class which holds a CachedResourceHandle<CachedSVGDocument>, but
+ can be placed in ReferenceFilterOperation's Data. It also calls
+ addClient() / removeClient(), in order to keep the CachedSVGDocument
+ alive until the FilterEffectRenderer can get it.
+ (WebCore::CachedSVGDocumentReference::CachedSVGDocumentReference):
+ (WebCore::CachedSVGDocumentReference::~CachedSVGDocumentReference):
+ (WebCore::CachedSVGDocumentReference::document):
+ Accessor for the underlying document.
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::loadPendingSVGDocuments):
+ Wrap the CachedSVGDocument handle in a CachedSVGDocumentReference, and
+ transfer ownership to the ReferenceFilterOperation.
+ (WebCore::StyleResolver::createFilterOperations):
+ Same as above.
+ * platform/graphics/filters/FilterOperation.h:
+ (Data):
+ New base class for generic data which can be deleted polymorphically.
+ (WebCore::FilterOperation::ReferenceFilterOperation::data):
+ (WebCore::FilterOperation::ReferenceFilterOperation::setData):
+ Use the above-mentioned Data class, instead of a void *.
+ (WebCore::FilterOperation::ReferenceFilterOperation::ReferenceFilterOperation):
+ Don't initialize data to null; OwnPtr will do that for us.
+ * rendering/FilterEffectRenderer.cpp:
+ (WebCore::FilterEffectRenderer::buildReferenceFilter):
+ Extract the cached SVG document from the reference data.
+ * rendering/RenderLayerFilterInfo.cpp:
+ (WebCore::RenderLayerFilterInfo::updateReferenceFilterClients):
+ Extract the cached SVG document from the reference data.
+
2012-10-25 Simon Fraser <[email protected]>
Incorrect tile size in the slow scrolling case
Added: trunk/Source/WebCore/css/CachedSVGDocumentReference.h (0 => 132528)
--- trunk/Source/WebCore/css/CachedSVGDocumentReference.h (rev 0)
+++ trunk/Source/WebCore/css/CachedSVGDocumentReference.h 2012-10-25 20:42:03 UTC (rev 132528)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CachedSVGDocumentReference_h
+#define CachedSVGDocumentReference_h
+
+#if ENABLE(SVG) && ENABLE(CSS_FILTERS)
+#include "CachedResourceHandle.h"
+#include "FilterOperation.h"
+
+namespace WebCore {
+
+class CachedSVGDocument;
+
+class CachedSVGDocumentReference : public ReferenceFilterOperation::Data, public CachedSVGDocumentClient {
+public:
+ CachedSVGDocumentReference(CachedSVGDocument* document) : m_document(document) { m_document->addClient(this); }
+ virtual ~CachedSVGDocumentReference() { m_document->removeClient(this); }
+ CachedSVGDocument* document() { return m_document.get(); }
+private:
+ CachedResourceHandle<CachedSVGDocument> m_document;
+};
+
+};
+
+#endif
+
+#endif
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (132527 => 132528)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2012-10-25 20:39:32 UTC (rev 132527)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2012-10-25 20:42:03 UTC (rev 132528)
@@ -148,6 +148,7 @@
#if ENABLE(SVG)
#include "CachedSVGDocument.h"
+#include "CachedSVGDocumentReference.h"
#include "SVGDocument.h"
#include "SVGElement.h"
#include "SVGNames.h"
@@ -4593,7 +4594,7 @@
continue;
// Stash the CachedSVGDocument on the reference filter.
- referenceFilter->setData(cachedDocument);
+ referenceFilter->setData(adoptPtr(new CachedSVGDocumentReference(cachedDocument)));
}
}
m_pendingSVGDocuments.clear();
@@ -4929,7 +4930,7 @@
if (!svgDocumentValue->loadRequested())
m_pendingSVGDocuments.set(operation.get(), svgDocumentValue);
else
- operation->setData(svgDocumentValue->cachedSVGDocument());
+ operation->setData(adoptPtr(new CachedSVGDocumentReference(svgDocumentValue->cachedSVGDocument())));
}
operations.operations().append(operation);
#endif
Modified: trunk/Source/WebCore/platform/graphics/filters/FilterOperation.h (132527 => 132528)
--- trunk/Source/WebCore/platform/graphics/filters/FilterOperation.h 2012-10-25 20:39:32 UTC (rev 132527)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterOperation.h 2012-10-25 20:42:03 UTC (rev 132528)
@@ -161,14 +161,19 @@
return adoptRef(new ReferenceFilterOperation(url, fragment, type));
}
+ class Data {
+ public:
+ virtual ~Data() { }
+ };
+
virtual bool affectsOpacity() const { return true; }
virtual bool movesPixels() const { return true; }
const String& url() const { return m_url; }
const String& fragment() const { return m_fragment; }
- void* data() const { return m_data; }
- void setData(void* data) { m_data = data; }
+ Data* data() const { return m_data.get(); }
+ void setData(PassOwnPtr<Data> data) { m_data = data; }
private:
@@ -184,13 +189,12 @@
: FilterOperation(type)
, m_url(url)
, m_fragment(fragment)
- , m_data(0)
{
}
String m_url;
String m_fragment;
- void* m_data;
+ OwnPtr<Data> m_data;
};
// GRAYSCALE, SEPIA, SATURATE and HUE_ROTATE are variations on a basic color matrix effect.
Modified: trunk/Source/WebCore/rendering/FilterEffectRenderer.cpp (132527 => 132528)
--- trunk/Source/WebCore/rendering/FilterEffectRenderer.cpp 2012-10-25 20:39:32 UTC (rev 132527)
+++ trunk/Source/WebCore/rendering/FilterEffectRenderer.cpp 2012-10-25 20:42:03 UTC (rev 132528)
@@ -54,6 +54,7 @@
#if ENABLE(SVG)
#include "CachedSVGDocument.h"
+#include "CachedSVGDocumentReference.h"
#include "SVGElement.h"
#include "SVGFilterPrimitiveStandardAttributes.h"
#include "SourceAlpha.h"
@@ -140,7 +141,8 @@
PassRefPtr<FilterEffect> FilterEffectRenderer::buildReferenceFilter(Document* document, PassRefPtr<FilterEffect> previousEffect, ReferenceFilterOperation* op)
{
#if ENABLE(SVG)
- CachedSVGDocument* cachedSVGDocument = static_cast<CachedSVGDocument*>(op->data());
+ CachedSVGDocumentReference* cachedSVGDocumentReference = static_cast<CachedSVGDocumentReference*>(op->data());
+ CachedSVGDocument* cachedSVGDocument = cachedSVGDocumentReference ? cachedSVGDocumentReference->document() : 0;
// If we have an SVG document, this is an external reference. Otherwise
// we look up the referenced node in the current document.
Modified: trunk/Source/WebCore/rendering/RenderLayerFilterInfo.cpp (132527 => 132528)
--- trunk/Source/WebCore/rendering/RenderLayerFilterInfo.cpp 2012-10-25 20:39:32 UTC (rev 132527)
+++ trunk/Source/WebCore/rendering/RenderLayerFilterInfo.cpp 2012-10-25 20:42:03 UTC (rev 132528)
@@ -37,6 +37,7 @@
#if ENABLE(SVG)
#include "CachedSVGDocument.h"
+#include "CachedSVGDocumentReference.h"
#include "SVGElement.h"
#include "SVGFilter.h"
#include "SVGFilterPrimitiveStandardAttributes.h"
@@ -129,7 +130,8 @@
if (filterOperation->getOperationType() != FilterOperation::REFERENCE)
continue;
ReferenceFilterOperation* referenceFilterOperation = static_cast<ReferenceFilterOperation*>(filterOperation.get());
- CachedSVGDocument* cachedSVGDocument = static_cast<CachedSVGDocument*>(referenceFilterOperation->data());
+ CachedSVGDocumentReference* documentReference = static_cast<CachedSVGDocumentReference*>(referenceFilterOperation->data());
+ CachedSVGDocument* cachedSVGDocument = documentReference ? documentReference->document() : 0;
if (cachedSVGDocument) {
// Reference is external; wait for notifyFinished().