mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-22 23:27:30 +09:00
Issue #1118 Part 3: Add a public RemoveAllListeners method on
EventListenerManager.
This commit is contained in:
parent
7d52521f95
commit
08c26a9adf
2 changed files with 25 additions and 4 deletions
|
|
@ -166,11 +166,11 @@ EventListenerManager::~EventListenerManager()
|
||||||
// XXX azakai: Is there any reason to not just call Disconnect
|
// XXX azakai: Is there any reason to not just call Disconnect
|
||||||
// from right here, if not previously called?
|
// from right here, if not previously called?
|
||||||
NS_ASSERTION(!mTarget, "didn't call Disconnect");
|
NS_ASSERTION(!mTarget, "didn't call Disconnect");
|
||||||
RemoveAllListeners();
|
RemoveAllListenersSilently();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
EventListenerManager::RemoveAllListeners()
|
EventListenerManager::RemoveAllListenersSilently()
|
||||||
{
|
{
|
||||||
if (mClearingListeners) {
|
if (mClearingListeners) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -1329,7 +1329,7 @@ void
|
||||||
EventListenerManager::Disconnect()
|
EventListenerManager::Disconnect()
|
||||||
{
|
{
|
||||||
mTarget = nullptr;
|
mTarget = nullptr;
|
||||||
RemoveAllListeners();
|
RemoveAllListenersSilently();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -1734,6 +1734,21 @@ EventListenerManager::IsApzAwareEvent(nsIAtom* aEvent)
|
||||||
return false;
|
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>
|
already_AddRefed<nsIScriptGlobalObject>
|
||||||
EventListenerManager::GetScriptGlobalAndDocument(nsIDocument** aDoc)
|
EventListenerManager::GetScriptGlobalAndDocument(nsIDocument** aDoc)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -472,6 +472,12 @@ public:
|
||||||
bool IsApzAwareListener(Listener* aListener);
|
bool IsApzAwareListener(Listener* aListener);
|
||||||
bool IsApzAwareEvent(nsIAtom* aEvent);
|
bool IsApzAwareEvent(nsIAtom* aEvent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all event listeners from the event target this EventListenerManager
|
||||||
|
* is for.
|
||||||
|
*/
|
||||||
|
void RemoveAllListeners();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void HandleEventInternal(nsPresContext* aPresContext,
|
void HandleEventInternal(nsPresContext* aPresContext,
|
||||||
WidgetEvent* aEvent,
|
WidgetEvent* aEvent,
|
||||||
|
|
@ -604,7 +610,7 @@ protected:
|
||||||
const nsAString& aTypeString,
|
const nsAString& aTypeString,
|
||||||
const EventListenerFlags& aFlags,
|
const EventListenerFlags& aFlags,
|
||||||
bool aAllEvents = false);
|
bool aAllEvents = false);
|
||||||
void RemoveAllListeners();
|
void RemoveAllListenersSilently();
|
||||||
void NotifyEventListenerRemoved(nsIAtom* aUserType);
|
void NotifyEventListenerRemoved(nsIAtom* aUserType);
|
||||||
const EventTypeData* GetTypeDataForIID(const nsIID& aIID);
|
const EventTypeData* GetTypeDataForIID(const nsIID& aIID);
|
||||||
const EventTypeData* GetTypeDataForEventName(nsIAtom* aName);
|
const EventTypeData* GetTypeDataForEventName(nsIAtom* aName);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue