From 70e0a918a66fb6fdf3b6ccc45cb50851c4ce2786 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 18 May 2012 10:29:40 +0200 Subject: [PATCH] Bug 754228 - nsBaseStateUpdatingCommand::{ToggleState,GetCurrentState} shouldn't have an aTagName argument; r=ehsan --- editor/composer/src/nsComposerCommands.cpp | 32 ++++++++++------------ editor/composer/src/nsComposerCommands.h | 21 +++++++------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/editor/composer/src/nsComposerCommands.cpp b/editor/composer/src/nsComposerCommands.cpp index 0ec0c925ca19..8596945a3f0e 100644 --- a/editor/composer/src/nsComposerCommands.cpp +++ b/editor/composer/src/nsComposerCommands.cpp @@ -118,7 +118,7 @@ nsBaseStateUpdatingCommand::DoCommand(const char *aCommandName, nsCOMPtr editor = do_QueryInterface(refCon); NS_ENSURE_TRUE(editor, NS_ERROR_NOT_INITIALIZED); - return ToggleState(editor, mTagName); + return ToggleState(editor); } NS_IMETHODIMP @@ -136,7 +136,7 @@ nsBaseStateUpdatingCommand::GetCommandStateParams(const char *aCommandName, { nsCOMPtr editor = do_QueryInterface(refCon); if (editor) - return GetCurrentState(editor, mTagName, aParams); + return GetCurrentState(editor, aParams); return NS_OK; } @@ -201,7 +201,6 @@ nsStyleUpdatingCommand::nsStyleUpdatingCommand(const char* aTagName) nsresult nsStyleUpdatingCommand::GetCurrentState(nsIEditor *aEditor, - const char* aTagName, nsICommandParams *aParams) { NS_ASSERTION(aEditor, "Need editor here"); @@ -214,7 +213,7 @@ nsStyleUpdatingCommand::GetCurrentState(nsIEditor *aEditor, bool anyOfSelectionHasProp = false; bool allOfSelectionHasProp = false; - nsCOMPtr styleAtom = do_GetAtom(aTagName); + nsCOMPtr styleAtom = do_GetAtom(mTagName); rv = htmlEditor->GetInlineProperty(styleAtom, EmptyString(), EmptyString(), &firstOfSelectionHasProp, @@ -232,7 +231,7 @@ nsStyleUpdatingCommand::GetCurrentState(nsIEditor *aEditor, } nsresult -nsStyleUpdatingCommand::ToggleState(nsIEditor *aEditor, const char* aTagName) +nsStyleUpdatingCommand::ToggleState(nsIEditor *aEditor) { nsCOMPtr htmlEditor = do_QueryInterface(aEditor); NS_ENSURE_TRUE(htmlEditor, NS_ERROR_NO_INTERFACE); @@ -246,7 +245,7 @@ nsStyleUpdatingCommand::ToggleState(nsIEditor *aEditor, const char* aTagName) // 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")) @@ -254,7 +253,7 @@ nsStyleUpdatingCommand::ToggleState(nsIEditor *aEditor, const char* aTagName) 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); @@ -296,8 +295,7 @@ nsListCommand::nsListCommand(const char* aTagName) } nsresult -nsListCommand::GetCurrentState(nsIEditor *aEditor, const char* aTagName, - nsICommandParams *aParams) +nsListCommand::GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams) { NS_ASSERTION(aEditor, "Need editor here"); nsCOMPtr htmlEditor = do_QueryInterface(aEditor); @@ -317,7 +315,7 @@ nsListCommand::GetCurrentState(nsIEditor *aEditor, const char* aTagName, } nsresult -nsListCommand::ToggleState(nsIEditor *aEditor, const char* aTagName) +nsListCommand::ToggleState(nsIEditor *aEditor) { nsCOMPtr editor = do_QueryInterface(aEditor); NS_ENSURE_TRUE(editor, NS_NOINTERFACE); @@ -329,7 +327,7 @@ nsListCommand::ToggleState(nsIEditor *aEditor, const char* aTagName) 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); @@ -350,7 +348,7 @@ nsListItemCommand::nsListItemCommand(const char* aTagName) } nsresult -nsListItemCommand::GetCurrentState(nsIEditor *aEditor, const char* aTagName, +nsListItemCommand::GetCurrentState(nsIEditor* aEditor, nsICommandParams *aParams) { NS_ASSERTION(aEditor, "Need editor here"); @@ -377,7 +375,7 @@ nsListItemCommand::GetCurrentState(nsIEditor *aEditor, const char* aTagName, } nsresult -nsListItemCommand::ToggleState(nsIEditor *aEditor, const char* aTagName) +nsListItemCommand::ToggleState(nsIEditor *aEditor) { NS_ASSERTION(aEditor, "Need editor here"); nsCOMPtr htmlEditor = do_QueryInterface(aEditor); @@ -390,7 +388,7 @@ nsListItemCommand::ToggleState(nsIEditor *aEditor, const char* aTagName) 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); @@ -1033,7 +1031,7 @@ nsAbsolutePositioningCommand::IsCommandEnabled(const char * aCommandName, } nsresult -nsAbsolutePositioningCommand::GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams) +nsAbsolutePositioningCommand::GetCurrentState(nsIEditor *aEditor, nsICommandParams *aParams) { NS_ASSERTION(aEditor, "Need an editor here"); @@ -1062,14 +1060,14 @@ nsAbsolutePositioningCommand::GetCurrentState(nsIEditor *aEditor, const char* aT } nsresult -nsAbsolutePositioningCommand::ToggleState(nsIEditor *aEditor, const char* aTagName) +nsAbsolutePositioningCommand::ToggleState(nsIEditor *aEditor) { NS_ASSERTION(aEditor, "Need an editor here"); nsCOMPtr htmlEditor = do_QueryInterface(aEditor); NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE); - nsCOMPtr elt; + nsCOMPtr elt; nsresult rv = htmlEditor->GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(elt)); NS_ENSURE_SUCCESS(rv, rv); diff --git a/editor/composer/src/nsComposerCommands.h b/editor/composer/src/nsComposerCommands.h index 2fc216361515..18e4121ba0e3 100644 --- a/editor/composer/src/nsComposerCommands.h +++ b/editor/composer/src/nsComposerCommands.h @@ -94,10 +94,10 @@ public: 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: @@ -116,11 +116,10 @@ public: 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); }; @@ -150,10 +149,10 @@ public: 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 @@ -165,10 +164,10 @@ public: 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) @@ -278,8 +277,8 @@ public: 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