Index: Source/core/svg/SVGElement.cpp |
diff --git a/Source/core/svg/SVGElement.cpp b/Source/core/svg/SVGElement.cpp |
index 11616ed0dd5297177619f7d8e391bd2d32da962b..81c7fad6838eb03a43977c5487ea1faecbfe819c 100644 |
--- a/Source/core/svg/SVGElement.cpp |
+++ b/Source/core/svg/SVGElement.cpp |
@@ -532,10 +532,10 @@ void SVGElement::mapInstanceToElement(SVGElementInstance* instance) |
{ |
ASSERT(instance); |
- HashSet<SVGElementInstance*>& instances = ensureSVGRareData()->elementInstances(); |
- ASSERT(!instances.contains(instance)); |
+ HashSet<SVGElement*>& instances = ensureSVGRareData()->elementInstances(); |
+ ASSERT(!instances.contains(instance->shadowTreeElement())); |
- instances.add(instance); |
+ instances.add(instance->shadowTreeElement()); |
} |
void SVGElement::removeInstanceMapping(SVGElementInstance* instance) |
@@ -543,16 +543,19 @@ void SVGElement::removeInstanceMapping(SVGElementInstance* instance) |
ASSERT(instance); |
ASSERT(hasSVGRareData()); |
- HashSet<SVGElementInstance*>& instances = svgRareData()->elementInstances(); |
- ASSERT(instances.contains(instance)); |
+ if (!instance->shadowTreeElement()) |
+ return; |
+ |
+ HashSet<SVGElement*>& instances = svgRareData()->elementInstances(); |
+ ASSERT(instances.contains(instance->shadowTreeElement())); |
- instances.remove(instance); |
+ instances.remove(instance->shadowTreeElement()); |
} |
-const HashSet<SVGElementInstance*>& SVGElement::instancesForElement() const |
+const HashSet<SVGElement*>& SVGElement::instancesForElement() const |
{ |
if (!hasSVGRareData()) { |
- DEFINE_STATIC_LOCAL(HashSet<SVGElementInstance*>, emptyInstances, ()); |
+ DEFINE_STATIC_LOCAL(HashSet<SVGElement*>, emptyInstances, ()); |
return emptyInstances; |
} |
return svgRareData()->elementInstances(); |
@@ -613,6 +616,15 @@ SVGElement* SVGElement::correspondingElement() |
return hasSVGRareData() ? svgRareData()->correspondingElement() : 0; |
} |
+SVGUseElement* SVGElement::correspondingUseElement() |
+{ |
+ if (ShadowRoot* root = containingShadowRoot()) { |
pdr.
2014/05/03 21:55:26
What if the <use> element is in a user-created sha
|
+ if (isSVGUseElement(root->host())) |
+ return toSVGUseElement(root->host()); |
+ } |
+ return 0; |
+} |
+ |
void SVGElement::setCorrespondingElement(SVGElement* correspondingElement) |
{ |
ensureSVGRareData()->setCorrespondingElement(correspondingElement); |
@@ -775,7 +787,7 @@ bool SVGElement::haveLoadedRequiredResources() |
return true; |
} |
-static inline void collectInstancesForSVGElement(SVGElement* element, HashSet<SVGElementInstance*>& instances) |
+static inline void collectInstancesForSVGElement(SVGElement* element, HashSet<SVGElement*>& instances) |
{ |
ASSERT(element); |
if (element->containingShadowRoot()) |
@@ -795,14 +807,11 @@ bool SVGElement::addEventListener(const AtomicString& eventType, PassRefPtr<Even |
return false; |
// Add event listener to all shadow tree DOM element instances |
- HashSet<SVGElementInstance*> instances; |
+ HashSet<SVGElement*> instances; |
collectInstancesForSVGElement(this, instances); |
- const HashSet<SVGElementInstance*>::const_iterator end = instances.end(); |
- for (HashSet<SVGElementInstance*>::const_iterator it = instances.begin(); it != end; ++it) { |
- ASSERT((*it)->shadowTreeElement()); |
- ASSERT((*it)->correspondingElement() == this); |
- |
- bool result = (*it)->shadowTreeElement()->Node::addEventListener(eventType, listener, useCapture); |
+ const HashSet<SVGElement*>::const_iterator end = instances.end(); |
+ for (HashSet<SVGElement*>::const_iterator it = instances.begin(); it != end; ++it) { |
+ bool result = (*it)->Node::addEventListener(eventType, listener, useCapture); |
ASSERT_UNUSED(result, result); |
} |
@@ -811,7 +820,7 @@ bool SVGElement::addEventListener(const AtomicString& eventType, PassRefPtr<Even |
bool SVGElement::removeEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture) |
{ |
- HashSet<SVGElementInstance*> instances; |
+ HashSet<SVGElement*> instances; |
collectInstancesForSVGElement(this, instances); |
if (instances.isEmpty()) |
return Node::removeEventListener(eventType, listener, useCapture); |
@@ -828,11 +837,9 @@ bool SVGElement::removeEventListener(const AtomicString& eventType, EventListene |
return false; |
// Remove event listener from all shadow tree DOM element instances |
- const HashSet<SVGElementInstance*>::const_iterator end = instances.end(); |
- for (HashSet<SVGElementInstance*>::const_iterator it = instances.begin(); it != end; ++it) { |
- ASSERT((*it)->correspondingElement() == this); |
- |
- SVGElement* shadowTreeElement = (*it)->shadowTreeElement(); |
+ const HashSet<SVGElement*>::const_iterator end = instances.end(); |
+ for (HashSet<SVGElement*>::const_iterator it = instances.begin(); it != end; ++it) { |
+ SVGElement* shadowTreeElement = *it; |
ASSERT(shadowTreeElement); |
if (shadowTreeElement->Node::removeEventListener(eventType, listener, useCapture)) |