Bug 754228 - nsBaseStateUpdatingCommand::{ToggleState,GetCurrentState} shouldn't have an aTagName argument; r=ehsan
authorMs2ger <ms2ger@gmail.com>
Fri, 18 May 2012 10:29:40 +0200
changeset 94321 6427475255158bfaf463925c21df7cf316fc701c
parent 94320 2b6889ef8f9d9b515275d33924c7290dbdad88f4
child 94322 3b08128bda097c8cb3f625568b81f8d32aeaaf80
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersehsan
bugs754228
milestone15.0a1
Bug 754228 - nsBaseStateUpdatingCommand::{ToggleState,GetCurrentState} shouldn't have an aTagName argument; r=ehsan
editor/composer/src/nsComposerCommands.cpp
editor/composer/src/nsComposerCommands.h
--- a/editor/composer/src/nsComposerCommands.cpp
+++ b/editor/composer/src/nsComposerCommands.cpp
@@ -113,17 +113,17 @@ nsBaseStateUpdatingCommand::IsCommandEna
 
 NS_IMETHODIMP
 nsBaseStateUpdatingCommand::DoCommand(const char *aCommandName,
                                       nsISupports *refCon)
 {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   NS_ENSURE_TRUE(editor, NS_ERROR_NOT_INITIALIZED);
 
-  return ToggleState(editor, mTagName);
+  return ToggleState(editor);
 }
 
 NS_IMETHODIMP
 nsBaseStateUpdatingCommand::DoCommandParams(const char *aCommandName,
                                             nsICommandParams *aParams,
                                             nsISupports *refCon)
 {
   return DoCommand(aCommandName, refCon);
@@ -131,17 +131,17 @@ nsBaseStateUpdatingCommand::DoCommandPar
 
 NS_IMETHODIMP
 nsBaseStateUpdatingCommand::GetCommandStateParams(const char *aCommandName, 
                                                   nsICommandParams *aParams,
                                                   nsISupports *refCon)
 {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (editor)
-    return GetCurrentState(editor, mTagName, aParams);
+    return GetCurrentState(editor, aParams);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsPasteNoFormattingCommand::IsCommandEnabled(const char * aCommandName, 
                                              nsISupports *refCon, 
                                              bool *outCmdEnabled)
@@ -196,30 +196,29 @@ nsPasteNoFormattingCommand::GetCommandSt
 
 nsStyleUpdatingCommand::nsStyleUpdatingCommand(const char* aTagName)
 : nsBaseStateUpdatingCommand(aTagName)
 {
 }
 
 nsresult
 nsStyleUpdatingCommand::GetCurrentState(nsIEditor *aEditor, 
-                                        const char* aTagName,
                                         nsICommandParams *aParams)
 {
   NS_ASSERTION(aEditor, "Need editor here");
   nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
   NS_ENSURE_TRUE(htmlEditor, NS_ERROR_NOT_INITIALIZED);
   
   nsresult rv = NS_OK;
 
   bool firstOfSelectionHasProp = false;
   bool anyOfSelectionHasProp = false;
   bool allOfSelectionHasProp = false;
 
-  nsCOMPtr<nsIAtom> styleAtom = do_GetAtom(aTagName);
+  nsCOMPtr<nsIAtom> styleAtom = do_GetAtom(mTagName);
   rv = htmlEditor->GetInlineProperty(styleAtom, EmptyString(), 
                                      EmptyString(), 
                                      &firstOfSelectionHasProp, 
                                      &anyOfSelectionHasProp, 
                                      &allOfSelectionHasProp);
 
   aParams->SetBooleanValue(STATE_ENABLED, NS_SUCCEEDED(rv));
   aParams->SetBooleanValue(STATE_ALL, allOfSelectionHasProp);
@@ -227,39 +226,39 @@ nsStyleUpdatingCommand::GetCurrentState(
   aParams->SetBooleanValue(STATE_MIXED, anyOfSelectionHasProp
            && !allOfSelectionHasProp);
   aParams->SetBooleanValue(STATE_BEGIN, firstOfSelectionHasProp);
   aParams->SetBooleanValue(STATE_END, allOfSelectionHasProp);//not completely accurate
   return NS_OK;
 }
 
 nsresult
-nsStyleUpdatingCommand::ToggleState(nsIEditor *aEditor, const char* aTagName)
+nsStyleUpdatingCommand::ToggleState(nsIEditor *aEditor)
 {
   nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
   NS_ENSURE_TRUE(htmlEditor, NS_ERROR_NO_INTERFACE);
 
   //create some params now...
   nsresult rv;
   nsCOMPtr<nsICommandParams> params =
       do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID,&rv);
   if (NS_FAILED(rv) || !params)
     return rv;
 
   // tags "href" and "name" are special cases in the core editor 
   // they are used to remove named anchor/link and shouldn't be used for insertion
-  nsAutoString tagName; tagName.AssignWithConversion(aTagName);
+  nsAutoString tagName; tagName.AssignWithConversion(mTagName);
   bool doTagRemoval;
   if (tagName.EqualsLiteral("href") ||
       tagName.EqualsLiteral("name"))
     doTagRemoval = true;
   else
   {
     // check current selection; set doTagRemoval if formatting should be removed
-    rv = GetCurrentState(aEditor, aTagName, params);
+    rv = GetCurrentState(aEditor, params);
     NS_ENSURE_SUCCESS(rv, rv);
     rv = params->GetBooleanValue(STATE_ALL, &doTagRemoval);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   if (doTagRemoval) {
     // Also remove equivalent properties (bug 317093)
     if (tagName.EqualsLiteral("b")) {
@@ -291,18 +290,17 @@ nsStyleUpdatingCommand::ToggleState(nsIE
 }
 
 nsListCommand::nsListCommand(const char* aTagName)
 : nsBaseStateUpdatingCommand(aTagName)
 {
 }
 
 nsresult
-nsListCommand::GetCurrentState(nsIEditor *aEditor, const char* aTagName,
-                               nsICommandParams *aParams)
+nsListCommand::GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams)
 {
   NS_ASSERTION(aEditor, "Need editor here");
   nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
   NS_ENSURE_TRUE(htmlEditor, NS_ERROR_NO_INTERFACE);
 
   bool bMixed;
   nsAutoString localName;
   nsresult rv = GetListState(htmlEditor, &bMixed, localName);
@@ -312,29 +310,29 @@ nsListCommand::GetCurrentState(nsIEditor
   bool inList = localName.EqualsASCII(mTagName);
   aParams->SetBooleanValue(STATE_ALL, !bMixed && inList);
   aParams->SetBooleanValue(STATE_MIXED, bMixed);
   aParams->SetBooleanValue(STATE_ENABLED, true);
   return NS_OK;
 }
 
 nsresult
-nsListCommand::ToggleState(nsIEditor *aEditor, const char* aTagName)
+nsListCommand::ToggleState(nsIEditor *aEditor)
 {
   nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(aEditor);
   NS_ENSURE_TRUE(editor, NS_NOINTERFACE);
   bool inList;
   // Need to use mTagName????
   nsresult rv;
   nsCOMPtr<nsICommandParams> params =
       do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID,&rv);
   if (NS_FAILED(rv) || !params)
     return rv;
 
-  rv = GetCurrentState(aEditor, mTagName, params);
+  rv = GetCurrentState(aEditor, params);
   rv = params->GetBooleanValue(STATE_ALL,&inList);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoString listType; listType.AssignWithConversion(mTagName);
   if (inList)
     rv = editor->RemoveList(listType);    
   else
   {
@@ -345,17 +343,17 @@ nsListCommand::ToggleState(nsIEditor *aE
 }
 
 nsListItemCommand::nsListItemCommand(const char* aTagName)
 : nsBaseStateUpdatingCommand(aTagName)
 {
 }
 
 nsresult
-nsListItemCommand::GetCurrentState(nsIEditor *aEditor, const char* aTagName,
+nsListItemCommand::GetCurrentState(nsIEditor* aEditor,
                                    nsICommandParams *aParams)
 {
   NS_ASSERTION(aEditor, "Need editor here");
   // 39584
   nsCOMPtr<nsIHTMLEditor>  htmlEditor = do_QueryInterface(aEditor);
   NS_ENSURE_TRUE(htmlEditor, NS_NOINTERFACE);
 
   bool bMixed, bLI, bDT, bDD;
@@ -372,30 +370,30 @@ nsListItemCommand::GetCurrentState(nsIEd
 
   aParams->SetBooleanValue(STATE_ALL, !bMixed && inList);
   aParams->SetBooleanValue(STATE_MIXED, bMixed);
 
   return NS_OK;
 }
 
 nsresult
-nsListItemCommand::ToggleState(nsIEditor *aEditor, const char* aTagName)
+nsListItemCommand::ToggleState(nsIEditor *aEditor)
 {
   NS_ASSERTION(aEditor, "Need editor here");
   nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
   NS_ENSURE_TRUE(htmlEditor, NS_ERROR_NOT_INITIALIZED);
 
   bool inList;
   // Need to use mTagName????
   nsresult rv;
   nsCOMPtr<nsICommandParams> params =
       do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID,&rv);
   if (NS_FAILED(rv) || !params)
     return rv;
-  rv = GetCurrentState(aEditor, mTagName, params);
+  rv = GetCurrentState(aEditor, params);
   rv = params->GetBooleanValue(STATE_ALL,&inList);
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_SUCCESS(rv, rv);
   
   if (inList) {
     // To remove a list, first get what kind of list we're in
     bool bMixed;
     nsAutoString localName;
@@ -1028,17 +1026,17 @@ nsAbsolutePositioningCommand::IsCommandE
       return htmlEditor->GetAbsolutePositioningEnabled(outCmdEnabled);
   }
 
   *outCmdEnabled = false;
   return NS_OK;
 }
 
 nsresult
-nsAbsolutePositioningCommand::GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams)
+nsAbsolutePositioningCommand::GetCurrentState(nsIEditor *aEditor, nsICommandParams *aParams)
 {
   NS_ASSERTION(aEditor, "Need an editor here");
   
   nsCOMPtr<nsIHTMLAbsPosEditor> htmlEditor = do_QueryInterface(aEditor);
   NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
 
   bool isEnabled;
   htmlEditor->GetAbsolutePositioningEnabled(&isEnabled);
@@ -1057,24 +1055,24 @@ nsAbsolutePositioningCommand::GetCurrent
     outStateString.AssignLiteral("absolute");
 
   aParams->SetBooleanValue(STATE_MIXED,false);
   aParams->SetCStringValue(STATE_ATTRIBUTE, NS_ConvertUTF16toUTF8(outStateString).get());
   return NS_OK;
 }
 
 nsresult
-nsAbsolutePositioningCommand::ToggleState(nsIEditor *aEditor, const char* aTagName)
+nsAbsolutePositioningCommand::ToggleState(nsIEditor *aEditor)
 {
   NS_ASSERTION(aEditor, "Need an editor here");
   
   nsCOMPtr<nsIHTMLAbsPosEditor> htmlEditor = do_QueryInterface(aEditor);
   NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
 
-  nsCOMPtr<nsIDOMElement>  elt;
+  nsCOMPtr<nsIDOMElement> elt;
   nsresult rv = htmlEditor->GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(elt));
   NS_ENSURE_SUCCESS(rv, rv);
 
   return htmlEditor->AbsolutePositionSelection(!elt);
 }
 
 
 NS_IMETHODIMP
--- a/editor/composer/src/nsComposerCommands.h
+++ b/editor/composer/src/nsComposerCommands.h
@@ -89,20 +89,20 @@ public:
     
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSICONTROLLERCOMMAND
 
 protected:
 
   // get the current state (on or off) for this style or block format
-  virtual nsresult  GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams) = 0;
+  virtual nsresult  GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams) = 0;
   
   // add/remove the style
-  virtual nsresult  ToggleState(nsIEditor *aEditor, const char* aTagName) = 0;
+  virtual nsresult  ToggleState(nsIEditor* aEditor) = 0;
 
 protected:
 
   const char* mTagName;
 };
 
 
 // Shared class for the various style updating commands like bold, italics etc.
@@ -111,21 +111,20 @@ class nsStyleUpdatingCommand : public ns
 {
 public:
 
             nsStyleUpdatingCommand(const char* aTagName);
            
 protected:
 
   // get the current state (on or off) for this style or block format
-  virtual nsresult  GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams);
+  virtual nsresult  GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams);
   
   // add/remove the style
-  virtual nsresult  ToggleState(nsIEditor *aEditor, const char* aTagName);
-  
+  virtual nsresult  ToggleState(nsIEditor* aEditor);
 };
 
 
 class nsInsertTagCommand : public nsBaseComposerCommand
 {
 public:
 
               nsInsertTagCommand(const char* aTagName);
@@ -145,35 +144,35 @@ class nsListCommand : public nsBaseState
 {
 public:
 
             nsListCommand(const char* aTagName);
 
 protected:
 
   // get the current state (on or off) for this style or block format
-  virtual nsresult  GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams);
+  virtual nsresult  GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams);
   
   // add/remove the style
-  virtual nsresult  ToggleState(nsIEditor *aEditor, const char* aTagName);
+  virtual nsresult  ToggleState(nsIEditor* aEditor);
 };
 
 class nsListItemCommand : public nsBaseStateUpdatingCommand
 {
 public:
 
             nsListItemCommand(const char* aTagName);
 
 protected:
 
   // get the current state (on or off) for this style or block format
-  virtual nsresult  GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams);
+  virtual nsresult  GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams);
   
   // add/remove the style
-  virtual nsresult  ToggleState(nsIEditor *aEditor, const char* aTagName);
+  virtual nsresult  ToggleState(nsIEditor* aEditor);
 };
 
 // Base class for commands whose state consists of a string (e.g. para format)
 class nsMultiStateCommand : public nsBaseComposerCommand
 {
 public:
   
                    nsMultiStateCommand();
@@ -273,18 +272,18 @@ protected:
 class nsAbsolutePositioningCommand : public nsBaseStateUpdatingCommand
 {
 public:
                    nsAbsolutePositioningCommand();
 
 protected:
 
   NS_IMETHOD IsCommandEnabled(const char *aCommandName, nsISupports *aCommandRefCon, bool *_retval);
-  virtual nsresult  GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams);
-  virtual nsresult  ToggleState(nsIEditor *aEditor, const char* aTagName);
+  virtual nsresult  GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams);
+  virtual nsresult  ToggleState(nsIEditor* aEditor);
 };
 
 // composer commands
 
 NS_DECL_COMPOSER_COMMAND(nsCloseCommand)
 NS_DECL_COMPOSER_COMMAND(nsDocumentStateCommand)
 NS_DECL_COMPOSER_COMMAND(nsSetDocumentStateCommand)
 NS_DECL_COMPOSER_COMMAND(nsSetDocumentOptionsCommand)