dom/base/nsGlobalWindowCommands.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/base/nsGlobalWindowCommands.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,902 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +
     1.9 +#include "nsGlobalWindowCommands.h"
    1.10 +
    1.11 +#include "nsIComponentManager.h"
    1.12 +#include "nsIDOMElement.h"
    1.13 +#include "nsIInterfaceRequestor.h"
    1.14 +#include "nsIInterfaceRequestorUtils.h"
    1.15 +#include "nsCRT.h"
    1.16 +#include "nsString.h"
    1.17 +#include "mozilla/ArrayUtils.h"
    1.18 +#include "mozilla/Preferences.h"
    1.19 +
    1.20 +#include "nsIControllerCommandTable.h"
    1.21 +#include "nsICommandParams.h"
    1.22 +
    1.23 +#include "nsPIDOMWindow.h"
    1.24 +#include "nsIPresShell.h"
    1.25 +#include "nsIDocShell.h"
    1.26 +#include "nsISelectionController.h"
    1.27 +#include "nsIWebNavigation.h"
    1.28 +#include "nsIContentViewerEdit.h"
    1.29 +#include "nsIContentViewer.h"
    1.30 +#include "nsFocusManager.h"
    1.31 +#include "nsCopySupport.h"
    1.32 +#include "nsIClipboard.h"
    1.33 +#include "mozilla/Attributes.h"
    1.34 +#include "mozilla/BasicEvents.h"
    1.35 +
    1.36 +#include "nsIClipboardDragDropHooks.h"
    1.37 +#include "nsIClipboardDragDropHookList.h"
    1.38 +
    1.39 +using namespace mozilla;
    1.40 +
    1.41 +const char * const sSelectAllString = "cmd_selectAll";
    1.42 +const char * const sSelectNoneString = "cmd_selectNone";
    1.43 +const char * const sCopyImageLocationString = "cmd_copyImageLocation";
    1.44 +const char * const sCopyImageContentsString = "cmd_copyImageContents";
    1.45 +const char * const sCopyImageString = "cmd_copyImage";
    1.46 +
    1.47 +const char * const sScrollTopString = "cmd_scrollTop";
    1.48 +const char * const sScrollBottomString = "cmd_scrollBottom";
    1.49 +const char * const sScrollPageUpString = "cmd_scrollPageUp";
    1.50 +const char * const sScrollPageDownString = "cmd_scrollPageDown";
    1.51 +const char * const sScrollLineUpString = "cmd_scrollLineUp";
    1.52 +const char * const sScrollLineDownString = "cmd_scrollLineDown";
    1.53 +const char * const sScrollLeftString = "cmd_scrollLeft";
    1.54 +const char * const sScrollRightString = "cmd_scrollRight";
    1.55 +const char * const sMoveTopString = "cmd_moveTop";
    1.56 +const char * const sMoveBottomString = "cmd_moveBottom";
    1.57 +const char * const sMovePageUpString = "cmd_movePageUp";
    1.58 +const char * const sMovePageDownString = "cmd_movePageDown";
    1.59 +const char * const sLinePreviousString = "cmd_linePrevious";
    1.60 +const char * const sLineNextString = "cmd_lineNext";
    1.61 +const char * const sCharPreviousString = "cmd_charPrevious";
    1.62 +const char * const sCharNextString = "cmd_charNext";
    1.63 +
    1.64 +// These are so the browser can use editor navigation key bindings
    1.65 +// helps with accessibility (boolean pref accessibility.browsewithcaret)
    1.66 +
    1.67 +const char * const sSelectCharPreviousString = "cmd_selectCharPrevious";
    1.68 +const char * const sSelectCharNextString = "cmd_selectCharNext";
    1.69 +
    1.70 +const char * const sWordPreviousString = "cmd_wordPrevious";
    1.71 +const char * const sWordNextString = "cmd_wordNext";
    1.72 +const char * const sSelectWordPreviousString = "cmd_selectWordPrevious";
    1.73 +const char * const sSelectWordNextString = "cmd_selectWordNext";
    1.74 +
    1.75 +const char * const sBeginLineString = "cmd_beginLine";
    1.76 +const char * const sEndLineString = "cmd_endLine";
    1.77 +const char * const sSelectBeginLineString = "cmd_selectBeginLine";
    1.78 +const char * const sSelectEndLineString = "cmd_selectEndLine";
    1.79 +
    1.80 +const char * const sSelectLinePreviousString = "cmd_selectLinePrevious";
    1.81 +const char * const sSelectLineNextString = "cmd_selectLineNext";
    1.82 +
    1.83 +const char * const sSelectPageUpString = "cmd_selectPageUp";
    1.84 +const char * const sSelectPageDownString = "cmd_selectPageDown";
    1.85 +
    1.86 +const char * const sSelectTopString = "cmd_selectTop";
    1.87 +const char * const sSelectBottomString = "cmd_selectBottom";
    1.88 +
    1.89 +
    1.90 +#if 0
    1.91 +#pragma mark -
    1.92 +#endif
    1.93 +
    1.94 +// a base class for selection-related commands, for code sharing
    1.95 +class nsSelectionCommandsBase : public nsIControllerCommand
    1.96 +{
    1.97 +public:
    1.98 +  virtual ~nsSelectionCommandsBase() {}
    1.99 +
   1.100 +  NS_DECL_ISUPPORTS
   1.101 +  NS_IMETHOD IsCommandEnabled(const char * aCommandName, nsISupports *aCommandContext, bool *_retval);
   1.102 +  NS_IMETHOD GetCommandStateParams(const char * aCommandName, nsICommandParams *aParams, nsISupports *aCommandContext);
   1.103 +  NS_IMETHOD DoCommandParams(const char * aCommandName, nsICommandParams *aParams, nsISupports *aCommandContext);
   1.104 +
   1.105 +protected:
   1.106 +
   1.107 +  static nsresult  GetPresShellFromWindow(nsPIDOMWindow *aWindow, nsIPresShell **aPresShell);
   1.108 +  static nsresult  GetSelectionControllerFromWindow(nsPIDOMWindow *aWindow, nsISelectionController **aSelCon);
   1.109 +
   1.110 +  // no member variables, please, we're stateless!
   1.111 +};
   1.112 +
   1.113 +// this class implements commands whose behavior depends on the 'browse with caret' setting
   1.114 +class nsSelectMoveScrollCommand : public nsSelectionCommandsBase
   1.115 +{
   1.116 +public:
   1.117 +
   1.118 +  NS_IMETHOD DoCommand(const char * aCommandName, nsISupports *aCommandContext);
   1.119 +
   1.120 +  // no member variables, please, we're stateless!
   1.121 +};
   1.122 +
   1.123 +// this class implements other selection commands
   1.124 +class nsSelectCommand : public nsSelectionCommandsBase
   1.125 +{
   1.126 +public:
   1.127 +
   1.128 +  NS_IMETHOD DoCommand(const char * aCommandName, nsISupports *aCommandContext);
   1.129 +
   1.130 +  // no member variables, please, we're stateless!
   1.131 +};
   1.132 +
   1.133 +#if 0
   1.134 +#pragma mark -
   1.135 +#endif
   1.136 +
   1.137 +
   1.138 +NS_IMPL_ISUPPORTS(nsSelectionCommandsBase, nsIControllerCommand)
   1.139 +
   1.140 +/* boolean isCommandEnabled (in string aCommandName, in nsISupports aCommandContext); */
   1.141 +NS_IMETHODIMP
   1.142 +nsSelectionCommandsBase::IsCommandEnabled(const char * aCommandName,
   1.143 +                                      nsISupports *aCommandContext,
   1.144 +                                      bool *outCmdEnabled)
   1.145 +{
   1.146 +  // XXX this needs fixing. e.g. you can't scroll up if you're already at the top of
   1.147 +  // the document.
   1.148 +  *outCmdEnabled = true;
   1.149 +  return NS_OK;
   1.150 +}
   1.151 +
   1.152 +/* void getCommandStateParams (in string aCommandName, in nsICommandParams aParams, in nsISupports aCommandContext); */
   1.153 +NS_IMETHODIMP
   1.154 +nsSelectionCommandsBase::GetCommandStateParams(const char *aCommandName,
   1.155 +                                            nsICommandParams *aParams, nsISupports *aCommandContext)
   1.156 +{
   1.157 +  // XXX we should probably return the enabled state
   1.158 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.159 +}
   1.160 +
   1.161 +/* void doCommandParams (in string aCommandName, in nsICommandParams aParams, in nsISupports aCommandContext); */
   1.162 +NS_IMETHODIMP
   1.163 +nsSelectionCommandsBase::DoCommandParams(const char *aCommandName,
   1.164 +                                       nsICommandParams *aParams, nsISupports *aCommandContext)
   1.165 +{
   1.166 +  return DoCommand(aCommandName, aCommandContext);
   1.167 +}
   1.168 +
   1.169 +// protected methods
   1.170 +
   1.171 +nsresult
   1.172 +nsSelectionCommandsBase::GetPresShellFromWindow(nsPIDOMWindow *aWindow, nsIPresShell **aPresShell)
   1.173 +{
   1.174 +  *aPresShell = nullptr;
   1.175 +  NS_ENSURE_TRUE(aWindow, NS_ERROR_FAILURE);
   1.176 +
   1.177 +  nsIDocShell *docShell = aWindow->GetDocShell();
   1.178 +  NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
   1.179 +
   1.180 +  NS_IF_ADDREF(*aPresShell = docShell->GetPresShell());
   1.181 +  return NS_OK;
   1.182 +}
   1.183 +
   1.184 +nsresult
   1.185 +nsSelectionCommandsBase::GetSelectionControllerFromWindow(nsPIDOMWindow *aWindow, nsISelectionController **aSelCon)
   1.186 +{
   1.187 +  *aSelCon = nullptr;
   1.188 +
   1.189 +  nsCOMPtr<nsIPresShell> presShell;
   1.190 +  GetPresShellFromWindow(aWindow, getter_AddRefs(presShell));
   1.191 +  if (presShell)
   1.192 +    return CallQueryInterface(presShell, aSelCon);
   1.193 +
   1.194 +  return NS_ERROR_FAILURE;
   1.195 +}
   1.196 +
   1.197 +#if 0
   1.198 +#pragma mark -
   1.199 +#endif
   1.200 +
   1.201 +static const struct BrowseCommand {
   1.202 +  const char *reverse, *forward;
   1.203 +  nsresult (NS_STDCALL nsISelectionController::*scroll)(bool);
   1.204 +  nsresult (NS_STDCALL nsISelectionController::*move)(bool, bool);
   1.205 +} browseCommands[] = {
   1.206 + { sScrollTopString, sScrollBottomString,
   1.207 +   &nsISelectionController::CompleteScroll },
   1.208 + { sScrollPageUpString, sScrollPageDownString,
   1.209 +   &nsISelectionController::ScrollPage },
   1.210 + { sScrollLineUpString, sScrollLineDownString,
   1.211 +   &nsISelectionController::ScrollLine },
   1.212 + { sScrollLeftString, sScrollRightString,
   1.213 +   &nsISelectionController::ScrollCharacter },
   1.214 + { sMoveTopString, sMoveBottomString,
   1.215 +   &nsISelectionController::CompleteScroll,
   1.216 +   &nsISelectionController::CompleteMove },
   1.217 + { sMovePageUpString, sMovePageDownString,
   1.218 +   &nsISelectionController::ScrollPage,
   1.219 +   &nsISelectionController::PageMove },
   1.220 + { sLinePreviousString, sLineNextString,
   1.221 +   &nsISelectionController::ScrollLine,
   1.222 +   &nsISelectionController::LineMove },
   1.223 + { sWordPreviousString, sWordNextString,
   1.224 +   &nsISelectionController::ScrollCharacter,
   1.225 +   &nsISelectionController::WordMove },
   1.226 + { sCharPreviousString, sCharNextString,
   1.227 +   &nsISelectionController::ScrollCharacter,
   1.228 +   &nsISelectionController::CharacterMove },
   1.229 + { sBeginLineString, sEndLineString,
   1.230 +   &nsISelectionController::CompleteScroll,
   1.231 +   &nsISelectionController::IntraLineMove }
   1.232 +};
   1.233 +
   1.234 +nsresult
   1.235 +nsSelectMoveScrollCommand::DoCommand(const char *aCommandName, nsISupports *aCommandContext)
   1.236 +{
   1.237 +  nsCOMPtr<nsPIDOMWindow> piWindow(do_QueryInterface(aCommandContext));
   1.238 +  nsCOMPtr<nsISelectionController> selCont;
   1.239 +  GetSelectionControllerFromWindow(piWindow, getter_AddRefs(selCont));
   1.240 +  NS_ENSURE_TRUE(selCont, NS_ERROR_NOT_INITIALIZED);       
   1.241 +
   1.242 +  // We allow the caret to be moved with arrow keys on any window for which
   1.243 +  // the caret is enabled. In particular, this includes caret-browsing mode
   1.244 +  // in non-chrome documents.
   1.245 +  bool caretOn = false;
   1.246 +  selCont->GetCaretEnabled(&caretOn);
   1.247 +  if (!caretOn) {
   1.248 +    caretOn = Preferences::GetBool("accessibility.browsewithcaret");
   1.249 +    if (caretOn) {
   1.250 +      nsCOMPtr<nsIDocShell> docShell = piWindow->GetDocShell();
   1.251 +      if (docShell && docShell->ItemType() == nsIDocShellTreeItem::typeChrome) {
   1.252 +        caretOn = false;
   1.253 +      }
   1.254 +    }
   1.255 +  }
   1.256 +
   1.257 +  for (size_t i = 0; i < ArrayLength(browseCommands); i++) {
   1.258 +    bool forward = !strcmp(aCommandName, browseCommands[i].forward);
   1.259 +    if (forward || !strcmp(aCommandName, browseCommands[i].reverse)) {
   1.260 +      if (caretOn && browseCommands[i].move &&
   1.261 +          NS_SUCCEEDED((selCont->*(browseCommands[i].move))(forward, false))) {
   1.262 +        // adjust the focus to the new caret position
   1.263 +        nsIFocusManager* fm = nsFocusManager::GetFocusManager();
   1.264 +        if (fm) {
   1.265 +          nsCOMPtr<nsIDOMElement> result;
   1.266 +          fm->MoveFocus(piWindow, nullptr, nsIFocusManager::MOVEFOCUS_CARET,
   1.267 +                        nsIFocusManager::FLAG_NOSCROLL,
   1.268 +                        getter_AddRefs(result));
   1.269 +        }
   1.270 +        return NS_OK;
   1.271 +      }
   1.272 +      return (selCont->*(browseCommands[i].scroll))(forward);
   1.273 +    }
   1.274 +  }
   1.275 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.276 +}
   1.277 +
   1.278 +
   1.279 +#if 0
   1.280 +#pragma mark -
   1.281 +#endif
   1.282 +
   1.283 +nsresult
   1.284 +nsSelectCommand::DoCommand(const char *aCommandName, nsISupports *aCommandContext)
   1.285 +{
   1.286 +  nsCOMPtr<nsPIDOMWindow> piWindow(do_QueryInterface(aCommandContext));
   1.287 +  nsCOMPtr<nsISelectionController> selCont;
   1.288 +  GetSelectionControllerFromWindow(piWindow, getter_AddRefs(selCont));
   1.289 +  NS_ENSURE_TRUE(selCont, NS_ERROR_NOT_INITIALIZED);       
   1.290 +
   1.291 +  nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
   1.292 +
   1.293 +  // These commands are so the browser can use caret navigation key bindings -
   1.294 +  // Helps with accessibility - aaronl@netscape.com
   1.295 +  if (!nsCRT::strcmp(aCommandName, sSelectCharPreviousString))
   1.296 +    rv = selCont->CharacterMove(false, true);
   1.297 +  else if (!nsCRT::strcmp(aCommandName, sSelectCharNextString))
   1.298 +    rv = selCont->CharacterMove(true, true);
   1.299 +  else if (!nsCRT::strcmp(aCommandName, sSelectWordPreviousString))
   1.300 +    rv = selCont->WordMove(false, true);
   1.301 +  else if (!nsCRT::strcmp(aCommandName, sSelectWordNextString))
   1.302 +    rv = selCont->WordMove(true, true);
   1.303 +  else if (!nsCRT::strcmp(aCommandName, sSelectBeginLineString))
   1.304 +    rv = selCont->IntraLineMove(false, true);
   1.305 +  else if (!nsCRT::strcmp(aCommandName, sSelectEndLineString))
   1.306 +    rv = selCont->IntraLineMove(true, true);
   1.307 +  else if (!nsCRT::strcmp(aCommandName, sSelectLinePreviousString))
   1.308 +    rv = selCont->LineMove(false, true);
   1.309 +  else if (!nsCRT::strcmp(aCommandName, sSelectLineNextString))
   1.310 +    rv = selCont->LineMove(true, true);
   1.311 +  else if (!nsCRT::strcmp(aCommandName, sSelectPageUpString))
   1.312 +    rv = selCont->PageMove(false, true);
   1.313 +  else if (!nsCRT::strcmp(aCommandName, sSelectPageDownString))
   1.314 +    rv = selCont->PageMove(true, true);
   1.315 +  else if (!nsCRT::strcmp(aCommandName, sSelectTopString))
   1.316 +    rv = selCont->CompleteMove(false, true);
   1.317 +  else if (!nsCRT::strcmp(aCommandName, sSelectBottomString))
   1.318 +    rv = selCont->CompleteMove(true, true);
   1.319 +
   1.320 +  return rv;
   1.321 +}
   1.322 +
   1.323 +#if 0
   1.324 +#pragma mark -
   1.325 +#endif
   1.326 +
   1.327 +class nsClipboardCommand MOZ_FINAL : public nsIControllerCommand
   1.328 +{
   1.329 +public:
   1.330 +
   1.331 +  NS_DECL_ISUPPORTS
   1.332 +  NS_DECL_NSICONTROLLERCOMMAND
   1.333 +};
   1.334 +
   1.335 +NS_IMPL_ISUPPORTS(nsClipboardCommand, nsIControllerCommand)
   1.336 +
   1.337 +nsresult
   1.338 +nsClipboardCommand::IsCommandEnabled(const char* aCommandName, nsISupports *aContext, bool *outCmdEnabled)
   1.339 +{
   1.340 +  NS_ENSURE_ARG_POINTER(outCmdEnabled);
   1.341 +  *outCmdEnabled = false;
   1.342 +
   1.343 +  if (strcmp(aCommandName, "cmd_copy"))
   1.344 +    return NS_OK;
   1.345 +
   1.346 +  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aContext);
   1.347 +  NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
   1.348 +
   1.349 +  nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
   1.350 +  *outCmdEnabled = nsCopySupport::CanCopy(doc);
   1.351 +  return NS_OK;
   1.352 +}
   1.353 +
   1.354 +nsresult
   1.355 +nsClipboardCommand::DoCommand(const char *aCommandName, nsISupports *aContext)
   1.356 +{
   1.357 +  if (strcmp(aCommandName, "cmd_copy"))
   1.358 +    return NS_OK;
   1.359 +
   1.360 +  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aContext);
   1.361 +  NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
   1.362 +
   1.363 +  nsIDocShell *docShell = window->GetDocShell();
   1.364 +  NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
   1.365 +
   1.366 +  nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
   1.367 +  NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
   1.368 +
   1.369 +  nsCopySupport::FireClipboardEvent(NS_COPY, nsIClipboard::kGlobalClipboard, presShell, nullptr);
   1.370 +  return NS_OK;
   1.371 +}
   1.372 +
   1.373 +NS_IMETHODIMP
   1.374 +nsClipboardCommand::GetCommandStateParams(const char *aCommandName,
   1.375 +                                              nsICommandParams *aParams, nsISupports *aCommandContext)
   1.376 +{
   1.377 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.378 +}
   1.379 +
   1.380 +nsresult
   1.381 +nsClipboardCommand::DoCommandParams(const char *aCommandName, nsICommandParams* aParams, nsISupports *aContext)
   1.382 +{
   1.383 +  return DoCommand(aCommandName, aContext);
   1.384 +}
   1.385 +
   1.386 +#if 0
   1.387 +#pragma mark -
   1.388 +#endif
   1.389 +
   1.390 +class nsSelectionCommand : public nsIControllerCommand
   1.391 +{
   1.392 +public:
   1.393 +  virtual ~nsSelectionCommand() {}
   1.394 +
   1.395 +  NS_DECL_ISUPPORTS
   1.396 +  NS_DECL_NSICONTROLLERCOMMAND
   1.397 +
   1.398 +protected:
   1.399 +
   1.400 +  virtual nsresult    IsClipboardCommandEnabled(const char * aCommandName, nsIContentViewerEdit* aEdit, bool *outCmdEnabled) = 0;
   1.401 +  virtual nsresult    DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams) = 0;
   1.402 +  
   1.403 +  static nsresult     GetContentViewerEditFromContext(nsISupports *aContext, nsIContentViewerEdit **aEditInterface);
   1.404 +  
   1.405 +  // no member variables, please, we're stateless!
   1.406 +};
   1.407 +
   1.408 +
   1.409 +NS_IMPL_ISUPPORTS(nsSelectionCommand, nsIControllerCommand)
   1.410 +
   1.411 +
   1.412 +/*---------------------------------------------------------------------------
   1.413 +
   1.414 +  nsSelectionCommand
   1.415 +
   1.416 +----------------------------------------------------------------------------*/
   1.417 +
   1.418 +NS_IMETHODIMP
   1.419 +nsSelectionCommand::IsCommandEnabled(const char * aCommandName,
   1.420 +                                     nsISupports *aCommandContext,
   1.421 +                                     bool *outCmdEnabled)
   1.422 +{
   1.423 +  NS_ENSURE_ARG_POINTER(outCmdEnabled);
   1.424 +  *outCmdEnabled = false;
   1.425 +
   1.426 +  nsCOMPtr<nsIContentViewerEdit> contentEdit;
   1.427 +  GetContentViewerEditFromContext(aCommandContext,  getter_AddRefs(contentEdit));
   1.428 +  NS_ENSURE_TRUE(contentEdit, NS_ERROR_NOT_INITIALIZED);
   1.429 +
   1.430 +  return IsClipboardCommandEnabled(aCommandName, contentEdit, outCmdEnabled);
   1.431 +}
   1.432 +
   1.433 +NS_IMETHODIMP
   1.434 +nsSelectionCommand::DoCommand(const char *aCommandName,
   1.435 +                              nsISupports *aCommandContext)
   1.436 +{
   1.437 +  nsCOMPtr<nsIContentViewerEdit> contentEdit;
   1.438 +  GetContentViewerEditFromContext(aCommandContext,  getter_AddRefs(contentEdit));
   1.439 +  NS_ENSURE_TRUE(contentEdit, NS_ERROR_NOT_INITIALIZED);
   1.440 +
   1.441 +  return DoClipboardCommand(aCommandName, contentEdit, nullptr);
   1.442 +}
   1.443 +
   1.444 +NS_IMETHODIMP
   1.445 +nsSelectionCommand::GetCommandStateParams(const char *aCommandName,
   1.446 +                                          nsICommandParams *aParams,
   1.447 +                                          nsISupports *aCommandContext)
   1.448 +{
   1.449 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.450 +}
   1.451 +
   1.452 +NS_IMETHODIMP
   1.453 +nsSelectionCommand::DoCommandParams(const char *aCommandName,
   1.454 +                                    nsICommandParams *aParams,
   1.455 +                                    nsISupports *aCommandContext)
   1.456 +{
   1.457 +  nsCOMPtr<nsIContentViewerEdit> contentEdit;
   1.458 +  GetContentViewerEditFromContext(aCommandContext,  getter_AddRefs(contentEdit));
   1.459 +  NS_ENSURE_TRUE(contentEdit, NS_ERROR_NOT_INITIALIZED);
   1.460 +
   1.461 +  return DoClipboardCommand(aCommandName, contentEdit, aParams);
   1.462 +}
   1.463 +
   1.464 +nsresult
   1.465 +nsSelectionCommand::GetContentViewerEditFromContext(nsISupports *aContext,
   1.466 +                                                    nsIContentViewerEdit **aEditInterface)
   1.467 +{
   1.468 +  NS_ENSURE_ARG(aEditInterface);
   1.469 +  *aEditInterface = nullptr;
   1.470 +
   1.471 +  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aContext);
   1.472 +  NS_ENSURE_TRUE(window, NS_ERROR_INVALID_ARG);
   1.473 +
   1.474 +  nsIDocShell *docShell = window->GetDocShell();
   1.475 +  NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
   1.476 +
   1.477 +  nsCOMPtr<nsIContentViewer> viewer;
   1.478 +  docShell->GetContentViewer(getter_AddRefs(viewer));
   1.479 +  nsCOMPtr<nsIContentViewerEdit> edit(do_QueryInterface(viewer));
   1.480 +  NS_ENSURE_TRUE(edit, NS_ERROR_FAILURE);
   1.481 +
   1.482 +  *aEditInterface = edit;
   1.483 +  NS_ADDREF(*aEditInterface);
   1.484 +  return NS_OK;
   1.485 +}
   1.486 +
   1.487 +#if 0
   1.488 +#pragma mark -
   1.489 +#endif
   1.490 +
   1.491 +#define NS_DECL_CLIPBOARD_COMMAND(_cmd)                                                     \
   1.492 +class _cmd : public nsSelectionCommand                                                      \
   1.493 +{                                                                                           \
   1.494 +protected:                                                                                  \
   1.495 +                                                                                            \
   1.496 +  virtual nsresult    IsClipboardCommandEnabled(const char* aCommandName,                   \
   1.497 +                                  nsIContentViewerEdit* aEdit, bool *outCmdEnabled);        \
   1.498 +  virtual nsresult    DoClipboardCommand(const char* aCommandName,                          \
   1.499 +                                  nsIContentViewerEdit* aEdit, nsICommandParams* aParams);  \
   1.500 +  /* no member variables, please, we're stateless! */                                       \
   1.501 +};
   1.502 +
   1.503 +NS_DECL_CLIPBOARD_COMMAND(nsClipboardCopyLinkCommand)
   1.504 +NS_DECL_CLIPBOARD_COMMAND(nsClipboardImageCommands)
   1.505 +NS_DECL_CLIPBOARD_COMMAND(nsClipboardSelectAllNoneCommands)
   1.506 +NS_DECL_CLIPBOARD_COMMAND(nsClipboardGetContentsCommand)
   1.507 +
   1.508 +nsresult
   1.509 +nsClipboardCopyLinkCommand::IsClipboardCommandEnabled(const char* aCommandName, nsIContentViewerEdit* aEdit, bool *outCmdEnabled)
   1.510 +{
   1.511 +  return aEdit->GetInLink(outCmdEnabled);
   1.512 +}
   1.513 +
   1.514 +nsresult
   1.515 +nsClipboardCopyLinkCommand::DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams)
   1.516 +{
   1.517 +  return aEdit->CopyLinkLocation();
   1.518 +}
   1.519 +
   1.520 +#if 0
   1.521 +#pragma mark -
   1.522 +#endif
   1.523 +
   1.524 +nsresult
   1.525 +nsClipboardImageCommands::IsClipboardCommandEnabled(const char* aCommandName, nsIContentViewerEdit* aEdit, bool *outCmdEnabled)
   1.526 +{
   1.527 +  return aEdit->GetInImage(outCmdEnabled);
   1.528 +}
   1.529 +
   1.530 +nsresult
   1.531 +nsClipboardImageCommands::DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams)
   1.532 +{
   1.533 +  if (!nsCRT::strcmp(sCopyImageLocationString, aCommandName))
   1.534 +    return aEdit->CopyImage(nsIContentViewerEdit::COPY_IMAGE_TEXT);
   1.535 +  if (!nsCRT::strcmp(sCopyImageContentsString, aCommandName))
   1.536 +    return aEdit->CopyImage(nsIContentViewerEdit::COPY_IMAGE_DATA);
   1.537 +  int32_t copyFlags = nsIContentViewerEdit::COPY_IMAGE_DATA | 
   1.538 +                      nsIContentViewerEdit::COPY_IMAGE_HTML;
   1.539 +  if (aParams)
   1.540 +    aParams->GetLongValue("imageCopy", &copyFlags);
   1.541 +  return aEdit->CopyImage(copyFlags);
   1.542 +}
   1.543 +
   1.544 +#if 0
   1.545 +#pragma mark -
   1.546 +#endif
   1.547 +
   1.548 +nsresult
   1.549 +nsClipboardSelectAllNoneCommands::IsClipboardCommandEnabled(const char* aCommandName, nsIContentViewerEdit* aEdit, bool *outCmdEnabled)
   1.550 +{
   1.551 +  *outCmdEnabled = true;
   1.552 +  return NS_OK;
   1.553 +}
   1.554 +
   1.555 +nsresult
   1.556 +nsClipboardSelectAllNoneCommands::DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams)
   1.557 +{
   1.558 +  if (!nsCRT::strcmp(sSelectAllString, aCommandName))
   1.559 +    return aEdit->SelectAll();
   1.560 +
   1.561 +  return aEdit->ClearSelection();
   1.562 +}
   1.563 +
   1.564 +
   1.565 +#if 0
   1.566 +#pragma mark -
   1.567 +#endif
   1.568 +
   1.569 +nsresult
   1.570 +nsClipboardGetContentsCommand::IsClipboardCommandEnabled(const char* aCommandName, nsIContentViewerEdit* aEdit, bool *outCmdEnabled)
   1.571 +{
   1.572 +  return aEdit->GetCanGetContents(outCmdEnabled);
   1.573 +}
   1.574 +
   1.575 +nsresult
   1.576 +nsClipboardGetContentsCommand::DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams)
   1.577 +{
   1.578 +  NS_ENSURE_ARG(aParams);
   1.579 +
   1.580 +  nsAutoCString mimeType("text/plain");
   1.581 +
   1.582 +  nsXPIDLCString format;    // nsICommandParams needs to use nsACString
   1.583 +  if (NS_SUCCEEDED(aParams->GetCStringValue("format", getter_Copies(format))))
   1.584 +    mimeType.Assign(format);
   1.585 +  
   1.586 +  bool selectionOnly = false;
   1.587 +  aParams->GetBooleanValue("selection_only", &selectionOnly);
   1.588 +  
   1.589 +  nsAutoString contents;
   1.590 +  nsresult rv = aEdit->GetContents(mimeType.get(), selectionOnly, contents);
   1.591 +  if (NS_FAILED(rv))
   1.592 +    return rv;
   1.593 +    
   1.594 +  return aParams->SetStringValue("result", contents);
   1.595 +}
   1.596 +
   1.597 +#if 0   // Remove unless needed again, bug 204777
   1.598 +class nsWebNavigationBaseCommand : public nsIControllerCommand
   1.599 +{
   1.600 +public:
   1.601 +  virtual ~nsWebNavigationBaseCommand() {}
   1.602 +
   1.603 +  NS_DECL_ISUPPORTS
   1.604 +  NS_DECL_NSICONTROLLERCOMMAND
   1.605 +
   1.606 +protected:
   1.607 +
   1.608 +  virtual nsresult    IsWebNavCommandEnabled(const char * aCommandName, nsIWebNavigation* aWebNavigation, bool *outCmdEnabled) = 0;
   1.609 +  virtual nsresult    DoWebNavCommand(const char *aCommandName, nsIWebNavigation* aWebNavigation) = 0;
   1.610 +  
   1.611 +  static nsresult     GetWebNavigationFromContext(nsISupports *aContext, nsIWebNavigation **aWebNavigation);
   1.612 +  
   1.613 +  // no member variables, please, we're stateless!
   1.614 +};
   1.615 +
   1.616 +class nsGoForwardCommand : public nsWebNavigationBaseCommand
   1.617 +{
   1.618 +protected:
   1.619 +
   1.620 +  virtual nsresult    IsWebNavCommandEnabled(const char * aCommandName, nsIWebNavigation* aWebNavigation, bool *outCmdEnabled);
   1.621 +  virtual nsresult    DoWebNavCommand(const char *aCommandName, nsIWebNavigation* aWebNavigation);
   1.622 +  // no member variables, please, we're stateless!
   1.623 +};
   1.624 +
   1.625 +class nsGoBackCommand : public nsWebNavigationBaseCommand
   1.626 +{
   1.627 +protected:
   1.628 +
   1.629 +  virtual nsresult    IsWebNavCommandEnabled(const char * aCommandName, nsIWebNavigation* aWebNavigation, bool *outCmdEnabled);
   1.630 +  virtual nsresult    DoWebNavCommand(const char *aCommandName, nsIWebNavigation* aWebNavigation);
   1.631 +  // no member variables, please, we're stateless!
   1.632 +};
   1.633 +
   1.634 +/*---------------------------------------------------------------------------
   1.635 +
   1.636 +  nsWebNavigationCommands
   1.637 +     no params
   1.638 +----------------------------------------------------------------------------*/
   1.639 +
   1.640 +NS_IMPL_ISUPPORTS(nsWebNavigationBaseCommand, nsIControllerCommand)
   1.641 +
   1.642 +NS_IMETHODIMP
   1.643 +nsWebNavigationBaseCommand::IsCommandEnabled(const char * aCommandName,
   1.644 +                                          nsISupports *aCommandContext,
   1.645 +                                          bool *outCmdEnabled)
   1.646 +{
   1.647 +  NS_ENSURE_ARG_POINTER(outCmdEnabled);
   1.648 +  *outCmdEnabled = false;
   1.649 +
   1.650 +  nsCOMPtr<nsIWebNavigation> webNav;
   1.651 +  GetWebNavigationFromContext(aCommandContext, getter_AddRefs(webNav));
   1.652 +  NS_ENSURE_TRUE(webNav, NS_ERROR_INVALID_ARG);
   1.653 +  
   1.654 +  return IsCommandEnabled(aCommandName, webNav, outCmdEnabled);
   1.655 +}
   1.656 +
   1.657 +NS_IMETHODIMP
   1.658 +nsWebNavigationBaseCommand::GetCommandStateParams(const char *aCommandName,
   1.659 +                                            nsICommandParams *aParams, nsISupports *aCommandContext)
   1.660 +{
   1.661 +  // XXX we should probably return the enabled state
   1.662 +  return NS_ERROR_NOT_IMPLEMENTED;
   1.663 +}
   1.664 +
   1.665 +NS_IMETHODIMP
   1.666 +nsWebNavigationBaseCommand::DoCommand(const char *aCommandName,
   1.667 +                                   nsISupports *aCommandContext)
   1.668 +{
   1.669 +  nsCOMPtr<nsIWebNavigation> webNav;
   1.670 +  GetWebNavigationFromContext(aCommandContext, getter_AddRefs(webNav));
   1.671 +  NS_ENSURE_TRUE(webNav, NS_ERROR_INVALID_ARG);
   1.672 +  
   1.673 +  return DoWebNavCommand(aCommandName, webNav);
   1.674 +}
   1.675 +
   1.676 +/* void doCommandParams (in string aCommandName, in nsICommandParams aParams, in nsISupports aCommandContext); */
   1.677 +NS_IMETHODIMP
   1.678 +nsWebNavigationBaseCommand::DoCommandParams(const char *aCommandName,
   1.679 +                                       nsICommandParams *aParams, nsISupports *aCommandContext)
   1.680 +{
   1.681 +  return DoCommand(aCommandName, aCommandContext);
   1.682 +}
   1.683 +
   1.684 +nsresult
   1.685 +nsWebNavigationBaseCommand::GetWebNavigationFromContext(nsISupports *aContext, nsIWebNavigation **aWebNavigation)
   1.686 +{
   1.687 +  nsCOMPtr<nsIInterfaceRequestor> windowReq = do_QueryInterface(aContext);
   1.688 +  CallGetInterface(windowReq.get(), aWebNavigation);
   1.689 +  return (*aWebNavigation) ? NS_OK : NS_ERROR_FAILURE;
   1.690 +}
   1.691 +
   1.692 +nsresult
   1.693 +nsGoForwardCommand::IsWebNavCommandEnabled(const char * aCommandName, nsIWebNavigation* aWebNavigation, bool *outCmdEnabled)
   1.694 +{
   1.695 +  return aWebNavigation->GetCanGoForward(outCmdEnabled);
   1.696 +}
   1.697 +
   1.698 +nsresult
   1.699 +nsGoForwardCommand::DoWebNavCommand(const char *aCommandName, nsIWebNavigation* aWebNavigation)
   1.700 +{
   1.701 +  return aWebNavigation->GoForward();
   1.702 +}
   1.703 +
   1.704 +nsresult
   1.705 +nsGoBackCommand::IsWebNavCommandEnabled(const char * aCommandName, nsIWebNavigation* aWebNavigation, bool *outCmdEnabled)
   1.706 +{
   1.707 +  return aWebNavigation->GetCanGoBack(outCmdEnabled);
   1.708 +}
   1.709 +
   1.710 +nsresult
   1.711 +nsGoBackCommand::DoWebNavCommand(const char *aCommandName, nsIWebNavigation* aWebNavigation)
   1.712 +{
   1.713 +  return aWebNavigation->GoBack();
   1.714 +}
   1.715 +#endif
   1.716 +
   1.717 +/*---------------------------------------------------------------------------
   1.718 +
   1.719 +  nsClipboardDragDropHookCommand
   1.720 +      params        value type   possible values
   1.721 +      "addhook"     isupports    nsIClipboardDragDropHooks as nsISupports
   1.722 +      "removehook"  isupports    nsIClipboardDragDropHooks as nsISupports
   1.723 +
   1.724 +----------------------------------------------------------------------------*/
   1.725 +
   1.726 +class nsClipboardDragDropHookCommand MOZ_FINAL : public nsIControllerCommand
   1.727 +{
   1.728 +public:
   1.729 +
   1.730 +  NS_DECL_ISUPPORTS
   1.731 +  NS_DECL_NSICONTROLLERCOMMAND
   1.732 +
   1.733 +protected:                                                                                   
   1.734 +  // no member variables, please, we're stateless!
   1.735 +};
   1.736 +
   1.737 +
   1.738 +NS_IMPL_ISUPPORTS(nsClipboardDragDropHookCommand, nsIControllerCommand)
   1.739 +
   1.740 +NS_IMETHODIMP
   1.741 +nsClipboardDragDropHookCommand::IsCommandEnabled(const char * aCommandName,
   1.742 +                                                 nsISupports *aCommandContext,
   1.743 +                                                 bool *outCmdEnabled)
   1.744 +{
   1.745 +  *outCmdEnabled = true;
   1.746 +  return NS_OK;
   1.747 +}
   1.748 +
   1.749 +NS_IMETHODIMP
   1.750 +nsClipboardDragDropHookCommand::DoCommand(const char *aCommandName,
   1.751 +                                          nsISupports *aCommandContext)
   1.752 +{
   1.753 +  return NS_ERROR_FAILURE;
   1.754 +}
   1.755 +
   1.756 +NS_IMETHODIMP
   1.757 +nsClipboardDragDropHookCommand::DoCommandParams(const char *aCommandName,
   1.758 +                                                nsICommandParams *aParams,
   1.759 +                                                nsISupports *aCommandContext)
   1.760 +{
   1.761 +  NS_ENSURE_ARG(aParams);
   1.762 +
   1.763 +  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aCommandContext);
   1.764 +  NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
   1.765 +
   1.766 +  nsIDocShell *docShell = window->GetDocShell();
   1.767 +
   1.768 +  nsCOMPtr<nsIClipboardDragDropHookList> obj = do_GetInterface(docShell);
   1.769 +  if (!obj) return NS_ERROR_INVALID_ARG;
   1.770 +
   1.771 +  nsCOMPtr<nsISupports> isuppHook;
   1.772 +
   1.773 +  nsresult returnValue = NS_OK;
   1.774 +  nsresult rv = aParams->GetISupportsValue("addhook", getter_AddRefs(isuppHook));
   1.775 +  if (NS_SUCCEEDED(rv))
   1.776 +  {
   1.777 +    nsCOMPtr<nsIClipboardDragDropHooks> hook = do_QueryInterface(isuppHook);
   1.778 +    if (hook)
   1.779 +      returnValue = obj->AddClipboardDragDropHooks(hook);
   1.780 +    else
   1.781 +      returnValue = NS_ERROR_INVALID_ARG;
   1.782 +  }
   1.783 +
   1.784 +  rv = aParams->GetISupportsValue("removehook", getter_AddRefs(isuppHook));
   1.785 +  if (NS_SUCCEEDED(rv))
   1.786 +  {
   1.787 +    nsCOMPtr<nsIClipboardDragDropHooks> hook = do_QueryInterface(isuppHook);
   1.788 +    if (hook)
   1.789 +    {
   1.790 +      rv = obj->RemoveClipboardDragDropHooks(hook);
   1.791 +      if (NS_FAILED(rv) && NS_SUCCEEDED(returnValue))
   1.792 +        returnValue = rv;
   1.793 +    }
   1.794 +    else
   1.795 +      returnValue = NS_ERROR_INVALID_ARG;
   1.796 +  }
   1.797 +
   1.798 +  return returnValue;
   1.799 +}
   1.800 +
   1.801 +NS_IMETHODIMP
   1.802 +nsClipboardDragDropHookCommand::GetCommandStateParams(const char *aCommandName,
   1.803 +                                                      nsICommandParams *aParams,
   1.804 +                                                      nsISupports *aCommandContext)
   1.805 +{
   1.806 +  NS_ENSURE_ARG_POINTER(aParams);
   1.807 +  return aParams->SetBooleanValue("state_enabled", true);
   1.808 +}
   1.809 +
   1.810 +/*---------------------------------------------------------------------------
   1.811 +
   1.812 +  RegisterWindowCommands
   1.813 +
   1.814 +----------------------------------------------------------------------------*/
   1.815 +
   1.816 +#define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName)                \
   1.817 +  {                                                                 \
   1.818 +    _cmdClass* theCmd = new _cmdClass();                            \
   1.819 +    if (!theCmd) return NS_ERROR_OUT_OF_MEMORY;                     \
   1.820 +    rv = inCommandTable->RegisterCommand(_cmdName,                  \
   1.821 +                   static_cast<nsIControllerCommand *>(theCmd));    \
   1.822 +  }
   1.823 +
   1.824 +#define NS_REGISTER_FIRST_COMMAND(_cmdClass, _cmdName)              \
   1.825 +  {                                                                 \
   1.826 +    _cmdClass* theCmd = new _cmdClass();                            \
   1.827 +    if (!theCmd) return NS_ERROR_OUT_OF_MEMORY;                     \
   1.828 +    rv = inCommandTable->RegisterCommand(_cmdName,                  \
   1.829 +                   static_cast<nsIControllerCommand *>(theCmd));
   1.830 +
   1.831 +#define NS_REGISTER_NEXT_COMMAND(_cmdClass, _cmdName)               \
   1.832 +    rv = inCommandTable->RegisterCommand(_cmdName,                  \
   1.833 +                   static_cast<nsIControllerCommand *>(theCmd));
   1.834 +
   1.835 +#define NS_REGISTER_LAST_COMMAND(_cmdClass, _cmdName)               \
   1.836 +    rv = inCommandTable->RegisterCommand(_cmdName,                  \
   1.837 +                   static_cast<nsIControllerCommand *>(theCmd));    \
   1.838 +  }
   1.839 +
   1.840 +
   1.841 +// static
   1.842 +nsresult
   1.843 +nsWindowCommandRegistration::RegisterWindowCommands(
   1.844 +                               nsIControllerCommandTable *inCommandTable)
   1.845 +{
   1.846 +  nsresult rv;
   1.847 +
   1.848 +  // XXX rework the macros to use a loop is possible, reducing code size
   1.849 +  
   1.850 +  // this set of commands is affected by the 'browse with caret' setting
   1.851 +  NS_REGISTER_FIRST_COMMAND(nsSelectMoveScrollCommand, sScrollTopString);
   1.852 +  NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sScrollBottomString);
   1.853 +  NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sScrollPageUpString);
   1.854 +  NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sScrollPageDownString);
   1.855 +  NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sScrollLineUpString);
   1.856 +  NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sScrollLineDownString);
   1.857 +  NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sScrollLeftString);
   1.858 +  NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sScrollRightString);
   1.859 +  NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sMoveTopString);
   1.860 +  NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sMoveBottomString);
   1.861 +  NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sWordPreviousString);
   1.862 +  NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sWordNextString);
   1.863 +  NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sBeginLineString);
   1.864 +  NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sEndLineString);
   1.865 +  NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sMovePageUpString);
   1.866 +  NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sMovePageDownString);
   1.867 +  NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sLinePreviousString);
   1.868 +  NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sLineNextString);
   1.869 +  NS_REGISTER_NEXT_COMMAND(nsSelectMoveScrollCommand, sCharPreviousString);
   1.870 +  NS_REGISTER_LAST_COMMAND(nsSelectMoveScrollCommand, sCharNextString);
   1.871 +
   1.872 +  NS_REGISTER_FIRST_COMMAND(nsSelectCommand, sSelectCharPreviousString);
   1.873 +  NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectCharNextString);
   1.874 +  NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectWordPreviousString);
   1.875 +  NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectWordNextString);
   1.876 +  NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectBeginLineString);
   1.877 +  NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectEndLineString);
   1.878 +  NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectLinePreviousString);
   1.879 +  NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectLineNextString);
   1.880 +  NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectPageUpString);
   1.881 +  NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectPageDownString);
   1.882 +  NS_REGISTER_NEXT_COMMAND(nsSelectCommand, sSelectTopString);
   1.883 +  NS_REGISTER_LAST_COMMAND(nsSelectCommand, sSelectBottomString);
   1.884 +
   1.885 +  NS_REGISTER_ONE_COMMAND(nsClipboardCommand, "cmd_cut");
   1.886 +  NS_REGISTER_ONE_COMMAND(nsClipboardCommand, "cmd_copy");
   1.887 +  NS_REGISTER_ONE_COMMAND(nsClipboardCommand, "cmd_paste");
   1.888 +  NS_REGISTER_ONE_COMMAND(nsClipboardCopyLinkCommand, "cmd_copyLink");
   1.889 +  NS_REGISTER_FIRST_COMMAND(nsClipboardImageCommands, sCopyImageLocationString);
   1.890 +  NS_REGISTER_NEXT_COMMAND(nsClipboardImageCommands, sCopyImageContentsString);
   1.891 +  NS_REGISTER_LAST_COMMAND(nsClipboardImageCommands, sCopyImageString);
   1.892 +  NS_REGISTER_FIRST_COMMAND(nsClipboardSelectAllNoneCommands, sSelectAllString);
   1.893 +  NS_REGISTER_LAST_COMMAND(nsClipboardSelectAllNoneCommands, sSelectNoneString);
   1.894 +
   1.895 +  NS_REGISTER_ONE_COMMAND(nsClipboardGetContentsCommand, "cmd_getContents");
   1.896 +
   1.897 +#if 0   // Remove unless needed again, bug 204777
   1.898 +  NS_REGISTER_ONE_COMMAND(nsGoBackCommand, "cmd_browserBack");
   1.899 +  NS_REGISTER_ONE_COMMAND(nsGoForwardCommand, "cmd_browserForward");
   1.900 +#endif
   1.901 +
   1.902 +  NS_REGISTER_ONE_COMMAND(nsClipboardDragDropHookCommand, "cmd_clipboardDragDropHook");
   1.903 +
   1.904 +  return rv;
   1.905 +}

mercurial