void SVGSMILElement::connectEventBaseConditions() { disconnectEventBaseConditions(); for (unsigned n = 0; n < m_conditions.size(); ++n) { Condition* condition = m_conditions[n].get(); if (condition->getType() == Condition::EventBase) { ASSERT(!condition->syncBase()); SVGElement* eventBase = eventBaseFor(*condition); if (!eventBase) { if (!condition->baseID().isEmpty() && !document().accessSVGExtensions().isElementPendingResource(this, AtomicString(condition->baseID()))) document().accessSVGExtensions().addPendingResource(AtomicString(condition->baseID()), this); continue; } ASSERT(!condition->eventListener()); condition->setEventListener(ConditionEventListener::create(this, condition)); eventBase->addEventListener(AtomicString(condition->name()), condition->eventListener(), false); addReferenceTo(eventBase); } } }
void SVGSMILElement::disconnectEventBaseConditions() { for (unsigned n = 0; n < m_conditions.size(); ++n) { Condition* condition = m_conditions[n].get(); if (condition->getType() == Condition::EventBase) { ASSERT(!condition->syncBase()); if (!condition->eventListener()) continue; // Note: It's a memory optimization to try to remove our condition // event listener, but it's not guaranteed to work, since we have // no guarantee that eventBaseFor() will be able to find our condition's // original eventBase. So, we also have to disconnect ourselves from // our condition event listener, in case it later fires. SVGElement* eventBase = eventBaseFor(*condition); if (eventBase) eventBase->removeEventListener(AtomicString(condition->name()), condition->eventListener(), false); condition->eventListener()->disconnectAnimation(); condition->setEventListener(nullptr); } } }