Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Attributes
nsWindowRoot Class Reference

#include <nsWindowRoot.h>

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

List of all members.

Public Member Functions

 nsWindowRoot (nsIDOMWindow *aWindow)
virtual ~nsWindowRoot ()
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMEVENTTARGET
NS_DECL_NSIDOM3EVENTTARGET
NS_DECL_NSIDOMNSEVENTTARGET
NS_IMETHOD 
HandleChromeEvent (nsPresContext *aPresContext, nsEvent *aEvent, nsIDOMEvent **aDOMEvent, PRUint32 aFlags, nsEventStatus *aEventStatus)
NS_IMETHOD AddEventListenerByIID (nsIDOMEventListener *aListener, const nsIID &aIID)
NS_IMETHOD RemoveEventListenerByIID (nsIDOMEventListener *aListener, const nsIID &aIID)
NS_IMETHOD GetListenerManager (nsIEventListenerManager **aInstancePtrResult)
NS_IMETHOD HandleEvent (nsIDOMEvent *aEvent)
NS_IMETHOD GetSystemEventGroup (nsIDOMEventGroup **aGroup)
virtual nsIDOMGCParticipantGetSCCIndex ()
 Get a reference node for what is known to be a strongly connected component of nsIDOMGCParticipants.
virtual void AppendReachableList (nsCOMArray< nsIDOMGCParticipant > &aArray)
 Append the list of nsIDOMGCPartipants reachable from this one via C++ getters exposed to script that return a different result from |GetSCCIndex|.
NS_IMETHOD GetFocusController (nsIFocusController **aResult)
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)
void handleChromeEvent (in nsPresContext aPresContext, in nsEventPtr aEvent, out nsIDOMEvent aDOMEvent, in unsigned long aFlags, inout nsEventStatus aStatus)
 Handle a chrome DOM event.

Protected Attributes

nsIDOMWindowmWindow
nsCOMPtr< nsIEventListenerManagermListenerManager
nsCOMPtr< nsIFocusControllermFocusController

Detailed Description

Definition at line 59 of file nsWindowRoot.h.


Constructor & Destructor Documentation

Definition at line 59 of file nsWindowRoot.cpp.

{
  mWindow = aWindow;

  // Create and init our focus controller.
  nsFocusController::Create(getter_AddRefs(mFocusController));

  nsCOMPtr<nsIDOMFocusListener> focusListener(do_QueryInterface(mFocusController));
  ++mRefCnt;
  AddEventListener(NS_LITERAL_STRING("focus"), focusListener, PR_TRUE);
  AddEventListener(NS_LITERAL_STRING("blur"), focusListener, PR_TRUE);
  --mRefCnt;
}

Here is the call graph for this function:

Definition at line 73 of file nsWindowRoot.cpp.

{
  if (mListenerManager) {
    mListenerManager->Disconnect();
  }
}

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 188 of file nsWindowRoot.cpp.

{
  nsCOMPtr<nsIEventListenerManager> manager;
  GetListenerManager(getter_AddRefs(manager));
  if (manager) {
    manager->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
    return NS_OK;
  }
  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

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

Append the list of nsIDOMGCPartipants reachable from this one via C++ getters exposed to script that return a different result from |GetSCCIndex|.

The caller is responsible for taking the transitive closure of |AppendReachableList|.

This will only be called on objects that are returned by GetSCCIndex.

null pointers may be appended; they will be ignored by the caller.

Implements nsIDOMGCParticipant.

Definition at line 308 of file nsWindowRoot.cpp.

{
}
boolean nsIDOM3EventTarget::canTrigger ( in DOMString  type) [inherited]
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.

Implements nsPIWindowRoot.

Definition at line 313 of file nsWindowRoot.cpp.

{
  *aResult = mFocusController;
  NS_IF_ADDREF(*aResult);
  return NS_OK;
}

Implements nsIDOMEventReceiver.

Definition at line 212 of file nsWindowRoot.cpp.

{
  if (!mListenerManager) {
    nsresult rv;
    mListenerManager = do_CreateInstance(kEventListenerManagerCID, &rv);
    if (NS_FAILED(rv)) return rv;
    mListenerManager->SetListenerTarget(
      NS_STATIC_CAST(nsIDOMEventReceiver*, this));
  }

  *aResult = mListenerManager;
  NS_ADDREF(*aResult);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Get a reference node for what is known to be a strongly connected component of nsIDOMGCParticipants.

For example, DOM trees are strongly connected, so can return the root node to greatly reduce the number of nodes on which we need to run graph algorithms.

Note that it's acceptable for nodes in a single strongly connected component to return different values for GetSCCIndex, as long as those two values claim that they're reachable from each other in AppendReachableList.

Implements nsIDOMGCParticipant.

Definition at line 302 of file nsWindowRoot.cpp.

{
  return this;
}

Implements nsIDOMEventReceiver.

Definition at line 235 of file nsWindowRoot.cpp.

{
  nsCOMPtr<nsIEventListenerManager> manager;
  if (NS_SUCCEEDED(GetListenerManager(getter_AddRefs(manager))) && manager) {
    return manager->GetSystemEventGroupLM(aGroup);
  }
  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

void nsIChromeEventHandler::handleChromeEvent ( in nsPresContext  aPresContext,
in nsEventPtr  aEvent,
out nsIDOMEvent  aDOMEvent,
in unsigned long  aFlags,
inout nsEventStatus  aStatus 
) [inherited]

Handle a chrome DOM event.

NS_IMETHODIMP nsWindowRoot::HandleChromeEvent ( nsPresContext aPresContext,
nsEvent aEvent,
nsIDOMEvent **  aDOMEvent,
PRUint32  aFlags,
nsEventStatus aEventStatus 
)

Definition at line 245 of file nsWindowRoot.cpp.

{
  // Make sure to tell the event that dispatch has started.
  NS_MARK_EVENT_DISPATCH_STARTED(aEvent);

  // Prevent the world from going
  // away until after we've finished handling the event.
  nsCOMPtr<nsIDOMWindow> kungFuDeathGrip(mWindow);

  nsresult ret = NS_OK;
  nsIDOMEvent* domEvent = nsnull;

  // We're at the top, so there's no bubbling or capturing here.
  if (NS_EVENT_FLAG_INIT & aFlags) {
    aDOMEvent = &domEvent;
    aEvent->flags = aFlags;
    aFlags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL);
  }

  //Local handling stage
  if (mListenerManager && !(aEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH)) {
    aEvent->flags |= aFlags;
    mListenerManager->HandleEvent(aPresContext, aEvent, aDOMEvent, this, aFlags, aEventStatus);
    aEvent->flags &= ~aFlags;
  }

  if (NS_EVENT_FLAG_INIT & aFlags) {
    // We're leaving the DOM event loop so if we created a DOM event,
    // release here.
    if (nsnull != *aDOMEvent) {
      nsrefcnt rc;
      NS_RELEASE2(*aDOMEvent, rc);
      if (0 != rc) {
        // Okay, so someone in the DOM loop (a listener, JS object)
        // still has a ref to the DOM Event but the internal data
        // hasn't been malloc'd.  Force a copy of the data here so the
        // DOM Event is still valid.
        nsIPrivateDOMEvent *privateEvent;
        if (NS_OK == (*aDOMEvent)->QueryInterface(NS_GET_IID(nsIPrivateDOMEvent), (void**)&privateEvent)) {
          privateEvent->DuplicatePrivateData();
          NS_RELEASE(privateEvent);
        }
      }
    }
    aDOMEvent = nsnull;

    // Now that we're done with this event, remove the flag that says
    // we're in the process of dispatching this event.
    NS_MARK_EVENT_DISPATCH_DONE(aEvent);
  }

  return ret;
}

Here is the call graph for this function:

Implements nsIDOMEventReceiver.

Definition at line 228 of file nsWindowRoot.cpp.

{
  PRBool defaultActionEnabled;
  return DispatchEvent(aEvent, &defaultActionEnabled);
}
boolean nsIDOM3EventTarget::isRegisteredHere ( in DOMString  type) [inherited]
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 200 of file nsWindowRoot.cpp.

{
  nsCOMPtr<nsIEventListenerManager> manager;
  GetListenerManager(getter_AddRefs(manager));
  if (manager) {
    manager->RemoveEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
    return NS_OK;
  }
  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

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

Member Data Documentation

Definition at line 97 of file nsWindowRoot.h.

Definition at line 95 of file nsWindowRoot.h.

Definition at line 94 of file nsWindowRoot.h.


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