зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1489308 part 3. Add a public RemoveAllListeners method on EventListenerManager. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D17321 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
af8e1b14b7
Коммит
b4c3949d4b
|
@ -147,10 +147,10 @@ EventListenerManager::~EventListenerManager() {
|
|||
// XXX azakai: Is there any reason to not just call Disconnect
|
||||
// from right here, if not previously called?
|
||||
NS_ASSERTION(!mTarget, "didn't call Disconnect");
|
||||
RemoveAllListeners();
|
||||
RemoveAllListenersSilently();
|
||||
}
|
||||
|
||||
void EventListenerManager::RemoveAllListeners() {
|
||||
void EventListenerManager::RemoveAllListenersSilently() {
|
||||
if (mClearingListeners) {
|
||||
return;
|
||||
}
|
||||
|
@ -1319,7 +1319,7 @@ void EventListenerManager::HandleEventInternal(nsPresContext* aPresContext,
|
|||
|
||||
void EventListenerManager::Disconnect() {
|
||||
mTarget = nullptr;
|
||||
RemoveAllListeners();
|
||||
RemoveAllListenersSilently();
|
||||
}
|
||||
|
||||
void EventListenerManager::AddEventListener(const nsAString& aType,
|
||||
|
@ -1706,6 +1706,19 @@ bool EventListenerManager::IsApzAwareEvent(nsAtom* aEvent) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void EventListenerManager::RemoveAllListeners() {
|
||||
while (!mListeners.IsEmpty()) {
|
||||
size_t idx = mListeners.Length() - 1;
|
||||
RefPtr<nsAtom> type = mListeners.ElementAt(idx).mTypeAtom;
|
||||
EventMessage message = mListeners.ElementAt(idx).mEventMessage;
|
||||
mListeners.RemoveElementAt(idx);
|
||||
NotifyEventListenerRemoved(type);
|
||||
if (IsDeviceType(message)) {
|
||||
DisableDevice(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<nsIScriptGlobalObject>
|
||||
EventListenerManager::GetScriptGlobalAndDocument(Document** aDoc) {
|
||||
nsCOMPtr<nsINode> node(do_QueryInterface(mTarget));
|
||||
|
|
|
@ -455,6 +455,12 @@ class EventListenerManager final : public EventListenerManagerBase {
|
|||
bool IsApzAwareListener(Listener* aListener);
|
||||
bool IsApzAwareEvent(nsAtom* aEvent);
|
||||
|
||||
/**
|
||||
* Remove all event listeners from the event target this EventListenerManager
|
||||
* is for.
|
||||
*/
|
||||
void RemoveAllListeners();
|
||||
|
||||
protected:
|
||||
void HandleEventInternal(nsPresContext* aPresContext, WidgetEvent* aEvent,
|
||||
dom::Event** aDOMEvent,
|
||||
|
@ -580,7 +586,7 @@ class EventListenerManager final : public EventListenerManagerBase {
|
|||
nsAtom* aUserType,
|
||||
const EventListenerFlags& aFlags,
|
||||
bool aAllEvents = false);
|
||||
void RemoveAllListeners();
|
||||
void RemoveAllListenersSilently();
|
||||
void NotifyEventListenerRemoved(nsAtom* aUserType);
|
||||
const EventTypeData* GetTypeDataForIID(const nsIID& aIID);
|
||||
const EventTypeData* GetTypeDataForEventName(nsAtom* aName);
|
||||
|
|
Загрузка…
Ссылка в новой задаче