Bug 434766 - Don't try to use the selection if we don't need one. r+sr=peterv
authorBlake Kaplan <mrbkap@gmail.com>
Wed, 01 Jul 2009 12:12:04 -0700
changeset 29948 b5bdefc2cac7e4ea1598294ce6afa2035a19dca7
parent 29947 a334624fc37ed006643f9fd6c90085975671d231
child 29949 9e01b09a82a4ebbc71869166ab47c3dae4c33673
push idunknown
push userunknown
push dateunknown
bugs434766
milestone1.9.2a1pre
Bug 434766 - Don't try to use the selection if we don't need one. r+sr=peterv
editor/libeditor/html/nsHTMLEditRules.cpp
--- a/editor/libeditor/html/nsHTMLEditRules.cpp
+++ b/editor/libeditor/html/nsHTMLEditRules.cpp
@@ -1,9 +1,10 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 sw=2 et tw=79: */
 /* ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
  * The contents of this file are subject to the Mozilla Public License Version
  * 1.1 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  * http://www.mozilla.org/MPL/
  *
@@ -595,17 +596,20 @@ nsHTMLEditRules::WillDoAction(nsISelecti
   *aCancel = PR_FALSE;
   *aHandled = PR_FALSE;
     
   // my kingdom for dynamic cast
   nsTextRulesInfo *info = static_cast<nsTextRulesInfo*>(aInfo);
 
   // Deal with actions for which we don't need to check whether the selection is
   // editable.
-  if (info->action == kOutputText) {
+  if (info->action == kOutputText ||
+      info->action == kUndo ||
+      info->action == kRedo)
+  {
     return nsTextEditRules::WillDoAction(aSelection, aInfo, aCancel, aHandled);
   }
 
   nsCOMPtr<nsIDOMRange> domRange;
   nsresult rv = aSelection->GetRangeAt(0, getter_AddRefs(domRange));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIDOMNode> selStartNode;
@@ -637,17 +641,17 @@ nsHTMLEditRules::WillDoAction(nsISelecti
       do_QueryInterface(range->GetCommonAncestor());
     if (!mHTMLEditor->IsModifiableNode(ancestor))
     {
       *aCancel = PR_TRUE;
 
       return NS_OK;
     }
   }
-    
+
   switch (info->action)
   {
     case kInsertText:
     case kInsertTextIME:
       return WillInsertText(info->action,
                             aSelection, 
                             aCancel, 
                             aHandled,