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

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

Issue 2722543002: Improve handling of duplicate id's for SVG resources (Closed)
Patch Set: Rebase Created 3 years, 9 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 f50247e0199b30ce70d3f2634876f15ba3c8931e..cf36a430aa6198a3035699bd6d8320e0787262d6 100644
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceContainer.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceContainer.cpp
@@ -67,31 +67,22 @@ void LayoutSVGResourceContainer::notifyContentChanged() {
}
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();
-
LayoutSVGHiddenContainer::willBeDestroyed();
- if (!m_registered)
- return;
svgTreeScopeResourcesFromElement(element()).removeResource(
- element()->getIdAttribute());
+ element()->getIdAttribute(), this);
+ DCHECK(m_clients.isEmpty());
}
void LayoutSVGResourceContainer::styleDidChange(StyleDifference diff,
const ComputedStyle* oldStyle) {
LayoutSVGHiddenContainer::styleDidChange(diff, oldStyle);
-
- if (m_registered)
- return;
- m_registered = true;
svgTreeScopeResourcesFromElement(element()).updateResource(
element()->getIdAttribute(), this);
}
-void LayoutSVGResourceContainer::detachAllClients() {
- const AtomicString& id = element()->getIdAttribute();
+void LayoutSVGResourceContainer::detachAllClients(const AtomicString& toId) {
+ removeAllClientsFromCache();
+
for (auto* client : m_clients) {
// Unlink the resource from the client's SVGResources. (The actual
// removal will be signaled after processing all the clients.)
@@ -104,22 +95,15 @@ void LayoutSVGResourceContainer::detachAllClients() {
// Add a pending resolution based on the id of the old resource.
Element* clientElement = toElement(client->node());
svgTreeScopeResourcesFromElement(clientElement)
- .addPendingResource(id, *clientElement);
+ .addPendingResource(toId, *clientElement);
}
-
- removeAllClientsFromCache();
+ m_clients.clear();
}
void LayoutSVGResourceContainer::idChanged(const AtomicString& oldId,
const AtomicString& newId) {
- // Invalidate all our current clients.
- removeAllClientsFromCache();
-
- // Remove old id, that is guaranteed to be present in cache.
- SVGTreeScopeResources& treeScopeResources =
- svgTreeScopeResourcesFromElement(element());
- treeScopeResources.removeResource(oldId);
- treeScopeResources.updateResource(newId, this);
+ svgTreeScopeResourcesFromElement(element()).updateResource(oldId, newId,
+ this);
}
void LayoutSVGResourceContainer::markAllClientsForInvalidation(

Powered by Google App Engine
This is Rietveld 408576698