Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
nsDOMEventRTTearoff Class Reference

nsDOMEventRTTearoff is a tearoff class used by nsGenericElement and nsGenericDOMDataNode classes for implementing the interfaces nsIDOMEventReceiver and nsIDOMEventTarget More...

#include <nsGenericElement.h>

Inheritance diagram for nsDOMEventRTTearoff:
Inheritance graph
[legend]
Collaboration diagram for nsDOMEventRTTearoff:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual ~nsDOMEventRTTearoff ()
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMEVENTTARGET
NS_DECL_NSIDOM3EVENTTARGET
NS_IMETHOD 
AddEventListenerByIID (nsIDOMEventListener *aListener, const nsIID &aIID)
NS_IMETHOD RemoveEventListenerByIID (nsIDOMEventListener *aListener, const nsIID &aIID)
NS_IMETHOD GetListenerManager (nsIEventListenerManager **aResult)
NS_IMETHOD HandleEvent (nsIDOMEvent *aEvent)
NS_IMETHOD GetSystemEventGroup (nsIDOMEventGroup **aGroup)
void addEventListener (in DOMString type, in nsIDOMEventListener listener, in boolean useCapture)
 This method allows the registration of event listeners on the event target.
void removeEventListener (in DOMString type, in nsIDOMEventListener listener, in boolean useCapture)
 This method allows the removal of event listeners from the event target.
boolean dispatchEvent (in nsIDOMEvent evt) raises (DOMException)
 This method allows the dispatch of events into the implementations event model.
void addGroupedEventListener (in DOMString type, in nsIDOMEventListener listener, in boolean useCapture, in nsIDOMEventGroup evtGroup)
void removeGroupedEventListener (in DOMString type, in nsIDOMEventListener listener, in boolean useCapture, in nsIDOMEventGroup evtGroup)
boolean canTrigger (in DOMString type)
boolean isRegisteredHere (in DOMString type)
void addEventListener (in DOMString type, in nsIDOMEventListener listener, in boolean useCapture, in boolean wantsUntrusted)
 This method is the same as the addEventListener() method defined in nsIDOMEventTarget, but it takes one additional argument which lets callers control whether or not they want to receive untrusted events (synthetic events generated by untrusted code)

Static Public Member Functions

static nsDOMEventRTTearoffCreate (nsIContent *aContent)
 Use this static method to create instances of nsDOMEventRTTearoff.
static void Shutdown ()
 Call before shutdown to clear the cache and free memory for this class.

Private Member Functions

 nsDOMEventRTTearoff (nsIContent *aContent)
void LastRelease ()
 This method gets called by Release() when it's time to delete the this object, in stead of always deleting the object we'll put the object in the cache if unless the cache is already full.
nsresult GetEventReceiver (nsIDOMEventReceiver **aReceiver)
nsresult GetDOM3EventTarget (nsIDOM3EventTarget **aTarget)

Private Attributes

nsCOMPtr< nsIContentmContent
 Strong reference back to the content object from where an instance of this class was 'torn off'.

Static Private Attributes

static nsDOMEventRTTearoffmCachedEventTearoff [NS_EVENT_TEAROFF_CACHE_SIZE]
static PRUint32 mCachedEventTearoffCount = 0

Detailed Description

nsDOMEventRTTearoff is a tearoff class used by nsGenericElement and nsGenericDOMDataNode classes for implementing the interfaces nsIDOMEventReceiver and nsIDOMEventTarget

Use the method nsDOMEventRTTearoff::Create() to create one of these babies.

See also:
nsDOMEventRTTearoff::Create

Definition at line 281 of file nsGenericElement.h.


Constructor & Destructor Documentation

Definition at line 526 of file nsGenericElement.cpp.

  : mContent(aContent)
{
}

Definition at line 531 of file nsGenericElement.cpp.

{
}

Member Function Documentation

void nsIDOMNSEventTarget::addEventListener ( in DOMString  type,
in nsIDOMEventListener  listener,
in boolean  useCapture,
in boolean  wantsUntrusted 
) [inherited]

This method is the same as the addEventListener() method defined in nsIDOMEventTarget, but it takes one additional argument which lets callers control whether or not they want to receive untrusted events (synthetic events generated by untrusted code)

Parameters:
typeSee the type argument to the same method in nsIDOMEventTarget.
listenerSee the listener argument to the same method in nsIDOMEventTarget.
useCaptureSee the listener argument to the same method in nsIDOMEventTarget.
wantsUntrustedIf false, the listener will not receive any untrusted events (see above), if true, the listener will receive events whether or not they're trusted
void nsIDOMEventTarget::addEventListener ( in DOMString  type,
in nsIDOMEventListener  listener,
in boolean  useCapture 
) [inherited]

This method allows the registration of event listeners on the event target.

If an EventListener is added to an EventTarget while it is processing an event, it will not be triggered by the current actions but may be triggered during a later stage of event flow, such as the bubbling phase.

If multiple identical EventListeners are registered on the same EventTarget with the same parameters the duplicate instances are discarded. They do not cause the EventListener to be called twice and since they are discarded they do not need to be removed with the removeEventListener method.

Parameters:
typeThe event type for which the user is registering
listenerThe listener parameter takes an interface implemented by the user which contains the methods to be called when the event occurs.
useCaptureIf true, useCapture indicates that the user wishes to initiate capture. After initiating capture, all events of the specified type will be dispatched to the registered EventListener before being dispatched to any EventTargets beneath them in the tree. Events which are bubbling upward through the tree will not trigger an EventListener designated to use capture.

Implements nsIDOMEventReceiver.

Definition at line 621 of file nsGenericElement.cpp.

{
  nsCOMPtr<nsIDOMEventReceiver> event_receiver;
  nsresult rv = GetEventReceiver(getter_AddRefs(event_receiver));
  NS_ENSURE_SUCCESS(rv, rv);

  return event_receiver->AddEventListenerByIID(aListener, aIID);
}

Here is the call graph for this function:

void nsIDOM3EventTarget::addGroupedEventListener ( in DOMString  type,
in nsIDOMEventListener  listener,
in boolean  useCapture,
in nsIDOMEventGroup  evtGroup 
) [inherited]
boolean nsIDOM3EventTarget::canTrigger ( in DOMString  type) [inherited]
nsDOMEventRTTearoff::Create ( nsIContent aContent) [static]

Use this static method to create instances of nsDOMEventRTTearoff.

Parameters:
aContentthe content to create a tearoff for

Definition at line 110 of file nsGenericDOMDataNode.cpp.

{
  return GetData(aNodeValue);
}

Here is the call graph for this function:

boolean nsIDOMEventTarget::dispatchEvent ( in nsIDOMEvent  evt) raises (DOMException) [inherited]

This method allows the dispatch of events into the implementations event model.

Events dispatched in this manner will have the same capturing and bubbling behavior as events dispatched directly by the implementation. The target of the event is the EventTarget on which dispatchEvent is called.

Parameters:
evtSpecifies the event type, behavior, and contextual information to be used in processing the event.
Returns:
Indicates whether any of the listeners which handled the event called preventDefault. If preventDefault was called the value is false, else the value is true.
Exceptions:
UNSPECIFIED_EVENT_TYPE_ERR,:Raised if the Event's type was not specified by initializing the event before dispatchEvent was called. Specification of the Event's type as null or an empty string will also trigger this exception.

Definition at line 611 of file nsGenericElement.cpp.

{
  nsCOMPtr<nsIEventListenerManager> listener_manager;
  nsresult rv = mContent->GetListenerManager(getter_AddRefs(listener_manager));
  NS_ENSURE_SUCCESS(rv, rv);

  return CallQueryInterface(listener_manager, aTarget);
}

Here is the call graph for this function:

Definition at line 601 of file nsGenericElement.cpp.

{
  nsCOMPtr<nsIEventListenerManager> listener_manager;
  nsresult rv = mContent->GetListenerManager(getter_AddRefs(listener_manager));
  NS_ENSURE_SUCCESS(rv, rv);

  return CallQueryInterface(listener_manager, aReceiver);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Implements nsIDOMEventReceiver.

Definition at line 643 of file nsGenericElement.cpp.

{
  return mContent->GetListenerManager(aResult);
}

Here is the caller graph for this function:

Implements nsIDOMEventReceiver.

Definition at line 659 of file nsGenericElement.cpp.

{
  nsCOMPtr<nsIEventListenerManager> manager;
  GetListenerManager(getter_AddRefs(manager));

  if (!manager) {
    return NS_ERROR_FAILURE;
  }

  return manager->GetSystemEventGroupLM(aGroup);
}

Here is the call graph for this function:

Implements nsIDOMEventReceiver.

Definition at line 649 of file nsGenericElement.cpp.

{
  nsCOMPtr<nsIDOMEventReceiver> event_receiver;
  nsresult rv = GetEventReceiver(getter_AddRefs(event_receiver));
  NS_ENSURE_SUCCESS(rv, rv);

  return event_receiver->HandleEvent(aEvent);
}

Here is the call graph for this function:

boolean nsIDOM3EventTarget::isRegisteredHere ( in DOMString  type) [inherited]

This method gets called by Release() when it's time to delete the this object, in stead of always deleting the object we'll put the object in the cache if unless the cache is already full.

Definition at line 575 of file nsGenericElement.cpp.

{
  if (mCachedEventTearoffCount < NS_EVENT_TEAROFF_CACHE_SIZE) {
    // There's still space in the cache for one more instance, put
    // this instance in the cache in stead of deleting it.
    mCachedEventTearoff[mCachedEventTearoffCount++] = this;

    // Don't set mContent to null directly since setting mContent to null
    // could result in code that grabs a tearoff from the cache and we don't
    // want to get reused while still being torn down.
    // See bug 330526.
    nsCOMPtr<nsIContent> kungFuDeathGrip;
    kungFuDeathGrip.swap(mContent);

    // The refcount balancing and destructor re-entrancy protection
    // code in Release() sets mRefCnt to 1 so we have to set it to 0
    // here to prevent leaks
    mRefCnt = 0;

    return;
  }

  delete this;
}

Here is the call graph for this function:

void nsIDOMEventTarget::removeEventListener ( in DOMString  type,
in nsIDOMEventListener  listener,
in boolean  useCapture 
) [inherited]

This method allows the removal of event listeners from the event target.

If an EventListener is removed from an EventTarget while it is processing an event, it will not be triggered by the current actions. EventListeners can never be invoked after being removed. Calling removeEventListener with arguments which do not identify any currently registered EventListener on the EventTarget has no effect.

Parameters:
typeSpecifies the event type of the EventListener being removed.
listenerThe EventListener parameter indicates the EventListener to be removed.
useCaptureSpecifies whether the EventListener being removed was registered as a capturing listener or not. If a listener was registered twice, one with capture and one without, each must be removed separately. Removal of a capturing listener does not affect a non-capturing version of the same listener, and vice versa.

Implements nsIDOMEventReceiver.

Definition at line 632 of file nsGenericElement.cpp.

{
  nsCOMPtr<nsIDOMEventReceiver> event_receiver;
  nsresult rv = GetEventReceiver(getter_AddRefs(event_receiver));
  NS_ENSURE_SUCCESS(rv, rv);

  return event_receiver->RemoveEventListenerByIID(aListener, aIID);
}

Here is the call graph for this function:

void nsIDOM3EventTarget::removeGroupedEventListener ( in DOMString  type,
in nsIDOMEventListener  listener,
in boolean  useCapture,
in nsIDOMEventGroup  evtGroup 
) [inherited]

Call before shutdown to clear the cache and free memory for this class.

Definition at line 566 of file nsGenericElement.cpp.

{
  // Clear our cache.
  while (mCachedEventTearoffCount) {
    delete mCachedEventTearoff[--mCachedEventTearoffCount];
  }
}

Member Data Documentation

Definition at line 294 of file nsGenericElement.h.

Definition at line 295 of file nsGenericElement.h.

Strong reference back to the content object from where an instance of this class was 'torn off'.

Definition at line 347 of file nsGenericElement.h.


The documentation for this class was generated from the following files: