Back to index

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

#include <nsXBLWindowHandler.h>

Inheritance diagram for nsXBLWindowHandler:
Inheritance graph
Collaboration diagram for nsXBLWindowHandler:
Collaboration graph

List of all members.

Public Member Functions

 nsXBLWindowHandler (nsIDOMElement *aElement, nsIDOMEventReceiver *aReceiver)
virtual ~nsXBLWindowHandler ()

Protected Member Functions

PRBool IsEditor ()
virtual nsresult EnsureHandlers (PRBool *aIsEditor)
virtual nsresult WalkHandlersInternal (nsIDOMEvent *aKeyEvent, nsIAtom *aEventType, nsXBLPrototypeHandler *aHandler)
virtual PRBool EventMatched (nsXBLPrototypeHandler *inHandler, nsIAtom *inEventType, nsIDOMEvent *inEvent)=0
already_AddRefed< nsIDOMElementGetElement ()

Protected Attributes

nsCOMPtr< nsIBoxObjectmBoxObjectForElement

Static Protected Attributes

static nsXBLSpecialDocInfosXBLSpecialDocInfo = nsnull

Static Private Attributes

static PRUint32 sRefCnt = 0

Detailed Description

Definition at line 65 of file nsXBLWindowHandler.h.

Constructor & Destructor Documentation

Definition at line 180 of file nsXBLWindowHandler.cpp.

  : mReceiver(aReceiver),
  if (aElement) {
    nsCOMPtr<nsIDOMDocument> domDoc;
    nsCOMPtr<nsIDOMNSDocument> nsDomDoc = do_QueryInterface(domDoc);
    if (nsDomDoc) {
      nsDomDoc->GetBoxObjectFor(aElement, getter_AddRefs(mBoxObjectForElement));

Here is the call graph for this function:

Definition at line 204 of file nsXBLWindowHandler.cpp.

Member Function Documentation

nsresult nsXBLWindowHandler::EnsureHandlers ( PRBool aIsEditor) [protected, virtual]

Reimplemented in nsXBLWindowKeyHandler.

Definition at line 364 of file nsXBLWindowHandler.cpp.

  if (!sXBLSpecialDocInfo)
    sXBLSpecialDocInfo = new nsXBLSpecialDocInfo();    
  if (!sXBLSpecialDocInfo) {
    if (aIsEditor) {
      *aIsEditor = PR_FALSE;

  // Now determine which handlers we should be using.
  PRBool isEditor = IsEditor();
  if (isEditor) {
    sXBLSpecialDocInfo->GetAllHandlers("editor", &mHandler, &mUserHandler);
  else {
    sXBLSpecialDocInfo->GetAllHandlers("browser", &mHandler, &mUserHandler);

  if (aIsEditor)
    *aIsEditor = isEditor;

  return NS_OK;
} // EnsureHandlers

Here is the call graph for this function:

virtual PRBool nsXBLWindowHandler::EventMatched ( nsXBLPrototypeHandler inHandler,
nsIAtom inEventType,
nsIDOMEvent inEvent 
) [protected, pure virtual]

Implemented in nsXBLWindowKeyHandler, and nsXBLWindowDragHandler.

Here is the caller graph for this function:

Definition at line 215 of file nsXBLWindowHandler.cpp.

  if (!mBoxObjectForElement) {
    return nsnull;
  nsCOMPtr<nsIDOMElement> element;
  nsIDOMElement* el = nsnull;
  return el;

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 233 of file nsXBLWindowHandler.cpp.

  nsCOMPtr<nsPIWindowRoot> windowRoot(do_QueryInterface(mReceiver));
  nsCOMPtr<nsIFocusController> focusController;
  if (!focusController) {
    NS_WARNING("********* Something went wrong! No focus controller on the root!!!\n");
    return PR_FALSE;

  nsCOMPtr<nsIDOMWindowInternal> focusedWindow;
  if (!focusedWindow)
    return PR_FALSE;
  nsCOMPtr<nsIScriptGlobalObject> obj(do_QueryInterface(focusedWindow));
  nsIDocShell *docShell = obj->GetDocShell();
  nsCOMPtr<nsIPresShell> presShell;
  if (docShell)

  if (presShell) {
    PRInt16 isEditor;
    return isEditor == nsISelectionDisplay::DISPLAY_ALL;

  return PR_FALSE;
} // IsEditor

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXBLWindowHandler::WalkHandlersInternal ( nsIDOMEvent aKeyEvent,
nsIAtom aEventType,
nsXBLPrototypeHandler aHandler 
) [protected, virtual]

Definition at line 273 of file nsXBLWindowHandler.cpp.

  nsresult rv;
  nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(aEvent));
  // Try all of the handlers until we find one that matches the event.
  for (nsXBLPrototypeHandler *currHandler = aHandler; currHandler;
       currHandler = currHandler->GetNextHandler()) {
    PRBool stopped;
    if (stopped) {
      // The event is finished, don't execute any more handlers
      return NS_OK;

    if (!EventMatched(currHandler, aEventType, aEvent))
      continue;  // try the next one

    // Before executing this handler, check that it's not disabled,
    // and that it has something to do (oncommand of the <key> or its
    // <command> is non-empty).
    nsCOMPtr<nsIContent> elt = currHandler->GetHandlerElement();
    nsCOMPtr<nsIDOMElement> commandElt;

    // See if we're in a XUL doc.
    nsCOMPtr<nsIDOMElement> el = GetElement();
    if (el && elt) {
      // We are.  Obtain our command attribute.
      nsAutoString command;
      elt->GetAttr(kNameSpaceID_None, nsXULAtoms::command, command);
      if (!command.IsEmpty()) {
        // Locate the command element in question.  Note that we
        // know "elt" is in a doc if we're dealing with it here.
        NS_ASSERTION(elt->IsInDoc(), "elt must be in document");
        nsCOMPtr<nsIDOMDocument> domDoc(
        if (domDoc)
          domDoc->GetElementById(command, getter_AddRefs(commandElt));

        if (!commandElt) {
          NS_ERROR("A XUL <key> is observing a command that doesn't exist. Unable to execute key binding!\n");

    if (!commandElt) {
      commandElt = do_QueryInterface(elt);

    if (commandElt) {
      nsAutoString value;
      commandElt->GetAttribute(NS_LITERAL_STRING("disabled"), value);
      if (value.EqualsLiteral("true")) {
        continue;  // this handler is disabled, try the next one

      // Check that there is an oncommand handler
      commandElt->GetAttribute(NS_LITERAL_STRING("oncommand"), value);
      if (value.IsEmpty()) {
        continue;  // nothing to do

    nsCOMPtr<nsIDOMEventReceiver> rec;
    nsCOMPtr<nsIDOMElement> element = GetElement();
    if (element) {
      rec = do_QueryInterface(commandElt);
    } else {
      rec = mReceiver;

    rv = currHandler->ExecuteHandler(rec, aEvent);
    if (NS_SUCCEEDED(rv)) {
      return NS_OK;

  return NS_OK;
} // WalkHandlersInternal

Here is the call graph for this function:

Member Data Documentation

Definition at line 95 of file nsXBLWindowHandler.h.

Definition at line 100 of file nsXBLWindowHandler.h.

Definition at line 96 of file nsXBLWindowHandler.h.

Definition at line 101 of file nsXBLWindowHandler.h.

PRUint32 nsXBLWindowHandler::sRefCnt = 0 [static, private]

Definition at line 107 of file nsXBLWindowHandler.h.

Definition at line 103 of file nsXBLWindowHandler.h.

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