Bug 680060 - [queryCommandEnabled] check `GetIsSelectionEditable' results; r=ehsan
authorFabien Cazenave <kaze@kompozer.net>
Thu, 18 Aug 2011 11:34:52 -0400
changeset 76809 fae3f1a9327b0270f33df3150be8bcbd6139fcd3
parent 76808 861e1307c43c06c74b623b9dd6af591f646ecd31
child 76810 6bb148047bb5f3715c812434b554db38cd692747
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs680060
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 680060 - [queryCommandEnabled] check `GetIsSelectionEditable' results; r=ehsan
editor/composer/src/nsComposerCommands.cpp
editor/libeditor/base/nsEditorCommands.cpp
--- a/editor/composer/src/nsComposerCommands.cpp
+++ b/editor/composer/src/nsComposerCommands.cpp
@@ -426,17 +426,18 @@ NS_IMETHODIMP
 nsRemoveListCommand::IsCommandEnabled(const char * aCommandName,
                                       nsISupports *refCon,
                                       PRBool *outCmdEnabled)
 {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (editor)
   {
     PRBool isEditable = PR_FALSE;
-    NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+    nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+    NS_ENSURE_SUCCESS(rv, rv);
     if (isEditable)
     {
       // It is enabled if we are in any list type
       PRBool bMixed;
       PRUnichar *tagStr;
       nsresult rv = GetListState(editor, &bMixed, &tagStr);
       NS_ENSURE_SUCCESS(rv, rv);
 
@@ -538,17 +539,18 @@ nsOutdentCommand::IsCommandEnabled(const
                                    nsISupports *refCon,
                                    PRBool *outCmdEnabled)
 {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(refCon);
   if (editor && htmlEditor)
   {
     PRBool canIndent, isEditable = PR_FALSE;
-    NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+    nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+    NS_ENSURE_SUCCESS(rv, rv);
     if (isEditable)
       return htmlEditor->GetIndentState(&canIndent, outCmdEnabled);
   }
 
   *outCmdEnabled = PR_FALSE;
   return NS_OK;
 }
 
@@ -1046,17 +1048,18 @@ nsAbsolutePositioningCommand::IsCommandE
                                                nsISupports *aCommandRefCon,
                                                PRBool *outCmdEnabled)
 {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   nsCOMPtr<nsIHTMLAbsPosEditor> htmlEditor = do_QueryInterface(aCommandRefCon);
   if (htmlEditor)
   {
     PRBool isEditable = PR_FALSE;
-    NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+    nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+    NS_ENSURE_SUCCESS(rv, rv);
     if (isEditable)
       return htmlEditor->GetAbsolutePositioningEnabled(outCmdEnabled);
   }
 
   *outCmdEnabled = PR_FALSE;
   return NS_OK;
 }
 
--- a/editor/libeditor/base/nsEditorCommands.cpp
+++ b/editor/libeditor/base/nsEditorCommands.cpp
@@ -66,17 +66,18 @@ nsUndoCommand::IsCommandEnabled(const ch
                                 nsISupports *aCommandRefCon, 
                                 PRBool *outCmdEnabled)
 {
   NS_ENSURE_ARG_POINTER(outCmdEnabled);
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (editor)
   {
     PRBool isEnabled, isEditable = PR_FALSE;
-    NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+    nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+    NS_ENSURE_SUCCESS(rv, rv);
     if (isEditable)
       return editor->CanUndo(&isEnabled, outCmdEnabled);
   }
 
   *outCmdEnabled = PR_FALSE;
   return NS_OK;
 }
 
@@ -114,17 +115,18 @@ nsRedoCommand::IsCommandEnabled(const ch
                                 nsISupports *aCommandRefCon,
                                 PRBool *outCmdEnabled)
 {
   NS_ENSURE_ARG_POINTER(outCmdEnabled);
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (editor)
   {
     PRBool isEnabled, isEditable = PR_FALSE;
-    NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+    nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+    NS_ENSURE_SUCCESS(rv, rv);
     if (isEditable)
       return editor->CanRedo(&isEnabled, outCmdEnabled);
   }
 
   *outCmdEnabled = PR_FALSE;
   return NS_OK;
 }
 
@@ -210,17 +212,18 @@ nsCutCommand::IsCommandEnabled(const cha
                                nsISupports *aCommandRefCon,
                                PRBool *outCmdEnabled)
 {
   NS_ENSURE_ARG_POINTER(outCmdEnabled);
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (editor)
   {
     PRBool isEditable = PR_FALSE;
-    NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+    nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+    NS_ENSURE_SUCCESS(rv, rv);
     if (isEditable)
       return editor->CanCut(outCmdEnabled);
   }
 
   *outCmdEnabled = PR_FALSE;
   return NS_OK;
 }
 
@@ -314,17 +317,18 @@ nsCopyCommand::IsCommandEnabled(const ch
                                 nsISupports *aCommandRefCon,
                                 PRBool *outCmdEnabled)
 {
   NS_ENSURE_ARG_POINTER(outCmdEnabled);
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (editor)
   {
     PRBool isEditable = PR_FALSE;
-    NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+    nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+    NS_ENSURE_SUCCESS(rv, rv);
     if (isEditable)
       return editor->CanCopy(outCmdEnabled);
   }
 
   *outCmdEnabled = PR_FALSE;
   return NS_OK;
 }
 
@@ -417,17 +421,18 @@ nsPasteCommand::IsCommandEnabled(const c
                                  nsISupports *aCommandRefCon,
                                  PRBool *outCmdEnabled)
 {
   NS_ENSURE_ARG_POINTER(outCmdEnabled);
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (editor)
   {
     PRBool isEditable = PR_FALSE;
-    NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+    nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+    NS_ENSURE_SUCCESS(rv, rv);
     if (isEditable)
       return editor->CanPaste(nsIClipboard::kGlobalClipboard, outCmdEnabled);
   }
 
   *outCmdEnabled = PR_FALSE;
   return NS_OK;
 }
 
@@ -464,17 +469,18 @@ nsPasteTransferableCommand::IsCommandEna
                                              nsISupports *aCommandRefCon,
                                              PRBool *outCmdEnabled)
 {
   NS_ENSURE_ARG_POINTER(outCmdEnabled);
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (editor)
   {
     PRBool isEditable = PR_FALSE;
-    NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+    nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+    NS_ENSURE_SUCCESS(rv, rv);
     if (isEditable)
       return editor->CanPasteTransferable(nsnull, outCmdEnabled);
   }
 
   *outCmdEnabled = PR_FALSE;
   return NS_OK;
 }
 
@@ -575,17 +581,18 @@ nsDeleteCommand::IsCommandEnabled(const 
   NS_ENSURE_ARG_POINTER(outCmdEnabled);
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   *outCmdEnabled = PR_FALSE;
 
   // we can delete when we can cut
   NS_ENSURE_TRUE(editor, NS_OK);
     
   PRBool isEditable = PR_FALSE;
-  NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+  nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   if (!isEditable)
     return NS_OK;
   else if (!nsCRT::strcmp(aCommandName,"cmd_delete"))
     return editor->CanCut(outCmdEnabled);
   else if (!nsCRT::strcmp(aCommandName,"cmd_deleteCharBackward"))
     *outCmdEnabled = PR_TRUE;
   else if (!nsCRT::strcmp(aCommandName,"cmd_deleteCharForward"))