Back to index

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

#include <nsXBLWindowKeyHandler.h>

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

List of all members.

Public Member Functions

 nsXBLWindowKeyHandler (nsIDOMElement *aElement, nsIDOMEventReceiver *aReceiver)
virtual ~nsXBLWindowKeyHandler ()
NS_IMETHOD HandleEvent (nsIDOMEvent *aEvent)
NS_IMETHOD KeyUp (nsIDOMEvent *aKeyEvent)
 Processes a key release event.
NS_IMETHOD KeyDown (nsIDOMEvent *aKeyEvent)
 Processes a key pressed event.
NS_IMETHOD KeyPress (nsIDOMEvent *aKeyEvent)
 Processes a key typed event.
void handleEvent (in nsIDOMEvent event)
 This method is called whenever an event occurs of the type for which the EventListener interface was registered.

Static Public Member Functions

static NS_DECL_ISUPPORTS NS_HIDDEN_ (void) ShutDown()

Protected Member Functions

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

Protected Attributes

nsCOMPtr< nsIBoxObjectmBoxObjectForElement
nsIDOMEventReceivermReceiver
nsXBLPrototypeHandlermHandler
nsXBLPrototypeHandlermUserHandler

Static Protected Attributes

static nsXBLSpecialDocInfosXBLSpecialDocInfo = nsnull

Detailed Description

Definition at line 50 of file nsXBLWindowKeyHandler.h.


Constructor & Destructor Documentation

Definition at line 65 of file nsXBLWindowKeyHandler.cpp.

  : nsXBLWindowHandler(aElement, aReceiver)
{
}

Definition at line 70 of file nsXBLWindowKeyHandler.cpp.

{
  // If mBoxObjectForElement is non-null, we created a prototype handler.
  if (mBoxObjectForElement)
    delete mHandler;
}

Member Function Documentation

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

Reimplemented from nsXBLWindowHandler.

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

Implements nsXBLWindowHandler.

Definition at line 215 of file nsXBLWindowHandler.cpp.

{
  if (!mBoxObjectForElement) {
    return nsnull;
  }
  nsCOMPtr<nsIDOMElement> element;
  mBoxObjectForElement->GetElement(getter_AddRefs(element));
  nsIDOMElement* el = nsnull;
  element.swap(el);
  return el;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 57 of file nsXBLWindowKeyHandler.h.

  {
    return NS_OK;
  };

This method is called whenever an event occurs of the type for which the EventListener interface was registered.

Parameters:
evtThe Event contains contextual information about the event. It also contains the stopPropagation and preventDefault methods which are used in determining the event's flow and default action.
PRBool nsXBLWindowHandler::IsEditor ( ) [protected, inherited]

Definition at line 233 of file nsXBLWindowHandler.cpp.

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

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

  if (presShell) {
    PRInt16 isEditor;
    presShell->GetSelectionFlags(&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:

Processes a key pressed event.

Parameters:
aKeyEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMKeyListener.

Processes a key typed event.

Parameters:
aKeyEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMKeyListener.

Processes a key release event.

Parameters:
aKeyEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMKeyListener.

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

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;
    privateEvent->IsDispatchStopped(&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(
           do_QueryInterface(elt->GetCurrentDoc()));
        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");
          continue;
        }
      }
    }

    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.

Definition at line 103 of file nsXBLWindowHandler.h.


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