void SVGResourcesCache::clientWillBeRemovedFromTree(LayoutObject* layoutObject) { if (!layoutObject->node()) return; LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation(layoutObject, false); if (!layoutObjectCanHaveResources(layoutObject)) return; SVGResourcesCache* cache = resourcesCacheFromLayoutObject(layoutObject); cache->removeResourcesFromLayoutObject(layoutObject); }
void SVGResourcesCache::clientDestroyed(LayoutObject* layoutObject) { ASSERT(layoutObject); SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(layoutObject); if (resources) resources->removeClientFromCache(layoutObject); SVGResourcesCache* cache = resourcesCacheFromLayoutObject(layoutObject); cache->removeResourcesFromLayoutObject(layoutObject); }
void SVGResourcesCache::resourceDestroyed(LayoutSVGResourceContainer* resource) { ASSERT(resource); SVGResourcesCache* cache = resourcesCacheFromLayoutObject(resource); // The resource itself may have clients, that need to be notified. cache->removeResourcesFromLayoutObject(resource); for (auto& objectResources : cache->m_cache) { objectResources.value->resourceDestroyed(resource); // Mark users of destroyed resources as pending resolution based on the id of the old resource. Element* resourceElement = resource->element(); Element* clientElement = toElement(objectResources.key->node()); SVGDocumentExtensions& extensions = clientElement->document().accessSVGExtensions(); extensions.addPendingResource(resourceElement->fastGetAttribute(HTMLNames::idAttr), clientElement); } }
void SVGResourcesCache::clientStyleChanged(LayoutObject* layoutObject, StyleDifference diff, const ComputedStyle& newStyle) { ASSERT(layoutObject); ASSERT(layoutObject->node()); ASSERT(layoutObject->node()->isSVGElement()); if (!diff.hasDifference() || !layoutObject->parent()) return; // In this case the proper SVGFE*Element will decide whether the modified CSS properties require a relayout or paintInvalidation. if (layoutObject->isSVGResourceFilterPrimitive() && !diff.needsLayout()) return; // Dynamic changes of CSS properties like 'clip-path' may require us to recompute the associated resources for a layoutObject. // FIXME: Avoid passing in a useless StyleDifference, but instead compare oldStyle/newStyle to see which resources changed // to be able to selectively rebuild individual resources, instead of all of them. if (layoutObjectCanHaveResources(layoutObject)) { SVGResourcesCache* cache = resourcesCacheFromLayoutObject(layoutObject); cache->removeResourcesFromLayoutObject(layoutObject); cache->addResourcesFromLayoutObject(layoutObject, newStyle); } LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation(layoutObject, false); }