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

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

Issue 1753823002: Clone non-markup event listeners for <use> in a separate pass (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@svg-useelm-shadowbuilder-cleanup
Patch Set: Created 4 years, 10 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
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGUseElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/svg/SVGUseElement.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGUseElement.cpp b/third_party/WebKit/Source/core/svg/SVGUseElement.cpp
index a729dbd6fa17cf14f72deb7affcff23adccee23f..f449147d68e725b0572e83348094a954857bb73f 100644
--- a/third_party/WebKit/Source/core/svg/SVGUseElement.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGUseElement.cpp
@@ -377,8 +377,6 @@ static PassRefPtrWillBeRawPtr<Node> cloneNodeAndAssociate(Node& toClone)
SVGElement& svgElement = toSVGElement(toClone);
ASSERT(!svgElement.correspondingElement());
toSVGElement(clone.get())->setCorrespondingElement(&svgElement);
- if (EventTargetData* data = toClone.eventTargetData())
- data->eventListenerMap.copyEventListenersNotCreatedFromMarkupToTarget(clone.get());
TrackExceptionState exceptionState;
for (RefPtrWillBeRawPtr<Node> node = toClone.firstChild(); node && !exceptionState.hadException(); node = node->nextSibling())
clone->appendChild(cloneNodeAndAssociate(*node), exceptionState);
@@ -413,8 +411,10 @@ void SVGUseElement::buildShadowAndInstanceTree(SVGElement* target)
// Non-appearing <use> content is easier to debug, then half-appearing content.
buildShadowTree(target, m_targetElementInstance.get(), false);
- if (instanceTreeIsLoading(m_targetElementInstance.get()))
+ if (instanceTreeIsLoading(m_targetElementInstance.get())) {
+ cloneNonMarkupEventListeners();
return;
+ }
// Assure shadow tree building was successful.
ASSERT(m_targetElementInstance);
@@ -434,6 +434,7 @@ void SVGUseElement::buildShadowAndInstanceTree(SVGElement* target)
m_targetElementInstance = toSVGElement(shadowTreeRootElement->firstChild());
transferUseWidthAndHeightIfNeeded(*this, m_targetElementInstance.get(), *m_targetElementInstance->correspondingElement());
+ cloneNonMarkupEventListeners();
ASSERT(m_targetElementInstance->parentNode() == shadowTreeRootElement);
@@ -517,8 +518,6 @@ void SVGUseElement::buildShadowTree(SVGElement* target, SVGElement* targetInstan
}
targetInstance->setCorrespondingElement(target);
- if (EventTargetData* data = target->eventTargetData())
- data->eventListenerMap.copyEventListenersNotCreatedFromMarkupToTarget(targetInstance);
for (RefPtrWillBeRawPtr<Node> child = target->firstChild(); child; child = child->nextSibling()) {
// Skip any disallowed element.
@@ -534,6 +533,14 @@ void SVGUseElement::buildShadowTree(SVGElement* target, SVGElement* targetInstan
}
}
+void SVGUseElement::cloneNonMarkupEventListeners()
+{
+ for (SVGElement& element : Traversal<SVGElement>::descendantsOf(*userAgentShadowRoot())) {
+ if (EventTargetData* data = element.correspondingElement()->eventTargetData())
+ data->eventListenerMap.copyEventListenersNotCreatedFromMarkupToTarget(&element);
+ }
+}
+
bool SVGUseElement::hasCycleUseReferencing(SVGUseElement* use, ContainerNode* targetInstance, SVGElement*& newTarget)
{
ASSERT(referencedScope());
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGUseElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698