Back to index

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

#include <nsXBLWindowDragHandler.h>

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

List of all members.

Public Member Functions

 nsXBLWindowDragHandler (nsIDOMEventReceiver *aReceiver)
virtual ~nsXBLWindowDragHandler ()
NS_IMETHOD HandleEvent (nsIDOMEvent *aEvent)
NS_IMETHOD DragGesture (nsIDOMEvent *aMouseEvent)
 Processes a drag gesture event.
NS_IMETHOD DragOver (nsIDOMEvent *aMouseEvent)
 Processes a drag over event.
NS_IMETHOD DragEnter (nsIDOMEvent *aMouseEvent)
 Processes a drag enter event.
NS_IMETHOD DragExit (nsIDOMEvent *aMouseEvent)
 Processes a drag Exit event.
NS_IMETHOD DragDrop (nsIDOMEvent *aMouseEvent)
 Processes a drag drop event.
void handleEvent (in nsIDOMEvent event)
 This method is called whenever an event occurs of the type for which the EventListener interface was registered.

Protected Member Functions

NS_IMETHOD WalkHandlers (nsIDOMEvent *aKeyEvent, nsIAtom *aEventType)
PRBool EventMatched (nsXBLPrototypeHandler *inHandler, nsIAtom *inEventType, nsIDOMEvent *inEvent)
PRBool IsEditor ()
virtual nsresult EnsureHandlers (PRBool *aIsEditor)
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 nsXBLWindowDragHandler.h.


Constructor & Destructor Documentation

Definition at line 55 of file nsXBLWindowDragHandler.cpp.

  : nsXBLWindowHandler(nsnull, aReceiver)
{
}

Definition at line 60 of file nsXBLWindowDragHandler.cpp.

{
}

Member Function Documentation

Processes a drag drop event.

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

Implements nsIDOMDragListener.

Definition at line 125 of file nsXBLWindowDragHandler.cpp.

{
  return WalkHandlers(aDragEvent, nsXBLAtoms::dragdrop);
}

Here is the call graph for this function:

Processes a drag enter event.

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

Implements nsIDOMDragListener.

Definition at line 107 of file nsXBLWindowDragHandler.cpp.

{
  return WalkHandlers(aDragEvent, nsXBLAtoms::dragenter);
}

Here is the call graph for this function:

Processes a drag Exit event.

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

Implements nsIDOMDragListener.

Definition at line 113 of file nsXBLWindowDragHandler.cpp.

{
  return WalkHandlers(aDragEvent, nsXBLAtoms::dragexit);
}

Here is the call graph for this function:

Processes a drag gesture event.

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

Implements nsIDOMDragListener.

Definition at line 101 of file nsXBLWindowDragHandler.cpp.

{
  return WalkHandlers(aDragEvent, nsXBLAtoms::draggesture);
}

Here is the call graph for this function:

Processes a drag over event.

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

Implements nsIDOMDragListener.

Definition at line 119 of file nsXBLWindowDragHandler.cpp.

{
  return WalkHandlers(aDragEvent, nsXBLAtoms::dragevent);
}

Here is the call graph for this function:

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

Reimplemented in nsXBLWindowKeyHandler.

Definition at line 364 of file nsXBLWindowHandler.cpp.

{
  if (!sXBLSpecialDocInfo)
    sXBLSpecialDocInfo = new nsXBLSpecialDocInfo();    
  if (!sXBLSpecialDocInfo) {
    if (aIsEditor) {
      *aIsEditor = PR_FALSE;
    }
    return NS_ERROR_OUT_OF_MEMORY;
  }
  sXBLSpecialDocInfo->LoadDocInfo();

  // 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:

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

Implements nsXBLWindowHandler.

Definition at line 137 of file nsXBLWindowDragHandler.cpp.

{
  nsCOMPtr<nsIDOMMouseEvent> dragEvent ( do_QueryInterface(inEvent) );
  if ( dragEvent )
    return inHandler->MouseEventMatched(inEventType, dragEvent);
  
  return PR_FALSE;
}

Here is the call graph for this function:

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 58 of file nsXBLWindowDragHandler.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:

NS_IMETHODIMP nsXBLWindowDragHandler::WalkHandlers ( nsIDOMEvent aKeyEvent,
nsIAtom aEventType 
) [protected]

Definition at line 68 of file nsXBLWindowDragHandler.cpp.

{
  nsCOMPtr<nsIDOMNSUIEvent> evt = do_QueryInterface(aDragEvent);
  PRBool prevent;
  evt->GetPreventDefault(&prevent);
  if (prevent)
    return NS_OK;

  // Make sure our event is really a mouse event
  nsCOMPtr<nsIDOMMouseEvent> dragEvent(do_QueryInterface(aDragEvent));
  if (!dragEvent)
    return NS_OK;

  nsresult rv = EnsureHandlers(nsnull);
  NS_ENSURE_SUCCESS(rv, rv);
  
  WalkHandlersInternal(aDragEvent, aEventType, mHandler);
  
  return NS_OK;
}

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, 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: