From cf8f0ec40420e6e0d311f9bc9b2b18096a37bd31 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Fri, 4 Aug 2017 15:41:42 +0900 Subject: [PATCH] Bug 1319340 - part2: GetCurrentState() of the classes in nsComposerCommands should take HTMLEditor instead of nsIEditor r=m_kato All GetCurrentState() methods in nsComposerCommands require HTMLEditor but its argument is nsIEditor*. So, it should take HTMLEditor* and it shouldn't be called if given editor isn't HTMLEditor since it's virtual method. MozReview-Commit-ID: HsvYJN8hIxN --HG-- extra : rebase_source : f8f9c8de902af5311771b71a96c76d63325970a5 --- editor/composer/nsComposerCommands.cpp | 232 ++++++++++++++----------- editor/composer/nsComposerCommands.h | 66 ++++--- 2 files changed, 169 insertions(+), 129 deletions(-) diff --git a/editor/composer/nsComposerCommands.cpp b/editor/composer/nsComposerCommands.cpp index 1943cdcd83ed..7d05db484920 100644 --- a/editor/composer/nsComposerCommands.cpp +++ b/editor/composer/nsComposerCommands.cpp @@ -7,6 +7,7 @@ #include // for printf #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc +#include "mozilla/HTMLEditor.h" // for HTMLEditor #include "nsAString.h" #include "nsCOMPtr.h" // for nsCOMPtr, do_QueryInterface, etc #include "nsComponentManagerUtils.h" // for do_CreateInstance @@ -30,7 +31,8 @@ class nsISupports; //prototype -nsresult GetListState(nsIHTMLEditor* aEditor, bool* aMixed, +nsresult GetListState(mozilla::HTMLEditor* aHTMLEditor, + bool* aMixed, nsAString& aLocalName); nsresult RemoveOneProperty(nsIHTMLEditor* aEditor, const nsAString& aProp); nsresult RemoveTextProperty(nsIHTMLEditor* aEditor, const nsAString& aProp); @@ -106,10 +108,14 @@ nsBaseStateUpdatingCommand::GetCommandStateParams(const char *aCommandName, nsISupports *refCon) { nsCOMPtr editor = do_QueryInterface(refCon); - if (editor) - return GetCurrentState(editor, aParams); - - return NS_OK; + if (!editor) { + return NS_OK; + } + mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor(); + if (NS_WARN_IF(!htmlEditor)) { + return NS_ERROR_INVALID_ARG; + } + return GetCurrentState(htmlEditor, aParams); } NS_IMETHODIMP @@ -171,22 +177,22 @@ nsStyleUpdatingCommand::nsStyleUpdatingCommand(nsIAtom* aTagName) } nsresult -nsStyleUpdatingCommand::GetCurrentState(nsIEditor *aEditor, +nsStyleUpdatingCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, nsICommandParams *aParams) { - NS_ASSERTION(aEditor, "Need editor here"); - nsCOMPtr htmlEditor = do_QueryInterface(aEditor); - NS_ENSURE_TRUE(htmlEditor, NS_ERROR_NOT_INITIALIZED); + if (NS_WARN_IF(!aHTMLEditor)) { + return NS_ERROR_INVALID_ARG; + } bool firstOfSelectionHasProp = false; bool anyOfSelectionHasProp = false; bool allOfSelectionHasProp = false; - nsresult rv = htmlEditor->GetInlineProperty(mTagName, EmptyString(), - EmptyString(), - &firstOfSelectionHasProp, - &anyOfSelectionHasProp, - &allOfSelectionHasProp); + nsresult rv = aHTMLEditor->GetInlineProperty(mTagName, EmptyString(), + EmptyString(), + &firstOfSelectionHasProp, + &anyOfSelectionHasProp, + &allOfSelectionHasProp); aParams->SetBooleanValue(STATE_ENABLED, NS_SUCCEEDED(rv)); aParams->SetBooleanValue(STATE_ALL, allOfSelectionHasProp); @@ -201,8 +207,13 @@ nsStyleUpdatingCommand::GetCurrentState(nsIEditor *aEditor, nsresult nsStyleUpdatingCommand::ToggleState(nsIEditor *aEditor) { - nsCOMPtr htmlEditor = do_QueryInterface(aEditor); - NS_ENSURE_TRUE(htmlEditor, NS_ERROR_NO_INTERFACE); + if (NS_WARN_IF(!aEditor)) { + return NS_ERROR_INVALID_ARG; + } + mozilla::HTMLEditor* htmlEditor = aEditor->AsHTMLEditor(); + if (NS_WARN_IF(!htmlEditor)) { + return NS_ERROR_INVALID_ARG; + } //create some params now... nsresult rv; @@ -218,7 +229,7 @@ nsStyleUpdatingCommand::ToggleState(nsIEditor *aEditor) doTagRemoval = true; } else { // check current selection; set doTagRemoval if formatting should be removed - rv = GetCurrentState(aEditor, params); + rv = GetCurrentState(htmlEditor, params); NS_ENSURE_SUCCESS(rv, rv); rv = params->GetBooleanValue(STATE_ALL, &doTagRemoval); NS_ENSURE_SUCCESS(rv, rv); @@ -261,15 +272,16 @@ nsListCommand::nsListCommand(nsIAtom* aTagName) } nsresult -nsListCommand::GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams) +nsListCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) { - NS_ASSERTION(aEditor, "Need editor here"); - nsCOMPtr htmlEditor = do_QueryInterface(aEditor); - NS_ENSURE_TRUE(htmlEditor, NS_ERROR_NO_INTERFACE); + if (NS_WARN_IF(!aHTMLEditor)) { + return NS_ERROR_INVALID_ARG; + } bool bMixed; nsAutoString localName; - nsresult rv = GetListState(htmlEditor, &bMixed, localName); + nsresult rv = GetListState(aHTMLEditor, &bMixed, localName); NS_ENSURE_SUCCESS(rv, rv); bool inList = mTagName->Equals(localName); @@ -282,8 +294,13 @@ nsListCommand::GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams) nsresult nsListCommand::ToggleState(nsIEditor *aEditor) { - nsCOMPtr editor = do_QueryInterface(aEditor); - NS_ENSURE_TRUE(editor, NS_NOINTERFACE); + if (NS_WARN_IF(!aEditor)) { + return NS_ERROR_INVALID_ARG; + } + mozilla::HTMLEditor* htmlEditor = aEditor->AsHTMLEditor(); + if (NS_WARN_IF(!htmlEditor)) { + return NS_ERROR_INVALID_ARG; + } nsresult rv; nsCOMPtr params = @@ -291,7 +308,7 @@ nsListCommand::ToggleState(nsIEditor *aEditor) if (NS_FAILED(rv) || !params) return rv; - rv = GetCurrentState(aEditor, params); + rv = GetCurrentState(htmlEditor, params); NS_ENSURE_SUCCESS(rv, rv); bool inList; @@ -300,9 +317,9 @@ nsListCommand::ToggleState(nsIEditor *aEditor) nsDependentAtomString listType(mTagName); if (inList) { - rv = editor->RemoveList(listType); + rv = htmlEditor->RemoveList(listType); } else { - rv = editor->MakeOrChangeList(listType, false, EmptyString()); + rv = htmlEditor->MakeOrChangeList(listType, false, EmptyString()); } return rv; @@ -314,16 +331,15 @@ nsListItemCommand::nsListItemCommand(nsIAtom* aTagName) } nsresult -nsListItemCommand::GetCurrentState(nsIEditor* aEditor, +nsListItemCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, nsICommandParams *aParams) { - NS_ASSERTION(aEditor, "Need editor here"); - // 39584 - nsCOMPtr htmlEditor = do_QueryInterface(aEditor); - NS_ENSURE_TRUE(htmlEditor, NS_NOINTERFACE); + if (NS_WARN_IF(!aHTMLEditor)) { + return NS_ERROR_INVALID_ARG; + } bool bMixed, bLI, bDT, bDD; - nsresult rv = htmlEditor->GetListItemState(&bMixed, &bLI, &bDT, &bDD); + nsresult rv = aHTMLEditor->GetListItemState(&bMixed, &bLI, &bDT, &bDD); NS_ENSURE_SUCCESS(rv, rv); bool inList = false; @@ -346,9 +362,13 @@ nsListItemCommand::GetCurrentState(nsIEditor* aEditor, nsresult nsListItemCommand::ToggleState(nsIEditor *aEditor) { - NS_ASSERTION(aEditor, "Need editor here"); - nsCOMPtr htmlEditor = do_QueryInterface(aEditor); - NS_ENSURE_TRUE(htmlEditor, NS_ERROR_NOT_INITIALIZED); + if (NS_WARN_IF(!aEditor)) { + return NS_ERROR_INVALID_ARG; + } + mozilla::HTMLEditor* htmlEditor = aEditor->AsHTMLEditor(); + if (NS_WARN_IF(!htmlEditor)) { + return NS_ERROR_INVALID_ARG; + } bool inList; // Need to use mTagName???? @@ -357,7 +377,7 @@ nsListItemCommand::ToggleState(nsIEditor *aEditor) do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID,&rv); if (NS_FAILED(rv) || !params) return rv; - rv = GetCurrentState(aEditor, params); + rv = GetCurrentState(htmlEditor, params); rv = params->GetBooleanValue(STATE_ALL,&inList); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv); @@ -398,8 +418,10 @@ nsRemoveListCommand::IsCommandEnabled(const char * aCommandName, } // It is enabled if we are in any list type - nsCOMPtr htmlEditor = do_QueryInterface(refCon); - NS_ENSURE_TRUE(htmlEditor, NS_ERROR_NO_INTERFACE); + mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor(); + if (NS_WARN_IF(!htmlEditor)) { + return NS_ERROR_INVALID_ARG; + } bool bMixed; nsAutoString localName; @@ -604,11 +626,14 @@ nsMultiStateCommand::GetCommandStateParams(const char *aCommandName, nsISupports *refCon) { nsCOMPtr editor = do_QueryInterface(refCon); - nsresult rv = NS_OK; - if (editor) { - rv = GetCurrentState(editor, aParams); + if (!editor) { + return NS_OK; } - return rv; + mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor(); + if (NS_WARN_IF(!htmlEditor)) { + return NS_ERROR_INVALID_ARG; + } + return GetCurrentState(htmlEditor, aParams); } nsParagraphStateCommand::nsParagraphStateCommand() @@ -617,17 +642,16 @@ nsParagraphStateCommand::nsParagraphStateCommand() } nsresult -nsParagraphStateCommand::GetCurrentState(nsIEditor *aEditor, - nsICommandParams *aParams) +nsParagraphStateCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) { - NS_ASSERTION(aEditor, "Need an editor here"); - - nsCOMPtr htmlEditor = do_QueryInterface(aEditor); - NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE); + if (NS_WARN_IF(!aHTMLEditor)) { + return NS_ERROR_INVALID_ARG; + } bool outMixed; nsAutoString outStateString; - nsresult rv = htmlEditor->GetParagraphState(&outMixed, outStateString); + nsresult rv = aHTMLEditor->GetParagraphState(&outMixed, outStateString); if (NS_SUCCEEDED(rv)) { nsAutoCString tOutStateString; LossyCopyUTF16toASCII(outStateString, tOutStateString); @@ -654,16 +678,16 @@ nsFontFaceStateCommand::nsFontFaceStateCommand() } nsresult -nsFontFaceStateCommand::GetCurrentState(nsIEditor *aEditor, - nsICommandParams *aParams) +nsFontFaceStateCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) { - NS_ASSERTION(aEditor, "Need an editor here"); - nsCOMPtr htmlEditor = do_QueryInterface(aEditor); - NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE); + if (NS_WARN_IF(!aHTMLEditor)) { + return NS_ERROR_INVALID_ARG; + } nsAutoString outStateString; bool outMixed; - nsresult rv = htmlEditor->GetFontFaceState(&outMixed, outStateString); + nsresult rv = aHTMLEditor->GetFontFaceState(&outMixed, outStateString); if (NS_SUCCEEDED(rv)) { aParams->SetBooleanValue(STATE_MIXED,outMixed); aParams->SetCStringValue(STATE_ATTRIBUTE, NS_ConvertUTF16toUTF8(outStateString).get()); @@ -671,7 +695,6 @@ nsFontFaceStateCommand::GetCurrentState(nsIEditor *aEditor, return rv; } - nsresult nsFontFaceStateCommand::SetState(nsIEditor *aEditor, nsString& newState) { @@ -708,21 +731,21 @@ nsFontSizeStateCommand::nsFontSizeStateCommand() } nsresult -nsFontSizeStateCommand::GetCurrentState(nsIEditor *aEditor, - nsICommandParams *aParams) +nsFontSizeStateCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) { - NS_ASSERTION(aEditor, "Need an editor here"); - nsCOMPtr htmlEditor = do_QueryInterface(aEditor); - NS_ENSURE_TRUE(htmlEditor, NS_ERROR_INVALID_ARG); + if (NS_WARN_IF(!aHTMLEditor)) { + return NS_ERROR_INVALID_ARG; + } nsAutoString outStateString; - nsCOMPtr fontAtom = NS_Atomize("font"); bool firstHas, anyHas, allHas; - nsresult rv = htmlEditor->GetInlinePropertyWithAttrValue(fontAtom, - NS_LITERAL_STRING("size"), - EmptyString(), - &firstHas, &anyHas, &allHas, - outStateString); + nsresult rv = aHTMLEditor->GetInlinePropertyWithAttrValue( + nsGkAtoms::font, + NS_LITERAL_STRING("size"), + EmptyString(), + &firstHas, &anyHas, &allHas, + outStateString); NS_ENSURE_SUCCESS(rv, rv); nsAutoCString tOutStateString; @@ -775,17 +798,16 @@ nsFontColorStateCommand::nsFontColorStateCommand() } nsresult -nsFontColorStateCommand::GetCurrentState(nsIEditor *aEditor, - nsICommandParams *aParams) +nsFontColorStateCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) { - NS_ASSERTION(aEditor, "Need an editor here"); - - nsCOMPtr htmlEditor = do_QueryInterface(aEditor); - NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE); + if (NS_WARN_IF(!aHTMLEditor)) { + return NS_ERROR_INVALID_ARG; + } bool outMixed; nsAutoString outStateString; - nsresult rv = htmlEditor->GetFontColorState(&outMixed, outStateString); + nsresult rv = aHTMLEditor->GetFontColorState(&outMixed, outStateString); NS_ENSURE_SUCCESS(rv, rv); nsAutoCString tOutStateString; @@ -817,16 +839,16 @@ nsHighlightColorStateCommand::nsHighlightColorStateCommand() } nsresult -nsHighlightColorStateCommand::GetCurrentState(nsIEditor *aEditor, - nsICommandParams *aParams) +nsHighlightColorStateCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) { - NS_ASSERTION(aEditor, "Need an editor here"); - nsCOMPtr htmlEditor = do_QueryInterface(aEditor); - NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE); + if (NS_WARN_IF(!aHTMLEditor)) { + return NS_ERROR_INVALID_ARG; + } bool outMixed; nsAutoString outStateString; - nsresult rv = htmlEditor->GetHighlightColorState(&outMixed, outStateString); + nsresult rv = aHTMLEditor->GetHighlightColorState(&outMixed, outStateString); NS_ENSURE_SUCCESS(rv, rv); nsAutoCString tOutStateString; @@ -873,17 +895,16 @@ nsBackgroundColorStateCommand::nsBackgroundColorStateCommand() } nsresult -nsBackgroundColorStateCommand::GetCurrentState(nsIEditor *aEditor, - nsICommandParams *aParams) +nsBackgroundColorStateCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) { - NS_ASSERTION(aEditor, "Need an editor here"); - - nsCOMPtr htmlEditor = do_QueryInterface(aEditor); - NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE); + if (NS_WARN_IF(!aHTMLEditor)) { + return NS_ERROR_INVALID_ARG; + } bool outMixed; nsAutoString outStateString; - nsresult rv = htmlEditor->GetBackgroundColorState(&outMixed, outStateString); + nsresult rv = aHTMLEditor->GetBackgroundColorState(&outMixed, outStateString); NS_ENSURE_SUCCESS(rv, rv); nsAutoCString tOutStateString; @@ -910,16 +931,16 @@ nsAlignCommand::nsAlignCommand() } nsresult -nsAlignCommand::GetCurrentState(nsIEditor *aEditor, nsICommandParams *aParams) +nsAlignCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) { - NS_ASSERTION(aEditor, "Need an editor here"); - - nsCOMPtr htmlEditor = do_QueryInterface(aEditor); - NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE); + if (NS_WARN_IF(!aHTMLEditor)) { + return NS_ERROR_INVALID_ARG; + } nsIHTMLEditor::EAlignment firstAlign; bool outMixed; - nsresult rv = htmlEditor->GetAlignment(&outMixed, &firstAlign); + nsresult rv = aHTMLEditor->GetAlignment(&outMixed, &firstAlign); NS_ENSURE_SUCCESS(rv, rv); @@ -985,15 +1006,15 @@ nsAbsolutePositioningCommand::IsCommandEnabled(const char * aCommandName, } nsresult -nsAbsolutePositioningCommand::GetCurrentState(nsIEditor *aEditor, nsICommandParams *aParams) +nsAbsolutePositioningCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) { - NS_ASSERTION(aEditor, "Need an editor here"); - - nsCOMPtr htmlEditor = do_QueryInterface(aEditor); - NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE); + if (NS_WARN_IF(!aHTMLEditor)) { + return NS_ERROR_INVALID_ARG; + } bool isEnabled; - htmlEditor->GetAbsolutePositioningEnabled(&isEnabled); + aHTMLEditor->GetAbsolutePositioningEnabled(&isEnabled); if (!isEnabled) { aParams->SetBooleanValue(STATE_MIXED,false); aParams->SetCStringValue(STATE_ATTRIBUTE, ""); @@ -1001,7 +1022,8 @@ nsAbsolutePositioningCommand::GetCurrentState(nsIEditor *aEditor, nsICommandPara } nsCOMPtr elt; - nsresult rv = htmlEditor->GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(elt)); + nsresult rv = + aHTMLEditor->GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(elt)); NS_ENSURE_SUCCESS(rv, rv); nsAutoString outStateString; @@ -1456,16 +1478,18 @@ nsInsertTagCommand::GetCommandStateParams(const char *aCommandName, /****************************/ nsresult -GetListState(nsIHTMLEditor* aEditor, bool* aMixed, nsAString& aLocalName) +GetListState(mozilla::HTMLEditor* aHTMLEditor, + bool* aMixed, + nsAString& aLocalName) { - MOZ_ASSERT(aEditor); + MOZ_ASSERT(aHTMLEditor); MOZ_ASSERT(aMixed); *aMixed = false; aLocalName.Truncate(); bool bOL, bUL, bDL; - nsresult rv = aEditor->GetListState(aMixed, &bOL, &bUL, &bDL); + nsresult rv = aHTMLEditor->GetListState(aMixed, &bOL, &bUL, &bDL); NS_ENSURE_SUCCESS(rv, rv); if (*aMixed) { diff --git a/editor/composer/nsComposerCommands.h b/editor/composer/nsComposerCommands.h index 3d3855d4004c..bb6c19a36fa1 100644 --- a/editor/composer/nsComposerCommands.h +++ b/editor/composer/nsComposerCommands.h @@ -16,6 +16,10 @@ class nsIEditor; class nsISupports; class nsString; +namespace mozilla { +class HTMLEditor; +} // namespace mozilla + // This is a virtual base class for commands registered with the composer controller. // Note that such commands are instantiated once per composer, so can store state. // Also note that IsCommandEnabled can be called with an editor that may not @@ -65,7 +69,8 @@ protected: virtual ~nsBaseStateUpdatingCommand(); // get the current state (on or off) for this style or block format - virtual nsresult GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams) = 0; + virtual nsresult GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) = 0; // add/remove the style virtual nsresult ToggleState(nsIEditor* aEditor) = 0; @@ -77,7 +82,7 @@ protected: // Shared class for the various style updating commands like bold, italics etc. // Suitable for commands whose state is either 'on' or 'off'. -class nsStyleUpdatingCommand : public nsBaseStateUpdatingCommand +class nsStyleUpdatingCommand final : public nsBaseStateUpdatingCommand { public: explicit nsStyleUpdatingCommand(nsIAtom* aTagName); @@ -85,7 +90,8 @@ public: protected: // get the current state (on or off) for this style or block format - virtual nsresult GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams); + virtual nsresult GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) override final; // add/remove the style virtual nsresult ToggleState(nsIEditor* aEditor); @@ -108,7 +114,7 @@ protected: }; -class nsListCommand : public nsBaseStateUpdatingCommand +class nsListCommand final : public nsBaseStateUpdatingCommand { public: explicit nsListCommand(nsIAtom* aTagName); @@ -116,13 +122,14 @@ public: protected: // get the current state (on or off) for this style or block format - virtual nsresult GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams); + virtual nsresult GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) override final; // add/remove the style virtual nsresult ToggleState(nsIEditor* aEditor); }; -class nsListItemCommand : public nsBaseStateUpdatingCommand +class nsListItemCommand final : public nsBaseStateUpdatingCommand { public: explicit nsListItemCommand(nsIAtom* aTagName); @@ -130,7 +137,8 @@ public: protected: // get the current state (on or off) for this style or block format - virtual nsresult GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams); + virtual nsresult GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) override final; // add/remove the style virtual nsresult ToggleState(nsIEditor* aEditor); @@ -149,47 +157,50 @@ public: protected: virtual ~nsMultiStateCommand(); - virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams) =0; + virtual nsresult GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) = 0; virtual nsresult SetState(nsIEditor *aEditor, nsString& newState) = 0; }; -class nsParagraphStateCommand : public nsMultiStateCommand +class nsParagraphStateCommand final : public nsMultiStateCommand { public: nsParagraphStateCommand(); protected: - virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams); + virtual nsresult GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) override final; virtual nsresult SetState(nsIEditor *aEditor, nsString& newState); }; -class nsFontFaceStateCommand : public nsMultiStateCommand +class nsFontFaceStateCommand final : public nsMultiStateCommand { public: nsFontFaceStateCommand(); protected: - virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams); + virtual nsresult GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) override final; virtual nsresult SetState(nsIEditor *aEditor, nsString& newState); }; -class nsFontSizeStateCommand : public nsMultiStateCommand +class nsFontSizeStateCommand final : public nsMultiStateCommand { public: nsFontSizeStateCommand(); protected: - virtual nsresult GetCurrentState(nsIEditor *aEditor, - nsICommandParams* aParams); + virtual nsresult GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) override final; virtual nsresult SetState(nsIEditor *aEditor, nsString& newState); }; -class nsHighlightColorStateCommand : public nsMultiStateCommand +class nsHighlightColorStateCommand final : public nsMultiStateCommand { public: nsHighlightColorStateCommand(); @@ -197,45 +208,49 @@ public: protected: NS_IMETHOD IsCommandEnabled(const char *aCommandName, nsISupports *aCommandRefCon, bool *_retval); - virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams); + virtual nsresult GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) override final; virtual nsresult SetState(nsIEditor *aEditor, nsString& newState); }; -class nsFontColorStateCommand : public nsMultiStateCommand +class nsFontColorStateCommand final : public nsMultiStateCommand { public: nsFontColorStateCommand(); protected: - virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams); + virtual nsresult GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) override final; virtual nsresult SetState(nsIEditor *aEditor, nsString& newState); }; -class nsAlignCommand : public nsMultiStateCommand +class nsAlignCommand final : public nsMultiStateCommand { public: nsAlignCommand(); protected: - virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams); + virtual nsresult GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) override final; virtual nsresult SetState(nsIEditor *aEditor, nsString& newState); }; -class nsBackgroundColorStateCommand : public nsMultiStateCommand +class nsBackgroundColorStateCommand final : public nsMultiStateCommand { public: nsBackgroundColorStateCommand(); protected: - virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams); + virtual nsresult GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) override final; virtual nsresult SetState(nsIEditor *aEditor, nsString& newState); }; -class nsAbsolutePositioningCommand : public nsBaseStateUpdatingCommand +class nsAbsolutePositioningCommand final : public nsBaseStateUpdatingCommand { public: nsAbsolutePositioningCommand(); @@ -243,7 +258,8 @@ public: protected: NS_IMETHOD IsCommandEnabled(const char *aCommandName, nsISupports *aCommandRefCon, bool *_retval); - virtual nsresult GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams); + virtual nsresult GetCurrentState(mozilla::HTMLEditor* aHTMLEditor, + nsICommandParams* aParams) override final; virtual nsresult ToggleState(nsIEditor* aEditor); };