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

Unified Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceContainer.cpp

Issue 2401343002: Tracking filter mutation via SVGElementProxy (Closed)
Patch Set: Rebase Created 4 years, 2 months 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/layout/svg/LayoutSVGResourceContainer.cpp
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceContainer.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceContainer.cpp
index 0d3edd3cd90d08a7564b4c5a0e523ca03ffe124b..f7002ff510313d7746a0962bdd5a3f91d74b54da 100644
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceContainer.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceContainer.cpp
@@ -25,9 +25,7 @@
#include "core/layout/svg/LayoutSVGResourceMasker.h"
#include "core/layout/svg/SVGResources.h"
#include "core/layout/svg/SVGResourcesCache.h"
-#include "core/paint/PaintLayer.h"
-#include "core/svg/SVGFilterElement.h"
-
+#include "core/svg/SVGElementProxy.h"
#include "wtf/AutoReset.h"
namespace blink {
@@ -63,15 +61,22 @@ void LayoutSVGResourceContainer::layout() {
clearInvalidationMask();
}
+void LayoutSVGResourceContainer::invalidateProxyClients(InvalidationMode) {
+ if (SVGElementProxyTracker* proxyTracker = elementProxyTracker())
+ proxyTracker->invalidateProxyClients();
+}
+
+void LayoutSVGResourceContainer::invalidateProxies() {
+ if (SVGElementProxyTracker* proxyTracker = elementProxyTracker())
+ proxyTracker->invalidateProxies();
+}
+
void LayoutSVGResourceContainer::willBeDestroyed() {
// Detach all clients referring to this resource. If the resource itself is
// a client, it will be detached from any such resources by the call to
// LayoutSVGHiddenContainer::willBeDestroyed() below.
detachAllClients();
-
- for (SVGResourceClient* client : m_resourceClients)
- client->filterWillBeDestroyed(toSVGFilterElement(element()));
- m_resourceClients.clear();
+ invalidateProxies();
LayoutSVGHiddenContainer::willBeDestroyed();
if (m_registered)
@@ -110,6 +115,7 @@ void LayoutSVGResourceContainer::detachAllClients() {
void LayoutSVGResourceContainer::idChanged() {
// Invalidate all our current clients.
removeAllClientsFromCache();
+ invalidateProxies();
// Remove old id, that is guaranteed to be present in cache.
SVGDocumentExtensions& extensions = svgExtensionsFromElement(element());
@@ -117,13 +123,16 @@ void LayoutSVGResourceContainer::idChanged() {
m_id = element()->getIdAttribute();
registerResource();
+ extensions.invalidatePendingProxies(m_id);
}
void LayoutSVGResourceContainer::markAllClientsForInvalidation(
InvalidationMode mode) {
- if ((m_clients.isEmpty() && m_resourceClients.isEmpty()) || m_isInvalidating)
+ if (m_isInvalidating)
+ return;
+ SVGElementProxyTracker* proxyTracker = elementProxyTracker();
+ if (m_clients.isEmpty() && (!proxyTracker || proxyTracker->isEmpty()))
return;
-
if (m_invalidationMask & mode)
return;
@@ -132,7 +141,9 @@ void LayoutSVGResourceContainer::markAllClientsForInvalidation(
bool needsLayout = mode == LayoutAndBoundariesInvalidation;
bool markForInvalidation = mode != ParentOnlyInvalidation;
+ // Invalidate clients registered on the this object (via SVGResources).
for (auto* client : m_clients) {
+ DCHECK(client->isSVG());
if (client->isSVGResourceContainer()) {
toLayoutSVGResourceContainer(client)->removeAllClientsFromCache(
markForInvalidation);
@@ -146,16 +157,12 @@ void LayoutSVGResourceContainer::markAllClientsForInvalidation(
client, needsLayout);
}
- markAllResourceClientsForInvalidation();
+ // Invalidate clients registered via an SVGElementProxy.
+ invalidateProxyClients(mode);
m_isInvalidating = false;
}
-void LayoutSVGResourceContainer::markAllResourceClientsForInvalidation() {
- for (SVGResourceClient* client : m_resourceClients)
- client->filterNeedsInvalidation();
-}
-
void LayoutSVGResourceContainer::markClientForInvalidation(
LayoutObject* client,
InvalidationMode mode) {
@@ -193,18 +200,6 @@ void LayoutSVGResourceContainer::removeClient(LayoutObject* client) {
m_clients.remove(client);
}
-void LayoutSVGResourceContainer::addResourceClient(SVGResourceClient* client) {
- ASSERT(client);
- m_resourceClients.add(client);
- clearInvalidationMask();
-}
-
-void LayoutSVGResourceContainer::removeResourceClient(
- SVGResourceClient* client) {
- ASSERT(client);
- m_resourceClients.remove(client);
-}
-
void LayoutSVGResourceContainer::invalidateCacheAndMarkForLayout(
SubtreeLayoutScope* layoutScope) {
if (selfNeedsLayout())
@@ -233,32 +228,18 @@ void LayoutSVGResourceContainer::registerResource() {
// Update cached resources of pending clients.
for (const auto& pendingClient : *clients) {
- ASSERT(pendingClient->hasPendingResources());
+ DCHECK(pendingClient->hasPendingResources());
extensions.clearHasPendingResourcesIfPossible(pendingClient);
LayoutObject* layoutObject = pendingClient->layoutObject();
if (!layoutObject)
continue;
-
- const ComputedStyle& style = layoutObject->styleRef();
-
- // If the client has a layer (is a non-SVGElement) we need to signal
- // invalidation in the same way as is done in
- // markAllResourceClientsForInvalidation above.
- if (layoutObject->hasLayer() && resourceType() == FilterResourceType) {
- if (!style.hasFilter())
- continue;
- toLayoutBoxModelObject(layoutObject)
- ->layer()
- ->filterNeedsPaintInvalidation();
- if (!layoutObject->isSVGRoot())
- continue;
- // A root SVG element with a filter, however, still needs to run
- // the full invalidation step below.
- }
+ DCHECK(layoutObject->isSVG() && (resourceType() != FilterResourceType ||
+ !layoutObject->isSVGRoot()));
StyleDifference diff;
diff.setNeedsFullLayout();
- SVGResourcesCache::clientStyleChanged(layoutObject, diff, style);
+ SVGResourcesCache::clientStyleChanged(layoutObject, diff,
+ layoutObject->styleRef());
layoutObject->setNeedsLayoutAndFullPaintInvalidation(
LayoutInvalidationReason::SvgResourceInvalidated);
}

Powered by Google App Engine
This is Rietveld 408576698