| 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..97724a341d5a06730807194ffa969651f2f73b65 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::notifyContentChanged() {
 | 
| +  if (SVGElementProxySet* proxySet = elementProxySet())
 | 
| +    proxySet->notifyContentChanged();
 | 
| +}
 | 
| +
 | 
| +void LayoutSVGResourceContainer::invalidateProxies() {
 | 
| +  if (SVGElementProxySet* proxySet = elementProxySet())
 | 
| +    proxySet->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;
 | 
| +  SVGElementProxySet* proxySet = elementProxySet();
 | 
| +  if (m_clients.isEmpty() && (!proxySet || proxySet->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.
 | 
| +  notifyContentChanged();
 | 
|  
 | 
|    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);
 | 
|    }
 | 
| 
 |