Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Static Protected Member Functions
nsSelectMoveScrollCommand Class Reference
Inheritance diagram for nsSelectMoveScrollCommand:
Inheritance graph
[legend]
Collaboration diagram for nsSelectMoveScrollCommand:
Collaboration graph
[legend]

List of all members.

Public Member Functions

boolean isCommandEnabled (in string aCommandName, in nsISupports aCommandContext)
 Returns true if the command is currently enabled.
void getCommandStateParams (in string aCommandName, in nsICommandParams aParams, in nsISupports aCommandContext)
void doCommand (in string aCommandName, in nsISupports aCommandContext)
 Execute the name command.
void doCommandParams (in string aCommandName, in nsICommandParams aParams, in nsISupports aCommandContext)

Protected Member Functions

virtual nsresult DoSelectCommand (const char *aCommandName, nsIDOMWindow *aWindow)
nsresult DoCommandBrowseWithCaretOn (const char *aCommandName, nsISelectionController *aSelectionController, nsIEventStateManager *aESM)
nsresult DoCommandBrowseWithCaretOff (const char *aCommandName, nsISelectionController *aSelectionController)

Static Protected Member Functions

static nsresult GetPresShellFromWindow (nsIDOMWindow *aWindow, nsIPresShell **aPresShell)
static nsresult GetSelectionControllerFromWindow (nsIDOMWindow *aWindow, nsISelectionController **aSelCon)
static nsresult GetEventStateManagerForWindow (nsIDOMWindow *aWindow, nsIEventStateManager **aEventStateManager)

Detailed Description

Definition at line 133 of file nsGlobalWindowCommands.cpp.


Member Function Documentation

void nsIControllerCommand::doCommand ( in string  aCommandName,
in nsISupports  aCommandContext 
) [inherited]

Execute the name command.

Parameters:
aCommandNamethe name of the command to execute.
aCommandContexta cookie held by the nsIControllerCommandTable, allowing the command to get some context information. The contents of this cookie are implementation-defined.
nsresult nsSelectMoveScrollCommand::DoCommandBrowseWithCaretOff ( const char *  aCommandName,
nsISelectionController aSelectionController 
) [protected]

Definition at line 326 of file nsGlobalWindowCommands.cpp.

{
  nsresult rv = NS_ERROR_NOT_IMPLEMENTED;

  if (!nsCRT::strcmp(aCommandName, sScrollTopString))   
    rv = aSelectionController->CompleteScroll(PR_FALSE);
  else if (!nsCRT::strcmp(aCommandName,sScrollBottomString))
    rv = aSelectionController->CompleteScroll(PR_TRUE);

  // cmd_MovePageUp/Down are used on Window/Unix. They move the caret
  // in caret browsing mode.
  else if (!nsCRT::strcmp(aCommandName, sMovePageUpString))
    rv = aSelectionController->ScrollPage(PR_FALSE);
  else if (!nsCRT::strcmp(aCommandName, sMovePageDownString))
    rv = aSelectionController->ScrollPage(PR_TRUE);
  // cmd_ScrollPageUp/Down are used on Mac. They do not move the
  // caret in caret browsing mode.
  else if (!nsCRT::strcmp(aCommandName, sScrollPageUpString))
    rv = aSelectionController->ScrollPage(PR_FALSE);
  else if (!nsCRT::strcmp(aCommandName, sScrollPageDownString))
    rv = aSelectionController->ScrollPage(PR_TRUE);

  else if (!nsCRT::strcmp(aCommandName, sScrollLineUpString))
    rv = aSelectionController->ScrollLine(PR_FALSE);
  else if (!nsCRT::strcmp(aCommandName, sScrollLineDownString))
    rv = aSelectionController->ScrollLine(PR_TRUE);
  else if (!nsCRT::strcmp(aCommandName, sScrollLeftString))
    rv = aSelectionController->ScrollHorizontal(PR_TRUE);
  else if (!nsCRT::strcmp(aCommandName, sScrollRightString))
    rv = aSelectionController->ScrollHorizontal(PR_FALSE);
  // cmd_beginLine/endLine with caret browsing off
  // will act as cmd_scrollTop/Bottom
  else if (!nsCRT::strcmp(aCommandName, sBeginLineString))
    rv = aSelectionController->CompleteScroll(PR_FALSE);
  else if (!nsCRT::strcmp(aCommandName, sEndLineString))
    rv = aSelectionController->CompleteScroll(PR_TRUE);

  return rv;
}

Here is the caller graph for this function:

nsresult nsSelectMoveScrollCommand::DoCommandBrowseWithCaretOn ( const char *  aCommandName,
nsISelectionController aSelectionController,
nsIEventStateManager aESM 
) [protected]

Definition at line 278 of file nsGlobalWindowCommands.cpp.

{
  nsresult rv = NS_ERROR_NOT_IMPLEMENTED;

  if (!nsCRT::strcmp(aCommandName, sScrollTopString))
    rv = aSelectionController->CompleteMove(PR_FALSE, PR_FALSE);
  else if (!nsCRT::strcmp(aCommandName,sScrollBottomString))
    rv = aSelectionController->CompleteMove(PR_TRUE, PR_FALSE);
  // cmd_MovePageUp/Down are used on Window/Unix. They move the caret
  // in caret browsing mode.
  else if (!nsCRT::strcmp(aCommandName, sMovePageUpString))
    rv = aSelectionController->PageMove(PR_FALSE, PR_FALSE);
  else if (!nsCRT::strcmp(aCommandName, sMovePageDownString))
    rv = aSelectionController->PageMove(PR_TRUE, PR_FALSE);
  // cmd_ScrollPageUp/Down are used on Mac, and for the spacebar on all platforms.
  // They do not move the caret in caret browsing mode.
  else if (!nsCRT::strcmp(aCommandName, sScrollPageUpString))
    rv = aSelectionController->ScrollPage(PR_FALSE);
  else if (!nsCRT::strcmp(aCommandName, sScrollPageDownString))
    rv = aSelectionController->ScrollPage(PR_TRUE);
  else if (!nsCRT::strcmp(aCommandName, sScrollLineUpString))
    rv = aSelectionController->LineMove(PR_FALSE, PR_FALSE);
  else if (!nsCRT::strcmp(aCommandName, sScrollLineDownString))
    rv = aSelectionController->LineMove(PR_TRUE, PR_FALSE);
  else if (!nsCRT::strcmp(aCommandName, sWordPreviousString))
    rv = aSelectionController->WordMove(PR_FALSE, PR_FALSE);
  else if (!nsCRT::strcmp(aCommandName, sWordNextString))
    rv = aSelectionController->WordMove(PR_TRUE, PR_FALSE);
  else if (!nsCRT::strcmp(aCommandName, sScrollLeftString))
    rv = aSelectionController->CharacterMove(PR_FALSE, PR_FALSE);
  else if (!nsCRT::strcmp(aCommandName, sScrollRightString))
    rv = aSelectionController->CharacterMove(PR_TRUE, PR_FALSE);
  else if (!nsCRT::strcmp(aCommandName, sBeginLineString))
    rv = aSelectionController->IntraLineMove(PR_FALSE, PR_FALSE);
  else if (!nsCRT::strcmp(aCommandName, sEndLineString))
    rv = aSelectionController->IntraLineMove(PR_TRUE, PR_FALSE);

  if (NS_SUCCEEDED(rv) && aESM)
  {
    PRBool dummy;
    aESM->MoveFocusToCaret(PR_TRUE, &dummy);
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIControllerCommand::doCommandParams ( in string  aCommandName,
in nsICommandParams  aParams,
in nsISupports  aCommandContext 
) [inherited]
nsresult nsSelectMoveScrollCommand::DoSelectCommand ( const char *  aCommandName,
nsIDOMWindow aWindow 
) [protected, virtual]

Implements nsSelectionCommandsBase.

Definition at line 253 of file nsGlobalWindowCommands.cpp.

{
  nsCOMPtr<nsISelectionController> selCont;
  GetSelectionControllerFromWindow(aWindow, getter_AddRefs(selCont));
  NS_ENSURE_TRUE(selCont, NS_ERROR_NOT_INITIALIZED);       

  PRBool caretOn = PR_FALSE;
  selCont->GetCaretEnabled(&caretOn);

  nsCOMPtr<nsIEventStateManager> esm;
  GetEventStateManagerForWindow(aWindow, getter_AddRefs(esm));

  nsresult rv;
  // We allow the caret to be moved with arrow keys on any window for which
  // the caret is enabled. In particular, this includes caret-browsing mode,
  // but we refer to this mode again in the test condition for readability.
  if (caretOn || (esm && esm->GetBrowseWithCaret()))
    rv = DoCommandBrowseWithCaretOn(aCommandName, selCont, esm);
  else
    rv = DoCommandBrowseWithCaretOff(aCommandName, selCont);

  return rv;
}

Here is the call graph for this function:

void nsIControllerCommand::getCommandStateParams ( in string  aCommandName,
in nsICommandParams  aParams,
in nsISupports  aCommandContext 
) [inherited]
nsresult nsSelectionCommandsBase::GetEventStateManagerForWindow ( nsIDOMWindow aWindow,
nsIEventStateManager **  aEventStateManager 
) [static, protected, inherited]

Definition at line 230 of file nsGlobalWindowCommands.cpp.

{
  *aEventStateManager = nsnull;

  nsCOMPtr<nsIPresShell> presShell;
  GetPresShellFromWindow(aWindow, getter_AddRefs(presShell));
  if (presShell)
  {
    nsPresContext *presContext = presShell->GetPresContext();
    if (presContext) {
      NS_ADDREF(*aEventStateManager = presContext->EventStateManager());
      return NS_OK;
    }
  }
  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsSelectionCommandsBase::GetPresShellFromWindow ( nsIDOMWindow aWindow,
nsIPresShell **  aPresShell 
) [static, protected, inherited]

Definition at line 203 of file nsGlobalWindowCommands.cpp.

{
  *aPresShell = nsnull;

  nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(aWindow));
  NS_ENSURE_TRUE(sgo, NS_ERROR_FAILURE);

  nsIDocShell *docShell = sgo->GetDocShell();
  NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);

  return docShell->GetPresShell(aPresShell);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsSelectionCommandsBase::GetSelectionControllerFromWindow ( nsIDOMWindow aWindow,
nsISelectionController **  aSelCon 
) [static, protected, inherited]

Definition at line 217 of file nsGlobalWindowCommands.cpp.

{
  *aSelCon = nsnull;

  nsCOMPtr<nsIPresShell> presShell;
  GetPresShellFromWindow(aWindow, getter_AddRefs(presShell));
  if (presShell)
    return CallQueryInterface(presShell, aSelCon);

  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

boolean nsIControllerCommand::isCommandEnabled ( in string  aCommandName,
in nsISupports  aCommandContext 
) [inherited]

Returns true if the command is currently enabled.

An nsIControllerCommand can implement more than one commands; say, a group of related commands (e.g. delete left/delete right). Because of this, the command name is passed to each method.

Parameters:
aCommandNamethe name of the command for which we want the enabled state.
aCommandContexta cookie held by the nsIControllerCommandTable, allowing the command to get some context information. The contents of this cookie are implementation-defined.

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