Bug 875050 - Add EventListenerAdded/Removed to EventTarget, r=bz

--HG--
extra : rebase_source : c7aea2048abd1d74ae02c1cfae84602cdf3af8c3
This commit is contained in:
Olli Pettay 2013-05-23 14:41:00 +03:00
parent c4af7d1677
commit 825b5cb20b
2 changed files with 13 additions and 0 deletions

View File

@ -60,6 +60,10 @@ public:
return SetEventHandler(type, aHandler, rv);
}
// Note, for an event 'foo' aType will be 'onfoo'.
virtual void EventListenerAdded(nsIAtom* aType) {}
virtual void EventListenerRemoved(nsIAtom* aType) {}
protected:
EventHandlerNonNull* GetEventHandler(nsIAtom* aType);
void SetEventHandler(nsIAtom* aType, EventHandlerNonNull* aHandler,

View File

@ -352,6 +352,9 @@ nsEventListenerManager::AddEventListenerInternal(
}
#endif
}
if (aTypeAtom && mTarget) {
mTarget->EventListenerAdded(aTypeAtom);
}
}
bool
@ -464,6 +467,9 @@ nsEventListenerManager::RemoveEventListenerInternal(
--count;
mNoListenerForEvent = NS_EVENT_TYPE_NULL;
mNoListenerForEventAtom = nullptr;
if (mTarget && aUserType) {
mTarget->EventListenerRemoved(aUserType);
}
if (!deviceType
#ifdef MOZ_B2G
@ -748,6 +754,9 @@ nsEventListenerManager::RemoveEventHandler(nsIAtom* aName)
mListeners.RemoveElementAt(uint32_t(ls - &mListeners.ElementAt(0)));
mNoListenerForEvent = NS_EVENT_TYPE_NULL;
mNoListenerForEventAtom = nullptr;
if (mTarget) {
mTarget->EventListenerRemoved(aName);
}
}
}