1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_EventListenerManager_h_
8 #define mozilla_EventListenerManager_h_
10 #include "mozilla/BasicEvents.h"
11 #include "mozilla/dom/AbortFollower.h"
12 #include "mozilla/dom/EventListenerBinding.h"
13 #include "mozilla/JSEventHandler.h"
14 #include "mozilla/MemoryReporting.h"
16 #include "nsCycleCollectionParticipant.h"
17 #include "nsGkAtoms.h"
18 #include "nsIDOMEventListener.h"
19 #include "nsTObserverArray.h"
22 class nsIEventListenerInfo
;
23 class nsPIDOMWindowInner
;
30 class ELMCreationDetector
;
31 class EventListenerManager
;
32 class ListenerSignalFollower
;
40 using EventListenerHolder
=
41 dom::CallbackObjectHolder
<dom::EventListener
, nsIDOMEventListener
>;
43 struct EventListenerFlags
{
44 friend class EventListenerManager
;
47 // If mListenerIsJSListener is true, the listener is implemented by JS.
48 // Otherwise, it's implemented by native code or JS but it's wrapped.
49 bool mListenerIsJSListener
: 1;
52 // If mCapture is true, it means the listener captures the event. Otherwise,
53 // it's listening at bubbling phase.
55 // If mInSystemGroup is true, the listener is listening to the events in the
57 bool mInSystemGroup
: 1;
58 // If mAllowUntrustedEvents is true, the listener is listening to the
59 // untrusted events too.
60 bool mAllowUntrustedEvents
: 1;
61 // If mPassive is true, the listener will not be calling preventDefault on the
62 // event. (If it does call preventDefault, we should ignore it).
64 // If mOnce is true, the listener will be removed from the manager before it
65 // is invoked, so that it would only be invoked once.
69 : mListenerIsJSListener(false),
71 mInSystemGroup(false),
72 mAllowUntrustedEvents(false),
76 bool EqualsForAddition(const EventListenerFlags
& aOther
) const {
77 return (mCapture
== aOther
.mCapture
&&
78 mInSystemGroup
== aOther
.mInSystemGroup
&&
79 mListenerIsJSListener
== aOther
.mListenerIsJSListener
&&
80 mAllowUntrustedEvents
== aOther
.mAllowUntrustedEvents
);
81 // Don't compare mPassive or mOnce
84 bool EqualsForRemoval(const EventListenerFlags
& aOther
) const {
85 return (mCapture
== aOther
.mCapture
&&
86 mInSystemGroup
== aOther
.mInSystemGroup
&&
87 mListenerIsJSListener
== aOther
.mListenerIsJSListener
);
88 // Don't compare mAllowUntrustedEvents, mPassive, or mOnce
92 inline EventListenerFlags
TrustedEventsAtBubble() {
93 EventListenerFlags flags
;
97 inline EventListenerFlags
TrustedEventsAtCapture() {
98 EventListenerFlags flags
;
99 flags
.mCapture
= true;
103 inline EventListenerFlags
AllEventsAtBubble() {
104 EventListenerFlags flags
;
105 flags
.mAllowUntrustedEvents
= true;
109 inline EventListenerFlags
AllEventsAtCapture() {
110 EventListenerFlags flags
;
111 flags
.mCapture
= true;
112 flags
.mAllowUntrustedEvents
= true;
116 inline EventListenerFlags
TrustedEventsAtSystemGroupBubble() {
117 EventListenerFlags flags
;
118 flags
.mInSystemGroup
= true;
122 inline EventListenerFlags
TrustedEventsAtSystemGroupCapture() {
123 EventListenerFlags flags
;
124 flags
.mCapture
= true;
125 flags
.mInSystemGroup
= true;
129 inline EventListenerFlags
AllEventsAtSystemGroupBubble() {
130 EventListenerFlags flags
;
131 flags
.mInSystemGroup
= true;
132 flags
.mAllowUntrustedEvents
= true;
136 inline EventListenerFlags
AllEventsAtSystemGroupCapture() {
137 EventListenerFlags flags
;
138 flags
.mCapture
= true;
139 flags
.mInSystemGroup
= true;
140 flags
.mAllowUntrustedEvents
= true;
144 class EventListenerManagerBase
{
146 EventListenerManagerBase();
148 EventMessage mNoListenerForEvent
;
149 uint16_t mMayHavePaintEventListener
: 1;
150 uint16_t mMayHaveMutationListeners
: 1;
151 uint16_t mMayHaveCapturingListeners
: 1;
152 uint16_t mMayHaveSystemGroupListeners
: 1;
153 uint16_t mMayHaveTouchEventListener
: 1;
154 uint16_t mMayHaveMouseEnterLeaveEventListener
: 1;
155 uint16_t mMayHavePointerEnterLeaveEventListener
: 1;
156 uint16_t mMayHaveKeyEventListener
: 1;
157 uint16_t mMayHaveInputOrCompositionEventListener
: 1;
158 uint16_t mMayHaveSelectionChangeEventListener
: 1;
159 uint16_t mMayHaveFormSelectEventListener
: 1;
160 uint16_t mMayHaveTransitionEventListener
: 1;
161 uint16_t mClearingListeners
: 1;
162 uint16_t mIsMainThreadELM
: 1;
163 uint16_t mHasNonPrivilegedClickListeners
: 1;
164 uint16_t mUnknownNonPrivilegedClickListeners
: 1;
168 * Event listener manager
171 class EventListenerManager final
: public EventListenerManagerBase
{
172 ~EventListenerManager();
176 class ListenerSignalFollower
: public dom::AbortFollower
{
178 explicit ListenerSignalFollower(EventListenerManager
* aListenerManager
,
179 Listener
* aListener
);
181 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
182 NS_DECL_CYCLE_COLLECTION_CLASS(ListenerSignalFollower
)
184 void RunAbortAlgorithm() override
;
187 mListenerManager
= nullptr;
193 ~ListenerSignalFollower() = default;
195 EventListenerManager
* mListenerManager
;
196 EventListenerHolder mListener
;
197 RefPtr
<nsAtom
> mTypeAtom
;
198 EventMessage mEventMessage
;
200 EventListenerFlags mFlags
;
204 RefPtr
<ListenerSignalFollower
> mSignalFollower
;
205 EventListenerHolder mListener
;
206 RefPtr
<nsAtom
> mTypeAtom
;
207 EventMessage mEventMessage
;
209 enum ListenerType
: uint8_t {
212 // A generic C++ implementation of nsIDOMEventListener.
214 // An event handler attribute using JSEventHandler.
216 // A scripted EventListener.
219 ListenerType mListenerType
;
221 bool mListenerIsHandler
: 1;
222 bool mHandlerIsString
: 1;
227 EventListenerFlags mFlags
;
229 JSEventHandler
* GetJSEventHandler() const {
230 return (mListenerType
== eJSEventListener
)
231 ? static_cast<JSEventHandler
*>(mListener
.GetXPCOMCallback())
236 : mEventMessage(eVoidEvent
),
237 mListenerType(eNoListener
),
238 mListenerIsHandler(false),
239 mHandlerIsString(false),
244 Listener(Listener
&& aOther
)
245 : mSignalFollower(std::move(aOther
.mSignalFollower
)),
246 mListener(std::move(aOther
.mListener
)),
247 mTypeAtom(std::move(aOther
.mTypeAtom
)),
248 mEventMessage(aOther
.mEventMessage
),
249 mListenerType(aOther
.mListenerType
),
250 mListenerIsHandler(aOther
.mListenerIsHandler
),
251 mHandlerIsString(aOther
.mHandlerIsString
),
252 mAllEvents(aOther
.mAllEvents
),
253 mIsChrome(aOther
.mIsChrome
),
254 mEnabled(aOther
.mEnabled
) {
255 aOther
.mEventMessage
= eVoidEvent
;
256 aOther
.mListenerType
= eNoListener
;
257 aOther
.mListenerIsHandler
= false;
258 aOther
.mHandlerIsString
= false;
259 aOther
.mAllEvents
= false;
260 aOther
.mIsChrome
= false;
261 aOther
.mEnabled
= true;
265 if ((mListenerType
== eJSEventListener
) && mListener
) {
266 static_cast<JSEventHandler
*>(mListener
.GetXPCOMCallback())
269 if (mSignalFollower
) {
270 mSignalFollower
->Disconnect();
274 MOZ_ALWAYS_INLINE
bool IsListening(const WidgetEvent
* aEvent
) const {
275 if (mFlags
.mInSystemGroup
!= aEvent
->mFlags
.mInSystemGroup
) {
278 // FIXME Should check !mFlags.mCapture when the event is in target
279 // phase because capture phase event listeners should not be fired.
280 // But it breaks at least <xul:dialog>'s buttons. Bug 235441.
281 return ((mFlags
.mCapture
&& aEvent
->mFlags
.mInCapturePhase
) ||
282 (!mFlags
.mCapture
&& aEvent
->mFlags
.mInBubblingPhase
));
286 explicit EventListenerManager(dom::EventTarget
* aTarget
);
288 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(EventListenerManager
)
290 NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(EventListenerManager
)
292 void AddEventListener(const nsAString
& aType
, nsIDOMEventListener
* aListener
,
293 bool aUseCapture
, bool aWantsUntrusted
) {
294 AddEventListener(aType
, EventListenerHolder(aListener
), aUseCapture
,
297 void AddEventListener(const nsAString
& aType
, dom::EventListener
* aListener
,
298 const dom::AddEventListenerOptionsOrBoolean
& aOptions
,
299 bool aWantsUntrusted
) {
300 AddEventListener(aType
, EventListenerHolder(aListener
), aOptions
,
303 void RemoveEventListener(const nsAString
& aType
,
304 nsIDOMEventListener
* aListener
, bool aUseCapture
) {
305 RemoveEventListener(aType
, EventListenerHolder(aListener
), aUseCapture
);
307 void RemoveEventListener(const nsAString
& aType
,
308 dom::EventListener
* aListener
,
309 const dom::EventListenerOptionsOrBoolean
& aOptions
) {
310 RemoveEventListener(aType
, EventListenerHolder(aListener
), aOptions
);
313 void AddListenerForAllEvents(dom::EventListener
* aListener
, bool aUseCapture
,
314 bool aWantsUntrusted
, bool aSystemEventGroup
);
315 void RemoveListenerForAllEvents(dom::EventListener
* aListener
,
316 bool aUseCapture
, bool aSystemEventGroup
);
319 * Sets events listeners of all types.
320 * @param an event listener
322 void AddEventListenerByType(nsIDOMEventListener
* aListener
,
323 const nsAString
& type
,
324 const EventListenerFlags
& aFlags
) {
325 AddEventListenerByType(EventListenerHolder(aListener
), type
, aFlags
);
327 void AddEventListenerByType(dom::EventListener
* aListener
,
328 const nsAString
& type
,
329 const EventListenerFlags
& aFlags
) {
330 AddEventListenerByType(EventListenerHolder(aListener
), type
, aFlags
);
332 void AddEventListenerByType(
333 EventListenerHolder aListener
, const nsAString
& type
,
334 const EventListenerFlags
& aFlags
,
335 const dom::Optional
<bool>& aPassive
= dom::Optional
<bool>(),
336 dom::AbortSignal
* aSignal
= nullptr);
337 void RemoveEventListenerByType(nsIDOMEventListener
* aListener
,
338 const nsAString
& type
,
339 const EventListenerFlags
& aFlags
) {
340 RemoveEventListenerByType(EventListenerHolder(aListener
), type
, aFlags
);
342 void RemoveEventListenerByType(dom::EventListener
* aListener
,
343 const nsAString
& type
,
344 const EventListenerFlags
& aFlags
) {
345 RemoveEventListenerByType(EventListenerHolder(aListener
), type
, aFlags
);
347 void RemoveEventListenerByType(EventListenerHolder aListener
,
348 const nsAString
& type
,
349 const EventListenerFlags
& aFlags
);
352 * Sets the current "inline" event listener for aName to be a
353 * function compiled from aFunc if !aDeferCompilation. If
354 * aDeferCompilation, then we assume that we can get the string from
355 * mTarget later and compile lazily.
357 * aElement, if not null, is the element the string is associated with.
359 // XXXbz does that play correctly with nodes being adopted across
360 // documents? Need to double-check the spec here.
361 nsresult
SetEventHandler(nsAtom
* aName
, const nsAString
& aFunc
,
362 bool aDeferCompilation
, bool aPermitUntrustedEvents
,
363 dom::Element
* aElement
);
365 * Remove the current "inline" event listener for aName.
367 void RemoveEventHandler(nsAtom
* aName
);
369 // We only get called from the event dispatch code, which knows to be careful
370 // with what it's doing. We could annotate ourselves as MOZ_CAN_RUN_SCRIPT,
371 // but then the event dispatch code would need a ton of MOZ_KnownLive for
372 // things that come from slightly complicated stack-lifetime data structures.
373 MOZ_CAN_RUN_SCRIPT_BOUNDARY
374 void HandleEvent(nsPresContext
* aPresContext
, WidgetEvent
* aEvent
,
375 dom::Event
** aDOMEvent
, dom::EventTarget
* aCurrentTarget
,
376 nsEventStatus
* aEventStatus
, bool aItemInShadowTree
) {
377 if (mListeners
.IsEmpty() || aEvent
->PropagationStopped()) {
381 if (!mMayHaveCapturingListeners
&& !aEvent
->mFlags
.mInBubblingPhase
) {
385 if (!mMayHaveSystemGroupListeners
&& aEvent
->mFlags
.mInSystemGroup
) {
389 // Check if we already know that there is no event listener for the event.
390 if (mNoListenerForEvent
== aEvent
->mMessage
&&
391 (mNoListenerForEvent
!= eUnidentifiedEvent
||
392 mNoListenerForEventAtom
== aEvent
->mSpecifiedEventType
)) {
395 HandleEventInternal(aPresContext
, aEvent
, aDOMEvent
, aCurrentTarget
,
396 aEventStatus
, aItemInShadowTree
);
400 * Tells the event listener manager that its target (which owns it) is
401 * no longer using it (and could go away).
406 * Allows us to quickly determine if we have mutation listeners registered.
408 bool HasMutationListeners();
411 * Allows us to quickly determine whether we have unload listeners registered.
413 bool HasUnloadListeners();
416 * Allows us to quickly determine whether we have beforeunload listeners
419 bool HasBeforeUnloadListeners();
422 * Returns the mutation bits depending on which mutation listeners are
423 * registered to this listener manager.
424 * @note If a listener is an nsIDOMMutationListener, all possible mutation
425 * event bits are returned. All bits are also returned if one of the
426 * event listeners is registered to handle DOMSubtreeModified events.
428 uint32_t MutationListenerBits();
431 * Returns true if there is at least one event listener for aEventName.
433 bool HasListenersFor(const nsAString
& aEventName
) const;
436 * Returns true if there is at least one event listener for aEventNameWithOn.
437 * Note that aEventNameWithOn must start with "on"!
439 bool HasListenersFor(nsAtom
* aEventNameWithOn
) const;
442 * Similar to HasListenersFor, but ignores system group listeners.
444 bool HasNonSystemGroupListenersFor(nsAtom
* aEventNameWithOn
) const;
447 * Returns true if there is at least one event listener.
449 bool HasListeners() const;
452 * Sets aList to the list of nsIEventListenerInfo objects representing the
453 * listeners managed by this listener manager.
455 nsresult
GetListenerInfo(nsTArray
<RefPtr
<nsIEventListenerInfo
>>& aList
);
457 nsresult
IsListenerEnabled(nsAString
& aType
, JSObject
* aListener
,
458 bool aCapturing
, bool aAllowsUntrusted
,
459 bool aInSystemEventGroup
, bool aIsHandler
,
462 nsresult
SetListenerEnabled(nsAString
& aType
, JSObject
* aListener
,
463 bool aCapturing
, bool aAllowsUntrusted
,
464 bool aInSystemEventGroup
, bool aIsHandler
,
467 uint32_t GetIdentifierForEvent(nsAtom
* aEvent
);
470 * Returns true if there may be a paint event listener registered,
471 * false if there definitely isn't.
473 bool MayHavePaintEventListener() const { return mMayHavePaintEventListener
; }
476 * Returns true if there may be a touch event listener registered,
477 * false if there definitely isn't.
479 bool MayHaveTouchEventListener() const { return mMayHaveTouchEventListener
; }
481 bool MayHaveMouseEnterLeaveEventListener() const {
482 return mMayHaveMouseEnterLeaveEventListener
;
484 bool MayHavePointerEnterLeaveEventListener() const {
485 return mMayHavePointerEnterLeaveEventListener
;
487 bool MayHaveSelectionChangeEventListener() const {
488 return mMayHaveSelectionChangeEventListener
;
490 bool MayHaveFormSelectEventListener() const {
491 return mMayHaveFormSelectEventListener
;
493 bool MayHaveTransitionEventListener() {
494 return mMayHaveTransitionEventListener
;
497 bool HasNonPrivilegedClickListeners();
500 * Returns true if there may be a key event listener (keydown, keypress,
501 * or keyup) registered, or false if there definitely isn't.
503 bool MayHaveKeyEventListener() const { return mMayHaveKeyEventListener
; }
506 * Returns true if there may be an advanced input event listener (input,
507 * compositionstart, compositionupdate, or compositionend) registered,
508 * or false if there definitely isn't.
510 bool MayHaveInputOrCompositionEventListener() const {
511 return mMayHaveInputOrCompositionEventListener
;
514 size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf
) const;
516 uint32_t ListenerCount() const { return mListeners
.Length(); }
520 void TraceListeners(JSTracer
* aTrc
);
522 dom::EventTarget
* GetTarget() { return mTarget
; }
524 bool HasNonSystemGroupListenersForUntrustedKeyEvents();
525 bool HasNonPassiveNonSystemGroupListenersForUntrustedKeyEvents();
527 bool HasApzAwareListeners();
528 bool IsApzAwareListener(Listener
* aListener
);
529 bool IsApzAwareEvent(nsAtom
* aEvent
);
531 bool HasNonPassiveWheelListener();
533 // Return true if aListener is a non-chrome-privileged click event listner
534 bool IsNonChromeClickListener(Listener
* aListener
);
536 * Remove all event listeners from the event target this EventListenerManager
539 void RemoveAllListeners();
543 void HandleEventInternal(nsPresContext
* aPresContext
, WidgetEvent
* aEvent
,
544 dom::Event
** aDOMEvent
,
545 dom::EventTarget
* aCurrentTarget
,
546 nsEventStatus
* aEventStatus
, bool aItemInShadowTree
);
549 nsresult
HandleEventSubType(Listener
* aListener
, dom::Event
* aDOMEvent
,
550 dom::EventTarget
* aCurrentTarget
);
553 * If the given EventMessage has a legacy version that we support, then this
554 * function returns that legacy version. Otherwise, this function simply
555 * returns the passed-in EventMessage.
557 EventMessage
GetLegacyEventMessage(EventMessage aEventMessage
) const;
560 * Get the event message for the given event name.
562 EventMessage
GetEventMessage(nsAtom
* aEventName
) const;
565 * Get the event message and atom for the given event type.
567 EventMessage
GetEventMessageAndAtomForListener(const nsAString
& aType
,
570 void ProcessApzAwareEventListenerAdd();
573 * Compile the "inline" event listener for aListener. The
574 * body of the listener can be provided in aBody; if this is null we
575 * will look for it on mTarget. If aBody is provided, aElement should be
576 * as well; otherwise it will also be inferred from mTarget.
578 nsresult
CompileEventHandlerInternal(Listener
* aListener
,
579 const nsAString
* aBody
,
580 dom::Element
* aElement
);
583 * Find the Listener for the "inline" event listener for aTypeAtom.
585 Listener
* FindEventHandler(EventMessage aEventMessage
, nsAtom
* aTypeAtom
);
588 * Set the "inline" event listener for aName to aHandler. aHandler may be
589 * have no actual handler set to indicate that we should lazily get and
590 * compile the string for this listener, but in that case aContext and
591 * aScopeGlobal must be non-null. Otherwise, aContext and aScopeGlobal are
592 * allowed to be null.
594 Listener
* SetEventHandlerInternal(nsAtom
* aName
,
595 const TypedEventHandler
& aHandler
,
596 bool aPermitUntrustedEvents
);
598 bool IsDeviceType(EventMessage aEventMessage
);
599 void EnableDevice(EventMessage aEventMessage
);
600 void DisableDevice(EventMessage aEventMessage
);
602 bool HasListenersForInternal(nsAtom
* aEventNameWithOn
,
603 bool aIgnoreSystemGroup
) const;
605 Listener
* GetListenerFor(nsAString
& aType
, JSObject
* aListener
,
606 bool aCapturing
, bool aAllowsUntrusted
,
607 bool aInSystemEventGroup
, bool aIsHandler
);
611 * Set the "inline" event listener for aEventName to aHandler. If
612 * aHandler is null, this will actually remove the event listener
614 void SetEventHandler(nsAtom
* aEventName
, dom::EventHandlerNonNull
* aHandler
);
615 void SetEventHandler(dom::OnErrorEventHandlerNonNull
* aHandler
);
616 void SetEventHandler(dom::OnBeforeUnloadEventHandlerNonNull
* aHandler
);
619 * Get the value of the "inline" event listener for aEventName.
620 * This may cause lazy compilation if the listener is uncompiled.
622 * Note: It's the caller's responsibility to make sure to call the right one
623 * of these methods. In particular, "onerror" events use
624 * OnErrorEventHandlerNonNull for some event targets and EventHandlerNonNull
627 dom::EventHandlerNonNull
* GetEventHandler(nsAtom
* aEventName
) {
628 const TypedEventHandler
* typedHandler
= GetTypedEventHandler(aEventName
);
629 return typedHandler
? typedHandler
->NormalEventHandler() : nullptr;
632 dom::OnErrorEventHandlerNonNull
* GetOnErrorEventHandler() {
633 const TypedEventHandler
* typedHandler
=
634 GetTypedEventHandler(nsGkAtoms::onerror
);
635 return typedHandler
? typedHandler
->OnErrorEventHandler() : nullptr;
638 dom::OnBeforeUnloadEventHandlerNonNull
* GetOnBeforeUnloadEventHandler() {
639 const TypedEventHandler
* typedHandler
=
640 GetTypedEventHandler(nsGkAtoms::onbeforeunload
);
641 return typedHandler
? typedHandler
->OnBeforeUnloadEventHandler() : nullptr;
645 already_AddRefed
<nsPIDOMWindowInner
> WindowFromListener(
646 Listener
* aListener
, bool aItemInShadowTree
);
650 * Helper method for implementing the various Get*EventHandler above. Will
651 * return null if we don't have an event handler for this event name.
653 const TypedEventHandler
* GetTypedEventHandler(nsAtom
* aEventName
);
655 void AddEventListener(const nsAString
& aType
, EventListenerHolder aListener
,
656 const dom::AddEventListenerOptionsOrBoolean
& aOptions
,
657 bool aWantsUntrusted
);
658 void AddEventListener(const nsAString
& aType
, EventListenerHolder aListener
,
659 bool aUseCapture
, bool aWantsUntrusted
);
660 void RemoveEventListener(const nsAString
& aType
,
661 EventListenerHolder aListener
,
662 const dom::EventListenerOptionsOrBoolean
& aOptions
);
663 void RemoveEventListener(const nsAString
& aType
,
664 EventListenerHolder aListener
, bool aUseCapture
);
666 void AddEventListenerInternal(EventListenerHolder aListener
,
667 EventMessage aEventMessage
, nsAtom
* aTypeAtom
,
668 const EventListenerFlags
& aFlags
,
669 bool aHandler
= false, bool aAllEvents
= false,
670 dom::AbortSignal
* aSignal
= nullptr);
671 void RemoveEventListenerInternal(EventListenerHolder aListener
,
672 EventMessage aEventMessage
,
674 const EventListenerFlags
& aFlags
,
675 bool aAllEvents
= false);
676 void RemoveAllListenersSilently();
677 void NotifyEventListenerRemoved(nsAtom
* aUserType
);
678 const EventTypeData
* GetTypeDataForIID(const nsIID
& aIID
);
679 const EventTypeData
* GetTypeDataForEventName(nsAtom
* aName
);
680 nsPIDOMWindowInner
* GetInnerWindowForTarget();
681 already_AddRefed
<nsPIDOMWindowInner
> GetTargetAsInnerWindow() const;
683 bool ListenerCanHandle(const Listener
* aListener
, const WidgetEvent
* aEvent
,
684 EventMessage aEventMessage
) const;
686 // BE AWARE, a lot of instances of EventListenerManager will be created.
687 // Therefor, we need to keep this class compact. When you add integer
688 // members, please add them to EventListemerManagerBase and check the size
691 already_AddRefed
<nsIScriptGlobalObject
> GetScriptGlobalAndDocument(
692 mozilla::dom::Document
** aDoc
);
694 void MaybeMarkPassive(EventMessage aMessage
, EventListenerFlags
& aFlags
);
696 nsAutoTObserverArray
<Listener
, 2> mListeners
;
697 dom::EventTarget
* MOZ_NON_OWNING_REF mTarget
;
698 RefPtr
<nsAtom
> mNoListenerForEventAtom
;
700 friend class ELMCreationDetector
;
701 static uint32_t sMainThreadCreatedCount
;
704 } // namespace mozilla
706 #endif // mozilla_EventListenerManager_h_