summaryrefslogtreecommitdiff
path: root/dom
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-08-06 08:52:49 +0000
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-08-06 09:57:37 +0000
commit80e4577e3b10245164d6a2c2416772b2819a9f6a (patch)
tree1edde1c509f306766cda56172f6f46cbbb9d9744 /dom
parentf5c848aa9b73ccaebd42dacaccfe7f2568ede343 (diff)
downloaduxp-80e4577e3b10245164d6a2c2416772b2819a9f6a.tar.gz
Issue #1118 Part 3: Add a public RemoveAllListeners method on
EventListenerManager.
Diffstat (limited to 'dom')
-rw-r--r--dom/events/EventListenerManager.cpp21
-rw-r--r--dom/events/EventListenerManager.h8
2 files changed, 25 insertions, 4 deletions
diff --git a/dom/events/EventListenerManager.cpp b/dom/events/EventListenerManager.cpp
index fe896870c9..0774c32966 100644
--- a/dom/events/EventListenerManager.cpp
+++ b/dom/events/EventListenerManager.cpp
@@ -166,11 +166,11 @@ 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()
+EventListenerManager::RemoveAllListenersSilently()
{
if (mClearingListeners) {
return;
@@ -1329,7 +1329,7 @@ void
EventListenerManager::Disconnect()
{
mTarget = nullptr;
- RemoveAllListeners();
+ RemoveAllListenersSilently();
}
void
@@ -1734,6 +1734,21 @@ EventListenerManager::IsApzAwareEvent(nsIAtom* aEvent)
return false;
}
+void
+EventListenerManager::RemoveAllListeners()
+{
+ while (!mListeners.IsEmpty()) {
+ size_t idx = mListeners.Length() - 1;
+ nsCOMPtr<nsIAtom> 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(nsIDocument** aDoc)
{
diff --git a/dom/events/EventListenerManager.h b/dom/events/EventListenerManager.h
index 6b09277881..36637cfd76 100644
--- a/dom/events/EventListenerManager.h
+++ b/dom/events/EventListenerManager.h
@@ -472,6 +472,12 @@ public:
bool IsApzAwareListener(Listener* aListener);
bool IsApzAwareEvent(nsIAtom* aEvent);
+ /**
+ * Remove all event listeners from the event target this EventListenerManager
+ * is for.
+ */
+ void RemoveAllListeners();
+
protected:
void HandleEventInternal(nsPresContext* aPresContext,
WidgetEvent* aEvent,
@@ -604,7 +610,7 @@ protected:
const nsAString& aTypeString,
const EventListenerFlags& aFlags,
bool aAllEvents = false);
- void RemoveAllListeners();
+ void RemoveAllListenersSilently();
void NotifyEventListenerRemoved(nsIAtom* aUserType);
const EventTypeData* GetTypeDataForIID(const nsIID& aIID);
const EventTypeData* GetTypeDataForEventName(nsIAtom* aName);