Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Unified Diff: third_party/WebKit/Source/core/svg/SVGResourceClient.cpp

Issue 2482353002: Revert of Tracking filter mutation via SVGElementProxy (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/svg/SVGResourceClient.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGResourceClient.cpp b/third_party/WebKit/Source/core/svg/SVGResourceClient.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4a580f31146f99c117ccf598bdac8885705c2f0c
--- /dev/null
+++ b/third_party/WebKit/Source/core/svg/SVGResourceClient.cpp
@@ -0,0 +1,86 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/svg/SVGResourceClient.h"
+
+#include "core/fetch/DocumentResourceReference.h"
+#include "core/layout/svg/LayoutSVGResourceContainer.h"
+#include "core/layout/svg/ReferenceFilterBuilder.h"
+#include "core/svg/SVGFilterElement.h"
+
+namespace blink {
+
+SVGResourceClient::SVGResourceClient() {
+ ThreadState::current()->registerPreFinalizer(this);
+}
+
+SVGResourceClient::~SVGResourceClient() {}
+
+void SVGResourceClient::addFilterReferences(const FilterOperations& operations,
+ const Document& document) {
+ for (size_t i = 0; i < operations.size(); ++i) {
+ FilterOperation* filterOperation = operations.operations().at(i);
+ if (filterOperation->type() != FilterOperation::REFERENCE)
+ continue;
+ ReferenceFilterOperation* referenceFilterOperation =
+ toReferenceFilterOperation(filterOperation);
+ DocumentResourceReference* documentReference =
+ ReferenceFilterBuilder::documentResourceReference(
+ referenceFilterOperation);
+ DocumentResource* cachedSVGDocument =
+ documentReference ? documentReference->document() : 0;
+
+ if (cachedSVGDocument) {
+ cachedSVGDocument->addClient(this);
+ m_externalFilterReferences.append(cachedSVGDocument);
+ } else {
+ Element* element =
+ document.getElementById(referenceFilterOperation->fragment());
+ if (!isSVGFilterElement(element))
+ continue;
+ SVGFilterElement* filter = toSVGFilterElement(element);
+ if (filter->layoutObject())
+ toLayoutSVGResourceContainer(filter->layoutObject())
+ ->addResourceClient(this);
+ else
+ filter->addClient(this);
+ m_internalFilterReferences.add(filter);
+ }
+ }
+}
+
+void SVGResourceClient::clearFilterReferences() {
+ for (SVGFilterElement* filter : m_internalFilterReferences) {
+ if (filter->layoutObject())
+ toLayoutSVGResourceContainer(filter->layoutObject())
+ ->removeResourceClient(this);
+ else
+ filter->removeClient(this);
+ }
+ m_internalFilterReferences.clear();
+
+ for (DocumentResource* documentResource : m_externalFilterReferences)
+ documentResource->removeClient(this);
+ m_externalFilterReferences.clear();
+}
+
+void SVGResourceClient::filterWillBeDestroyed(SVGFilterElement* filter) {
+ m_internalFilterReferences.remove(filter);
+ // TODO(Oilpan): Currently filterNeedsInvalidation() is not called when
+ // the filter is removed from m_internalFilterReferences by weak processing.
+ // It needs to be called.
+ filterNeedsInvalidation();
+}
+
+void SVGResourceClient::notifyFinished(Resource*) {
+ filterNeedsInvalidation();
+}
+
+DEFINE_TRACE(SVGResourceClient) {
+ visitor->trace(m_internalFilterReferences);
+ visitor->trace(m_externalFilterReferences);
+ DocumentResourceClient::trace(visitor);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698