LCOV - code coverage report
Current view: directory - dom/base - nsGlobalWindowCommands.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 286 0 0.0 %
Date: 2012-06-02 Functions: 59 0 0.0 %

       1                 : /* ***** BEGIN LICENSE BLOCK *****
       2                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       3                 :  *
       4                 :  * The contents of this file are subject to the Mozilla Public License Version
       5                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       6                 :  * the License. You may obtain a copy of the License at
       7                 :  * http://www.mozilla.org/MPL/
       8                 :  *
       9                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      10                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      11                 :  * for the specific language governing rights and limitations under the
      12                 :  * License.
      13                 :  *
      14                 :  * The Original Code is mozilla.org code.
      15                 :  *
      16                 :  * The Initial Developer of the Original Code is
      17                 :  * Netscape Communications, Inc.
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2003
      19                 :  * the Initial Developer. All Rights Reserved.
      20                 :  *
      21                 :  * Contributor(s):
      22                 :  *   Kathleen Brade <brade@netscape.com>
      23                 :  *   Simon Fraser   <sfraser@netscape.com>
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : 
      40                 : #include "nsGlobalWindowCommands.h"
      41                 : 
      42                 : #include "nsIComponentManager.h"
      43                 : #include "nsIInterfaceRequestor.h"
      44                 : #include "nsIInterfaceRequestorUtils.h"
      45                 : #include "nsCRT.h"
      46                 : #include "nsString.h"
      47                 : #include "mozilla/Preferences.h"
      48                 : #include "mozilla/Util.h"
      49                 : 
      50                 : #include "nsIControllerCommandTable.h"
      51                 : #include "nsICommandParams.h"
      52                 : 
      53                 : #include "nsPIDOMWindow.h"
      54                 : #include "nsIPresShell.h"
      55                 : #include "nsIDocShell.h"
      56                 : #include "nsIDocShellTreeItem.h"
      57                 : #include "nsISelectionController.h"
      58                 : #include "nsIWebNavigation.h"
      59                 : #include "nsIContentViewerEdit.h"
      60                 : #include "nsIContentViewer.h"
      61                 : #include "nsFocusManager.h"
      62                 : #include "nsCopySupport.h"
      63                 : #include "nsGUIEvent.h"
      64                 : 
      65                 : #include "nsIClipboardDragDropHooks.h"
      66                 : #include "nsIClipboardDragDropHookList.h"
      67                 : 
      68                 : using namespace mozilla;
      69                 : 
      70                 : const char * const sSelectAllString = "cmd_selectAll";
      71                 : const char * const sSelectNoneString = "cmd_selectNone";
      72                 : const char * const sCopyImageLocationString = "cmd_copyImageLocation";
      73                 : const char * const sCopyImageContentsString = "cmd_copyImageContents";
      74                 : const char * const sCopyImageString = "cmd_copyImage";
      75                 : 
      76                 : const char * const sScrollTopString = "cmd_scrollTop";
      77                 : const char * const sScrollBottomString = "cmd_scrollBottom";
      78                 : const char * const sScrollPageUpString = "cmd_scrollPageUp";
      79                 : const char * const sScrollPageDownString = "cmd_scrollPageDown";
      80                 : const char * const sScrollLineUpString = "cmd_scrollLineUp";
      81                 : const char * const sScrollLineDownString = "cmd_scrollLineDown";
      82                 : const char * const sScrollLeftString = "cmd_scrollLeft";
      83                 : const char * const sScrollRightString = "cmd_scrollRight";
      84                 : const char * const sMoveTopString = "cmd_moveTop";
      85                 : const char * const sMoveBottomString = "cmd_moveBottom";
      86                 : const char * const sMovePageUpString = "cmd_movePageUp";
      87                 : const char * const sMovePageDownString = "cmd_movePageDown";
      88                 : const char * const sLinePreviousString = "cmd_linePrevious";
      89                 : const char * const sLineNextString = "cmd_lineNext";
      90                 : const char * const sCharPreviousString = "cmd_charPrevious";
      91                 : const char * const sCharNextString = "cmd_charNext";
      92                 : 
      93                 : // These are so the browser can use editor navigation key bindings
      94                 : // helps with accessibility (boolean pref accessibility.browsewithcaret)
      95                 : 
      96                 : const char * const sSelectCharPreviousString = "cmd_selectCharPrevious";
      97                 : const char * const sSelectCharNextString = "cmd_selectCharNext";
      98                 : 
      99                 : const char * const sWordPreviousString = "cmd_wordPrevious";
     100                 : const char * const sWordNextString = "cmd_wordNext";
     101                 : const char * const sSelectWordPreviousString = "cmd_selectWordPrevious";
     102                 : const char * const sSelectWordNextString = "cmd_selectWordNext";
     103                 : 
     104                 : const char * const sBeginLineString = "cmd_beginLine";
     105                 : const char * const sEndLineString = "cmd_endLine";
     106                 : const char * const sSelectBeginLineString = "cmd_selectBeginLine";
     107                 : const char * const sSelectEndLineString = "cmd_selectEndLine";
     108                 : 
     109                 : const char * const sSelectLinePreviousString = "cmd_selectLinePrevious";
     110                 : const char * const sSelectLineNextString = "cmd_selectLineNext";
     111                 : 
     112                 : const char * const sSelectPageUpString = "cmd_selectPageUp";
     113                 : const char * const sSelectPageDownString = "cmd_selectPageDown";
     114                 : 
     115                 : const char * const sSelectTopString = "cmd_selectTop";
     116                 : const char * const sSelectBottomString = "cmd_selectBottom";
     117                 : 
     118                 : 
     119                 : #if 0
     120                 : #pragma mark -
     121                 : #endif
     122                 : 
     123                 : // a base class for selection-related commands, for code sharing
     124                 : class nsSelectionCommandsBase : public nsIControllerCommand
     125               0 : {
     126                 : public:
     127                 : 
     128                 :   NS_DECL_ISUPPORTS
     129                 :   NS_IMETHOD IsCommandEnabled(const char * aCommandName, nsISupports *aCommandContext, bool *_retval NS_OUTPARAM);
     130                 :   NS_IMETHOD GetCommandStateParams(const char * aCommandName, nsICommandParams *aParams, nsISupports *aCommandContext);
     131                 :   NS_IMETHOD DoCommandParams(const char * aCommandName, nsICommandParams *aParams, nsISupports *aCommandContext);
     132                 : 
     133                 : protected:
     134                 : 
     135                 :   static nsresult  GetPresShellFromWindow(nsPIDOMWindow *aWindow, nsIPresShell **aPresShell);
     136                 :   static nsresult  GetSelectionControllerFromWindow(nsPIDOMWindow *aWindow, nsISelectionController **aSelCon);
     137                 : 
     138                 :   // no member variables, please, we're stateless!
     139                 : };
     140                 : 
     141                 : // this class implements commands whose behavior depends on the 'browse with caret' setting
     142                 : class nsSelectMoveScrollCommand : public nsSelectionCommandsBase
     143               0 : {
     144                 : public:
     145                 : 
     146                 :   NS_IMETHOD DoCommand(const char * aCommandName, nsISupports *aCommandContext);
     147                 : 
     148                 :   // no member variables, please, we're stateless!
     149                 : };
     150                 : 
     151                 : // this class implements other selection commands
     152                 : class nsSelectCommand : public nsSelectionCommandsBase
     153               0 : {
     154                 : public:
     155                 : 
     156                 :   NS_IMETHOD DoCommand(const char * aCommandName, nsISupports *aCommandContext);
     157                 : 
     158                 :   // no member variables, please, we're stateless!
     159                 : };
     160                 : 
     161                 : #if 0
     162                 : #pragma mark -
     163                 : #endif
     164                 : 
     165                 : 
     166               0 : NS_IMPL_ISUPPORTS1(nsSelectionCommandsBase, nsIControllerCommand)
     167                 : 
     168                 : /* boolean isCommandEnabled (in string aCommandName, in nsISupports aCommandContext); */
     169                 : NS_IMETHODIMP
     170               0 : nsSelectionCommandsBase::IsCommandEnabled(const char * aCommandName,
     171                 :                                       nsISupports *aCommandContext,
     172                 :                                       bool *outCmdEnabled)
     173                 : {
     174                 :   // XXX this needs fixing. e.g. you can't scroll up if you're already at the top of
     175                 :   // the document.
     176               0 :   *outCmdEnabled = true;
     177               0 :   return NS_OK;
     178                 : }
     179                 : 
     180                 : /* void getCommandStateParams (in string aCommandName, in nsICommandParams aParams, in nsISupports aCommandContext); */
     181                 : NS_IMETHODIMP
     182               0 : nsSelectionCommandsBase::GetCommandStateParams(const char *aCommandName,
     183                 :                                             nsICommandParams *aParams, nsISupports *aCommandContext)
     184                 : {
     185                 :   // XXX we should probably return the enabled state
     186               0 :   return NS_ERROR_NOT_IMPLEMENTED;
     187                 : }
     188                 : 
     189                 : /* void doCommandParams (in string aCommandName, in nsICommandParams aParams, in nsISupports aCommandContext); */
     190                 : NS_IMETHODIMP
     191               0 : nsSelectionCommandsBase::DoCommandParams(const char *aCommandName,
     192                 :                                        nsICommandParams *aParams, nsISupports *aCommandContext)
     193                 : {
     194               0 :   return DoCommand(aCommandName, aCommandContext);
     195                 : }
     196                 : 
     197                 : // protected methods
     198                 : 
     199                 : nsresult
     200               0 : nsSelectionCommandsBase::GetPresShellFromWindow(nsPIDOMWindow *aWindow, nsIPresShell **aPresShell)
     201                 : {
     202               0 :   *aPresShell = nsnull;
     203               0 :   NS_ENSURE_TRUE(aWindow, NS_ERROR_FAILURE);
     204                 : 
     205               0 :   nsIDocShell *docShell = aWindow->GetDocShell();
     206               0 :   NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
     207                 : 
     208               0 :   return docShell->GetPresShell(aPresShell);
     209                 : }
     210                 : 
     211                 : nsresult
     212               0 : nsSelectionCommandsBase::GetSelectionControllerFromWindow(nsPIDOMWindow *aWindow, nsISelectionController **aSelCon)
     213                 : {
     214               0 :   *aSelCon = nsnull;
     215                 : 
     216               0 :   nsCOMPtr<nsIPresShell> presShell;
     217               0 :   GetPresShellFromWindow(aWindow, getter_AddRefs(presShell));
     218               0 :   if (presShell)
     219               0 :     return CallQueryInterface(presShell, aSelCon);
     220                 : 
     221               0 :   return NS_ERROR_FAILURE;
     222                 : }
     223                 : 
     224                 : #if 0
     225                 : #pragma mark -
     226                 : #endif
     227                 : 
     228                 : static const struct BrowseCommand {
     229                 :   const char *reverse, *forward;
     230                 :   nsresult (NS_STDCALL nsISelectionController::*scroll)(bool);
     231                 :   nsresult (NS_STDCALL nsISelectionController::*move)(bool, bool);
     232                 : } browseCommands[] = {
     233                 :  { sScrollTopString, sScrollBottomString,
     234                 :    &nsISelectionController::CompleteScroll },
     235                 :  { sScrollPageUpString, sScrollPageDownString,
     236                 :    &nsISelectionController::ScrollPage },
     237                 :  { sScrollLineUpString, sScrollLineDownString,
     238                 :    &nsISelectionController::ScrollLine },
     239                 :  { sScrollLeftString, sScrollRightString,
     240                 :    &nsISelectionController::ScrollCharacter },
     241                 :  { sMoveTopString, sMoveBottomString,
     242                 :    &nsISelectionController::CompleteScroll,
     243                 :    &nsISelectionController::CompleteMove },
     244                 :  { sMovePageUpString, sMovePageDownString,
     245                 :    &nsISelectionController::ScrollPage,
     246                 :    &nsISelectionController::PageMove },
     247                 :  { sLinePreviousString, sLineNextString,
     248                 :    &nsISelectionController::ScrollLine,
     249                 :    &nsISelectionController::LineMove },
     250                 :  { sWordPreviousString, sWordNextString,
     251                 :    &nsISelectionController::ScrollCharacter,
     252                 :    &nsISelectionController::WordMove },
     253                 :  { sCharPreviousString, sCharNextString,
     254                 :    &nsISelectionController::ScrollCharacter,
     255                 :    &nsISelectionController::CharacterMove },
     256                 :  { sBeginLineString, sEndLineString,
     257                 :    &nsISelectionController::CompleteScroll,
     258                 :    &nsISelectionController::IntraLineMove }
     259                 : };
     260                 : 
     261                 : nsresult
     262               0 : nsSelectMoveScrollCommand::DoCommand(const char *aCommandName, nsISupports *aCommandContext)
     263                 : {
     264               0 :   nsCOMPtr<nsPIDOMWindow> piWindow(do_QueryInterface(aCommandContext));
     265               0 :   nsCOMPtr<nsISelectionController> selCont;
     266               0 :   GetSelectionControllerFromWindow(piWindow, getter_AddRefs(selCont));
     267               0 :   NS_ENSURE_TRUE(selCont, NS_ERROR_NOT_INITIALIZED);       
     268                 : 
     269                 :   // We allow the caret to be moved with arrow keys on any window for which
     270                 :   // the caret is enabled. In particular, this includes caret-browsing mode
     271                 :   // in non-chrome documents.
     272               0 :   bool caretOn = false;
     273               0 :   selCont->GetCaretEnabled(&caretOn);
     274               0 :   if (!caretOn) {
     275               0 :     caretOn = Preferences::GetBool("accessibility.browsewithcaret");
     276               0 :     if (caretOn) {
     277               0 :       nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(piWindow->GetDocShell());
     278               0 :       if (dsti) {
     279                 :         PRInt32 itemType;
     280               0 :         dsti->GetItemType(&itemType);
     281               0 :         if (itemType == nsIDocShellTreeItem::typeChrome) {
     282               0 :           caretOn = false;
     283                 :         }
     284                 :       }
     285                 :     }
     286                 :   }
     287                 : 
     288               0 :   for (size_t i = 0; i < ArrayLength(browseCommands); i++) {
     289               0 :     bool forward = !strcmp(aCommandName, browseCommands[i].forward);
     290               0 :     if (forward || !strcmp(aCommandName, browseCommands[i].reverse)) {
     291               0 :       if (caretOn && browseCommands[i].move &&
     292               0 :           NS_SUCCEEDED((selCont->*(browseCommands[i].move))(forward, false))) {
     293                 :         // adjust the focus to the new caret position
     294               0 :         nsIFocusManager* fm = nsFocusManager::GetFocusManager();
     295               0 :         if (fm) {
     296               0 :           nsCOMPtr<nsIDOMElement> result;
     297                 :           fm->MoveFocus(piWindow, nsnull, nsIFocusManager::MOVEFOCUS_CARET,
     298                 :                         nsIFocusManager::FLAG_NOSCROLL,
     299               0 :                         getter_AddRefs(result));
     300                 :         }
     301               0 :         return NS_OK;
     302                 :       }
     303               0 :       return (selCont->*(browseCommands[i].scroll))(forward);
     304                 :     }
     305                 :   }
     306               0 :   return NS_ERROR_NOT_IMPLEMENTED;
     307                 : }
     308                 : 
     309                 : 
     310                 : #if 0
     311                 : #pragma mark -
     312                 : #endif
     313                 : 
     314                 : nsresult
     315               0 : nsSelectCommand::DoCommand(const char *aCommandName, nsISupports *aCommandContext)
     316                 : {
     317               0 :   nsCOMPtr<nsPIDOMWindow> piWindow(do_QueryInterface(aCommandContext));
     318               0 :   nsCOMPtr<nsISelectionController> selCont;
     319               0 :   GetSelectionControllerFromWindow(piWindow, getter_AddRefs(selCont));
     320               0 :   NS_ENSURE_TRUE(selCont, NS_ERROR_NOT_INITIALIZED);       
     321                 : 
     322               0 :   nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
     323                 : 
     324                 :   // These commands are so the browser can use caret navigation key bindings -
     325                 :   // Helps with accessibility - aaronl@netscape.com
     326               0 :   if (!nsCRT::strcmp(aCommandName, sSelectCharPreviousString))
     327               0 :     rv = selCont->CharacterMove(false, true);
     328               0 :   else if (!nsCRT::strcmp(aCommandName, sSelectCharNextString))
     329               0 :     rv = selCont->CharacterMove(true, true);
     330               0 :   else if (!nsCRT::strcmp(aCommandName, sSelectWordPreviousString))
     331               0 :     rv = selCont->WordMove(false, true);
     332               0 :   else if (!nsCRT::strcmp(aCommandName, sSelectWordNextString))
     333               0 :     rv = selCont->WordMove(true, true);
     334               0 :   else if (!nsCRT::strcmp(aCommandName, sSelectBeginLineString))
     335               0 :     rv = selCont->IntraLineMove(false, true);
     336               0 :   else if (!nsCRT::strcmp(aCommandName, sSelectEndLineString))
     337               0 :     rv = selCont->IntraLineMove(true, true);
     338               0 :   else if (!nsCRT::strcmp(aCommandName, sSelectLinePreviousString))
     339               0 :     rv = selCont->LineMove(false, true);
     340               0 :   else if (!nsCRT::strcmp(aCommandName, sSelectLineNextString))
     341               0 :     rv = selCont->LineMove(true, true);
     342               0 :   else if (!nsCRT::strcmp(aCommandName, sSelectPageUpString))
     343               0 :     rv = selCont->PageMove(false, true);
     344               0 :   else if (!nsCRT::strcmp(aCommandName, sSelectPageDownString))
     345               0 :     rv = selCont->PageMove(true, true);
     346               0 :   else if (!nsCRT::strcmp(aCommandName, sSelectTopString))
     347               0 :     rv = selCont->CompleteMove(false, true);
     348               0 :   else if (!nsCRT::strcmp(aCommandName, sSelectBottomString))
     349               0 :     rv = selCont->CompleteMove(true, true);
     350                 : 
     351               0 :   return rv;
     352                 : }
     353                 : 
     354                 : #if 0
     355                 : #pragma mark -
     356                 : #endif
     357                 : 
     358                 : class nsClipboardCommand : public nsIControllerCommand
     359               0 : {
     360                 : public:
     361                 : 
     362                 :   NS_DECL_ISUPPORTS
     363                 :   NS_DECL_NSICONTROLLERCOMMAND
     364                 : };
     365                 : 
     366               0 : NS_IMPL_ISUPPORTS1(nsClipboardCommand, nsIControllerCommand)
     367                 : 
     368                 : nsresult
     369               0 : nsClipboardCommand::IsCommandEnabled(const char* aCommandName, nsISupports *aContext, bool *outCmdEnabled)
     370                 : {
     371               0 :   NS_ENSURE_ARG_POINTER(outCmdEnabled);
     372               0 :   *outCmdEnabled = false;
     373                 : 
     374               0 :   if (strcmp(aCommandName, "cmd_copy"))
     375               0 :     return NS_OK;
     376                 : 
     377               0 :   nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aContext);
     378               0 :   NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
     379                 : 
     380               0 :   nsCOMPtr<nsIDocument> doc = do_QueryInterface(window->GetExtantDocument());
     381               0 :   *outCmdEnabled = nsCopySupport::CanCopy(doc);
     382               0 :   return NS_OK;
     383                 : }
     384                 : 
     385                 : nsresult
     386               0 : nsClipboardCommand::DoCommand(const char *aCommandName, nsISupports *aContext)
     387                 : {
     388               0 :   if (strcmp(aCommandName, "cmd_copy"))
     389               0 :     return NS_OK;
     390                 : 
     391               0 :   nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aContext);
     392               0 :   NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
     393                 : 
     394               0 :   nsIDocShell *docShell = window->GetDocShell();
     395               0 :   NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
     396                 : 
     397               0 :   nsCOMPtr<nsIPresShell> presShell;
     398               0 :   docShell->GetPresShell(getter_AddRefs(presShell));
     399               0 :   NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
     400                 : 
     401               0 :   nsCopySupport::FireClipboardEvent(NS_COPY, presShell, nsnull);
     402               0 :   return NS_OK;
     403                 : }
     404                 : 
     405                 : NS_IMETHODIMP
     406               0 : nsClipboardCommand::GetCommandStateParams(const char *aCommandName,
     407                 :                                               nsICommandParams *aParams, nsISupports *aCommandContext)
     408                 : {
     409               0 :   return NS_ERROR_NOT_IMPLEMENTED;
     410                 : }
     411                 : 
     412                 : nsresult
     413               0 : nsClipboardCommand::DoCommandParams(const char *aCommandName, nsICommandParams* aParams, nsISupports *aContext)
     414                 : {
     415               0 :   return DoCommand(aCommandName, aContext);
     416                 : }
     417                 : 
     418                 : #if 0
     419                 : #pragma mark -
     420                 : #endif
     421                 : 
     422                 : class nsSelectionCommand : public nsIControllerCommand
     423               0 : {
     424                 : public:
     425                 : 
     426                 :   NS_DECL_ISUPPORTS
     427                 :   NS_DECL_NSICONTROLLERCOMMAND
     428                 : 
     429                 : protected:
     430                 : 
     431                 :   virtual nsresult    IsClipboardCommandEnabled(const char * aCommandName, nsIContentViewerEdit* aEdit, bool *outCmdEnabled) = 0;
     432                 :   virtual nsresult    DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams) = 0;
     433                 :   
     434                 :   static nsresult     GetContentViewerEditFromContext(nsISupports *aContext, nsIContentViewerEdit **aEditInterface);
     435                 :   
     436                 :   // no member variables, please, we're stateless!
     437                 : };
     438                 : 
     439                 : 
     440               0 : NS_IMPL_ISUPPORTS1(nsSelectionCommand, nsIControllerCommand)
     441                 : 
     442                 : 
     443                 : /*---------------------------------------------------------------------------
     444                 : 
     445                 :   nsSelectionCommand
     446                 : 
     447                 : ----------------------------------------------------------------------------*/
     448                 : 
     449                 : NS_IMETHODIMP
     450               0 : nsSelectionCommand::IsCommandEnabled(const char * aCommandName,
     451                 :                                      nsISupports *aCommandContext,
     452                 :                                      bool *outCmdEnabled)
     453                 : {
     454               0 :   NS_ENSURE_ARG_POINTER(outCmdEnabled);
     455               0 :   *outCmdEnabled = false;
     456                 : 
     457               0 :   nsCOMPtr<nsIContentViewerEdit> contentEdit;
     458               0 :   GetContentViewerEditFromContext(aCommandContext,  getter_AddRefs(contentEdit));
     459               0 :   NS_ENSURE_TRUE(contentEdit, NS_ERROR_NOT_INITIALIZED);
     460                 : 
     461               0 :   return IsClipboardCommandEnabled(aCommandName, contentEdit, outCmdEnabled);
     462                 : }
     463                 : 
     464                 : NS_IMETHODIMP
     465               0 : nsSelectionCommand::DoCommand(const char *aCommandName,
     466                 :                               nsISupports *aCommandContext)
     467                 : {
     468               0 :   nsCOMPtr<nsIContentViewerEdit> contentEdit;
     469               0 :   GetContentViewerEditFromContext(aCommandContext,  getter_AddRefs(contentEdit));
     470               0 :   NS_ENSURE_TRUE(contentEdit, NS_ERROR_NOT_INITIALIZED);
     471                 : 
     472               0 :   return DoClipboardCommand(aCommandName, contentEdit, nsnull);
     473                 : }
     474                 : 
     475                 : NS_IMETHODIMP
     476               0 : nsSelectionCommand::GetCommandStateParams(const char *aCommandName,
     477                 :                                           nsICommandParams *aParams,
     478                 :                                           nsISupports *aCommandContext)
     479                 : {
     480               0 :   return NS_ERROR_NOT_IMPLEMENTED;
     481                 : }
     482                 : 
     483                 : NS_IMETHODIMP
     484               0 : nsSelectionCommand::DoCommandParams(const char *aCommandName,
     485                 :                                     nsICommandParams *aParams,
     486                 :                                     nsISupports *aCommandContext)
     487                 : {
     488               0 :   nsCOMPtr<nsIContentViewerEdit> contentEdit;
     489               0 :   GetContentViewerEditFromContext(aCommandContext,  getter_AddRefs(contentEdit));
     490               0 :   NS_ENSURE_TRUE(contentEdit, NS_ERROR_NOT_INITIALIZED);
     491                 : 
     492               0 :   return DoClipboardCommand(aCommandName, contentEdit, aParams);
     493                 : }
     494                 : 
     495                 : nsresult
     496               0 : nsSelectionCommand::GetContentViewerEditFromContext(nsISupports *aContext,
     497                 :                                                     nsIContentViewerEdit **aEditInterface)
     498                 : {
     499               0 :   NS_ENSURE_ARG(aEditInterface);
     500               0 :   *aEditInterface = nsnull;
     501                 : 
     502               0 :   nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aContext);
     503               0 :   NS_ENSURE_TRUE(window, NS_ERROR_INVALID_ARG);
     504                 : 
     505               0 :   nsIDocShell *docShell = window->GetDocShell();
     506               0 :   NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
     507                 : 
     508               0 :   nsCOMPtr<nsIContentViewer> viewer;
     509               0 :   docShell->GetContentViewer(getter_AddRefs(viewer));
     510               0 :   nsCOMPtr<nsIContentViewerEdit> edit(do_QueryInterface(viewer));
     511               0 :   NS_ENSURE_TRUE(edit, NS_ERROR_FAILURE);
     512                 : 
     513               0 :   *aEditInterface = edit;
     514               0 :   NS_ADDREF(*aEditInterface);
     515               0 :   return NS_OK;
     516                 : }
     517                 : 
     518                 : #if 0
     519                 : #pragma mark -
     520                 : #endif
     521                 : 
     522                 : #define NS_DECL_CLIPBOARD_COMMAND(_cmd)                                                     \
     523                 : class _cmd : public nsSelectionCommand                                                  \
     524                 : {                                                                                           \
     525                 : protected:                                                                                  \
     526                 :                                                                                             \
     527                 :   virtual nsresult    IsClipboardCommandEnabled(const char* aCommandName,                   \
     528                 :                                   nsIContentViewerEdit* aEdit, bool *outCmdEnabled);      \
     529                 :   virtual nsresult    DoClipboardCommand(const char* aCommandName,                          \
     530                 :                                   nsIContentViewerEdit* aEdit, nsICommandParams* aParams);  \
     531                 :   /* no member variables, please, we're stateless! */                                       \
     532                 : };
     533                 : 
     534               0 : NS_DECL_CLIPBOARD_COMMAND(nsClipboardCopyLinkCommand)
     535               0 : NS_DECL_CLIPBOARD_COMMAND(nsClipboardImageCommands)
     536               0 : NS_DECL_CLIPBOARD_COMMAND(nsClipboardSelectAllNoneCommands)
     537               0 : NS_DECL_CLIPBOARD_COMMAND(nsClipboardGetContentsCommand)
     538                 : 
     539                 : nsresult
     540               0 : nsClipboardCopyLinkCommand::IsClipboardCommandEnabled(const char* aCommandName, nsIContentViewerEdit* aEdit, bool *outCmdEnabled)
     541                 : {
     542               0 :   return aEdit->GetInLink(outCmdEnabled);
     543                 : }
     544                 : 
     545                 : nsresult
     546               0 : nsClipboardCopyLinkCommand::DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams)
     547                 : {
     548               0 :   return aEdit->CopyLinkLocation();
     549                 : }
     550                 : 
     551                 : #if 0
     552                 : #pragma mark -
     553                 : #endif
     554                 : 
     555                 : nsresult
     556               0 : nsClipboardImageCommands::IsClipboardCommandEnabled(const char* aCommandName, nsIContentViewerEdit* aEdit, bool *outCmdEnabled)
     557                 : {
     558               0 :   return aEdit->GetInImage(outCmdEnabled);
     559                 : }
     560                 : 
     561                 : nsresult
     562               0 : nsClipboardImageCommands::DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams)
     563                 : {
     564               0 :   if (!nsCRT::strcmp(sCopyImageLocationString, aCommandName))
     565               0 :     return aEdit->CopyImage(nsIContentViewerEdit::COPY_IMAGE_TEXT);
     566               0 :   if (!nsCRT::strcmp(sCopyImageContentsString, aCommandName))
     567               0 :     return aEdit->CopyImage(nsIContentViewerEdit::COPY_IMAGE_DATA);
     568                 :   PRInt32 copyFlags = nsIContentViewerEdit::COPY_IMAGE_DATA | 
     569               0 :                       nsIContentViewerEdit::COPY_IMAGE_HTML;
     570               0 :   if (aParams)
     571               0 :     aParams->GetLongValue("imageCopy", &copyFlags);
     572               0 :   return aEdit->CopyImage(copyFlags);
     573                 : }
     574                 : 
     575                 : #if 0
     576                 : #pragma mark -
     577                 : #endif
     578                 : 
     579                 : nsresult
     580               0 : nsClipboardSelectAllNoneCommands::IsClipboardCommandEnabled(const char* aCommandName, nsIContentViewerEdit* aEdit, bool *outCmdEnabled)
     581                 : {
     582               0 :   *outCmdEnabled = true;
     583               0 :   return NS_OK;
     584                 : }
     585                 : 
     586                 : nsresult
     587               0 : nsClipboardSelectAllNoneCommands::DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams)
     588                 : {
     589               0 :   if (!nsCRT::strcmp(sSelectAllString, aCommandName))
     590               0 :     return aEdit->SelectAll();
     591                 : 
     592               0 :   return aEdit->ClearSelection();
     593                 : }
     594                 : 
     595                 : 
     596                 : #if 0
     597                 : #pragma mark -
     598                 : #endif
     599                 : 
     600                 : nsresult
     601               0 : nsClipboardGetContentsCommand::IsClipboardCommandEnabled(const char* aCommandName, nsIContentViewerEdit* aEdit, bool *outCmdEnabled)
     602                 : {
     603               0 :   return aEdit->GetCanGetContents(outCmdEnabled);
     604                 : }
     605                 : 
     606                 : nsresult
     607               0 : nsClipboardGetContentsCommand::DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams)
     608                 : {
     609               0 :   NS_ENSURE_ARG(aParams);
     610                 : 
     611               0 :   nsCAutoString mimeType("text/plain");
     612                 : 
     613               0 :   nsXPIDLCString format;    // nsICommandParams needs to use nsACString
     614               0 :   if (NS_SUCCEEDED(aParams->GetCStringValue("format", getter_Copies(format))))
     615               0 :     mimeType.Assign(format);
     616                 :   
     617               0 :   bool selectionOnly = false;
     618               0 :   aParams->GetBooleanValue("selection_only", &selectionOnly);
     619                 :   
     620               0 :   nsAutoString contents;
     621               0 :   nsresult rv = aEdit->GetContents(mimeType.get(), selectionOnly, contents);
     622               0 :   if (NS_FAILED(rv))
     623               0 :     return rv;
     624                 :     
     625               0 :   return aParams->SetStringValue("result", contents);
     626                 : }
     627                 : 
     628                 : 
     629                 : #if 0
     630                 : #pragma mark -
     631                 : #endif
     632                 : 
     633                 : class nsWebNavigationBaseCommand : public nsIControllerCommand
     634                 : {
     635                 : public:
     636                 : 
     637                 :   NS_DECL_ISUPPORTS
     638                 :   NS_DECL_NSICONTROLLERCOMMAND
     639                 : 
     640                 : protected:
     641                 : 
     642                 :   virtual nsresult    IsWebNavCommandEnabled(const char * aCommandName, nsIWebNavigation* aWebNavigation, bool *outCmdEnabled) = 0;
     643                 :   virtual nsresult    DoWebNavCommand(const char *aCommandName, nsIWebNavigation* aWebNavigation) = 0;
     644                 :   
     645                 :   static nsresult     GetWebNavigationFromContext(nsISupports *aContext, nsIWebNavigation **aWebNavigation);
     646                 :   
     647                 :   // no member variables, please, we're stateless!
     648                 : };
     649                 : 
     650                 : #if 0   // Remove unless needed again, bug 204777
     651                 : class nsGoForwardCommand : public nsWebNavigationBaseCommand
     652                 : {
     653                 : protected:
     654                 : 
     655                 :   virtual nsresult    IsWebNavCommandEnabled(const char * aCommandName, nsIWebNavigation* aWebNavigation, bool *outCmdEnabled);
     656                 :   virtual nsresult    DoWebNavCommand(const char *aCommandName, nsIWebNavigation* aWebNavigation);
     657                 :   // no member variables, please, we're stateless!
     658                 : };
     659                 : 
     660                 : class nsGoBackCommand : public nsWebNavigationBaseCommand
     661                 : {
     662                 : protected:
     663                 : 
     664                 :   virtual nsresult    IsWebNavCommandEnabled(const char * aCommandName, nsIWebNavigation* aWebNavigation, bool *outCmdEnabled);
     665                 :   virtual nsresult    DoWebNavCommand(const char *aCommandName, nsIWebNavigation* aWebNavigation);
     666                 :   // no member variables, please, we're stateless!
     667                 : };
     668                 : #endif
     669                 : 
     670                 : /*---------------------------------------------------------------------------
     671                 : 
     672                 :   nsWebNavigationCommands
     673                 :      no params
     674                 : ----------------------------------------------------------------------------*/
     675                 : 
     676               0 : NS_IMPL_ISUPPORTS1(nsWebNavigationBaseCommand, nsIControllerCommand)
     677                 : 
     678                 : NS_IMETHODIMP
     679               0 : nsWebNavigationBaseCommand::IsCommandEnabled(const char * aCommandName,
     680                 :                                           nsISupports *aCommandContext,
     681                 :                                           bool *outCmdEnabled)
     682                 : {
     683               0 :   NS_ENSURE_ARG_POINTER(outCmdEnabled);
     684               0 :   *outCmdEnabled = false;
     685                 : 
     686               0 :   nsCOMPtr<nsIWebNavigation> webNav;
     687               0 :   GetWebNavigationFromContext(aCommandContext, getter_AddRefs(webNav));
     688               0 :   NS_ENSURE_TRUE(webNav, NS_ERROR_INVALID_ARG);
     689                 :   
     690               0 :   return IsCommandEnabled(aCommandName, webNav, outCmdEnabled);
     691                 : }
     692                 : 
     693                 : NS_IMETHODIMP
     694               0 : nsWebNavigationBaseCommand::GetCommandStateParams(const char *aCommandName,
     695                 :                                             nsICommandParams *aParams, nsISupports *aCommandContext)
     696                 : {
     697                 :   // XXX we should probably return the enabled state
     698               0 :   return NS_ERROR_NOT_IMPLEMENTED;
     699                 : }
     700                 : 
     701                 : NS_IMETHODIMP
     702               0 : nsWebNavigationBaseCommand::DoCommand(const char *aCommandName,
     703                 :                                    nsISupports *aCommandContext)
     704                 : {
     705               0 :   nsCOMPtr<nsIWebNavigation> webNav;
     706               0 :   GetWebNavigationFromContext(aCommandContext, getter_AddRefs(webNav));
     707               0 :   NS_ENSURE_TRUE(webNav, NS_ERROR_INVALID_ARG);
     708                 :   
     709               0 :   return DoWebNavCommand(aCommandName, webNav);
     710                 : }
     711                 : 
     712                 : /* void doCommandParams (in string aCommandName, in nsICommandParams aParams, in nsISupports aCommandContext); */
     713                 : NS_IMETHODIMP
     714               0 : nsWebNavigationBaseCommand::DoCommandParams(const char *aCommandName,
     715                 :                                        nsICommandParams *aParams, nsISupports *aCommandContext)
     716                 : {
     717               0 :   return DoCommand(aCommandName, aCommandContext);
     718                 : }
     719                 : 
     720                 : nsresult
     721               0 : nsWebNavigationBaseCommand::GetWebNavigationFromContext(nsISupports *aContext, nsIWebNavigation **aWebNavigation)
     722                 : {
     723               0 :   nsCOMPtr<nsIInterfaceRequestor> windowReq = do_QueryInterface(aContext);
     724               0 :   CallGetInterface(windowReq.get(), aWebNavigation);
     725               0 :   return (*aWebNavigation) ? NS_OK : NS_ERROR_FAILURE;
     726                 : }
     727                 : 
     728                 : #if 0
     729                 : #pragma mark -
     730                 : #endif
     731                 : 
     732                 : #if 0   // Remove unless needed again, bug 204777
     733                 : nsresult
     734                 : nsGoForwardCommand::IsWebNavCommandEnabled(const char * aCommandName, nsIWebNavigation* aWebNavigation, bool *outCmdEnabled)
     735                 : {
     736                 :   return aWebNavigation->GetCanGoForward(outCmdEnabled);
     737                 : }
     738                 : 
     739                 : nsresult
     740                 : nsGoForwardCommand::DoWebNavCommand(const char *aCommandName, nsIWebNavigation* aWebNavigation)
     741                 : {
     742                 :   return aWebNavigation->GoForward();
     743                 : }
     744                 : 
     745                 : nsresult
     746                 : nsGoBackCommand::IsWebNavCommandEnabled(const char * aCommandName, nsIWebNavigation* aWebNavigation, bool *outCmdEnabled)
     747                 : {
     748                 :   return aWebNavigation->GetCanGoBack(outCmdEnabled);
     749                 : }
     750                 : 
     751                 : nsresult
     752                 : nsGoBackCommand::DoWebNavCommand(const char *aCommandName, nsIWebNavigation* aWebNavigation)
     753                 : {
     754                 :   return aWebNavigation->GoBack();
     755                 : }
     756                 : #endif
     757                 : 
     758                 : /*---------------------------------------------------------------------------
     759                 : 
     760                 :   nsClipboardDragDropHookCommand
     761                 :       params        value type   possible values
     762                 :       "addhook"     isupports    nsIClipboardDragDropHooks as nsISupports
     763                 :       "removehook"  isupports    nsIClipboardDragDropHooks as nsISupports
     764                 : 
     765                 : ----------------------------------------------------------------------------*/
     766                 : 
     767                 : class nsClipboardDragDropHookCommand : public nsIControllerCommand
     768               0 : {
     769                 : public:
     770                 : 
     771                 :   NS_DECL_ISUPPORTS
     772                 :   NS_DECL_NSICONTROLLERCOMMAND
     773                 : 
     774                 : protected:                                                                                   
     775                 :   // no member variables, please, we're stateless!
     776                 : };
     777                 : 
     778                 : 
     779               0 : NS_IMPL_ISUPPORTS1(nsClipboardDragDropHookCommand, nsIControllerCommand)
     780                 : 
     781                 : NS_IMETHODIMP
     782               0 : nsClipboardDragDropHookCommand::IsCommandEnabled(const char * aCommandName,
     783                 :                                                  nsISupports *aCommandContext,
     784                 :                                                  bool *outCmdEnabled)
     785                 : {
     786               0 :   *outCmdEnabled = true;
     787               0 :   return NS_OK;
     788                 : }
     789                 : 
     790                 : NS_IMETHODIMP
     791               0 : nsClipboardDragDropHookCommand::DoCommand(const char *aCommandName,
     792                 :                                           nsISupports *aCommandContext)
     793                 : {
     794               0 :   return NS_ERROR_FAILURE;
     795                 : }
     796                 : 
     797                 : NS_IMETHODIMP
     798               0 : nsClipboardDragDropHookCommand::DoCommandParams(const char *aCommandName,
     799                 :                                                 nsICommandParams *aParams,
     800                 :                                                 nsISupports *aCommandContext)
     801                 : {
     802               0 :   NS_ENSURE_ARG(aParams);
     803                 : 
     804               0 :   nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aCommandContext);
     805               0 :   NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
     806                 : 
     807               0 :   nsIDocShell *docShell = window->GetDocShell();
     808                 : 
     809               0 :   nsCOMPtr<nsIClipboardDragDropHookList> obj = do_GetInterface(docShell);
     810               0 :   if (!obj) return NS_ERROR_INVALID_ARG;
     811                 : 
     812               0 :   nsCOMPtr<nsISupports> isuppHook;
     813                 : 
     814               0 :   nsresult returnValue = NS_OK;
     815               0 :   nsresult rv = aParams->GetISupportsValue("addhook", getter_AddRefs(isuppHook));
     816               0 :   if (NS_SUCCEEDED(rv))
     817                 :   {
     818               0 :     nsCOMPtr<nsIClipboardDragDropHooks> hook = do_QueryInterface(isuppHook);
     819               0 :     if (hook)
     820               0 :       returnValue = obj->AddClipboardDragDropHooks(hook);
     821                 :     else
     822               0 :       returnValue = NS_ERROR_INVALID_ARG;
     823                 :   }
     824                 : 
     825               0 :   rv = aParams->GetISupportsValue("removehook", getter_AddRefs(isuppHook));
     826               0 :   if (NS_SUCCEEDED(rv))
     827                 :   {
     828               0 :     nsCOMPtr<nsIClipboardDragDropHooks> hook = do_QueryInterface(isuppHook);
     829               0 :     if (hook)
     830                 :     {
     831               0 :       rv = obj->RemoveClipboardDragDropHooks(hook);
     832               0 :       if (NS_FAILED(rv) && NS_SUCCEEDED(returnValue))
     833               0 :         returnValue = rv;
     834                 :     }
     835                 :     else
     836               0 :       returnValue = NS_ERROR_INVALID_ARG;
     837                 :   }
     838                 : 
     839               0 :   return returnValue;
     840                 : }
     841                 : 
     842                 : NS_IMETHODIMP
     843               0 : nsClipboardDragDropHookCommand::GetCommandStateParams(const char *aCommandName,
     844                 :                                                       nsICommandParams *aParams,
     845                 :                                                       nsISupports *aCommandContext)
     846                 : {
     847               0 :   NS_ENSURE_ARG_POINTER(aParams);
     848               0 :   return aParams->SetBooleanValue("state_enabled", true);
     849                 : }
     850                 : 
     851                 : /*---------------------------------------------------------------------------
     852                 : 
     853                 :   RegisterWindowCommands
     854                 : 
     855                 : ----------------------------------------------------------------------------*/
     856                 : 
     857                 : #define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName)                \
     858                 :   {                                                                 \
     859                 :     _cmdClass* theCmd = new _cmdClass();                            \
     860                 :     if (!theCmd) return NS_ERROR_OUT_OF_MEMORY;                     \
     861                 :     rv = inCommandTable->RegisterCommand(_cmdName,                  \
     862                 :                    static_cast<nsIControllerCommand *>(theCmd));    \
     863                 :   }
     864                 : 
     865                 : #define NS_REGISTER_FIRST_COMMAND(_cmdClass, _cmdName)              \
     866                 :   {                                                                 \
     867                 :     _cmdClass* theCmd = new _cmdClass();                            \
     868                 :     if (!theCmd) return NS_ERROR_OUT_OF_MEMORY;                     \
     869                 :     rv = inCommandTable->RegisterCommand(_cmdName,                  \
     870                 :                    static_cast<nsIControllerCommand *>(theCmd));
     871                 : 
     872                 : #define NS_REGISTER_NEXT_COMMAND(_cmdClass, _cmdName)               \
     873                 :     rv = inCommandTable->RegisterCommand(_cmdName,                  \
     874                 :                    static_cast<nsIControllerCommand *>(theCmd));
     875                 : 
     876                 : #define NS_REGISTER_LAST_COMMAND(_cmdClass, _cmdName)               \
     877                 :     rv = inCommandTable->RegisterCommand(_cmdName,                  \
     878                 :                    static_cast<nsIControllerCommand *>(theCmd));    \
     879                 :   }
     880                 : 
     881                 : 
     882                 : // static
     883                 : nsresult
     884               0 : nsWindowCommandRegistration::RegisterWindowCommands(
     885                 :                                nsIControllerCommandTable *inCommandTable)
     886                 : {
     887                 :   nsresult rv;
     888                 : 
     889                 :   // XXX rework the macros to use a loop is possible, reducing code size
     890                 :   
     891                 :   // this set of commands is affected by the 'browse with caret' setting
     892               0 :   NS_REGISTER_FIRST_COMMAND(nsSelectMoveScrollCommand, sScrollTopString);
     893               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sScrollBottomString);
     894               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sScrollPageUpString);
     895               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sScrollPageDownString);
     896               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sScrollLineUpString);
     897               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sScrollLineDownString);
     898               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sScrollLeftString);
     899               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sScrollRightString);
     900               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sMoveTopString);
     901               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sMoveBottomString);
     902               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sWordPreviousString);
     903               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sWordNextString);
     904               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sBeginLineString);
     905               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sEndLineString);
     906               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sMovePageUpString);
     907               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sMovePageDownString);
     908               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sLinePreviousString);
     909               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sLineNextString);
     910               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sCharPreviousString);
     911               0 :   NS_REGISTER_LAST_COMMAND(nsSelectMoveScrollCommand, sCharNextString);
     912                 : 
     913               0 :   NS_REGISTER_FIRST_COMMAND(nsSelectCommand, sSelectCharPreviousString);
     914               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectCharNextString);
     915               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectWordPreviousString);
     916               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectWordNextString);
     917               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectBeginLineString);
     918               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectEndLineString);
     919               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectLinePreviousString);
     920               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectLineNextString);
     921               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectPageUpString);
     922               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectPageDownString);
     923               0 :   NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectTopString);
     924               0 :   NS_REGISTER_LAST_COMMAND(nsSelectCommand, sSelectBottomString);
     925                 : 
     926               0 :   NS_REGISTER_ONE_COMMAND(nsClipboardCommand, "cmd_cut");
     927               0 :   NS_REGISTER_ONE_COMMAND(nsClipboardCommand, "cmd_copy");
     928               0 :   NS_REGISTER_ONE_COMMAND(nsClipboardCommand, "cmd_paste");
     929               0 :   NS_REGISTER_ONE_COMMAND(nsClipboardCopyLinkCommand, "cmd_copyLink");
     930               0 :   NS_REGISTER_FIRST_COMMAND(nsClipboardImageCommands, sCopyImageLocationString);
     931               0 :   NS_REGISTER_NEXT_COMMAND(nsClipboardImageCommands, sCopyImageContentsString);
     932               0 :   NS_REGISTER_LAST_COMMAND(nsClipboardImageCommands, sCopyImageString);
     933               0 :   NS_REGISTER_FIRST_COMMAND(nsClipboardSelectAllNoneCommands, sSelectAllString);
     934               0 :   NS_REGISTER_LAST_COMMAND(nsClipboardSelectAllNoneCommands, sSelectNoneString);
     935                 : 
     936               0 :   NS_REGISTER_ONE_COMMAND(nsClipboardGetContentsCommand, "cmd_getContents");
     937                 : 
     938                 : #if 0   // Remove unless needed again, bug 204777
     939                 :   NS_REGISTER_ONE_COMMAND(nsGoBackCommand, "cmd_browserBack");
     940                 :   NS_REGISTER_ONE_COMMAND(nsGoForwardCommand, "cmd_browserForward");
     941                 : #endif
     942                 : 
     943               0 :   NS_REGISTER_ONE_COMMAND(nsClipboardDragDropHookCommand, "cmd_clipboardDragDropHook");
     944                 : 
     945               0 :   return rv;
     946                 : }

Generated by: LCOV version 1.7