rename from editor/composer/nsComposerCommands.cpp
rename to editor/composer/HTMLEditorCommands.cpp
--- a/editor/composer/nsComposerCommands.cpp
+++ b/editor/composer/HTMLEditorCommands.cpp
@@ -5,134 +5,133 @@
#include <stdio.h> // for printf
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/EditorBase.h" // for EditorBase
#include "mozilla/ErrorResult.h"
#include "mozilla/HTMLEditor.h" // for HTMLEditor
+#include "mozilla/HTMLEditorCommands.h"
#include "mozilla/dom/Element.h"
#include "nsAString.h"
#include "nsCOMPtr.h" // for nsCOMPtr, do_QueryInterface, etc
#include "nsComponentManagerUtils.h" // for do_CreateInstance
-#include "nsComposerCommands.h"
#include "nsDebug.h" // for NS_ENSURE_TRUE, etc
#include "nsError.h" // for NS_OK, NS_ERROR_FAILURE, etc
#include "nsGkAtoms.h" // for nsGkAtoms, nsGkAtoms::font, etc
#include "nsAtom.h" // for nsAtom, etc
#include "nsIClipboard.h" // for nsIClipboard, etc
#include "nsICommandParams.h" // for nsICommandParams, etc
#include "nsID.h"
#include "nsIEditor.h" // for nsIEditor
#include "nsIHTMLEditor.h" // for nsIHTMLEditor, etc
#include "nsLiteralString.h" // for NS_LITERAL_STRING
#include "nsReadableUtils.h" // for EmptyString
#include "nsString.h" // for nsAutoString, nsString, etc
#include "nsStringFwd.h" // for nsString
class nsISupports;
-using mozilla::dom::Element;
-using mozilla::ErrorResult;
+
+namespace mozilla {
+using dom::Element;
//prototype
static nsresult
-GetListState(mozilla::HTMLEditor* aHTMLEditor,
- bool* aMixed,
- nsAString& aLocalName);
+GetListState(HTMLEditor* aHTMLEditor, bool* aMixed, nsAString& aLocalName);
//defines
#define STATE_ENABLED "state_enabled"
#define STATE_ALL "state_all"
#define STATE_ANY "state_any"
#define STATE_MIXED "state_mixed"
#define STATE_BEGIN "state_begin"
#define STATE_END "state_end"
#define STATE_ATTRIBUTE "state_attribute"
#define STATE_DATA "state_data"
-nsBaseComposerCommand::nsBaseComposerCommand()
+HTMLEditorCommandBase::HTMLEditorCommandBase()
{
}
-NS_IMPL_ISUPPORTS(nsBaseComposerCommand, nsIControllerCommand)
+NS_IMPL_ISUPPORTS(HTMLEditorCommandBase, nsIControllerCommand)
-nsBaseStateUpdatingCommand::nsBaseStateUpdatingCommand(nsAtom* aTagName)
-: nsBaseComposerCommand()
-, mTagName(aTagName)
+StateUpdatingCommandBase::StateUpdatingCommandBase(nsAtom* aTagName)
+ : HTMLEditorCommandBase()
+ , mTagName(aTagName)
{
MOZ_ASSERT(mTagName);
}
-nsBaseStateUpdatingCommand::~nsBaseStateUpdatingCommand()
+StateUpdatingCommandBase::~StateUpdatingCommandBase()
{
}
NS_IMETHODIMP
-nsBaseStateUpdatingCommand::IsCommandEnabled(const char *aCommandName,
- nsISupports *refCon,
- bool *outCmdEnabled)
+StateUpdatingCommandBase::IsCommandEnabled(const char* aCommandName,
+ nsISupports* refCon,
+ bool* outCmdEnabled)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
*outCmdEnabled = false;
return NS_OK;
}
mozilla::EditorBase* editorBase = editor->AsEditorBase();
MOZ_ASSERT(editorBase);
*outCmdEnabled = editorBase->IsSelectionEditable();
return NS_OK;
}
NS_IMETHODIMP
-nsBaseStateUpdatingCommand::DoCommand(const char *aCommandName,
- nsISupports *refCon)
+StateUpdatingCommandBase::DoCommand(const char* aCommandName,
+ nsISupports* refCon)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (NS_WARN_IF(!editor)) {
return NS_ERROR_FAILURE;
}
mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
if (NS_WARN_IF(!htmlEditor)) {
return NS_ERROR_FAILURE;
}
return ToggleState(htmlEditor);
}
NS_IMETHODIMP
-nsBaseStateUpdatingCommand::DoCommandParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+StateUpdatingCommandBase::DoCommandParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
return DoCommand(aCommandName, refCon);
}
NS_IMETHODIMP
-nsBaseStateUpdatingCommand::GetCommandStateParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+StateUpdatingCommandBase::GetCommandStateParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
return NS_OK;
}
mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
if (NS_WARN_IF(!htmlEditor)) {
return NS_ERROR_FAILURE;
}
return GetCurrentState(htmlEditor, aParams);
}
NS_IMETHODIMP
-nsPasteNoFormattingCommand::IsCommandEnabled(const char * aCommandName,
- nsISupports *refCon,
- bool *outCmdEnabled)
+PasteNoFormattingCommand::IsCommandEnabled(const char* aCommandName,
+ nsISupports* refCon,
+ bool* outCmdEnabled)
{
NS_ENSURE_ARG_POINTER(outCmdEnabled);
*outCmdEnabled = false;
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (NS_WARN_IF(!editor)) {
return NS_ERROR_FAILURE;
}
@@ -143,60 +142,60 @@ nsPasteNoFormattingCommand::IsCommandEna
mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
if (NS_WARN_IF(!htmlEditor)) {
return NS_ERROR_FAILURE;
}
return htmlEditor->CanPaste(nsIClipboard::kGlobalClipboard, outCmdEnabled);
}
NS_IMETHODIMP
-nsPasteNoFormattingCommand::DoCommand(const char *aCommandName,
- nsISupports *refCon)
+PasteNoFormattingCommand::DoCommand(const char* aCommandName,
+ nsISupports* refCon)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (NS_WARN_IF(!editor)) {
return NS_ERROR_FAILURE;
}
mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
if (NS_WARN_IF(!htmlEditor)) {
return NS_ERROR_FAILURE;
}
return htmlEditor->PasteNoFormatting(nsIClipboard::kGlobalClipboard);
}
NS_IMETHODIMP
-nsPasteNoFormattingCommand::DoCommandParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+PasteNoFormattingCommand::DoCommandParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
return DoCommand(aCommandName, refCon);
}
NS_IMETHODIMP
-nsPasteNoFormattingCommand::GetCommandStateParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+PasteNoFormattingCommand::GetCommandStateParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
NS_ENSURE_ARG_POINTER(aParams);
bool enabled = false;
nsresult rv = IsCommandEnabled(aCommandName, refCon, &enabled);
NS_ENSURE_SUCCESS(rv, rv);
return aParams->SetBooleanValue(STATE_ENABLED, enabled);
}
-nsStyleUpdatingCommand::nsStyleUpdatingCommand(nsAtom* aTagName)
-: nsBaseStateUpdatingCommand(aTagName)
+StyleUpdatingCommand::StyleUpdatingCommand(nsAtom* aTagName)
+ : StateUpdatingCommandBase(aTagName)
{
}
nsresult
-nsStyleUpdatingCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor,
- nsICommandParams *aParams)
+StyleUpdatingCommand::GetCurrentState(HTMLEditor* aHTMLEditor,
+ nsICommandParams *aParams)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
bool firstOfSelectionHasProp = false;
bool anyOfSelectionHasProp = false;
bool allOfSelectionHasProp = false;
@@ -213,17 +212,17 @@ 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(mozilla::HTMLEditor* aHTMLEditor)
+StyleUpdatingCommand::ToggleState(HTMLEditor* aHTMLEditor)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
//create some params now...
nsresult rv;
nsCOMPtr<nsICommandParams> params =
@@ -280,24 +279,24 @@ nsStyleUpdatingCommand::ToggleState(mozi
rv = aHTMLEditor->SetInlineProperty(mTagName, nullptr, EmptyString());
}
aHTMLEditor->EndTransaction();
return rv;
}
-nsListCommand::nsListCommand(nsAtom* aTagName)
-: nsBaseStateUpdatingCommand(aTagName)
+ListCommand::ListCommand(nsAtom* aTagName)
+ : StateUpdatingCommandBase(aTagName)
{
}
nsresult
-nsListCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor,
- nsICommandParams* aParams)
+ListCommand::GetCurrentState(HTMLEditor* aHTMLEditor,
+ nsICommandParams* aParams)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
bool bMixed;
nsAutoString localName;
nsresult rv = GetListState(aHTMLEditor, &bMixed, localName);
@@ -306,17 +305,17 @@ nsListCommand::GetCurrentState(mozilla::
bool inList = mTagName->Equals(localName);
aParams->SetBooleanValue(STATE_ALL, !bMixed && inList);
aParams->SetBooleanValue(STATE_MIXED, bMixed);
aParams->SetBooleanValue(STATE_ENABLED, true);
return NS_OK;
}
nsresult
-nsListCommand::ToggleState(mozilla::HTMLEditor* aHTMLEditor)
+ListCommand::ToggleState(HTMLEditor* aHTMLEditor)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
nsresult rv;
nsCOMPtr<nsICommandParams> params =
do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID,&rv);
@@ -335,24 +334,24 @@ nsListCommand::ToggleState(mozilla::HTML
rv = aHTMLEditor->RemoveList(listType);
} else {
rv = aHTMLEditor->MakeOrChangeList(listType, false, EmptyString());
}
return rv;
}
-nsListItemCommand::nsListItemCommand(nsAtom* aTagName)
-: nsBaseStateUpdatingCommand(aTagName)
+ListItemCommand::ListItemCommand(nsAtom* aTagName)
+ : StateUpdatingCommandBase(aTagName)
{
}
nsresult
-nsListItemCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor,
- nsICommandParams *aParams)
+ListItemCommand::GetCurrentState(HTMLEditor* aHTMLEditor,
+ nsICommandParams *aParams)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
bool bMixed, bLI, bDT, bDD;
nsresult rv = aHTMLEditor->GetListItemState(&bMixed, &bLI, &bDT, &bDD);
NS_ENSURE_SUCCESS(rv, rv);
@@ -370,17 +369,17 @@ nsListItemCommand::GetCurrentState(mozil
aParams->SetBooleanValue(STATE_ALL, !bMixed && inList);
aParams->SetBooleanValue(STATE_MIXED, bMixed);
return NS_OK;
}
nsresult
-nsListItemCommand::ToggleState(mozilla::HTMLEditor* aHTMLEditor)
+ListItemCommand::ToggleState(HTMLEditor* aHTMLEditor)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
bool inList;
// Need to use mTagName????
nsresult rv;
@@ -408,19 +407,19 @@ nsListItemCommand::ToggleState(mozilla::
// Set to the requested paragraph type
//XXX Note: This actually doesn't work for "LI",
// but we currently don't use this for non DL lists anyway.
// Problem: won't this replace any current block paragraph style?
return aHTMLEditor->SetParagraphFormat(nsDependentAtomString(mTagName));
}
NS_IMETHODIMP
-nsRemoveListCommand::IsCommandEnabled(const char * aCommandName,
- nsISupports *refCon,
- bool *outCmdEnabled)
+RemoveListCommand::IsCommandEnabled(const char* aCommandName,
+ nsISupports* refCon,
+ bool* outCmdEnabled)
{
*outCmdEnabled = false;
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
return NS_OK;
}
mozilla::EditorBase* editorBase = editor->AsEditorBase();
@@ -442,187 +441,187 @@ nsRemoveListCommand::IsCommandEnabled(co
NS_ENSURE_SUCCESS(rv, rv);
*outCmdEnabled = bMixed || !localName.IsEmpty();
return NS_OK;
}
NS_IMETHODIMP
-nsRemoveListCommand::DoCommand(const char *aCommandName, nsISupports *refCon)
+RemoveListCommand::DoCommand(const char* aCommandName, nsISupports* refCon)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
return NS_OK;
}
mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
if (!htmlEditor) {
return NS_OK;
}
// This removes any list type
return htmlEditor->RemoveList(EmptyString());
}
NS_IMETHODIMP
-nsRemoveListCommand::DoCommandParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+RemoveListCommand::DoCommandParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
return DoCommand(aCommandName, refCon);
}
NS_IMETHODIMP
-nsRemoveListCommand::GetCommandStateParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+RemoveListCommand::GetCommandStateParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
bool outCmdEnabled = false;
IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
return aParams->SetBooleanValue(STATE_ENABLED,outCmdEnabled);
}
NS_IMETHODIMP
-nsIndentCommand::IsCommandEnabled(const char * aCommandName,
- nsISupports *refCon, bool *outCmdEnabled)
+IndentCommand::IsCommandEnabled(const char* aCommandName,
+ nsISupports* refCon, bool* outCmdEnabled)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
*outCmdEnabled = false;
return NS_OK;
}
mozilla::EditorBase* editorBase = editor->AsEditorBase();
MOZ_ASSERT(editorBase);
*outCmdEnabled = editorBase->IsSelectionEditable();
return NS_OK;
}
NS_IMETHODIMP
-nsIndentCommand::DoCommand(const char *aCommandName, nsISupports *refCon)
+IndentCommand::DoCommand(const char* aCommandName, nsISupports* refCon)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
return NS_OK;
}
mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
if (!htmlEditor) {
return NS_OK;
}
return htmlEditor->Indent(NS_LITERAL_STRING("indent"));
}
NS_IMETHODIMP
-nsIndentCommand::DoCommandParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+IndentCommand::DoCommandParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
return DoCommand(aCommandName, refCon);
}
NS_IMETHODIMP
-nsIndentCommand::GetCommandStateParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+IndentCommand::GetCommandStateParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
bool outCmdEnabled = false;
IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
return aParams->SetBooleanValue(STATE_ENABLED,outCmdEnabled);
}
//OUTDENT
NS_IMETHODIMP
-nsOutdentCommand::IsCommandEnabled(const char * aCommandName,
- nsISupports *refCon,
- bool *outCmdEnabled)
+OutdentCommand::IsCommandEnabled(const char* aCommandName,
+ nsISupports* refCon,
+ bool* outCmdEnabled)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
*outCmdEnabled = false;
return NS_OK;
}
mozilla::EditorBase* editorBase = editor->AsEditorBase();
MOZ_ASSERT(editorBase);
*outCmdEnabled = editorBase->IsSelectionEditable();
return NS_OK;
}
NS_IMETHODIMP
-nsOutdentCommand::DoCommand(const char *aCommandName, nsISupports *refCon)
+OutdentCommand::DoCommand(const char* aCommandName, nsISupports* refCon)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
return NS_OK;
}
mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
if (!htmlEditor) {
return NS_OK;
}
return htmlEditor->Indent(NS_LITERAL_STRING("outdent"));
}
NS_IMETHODIMP
-nsOutdentCommand::DoCommandParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+OutdentCommand::DoCommandParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
return DoCommand(aCommandName, refCon);
}
NS_IMETHODIMP
-nsOutdentCommand::GetCommandStateParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+OutdentCommand::GetCommandStateParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
bool outCmdEnabled = false;
IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
return aParams->SetBooleanValue(STATE_ENABLED,outCmdEnabled);
}
-nsMultiStateCommand::nsMultiStateCommand()
-: nsBaseComposerCommand()
+MultiStateCommandBase::MultiStateCommandBase()
+ : HTMLEditorCommandBase()
{
}
-nsMultiStateCommand::~nsMultiStateCommand()
+MultiStateCommandBase::~MultiStateCommandBase()
{
}
NS_IMETHODIMP
-nsMultiStateCommand::IsCommandEnabled(const char * aCommandName,
- nsISupports *refCon,
- bool *outCmdEnabled)
+MultiStateCommandBase::IsCommandEnabled(const char* aCommandName,
+ nsISupports* refCon,
+ bool *outCmdEnabled)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
*outCmdEnabled = false;
return NS_OK;
}
mozilla::EditorBase* editorBase = editor->AsEditorBase();
MOZ_ASSERT(editorBase);
// should be disabled sometimes, like if the current selection is an image
*outCmdEnabled = editorBase->IsSelectionEditable();
return NS_OK;
}
NS_IMETHODIMP
-nsMultiStateCommand::DoCommand(const char *aCommandName, nsISupports *refCon)
+MultiStateCommandBase::DoCommand(const char* aCommandName, nsISupports* refCon)
{
#ifdef DEBUG
- printf("who is calling nsMultiStateCommand::DoCommand \
+ printf("who is calling MultiStateCommandBase::DoCommand \
(no implementation)? %s\n", aCommandName);
#endif
return NS_OK;
}
NS_IMETHODIMP
-nsMultiStateCommand::DoCommandParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+MultiStateCommandBase::DoCommandParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
return NS_OK;
}
mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
if (NS_WARN_IF(!htmlEditor)) {
return NS_ERROR_FAILURE;
@@ -636,39 +635,39 @@ nsMultiStateCommand::DoCommandParams(con
CopyASCIItoUTF16(s, tString);
else
aParams->GetStringValue(STATE_ATTRIBUTE, tString);
}
return SetState(htmlEditor, tString);
}
NS_IMETHODIMP
-nsMultiStateCommand::GetCommandStateParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+MultiStateCommandBase::GetCommandStateParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
return NS_OK;
}
mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
if (NS_WARN_IF(!htmlEditor)) {
return NS_ERROR_FAILURE;
}
return GetCurrentState(htmlEditor, aParams);
}
-nsParagraphStateCommand::nsParagraphStateCommand()
-: nsMultiStateCommand()
+ParagraphStateCommand::ParagraphStateCommand()
+ : MultiStateCommandBase()
{
}
nsresult
-nsParagraphStateCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor,
- nsICommandParams* aParams)
+ParagraphStateCommand::GetCurrentState(HTMLEditor* aHTMLEditor,
+ nsICommandParams* aParams)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
bool outMixed;
nsAutoString outStateString;
nsresult rv = aHTMLEditor->GetParagraphState(&outMixed, outStateString);
@@ -677,51 +676,51 @@ nsParagraphStateCommand::GetCurrentState
LossyCopyUTF16toASCII(outStateString, tOutStateString);
aParams->SetBooleanValue(STATE_MIXED,outMixed);
aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
}
return rv;
}
nsresult
-nsParagraphStateCommand::SetState(mozilla::HTMLEditor* aHTMLEditor,
- nsString& newState)
+ParagraphStateCommand::SetState(HTMLEditor* aHTMLEditor,
+ const nsString& newState)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
return aHTMLEditor->SetParagraphFormat(newState);
}
-nsFontFaceStateCommand::nsFontFaceStateCommand()
-: nsMultiStateCommand()
+FontFaceStateCommand::FontFaceStateCommand()
+ : MultiStateCommandBase()
{
}
nsresult
-nsFontFaceStateCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor,
- nsICommandParams* aParams)
+FontFaceStateCommand::GetCurrentState(HTMLEditor* aHTMLEditor,
+ nsICommandParams* aParams)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
nsAutoString outStateString;
bool outMixed;
nsresult rv = aHTMLEditor->GetFontFaceState(&outMixed, outStateString);
if (NS_SUCCEEDED(rv)) {
aParams->SetBooleanValue(STATE_MIXED,outMixed);
aParams->SetCStringValue(STATE_ATTRIBUTE, NS_ConvertUTF16toUTF8(outStateString).get());
}
return rv;
}
nsresult
-nsFontFaceStateCommand::SetState(mozilla::HTMLEditor* aHTMLEditor,
- nsString& newState)
+FontFaceStateCommand::SetState(HTMLEditor* aHTMLEditor,
+ const nsString& newState)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
if (newState.EqualsLiteral("tt")) {
// The old "teletype" attribute
nsresult rv = aHTMLEditor->SetInlineProperty(nsGkAtoms::tt, nullptr,
@@ -738,24 +737,24 @@ nsFontFaceStateCommand::SetState(mozilla
if (newState.IsEmpty() || newState.EqualsLiteral("normal")) {
return aHTMLEditor->RemoveInlineProperty(nsGkAtoms::font, nsGkAtoms::face);
}
return aHTMLEditor->SetInlineProperty(nsGkAtoms::font, nsGkAtoms::face,
newState);
}
-nsFontSizeStateCommand::nsFontSizeStateCommand()
- : nsMultiStateCommand()
+FontSizeStateCommand::FontSizeStateCommand()
+ : MultiStateCommandBase()
{
}
nsresult
-nsFontSizeStateCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor,
- nsICommandParams* aParams)
+FontSizeStateCommand::GetCurrentState(HTMLEditor* aHTMLEditor,
+ nsICommandParams* aParams)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
nsAutoString outStateString;
bool firstHas, anyHas, allHas;
nsresult rv = aHTMLEditor->GetInlinePropertyWithAttrValue(
@@ -781,18 +780,18 @@ nsFontSizeStateCommand::GetCurrentState(
// -1
// 0
// +1
// +2
// +3
// medium
// normal
nsresult
-nsFontSizeStateCommand::SetState(mozilla::HTMLEditor* aHTMLEditor,
- nsString& newState)
+FontSizeStateCommand::SetState(HTMLEditor* aHTMLEditor,
+ const nsString& newState)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
if (!newState.IsEmpty() &&
!newState.EqualsLiteral("normal") &&
!newState.EqualsLiteral("medium")) {
@@ -806,24 +805,24 @@ nsFontSizeStateCommand::SetState(mozilla
NS_ENSURE_SUCCESS(rv, rv);
rv = aHTMLEditor->RemoveInlineProperty(nsGkAtoms::big, nullptr);
NS_ENSURE_SUCCESS(rv, rv);
return aHTMLEditor->RemoveInlineProperty(nsGkAtoms::small, nullptr);
}
-nsFontColorStateCommand::nsFontColorStateCommand()
-: nsMultiStateCommand()
+FontColorStateCommand::FontColorStateCommand()
+ : MultiStateCommandBase()
{
}
nsresult
-nsFontColorStateCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor,
- nsICommandParams* aParams)
+FontColorStateCommand::GetCurrentState(HTMLEditor* aHTMLEditor,
+ nsICommandParams* aParams)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
bool outMixed;
nsAutoString outStateString;
nsresult rv = aHTMLEditor->GetFontColorState(&outMixed, outStateString);
@@ -832,40 +831,40 @@ nsFontColorStateCommand::GetCurrentState
nsAutoCString tOutStateString;
LossyCopyUTF16toASCII(outStateString, tOutStateString);
aParams->SetBooleanValue(STATE_MIXED, outMixed);
aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
return NS_OK;
}
nsresult
-nsFontColorStateCommand::SetState(mozilla::HTMLEditor* aHTMLEditor,
- nsString& newState)
+FontColorStateCommand::SetState(HTMLEditor* aHTMLEditor,
+ const nsString& newState)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
if (newState.IsEmpty() || newState.EqualsLiteral("normal")) {
return aHTMLEditor->RemoveInlineProperty(nsGkAtoms::font,
nsGkAtoms::color);
}
return aHTMLEditor->SetInlineProperty(nsGkAtoms::font, nsGkAtoms::color,
newState);
}
-nsHighlightColorStateCommand::nsHighlightColorStateCommand()
-: nsMultiStateCommand()
+HighlightColorStateCommand::HighlightColorStateCommand()
+ : MultiStateCommandBase()
{
}
nsresult
-nsHighlightColorStateCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor,
- nsICommandParams* aParams)
+HighlightColorStateCommand::GetCurrentState(HTMLEditor* aHTMLEditor,
+ nsICommandParams* aParams)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
bool outMixed;
nsAutoString outStateString;
nsresult rv = aHTMLEditor->GetHighlightColorState(&outMixed, outStateString);
@@ -874,57 +873,57 @@ nsHighlightColorStateCommand::GetCurrent
nsAutoCString tOutStateString;
LossyCopyUTF16toASCII(outStateString, tOutStateString);
aParams->SetBooleanValue(STATE_MIXED, outMixed);
aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
return NS_OK;
}
nsresult
-nsHighlightColorStateCommand::SetState(mozilla::HTMLEditor* aHTMLEditor,
- nsString& newState)
+HighlightColorStateCommand::SetState(HTMLEditor* aHTMLEditor,
+ const nsString& newState)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
if (newState.IsEmpty() || newState.EqualsLiteral("normal")) {
return aHTMLEditor->RemoveInlineProperty(nsGkAtoms::font,
nsGkAtoms::bgcolor);
}
return aHTMLEditor->SetInlineProperty(nsGkAtoms::font,
nsGkAtoms::bgcolor,
newState);
}
NS_IMETHODIMP
-nsHighlightColorStateCommand::IsCommandEnabled(const char * aCommandName,
- nsISupports *refCon,
- bool *outCmdEnabled)
+HighlightColorStateCommand::IsCommandEnabled(const char* aCommandName,
+ nsISupports* refCon,
+ bool* outCmdEnabled)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
*outCmdEnabled = false;
return NS_OK;
}
mozilla::EditorBase* editorBase = editor->AsEditorBase();
MOZ_ASSERT(editorBase);
*outCmdEnabled = editorBase->IsSelectionEditable();
return NS_OK;
}
-nsBackgroundColorStateCommand::nsBackgroundColorStateCommand()
-: nsMultiStateCommand()
+BackgroundColorStateCommand::BackgroundColorStateCommand()
+ : MultiStateCommandBase()
{
}
nsresult
-nsBackgroundColorStateCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor,
- nsICommandParams* aParams)
+BackgroundColorStateCommand::GetCurrentState(HTMLEditor* aHTMLEditor,
+ nsICommandParams* aParams)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
bool outMixed;
nsAutoString outStateString;
nsresult rv = aHTMLEditor->GetBackgroundColorState(&outMixed, outStateString);
@@ -933,33 +932,33 @@ nsBackgroundColorStateCommand::GetCurren
nsAutoCString tOutStateString;
LossyCopyUTF16toASCII(outStateString, tOutStateString);
aParams->SetBooleanValue(STATE_MIXED, outMixed);
aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
return NS_OK;
}
nsresult
-nsBackgroundColorStateCommand::SetState(mozilla::HTMLEditor* aHTMLEditor,
- nsString& newState)
+BackgroundColorStateCommand::SetState(HTMLEditor* aHTMLEditor,
+ const nsString& newState)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
return aHTMLEditor->SetBackgroundColor(newState);
}
-nsAlignCommand::nsAlignCommand()
-: nsMultiStateCommand()
+AlignCommand::AlignCommand()
+ : MultiStateCommandBase()
{
}
nsresult
-nsAlignCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor,
- nsICommandParams* aParams)
+AlignCommand::GetCurrentState(HTMLEditor* aHTMLEditor,
+ nsICommandParams* aParams)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
nsIHTMLEditor::EAlignment firstAlign;
bool outMixed;
nsresult rv = aHTMLEditor->GetAlignment(&outMixed, &firstAlign);
@@ -988,34 +987,34 @@ nsAlignCommand::GetCurrentState(mozilla:
nsAutoCString tOutStateString;
LossyCopyUTF16toASCII(outStateString, tOutStateString);
aParams->SetBooleanValue(STATE_MIXED,outMixed);
aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
return NS_OK;
}
nsresult
-nsAlignCommand::SetState(mozilla::HTMLEditor* aHTMLEditor,
- nsString& newState)
+AlignCommand::SetState(HTMLEditor* aHTMLEditor,
+ const nsString& newState)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
return aHTMLEditor->Align(newState);
}
-nsAbsolutePositioningCommand::nsAbsolutePositioningCommand()
-: nsBaseStateUpdatingCommand(nsGkAtoms::_empty)
+AbsolutePositioningCommand::AbsolutePositioningCommand()
+ : StateUpdatingCommandBase(nsGkAtoms::_empty)
{
}
NS_IMETHODIMP
-nsAbsolutePositioningCommand::IsCommandEnabled(const char * aCommandName,
- nsISupports *aCommandRefCon,
- bool *outCmdEnabled)
+AbsolutePositioningCommand::IsCommandEnabled(const char* aCommandName,
+ nsISupports* aCommandRefCon,
+ bool* outCmdEnabled)
{
*outCmdEnabled = false;
nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
if (!editor) {
return NS_OK;
}
mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
@@ -1025,18 +1024,18 @@ nsAbsolutePositioningCommand::IsCommandE
if (!htmlEditor->IsSelectionEditable()) {
return NS_OK;
}
*outCmdEnabled = htmlEditor->AbsolutePositioningEnabled();
return NS_OK;
}
nsresult
-nsAbsolutePositioningCommand::GetCurrentState(mozilla::HTMLEditor* aHTMLEditor,
- nsICommandParams* aParams)
+AbsolutePositioningCommand::GetCurrentState(HTMLEditor* aHTMLEditor,
+ nsICommandParams* aParams)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
bool isEnabled = aHTMLEditor->AbsolutePositioningEnabled();
if (!isEnabled) {
aParams->SetBooleanValue(STATE_MIXED,false);
@@ -1047,32 +1046,32 @@ nsAbsolutePositioningCommand::GetCurrent
RefPtr<Element> container =
aHTMLEditor->GetAbsolutelyPositionedSelectionContainer();
aParams->SetBooleanValue(STATE_MIXED, false);
aParams->SetCStringValue(STATE_ATTRIBUTE, container ? "absolute" : "");
return NS_OK;
}
nsresult
-nsAbsolutePositioningCommand::ToggleState(mozilla::HTMLEditor* aHTMLEditor)
+AbsolutePositioningCommand::ToggleState(HTMLEditor* aHTMLEditor)
{
if (NS_WARN_IF(!aHTMLEditor)) {
return NS_ERROR_INVALID_ARG;
}
RefPtr<Element> container =
aHTMLEditor->GetAbsolutelyPositionedSelectionContainer();
return aHTMLEditor->SetSelectionToAbsoluteOrStatic(!container);
}
NS_IMETHODIMP
-nsDecreaseZIndexCommand::IsCommandEnabled(const char * aCommandName,
- nsISupports *refCon,
- bool *outCmdEnabled)
+DecreaseZIndexCommand::IsCommandEnabled(const char* aCommandName,
+ nsISupports* refCon,
+ bool* outCmdEnabled)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (NS_WARN_IF(!editor)) {
return NS_ERROR_FAILURE;
}
mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
if (NS_WARN_IF(!htmlEditor)) {
return NS_ERROR_FAILURE;
@@ -1089,56 +1088,56 @@ nsDecreaseZIndexCommand::IsCommandEnable
}
int32_t z = htmlEditor->GetZIndex(*positionedElement);
*outCmdEnabled = (z > 0);
return NS_OK;
}
NS_IMETHODIMP
-nsDecreaseZIndexCommand::DoCommand(const char *aCommandName,
- nsISupports *refCon)
+DecreaseZIndexCommand::DoCommand(const char* aCommandName,
+ nsISupports* refCon)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (NS_WARN_IF(!editor)) {
return NS_ERROR_FAILURE;
}
mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
if (NS_WARN_IF(!htmlEditor)) {
return NS_ERROR_FAILURE;
}
return htmlEditor->AddZIndex(-1);
}
NS_IMETHODIMP
-nsDecreaseZIndexCommand::DoCommandParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+DecreaseZIndexCommand::DoCommandParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
return DoCommand(aCommandName, refCon);
}
NS_IMETHODIMP
-nsDecreaseZIndexCommand::GetCommandStateParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+DecreaseZIndexCommand::GetCommandStateParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
NS_ENSURE_ARG_POINTER(aParams);
bool enabled = false;
nsresult rv = IsCommandEnabled(aCommandName, refCon, &enabled);
NS_ENSURE_SUCCESS(rv, rv);
return aParams->SetBooleanValue(STATE_ENABLED, enabled);
}
NS_IMETHODIMP
-nsIncreaseZIndexCommand::IsCommandEnabled(const char * aCommandName,
- nsISupports *refCon,
- bool *outCmdEnabled)
+IncreaseZIndexCommand::IsCommandEnabled(const char* aCommandName,
+ nsISupports* refCon,
+ bool* outCmdEnabled)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (NS_WARN_IF(!editor)) {
return NS_ERROR_FAILURE;
}
mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
if (NS_WARN_IF(!htmlEditor)) {
return NS_ERROR_FAILURE;
@@ -1149,222 +1148,222 @@ nsIncreaseZIndexCommand::IsCommandEnable
return NS_OK;
Element* positionedElement = htmlEditor->GetPositionedElement();
*outCmdEnabled = (nullptr != positionedElement);
return NS_OK;
}
NS_IMETHODIMP
-nsIncreaseZIndexCommand::DoCommand(const char *aCommandName,
- nsISupports *refCon)
+IncreaseZIndexCommand::DoCommand(const char* aCommandName,
+ nsISupports* refCon)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (NS_WARN_IF(!editor)) {
return NS_ERROR_FAILURE;
}
mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
if (NS_WARN_IF(!htmlEditor)) {
return NS_ERROR_FAILURE;
}
return htmlEditor->AddZIndex(1);
}
NS_IMETHODIMP
-nsIncreaseZIndexCommand::DoCommandParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+IncreaseZIndexCommand::DoCommandParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
return DoCommand(aCommandName, refCon);
}
NS_IMETHODIMP
-nsIncreaseZIndexCommand::GetCommandStateParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+IncreaseZIndexCommand::GetCommandStateParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
NS_ENSURE_ARG_POINTER(aParams);
bool enabled = false;
nsresult rv = IsCommandEnabled(aCommandName, refCon, &enabled);
NS_ENSURE_SUCCESS(rv, rv);
return aParams->SetBooleanValue(STATE_ENABLED, enabled);
}
NS_IMETHODIMP
-nsRemoveStylesCommand::IsCommandEnabled(const char * aCommandName,
- nsISupports *refCon,
- bool *outCmdEnabled)
+RemoveStylesCommand::IsCommandEnabled(const char* aCommandName,
+ nsISupports* refCon,
+ bool* outCmdEnabled)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
*outCmdEnabled = false;
return NS_OK;
}
mozilla::EditorBase* editorBase = editor->AsEditorBase();
MOZ_ASSERT(editorBase);
// test if we have any styles?
*outCmdEnabled = editorBase->IsSelectionEditable();
return NS_OK;
}
NS_IMETHODIMP
-nsRemoveStylesCommand::DoCommand(const char *aCommandName,
- nsISupports *refCon)
+RemoveStylesCommand::DoCommand(const char* aCommandName,
+ nsISupports* refCon)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
return NS_OK;
}
mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
if (!htmlEditor) {
return NS_OK;
}
return htmlEditor->RemoveAllInlineProperties();
}
NS_IMETHODIMP
-nsRemoveStylesCommand::DoCommandParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+RemoveStylesCommand::DoCommandParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
return DoCommand(aCommandName, refCon);
}
NS_IMETHODIMP
-nsRemoveStylesCommand::GetCommandStateParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+RemoveStylesCommand::GetCommandStateParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
bool outCmdEnabled = false;
IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
return aParams->SetBooleanValue(STATE_ENABLED,outCmdEnabled);
}
NS_IMETHODIMP
-nsIncreaseFontSizeCommand::IsCommandEnabled(const char * aCommandName,
- nsISupports *refCon,
- bool *outCmdEnabled)
+IncreaseFontSizeCommand::IsCommandEnabled(const char* aCommandName,
+ nsISupports* refCon,
+ bool* outCmdEnabled)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
*outCmdEnabled = false;
return NS_OK;
}
mozilla::EditorBase* editorBase = editor->AsEditorBase();
MOZ_ASSERT(editorBase);
// test if we are at max size?
*outCmdEnabled = editorBase->IsSelectionEditable();
return NS_OK;
}
NS_IMETHODIMP
-nsIncreaseFontSizeCommand::DoCommand(const char *aCommandName,
- nsISupports *refCon)
+IncreaseFontSizeCommand::DoCommand(const char* aCommandName,
+ nsISupports* refCon)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
return NS_OK;
}
mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
if (!htmlEditor) {
return NS_OK;
}
return htmlEditor->IncreaseFontSize();
}
NS_IMETHODIMP
-nsIncreaseFontSizeCommand::DoCommandParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+IncreaseFontSizeCommand::DoCommandParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
return DoCommand(aCommandName, refCon);
}
NS_IMETHODIMP
-nsIncreaseFontSizeCommand::GetCommandStateParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+IncreaseFontSizeCommand::GetCommandStateParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
bool outCmdEnabled = false;
IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
return aParams->SetBooleanValue(STATE_ENABLED,outCmdEnabled);
}
NS_IMETHODIMP
-nsDecreaseFontSizeCommand::IsCommandEnabled(const char * aCommandName,
- nsISupports *refCon,
- bool *outCmdEnabled)
+DecreaseFontSizeCommand::IsCommandEnabled(const char* aCommandName,
+ nsISupports* refCon,
+ bool* outCmdEnabled)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
*outCmdEnabled = false;
return NS_OK;
}
mozilla::EditorBase* editorBase = editor->AsEditorBase();
MOZ_ASSERT(editorBase);
// test if we are at min size?
*outCmdEnabled = editorBase->IsSelectionEditable();
return NS_OK;
}
NS_IMETHODIMP
-nsDecreaseFontSizeCommand::DoCommand(const char *aCommandName,
- nsISupports *refCon)
+DecreaseFontSizeCommand::DoCommand(const char* aCommandName,
+ nsISupports* refCon)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
return NS_OK;
}
mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
if (!htmlEditor) {
return NS_OK;
}
return htmlEditor->DecreaseFontSize();
}
NS_IMETHODIMP
-nsDecreaseFontSizeCommand::DoCommandParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+DecreaseFontSizeCommand::DoCommandParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
return DoCommand(aCommandName, refCon);
}
NS_IMETHODIMP
-nsDecreaseFontSizeCommand::GetCommandStateParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+DecreaseFontSizeCommand::GetCommandStateParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
bool outCmdEnabled = false;
IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
return aParams->SetBooleanValue(STATE_ENABLED,outCmdEnabled);
}
NS_IMETHODIMP
-nsInsertHTMLCommand::IsCommandEnabled(const char * aCommandName,
- nsISupports *refCon,
- bool *outCmdEnabled)
+InsertHTMLCommand::IsCommandEnabled(const char* aCommandName,
+ nsISupports* refCon,
+ bool* outCmdEnabled)
{
NS_ENSURE_ARG_POINTER(outCmdEnabled);
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
*outCmdEnabled = false;
return NS_OK;
}
mozilla::EditorBase* editorBase = editor->AsEditorBase();
MOZ_ASSERT(editorBase);
*outCmdEnabled = editorBase->IsSelectionEditable();
return NS_OK;
}
NS_IMETHODIMP
-nsInsertHTMLCommand::DoCommand(const char *aCommandName, nsISupports *refCon)
+InsertHTMLCommand::DoCommand(const char* aCommandName, nsISupports* refCon)
{
// If nsInsertHTMLCommand is called with no parameters, it was probably called with
// an empty string parameter ''. In this case, it should act the same as the delete command
NS_ENSURE_ARG_POINTER(refCon);
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (NS_WARN_IF(!editor)) {
return NS_ERROR_FAILURE;
@@ -1373,19 +1372,19 @@ nsInsertHTMLCommand::DoCommand(const cha
if (NS_WARN_IF(!htmlEditor)) {
return NS_ERROR_FAILURE;
}
nsAutoString html;
return htmlEditor->InsertHTML(html);
}
NS_IMETHODIMP
-nsInsertHTMLCommand::DoCommandParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+InsertHTMLCommand::DoCommandParams(const char* aCommandName,
+ nsICommandParams* aParams,
+ nsISupports* refCon)
{
NS_ENSURE_ARG_POINTER(aParams);
NS_ENSURE_ARG_POINTER(refCon);
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (NS_WARN_IF(!editor)) {
return NS_ERROR_FAILURE;
}
@@ -1398,59 +1397,59 @@ nsInsertHTMLCommand::DoCommandParams(con
nsAutoString html;
nsresult rv = aParams->GetStringValue(STATE_DATA, html);
NS_ENSURE_SUCCESS(rv, rv);
return htmlEditor->InsertHTML(html);
}
NS_IMETHODIMP
-nsInsertHTMLCommand::GetCommandStateParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+InsertHTMLCommand::GetCommandStateParams(const char *aCommandName,
+ nsICommandParams *aParams,
+ nsISupports *refCon)
{
NS_ENSURE_ARG_POINTER(aParams);
NS_ENSURE_ARG_POINTER(refCon);
bool outCmdEnabled = false;
IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
return aParams->SetBooleanValue(STATE_ENABLED, outCmdEnabled);
}
-nsInsertTagCommand::nsInsertTagCommand(nsAtom* aTagName)
-: nsBaseComposerCommand()
-, mTagName(aTagName)
+InsertTagCommand::InsertTagCommand(nsAtom* aTagName)
+ : HTMLEditorCommandBase()
+ , mTagName(aTagName)
{
MOZ_ASSERT(mTagName);
}
-nsInsertTagCommand::~nsInsertTagCommand()
+InsertTagCommand::~InsertTagCommand()
{
}
NS_IMETHODIMP
-nsInsertTagCommand::IsCommandEnabled(const char * aCommandName,
- nsISupports *refCon,
- bool *outCmdEnabled)
+InsertTagCommand::IsCommandEnabled(const char* aCommandName,
+ nsISupports* refCon,
+ bool* outCmdEnabled)
{
NS_ENSURE_ARG_POINTER(outCmdEnabled);
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (!editor) {
*outCmdEnabled = false;
return NS_OK;
}
mozilla::EditorBase* editorBase = editor->AsEditorBase();
MOZ_ASSERT(editorBase);
*outCmdEnabled = editorBase->IsSelectionEditable();
return NS_OK;
}
// corresponding STATE_ATTRIBUTE is: src (img) and href (a)
NS_IMETHODIMP
-nsInsertTagCommand::DoCommand(const char *aCmdName, nsISupports *refCon)
+InsertTagCommand::DoCommand(const char* aCmdName, nsISupports* refCon)
{
NS_ENSURE_TRUE(mTagName == nsGkAtoms::hr, NS_ERROR_NOT_IMPLEMENTED);
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (NS_WARN_IF(!editor)) {
return NS_ERROR_FAILURE;
}
mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
@@ -1462,19 +1461,19 @@ nsInsertTagCommand::DoCommand(const char
nsresult rv = htmlEditor->CreateElementWithDefaults(
nsDependentAtomString(mTagName), getter_AddRefs(newElement));
NS_ENSURE_SUCCESS(rv, rv);
return htmlEditor->InsertElementAtSelection(newElement, true);
}
NS_IMETHODIMP
-nsInsertTagCommand::DoCommandParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+InsertTagCommand::DoCommandParams(const char *aCommandName,
+ nsICommandParams *aParams,
+ nsISupports *refCon)
{
NS_ENSURE_ARG_POINTER(refCon);
// inserting an hr shouldn't have an parameters, just call DoCommand for that
if (mTagName == nsGkAtoms::hr) {
return DoCommand(aCommandName, refCon);
}
@@ -1523,37 +1522,35 @@ nsInsertTagCommand::DoCommandParams(cons
// do actual insertion
if (mTagName == nsGkAtoms::a) {
return htmlEditor->InsertLinkAroundSelection(elem);
}
return htmlEditor->InsertElementAtSelection(elem, true);
}
NS_IMETHODIMP
-nsInsertTagCommand::GetCommandStateParams(const char *aCommandName,
- nsICommandParams *aParams,
- nsISupports *refCon)
+InsertTagCommand::GetCommandStateParams(const char *aCommandName,
+ nsICommandParams *aParams,
+ nsISupports *refCon)
{
NS_ENSURE_ARG_POINTER(aParams);
NS_ENSURE_ARG_POINTER(refCon);
bool outCmdEnabled = false;
IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
return aParams->SetBooleanValue(STATE_ENABLED, outCmdEnabled);
}
/****************************/
//HELPER METHODS
/****************************/
static nsresult
-GetListState(mozilla::HTMLEditor* aHTMLEditor,
- bool* aMixed,
- nsAString& aLocalName)
+GetListState(HTMLEditor* aHTMLEditor, bool* aMixed, nsAString& aLocalName)
{
MOZ_ASSERT(aHTMLEditor);
MOZ_ASSERT(aMixed);
*aMixed = false;
aLocalName.Truncate();
bool bOL, bUL, bDL;
@@ -1568,8 +1565,10 @@ GetListState(mozilla::HTMLEditor* aHTMLE
aLocalName.AssignLiteral("ol");
} else if (bUL) {
aLocalName.AssignLiteral("ul");
} else if (bDL) {
aLocalName.AssignLiteral("dl");
}
return NS_OK;
}
+
+} // namespace mozilla
--- a/editor/composer/HTMLEditorController.cpp
+++ b/editor/composer/HTMLEditorController.cpp
@@ -1,17 +1,17 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/HTMLEditorController.h"
+#include "mozilla/HTMLEditorCommands.h" // for StyleUpdatingCommand, etc
#include "mozilla/mozalloc.h" // for operator new
-#include "nsComposerCommands.h" // for nsStyleUpdatingCommand, etc
#include "nsError.h" // for NS_OK
#include "nsGkAtoms.h" // for nsGkAtoms, nsGkAtoms::a, etc
#include "nsIControllerCommandTable.h" // for nsIControllerCommandTable
class nsIControllerCommand;
namespace mozilla {
@@ -53,94 +53,94 @@ namespace mozilla {
// static
nsresult
HTMLEditorController::RegisterEditorDocStateCommands(
nsIControllerCommandTable *inCommandTable)
{
// observer commands for document state
- NS_REGISTER_FIRST_COMMAND(nsDocumentStateCommand, "obs_documentCreated")
- NS_REGISTER_NEXT_COMMAND(nsDocumentStateCommand, "obs_documentWillBeDestroyed")
- NS_REGISTER_LAST_COMMAND(nsDocumentStateCommand, "obs_documentLocationChanged")
+ NS_REGISTER_FIRST_COMMAND(DocumentStateCommand, "obs_documentCreated")
+ NS_REGISTER_NEXT_COMMAND(DocumentStateCommand, "obs_documentWillBeDestroyed")
+ NS_REGISTER_LAST_COMMAND(DocumentStateCommand, "obs_documentLocationChanged")
// commands that may get or change state
- NS_REGISTER_FIRST_COMMAND(nsSetDocumentStateCommand, "cmd_setDocumentModified")
- NS_REGISTER_NEXT_COMMAND(nsSetDocumentStateCommand, "cmd_setDocumentUseCSS")
- NS_REGISTER_NEXT_COMMAND(nsSetDocumentStateCommand, "cmd_setDocumentReadOnly")
- NS_REGISTER_NEXT_COMMAND(nsSetDocumentStateCommand, "cmd_insertBrOnReturn")
- NS_REGISTER_NEXT_COMMAND(nsSetDocumentStateCommand, "cmd_defaultParagraphSeparator")
- NS_REGISTER_NEXT_COMMAND(nsSetDocumentStateCommand, "cmd_enableObjectResizing")
- NS_REGISTER_LAST_COMMAND(nsSetDocumentStateCommand, "cmd_enableInlineTableEditing")
+ NS_REGISTER_FIRST_COMMAND(SetDocumentStateCommand, "cmd_setDocumentModified")
+ NS_REGISTER_NEXT_COMMAND(SetDocumentStateCommand, "cmd_setDocumentUseCSS")
+ NS_REGISTER_NEXT_COMMAND(SetDocumentStateCommand, "cmd_setDocumentReadOnly")
+ NS_REGISTER_NEXT_COMMAND(SetDocumentStateCommand, "cmd_insertBrOnReturn")
+ NS_REGISTER_NEXT_COMMAND(SetDocumentStateCommand, "cmd_defaultParagraphSeparator")
+ NS_REGISTER_NEXT_COMMAND(SetDocumentStateCommand, "cmd_enableObjectResizing")
+ NS_REGISTER_LAST_COMMAND(SetDocumentStateCommand, "cmd_enableInlineTableEditing")
- NS_REGISTER_ONE_COMMAND(nsSetDocumentOptionsCommand, "cmd_setDocumentOptions")
+ NS_REGISTER_ONE_COMMAND(SetDocumentOptionsCommand, "cmd_setDocumentOptions")
return NS_OK;
}
// static
nsresult
HTMLEditorController::RegisterHTMLEditorCommands(
nsIControllerCommandTable *inCommandTable)
{
// Edit menu
- NS_REGISTER_ONE_COMMAND(nsPasteNoFormattingCommand, "cmd_pasteNoFormatting");
+ NS_REGISTER_ONE_COMMAND(PasteNoFormattingCommand, "cmd_pasteNoFormatting");
// indent/outdent
- NS_REGISTER_ONE_COMMAND(nsIndentCommand, "cmd_indent");
- NS_REGISTER_ONE_COMMAND(nsOutdentCommand, "cmd_outdent");
+ NS_REGISTER_ONE_COMMAND(IndentCommand, "cmd_indent");
+ NS_REGISTER_ONE_COMMAND(OutdentCommand, "cmd_outdent");
// Styles
- NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_bold", nsGkAtoms::b);
- NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_italic", nsGkAtoms::i);
- NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_underline", nsGkAtoms::u);
- NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_tt", nsGkAtoms::tt);
+ NS_REGISTER_STYLE_COMMAND(StyleUpdatingCommand, "cmd_bold", nsGkAtoms::b);
+ NS_REGISTER_STYLE_COMMAND(StyleUpdatingCommand, "cmd_italic", nsGkAtoms::i);
+ NS_REGISTER_STYLE_COMMAND(StyleUpdatingCommand, "cmd_underline", nsGkAtoms::u);
+ NS_REGISTER_STYLE_COMMAND(StyleUpdatingCommand, "cmd_tt", nsGkAtoms::tt);
- NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_strikethrough", nsGkAtoms::strike);
- NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_superscript", nsGkAtoms::sup);
- NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_subscript", nsGkAtoms::sub);
- NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_nobreak", nsGkAtoms::nobr);
+ NS_REGISTER_STYLE_COMMAND(StyleUpdatingCommand, "cmd_strikethrough", nsGkAtoms::strike);
+ NS_REGISTER_STYLE_COMMAND(StyleUpdatingCommand, "cmd_superscript", nsGkAtoms::sup);
+ NS_REGISTER_STYLE_COMMAND(StyleUpdatingCommand, "cmd_subscript", nsGkAtoms::sub);
+ NS_REGISTER_STYLE_COMMAND(StyleUpdatingCommand, "cmd_nobreak", nsGkAtoms::nobr);
- NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_em", nsGkAtoms::em);
- NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_strong", nsGkAtoms::strong);
- NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_cite", nsGkAtoms::cite);
- NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_abbr", nsGkAtoms::abbr);
- NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_acronym", nsGkAtoms::acronym);
- NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_code", nsGkAtoms::code);
- NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_samp", nsGkAtoms::samp);
- NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_var", nsGkAtoms::var);
- NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_removeLinks", nsGkAtoms::href);
+ NS_REGISTER_STYLE_COMMAND(StyleUpdatingCommand, "cmd_em", nsGkAtoms::em);
+ NS_REGISTER_STYLE_COMMAND(StyleUpdatingCommand, "cmd_strong", nsGkAtoms::strong);
+ NS_REGISTER_STYLE_COMMAND(StyleUpdatingCommand, "cmd_cite", nsGkAtoms::cite);
+ NS_REGISTER_STYLE_COMMAND(StyleUpdatingCommand, "cmd_abbr", nsGkAtoms::abbr);
+ NS_REGISTER_STYLE_COMMAND(StyleUpdatingCommand, "cmd_acronym", nsGkAtoms::acronym);
+ NS_REGISTER_STYLE_COMMAND(StyleUpdatingCommand, "cmd_code", nsGkAtoms::code);
+ NS_REGISTER_STYLE_COMMAND(StyleUpdatingCommand, "cmd_samp", nsGkAtoms::samp);
+ NS_REGISTER_STYLE_COMMAND(StyleUpdatingCommand, "cmd_var", nsGkAtoms::var);
+ NS_REGISTER_STYLE_COMMAND(StyleUpdatingCommand, "cmd_removeLinks", nsGkAtoms::href);
// lists
- NS_REGISTER_STYLE_COMMAND(nsListCommand, "cmd_ol", nsGkAtoms::ol);
- NS_REGISTER_STYLE_COMMAND(nsListCommand, "cmd_ul", nsGkAtoms::ul);
- NS_REGISTER_STYLE_COMMAND(nsListItemCommand, "cmd_dt", nsGkAtoms::dt);
- NS_REGISTER_STYLE_COMMAND(nsListItemCommand, "cmd_dd", nsGkAtoms::dd);
- NS_REGISTER_ONE_COMMAND(nsRemoveListCommand, "cmd_removeList");
+ NS_REGISTER_STYLE_COMMAND(ListCommand, "cmd_ol", nsGkAtoms::ol);
+ NS_REGISTER_STYLE_COMMAND(ListCommand, "cmd_ul", nsGkAtoms::ul);
+ NS_REGISTER_STYLE_COMMAND(ListItemCommand, "cmd_dt", nsGkAtoms::dt);
+ NS_REGISTER_STYLE_COMMAND(ListItemCommand, "cmd_dd", nsGkAtoms::dd);
+ NS_REGISTER_ONE_COMMAND(RemoveListCommand, "cmd_removeList");
// format stuff
- NS_REGISTER_ONE_COMMAND(nsParagraphStateCommand, "cmd_paragraphState");
- NS_REGISTER_ONE_COMMAND(nsFontFaceStateCommand, "cmd_fontFace");
- NS_REGISTER_ONE_COMMAND(nsFontSizeStateCommand, "cmd_fontSize");
- NS_REGISTER_ONE_COMMAND(nsFontColorStateCommand, "cmd_fontColor");
- NS_REGISTER_ONE_COMMAND(nsBackgroundColorStateCommand, "cmd_backgroundColor");
- NS_REGISTER_ONE_COMMAND(nsHighlightColorStateCommand, "cmd_highlight");
+ NS_REGISTER_ONE_COMMAND(ParagraphStateCommand, "cmd_paragraphState");
+ NS_REGISTER_ONE_COMMAND(FontFaceStateCommand, "cmd_fontFace");
+ NS_REGISTER_ONE_COMMAND(FontSizeStateCommand, "cmd_fontSize");
+ NS_REGISTER_ONE_COMMAND(FontColorStateCommand, "cmd_fontColor");
+ NS_REGISTER_ONE_COMMAND(BackgroundColorStateCommand, "cmd_backgroundColor");
+ NS_REGISTER_ONE_COMMAND(HighlightColorStateCommand, "cmd_highlight");
- NS_REGISTER_ONE_COMMAND(nsAlignCommand, "cmd_align");
- NS_REGISTER_ONE_COMMAND(nsRemoveStylesCommand, "cmd_removeStyles");
+ NS_REGISTER_ONE_COMMAND(AlignCommand, "cmd_align");
+ NS_REGISTER_ONE_COMMAND(RemoveStylesCommand, "cmd_removeStyles");
- NS_REGISTER_ONE_COMMAND(nsIncreaseFontSizeCommand, "cmd_increaseFont");
- NS_REGISTER_ONE_COMMAND(nsDecreaseFontSizeCommand, "cmd_decreaseFont");
+ NS_REGISTER_ONE_COMMAND(IncreaseFontSizeCommand, "cmd_increaseFont");
+ NS_REGISTER_ONE_COMMAND(DecreaseFontSizeCommand, "cmd_decreaseFont");
// Insert content
- NS_REGISTER_ONE_COMMAND(nsInsertHTMLCommand, "cmd_insertHTML");
- NS_REGISTER_TAG_COMMAND(nsInsertTagCommand, "cmd_insertLinkNoUI", nsGkAtoms::a);
- NS_REGISTER_TAG_COMMAND(nsInsertTagCommand, "cmd_insertImageNoUI", nsGkAtoms::img);
- NS_REGISTER_TAG_COMMAND(nsInsertTagCommand, "cmd_insertHR", nsGkAtoms::hr);
+ NS_REGISTER_ONE_COMMAND(InsertHTMLCommand, "cmd_insertHTML");
+ NS_REGISTER_TAG_COMMAND(InsertTagCommand, "cmd_insertLinkNoUI", nsGkAtoms::a);
+ NS_REGISTER_TAG_COMMAND(InsertTagCommand, "cmd_insertImageNoUI", nsGkAtoms::img);
+ NS_REGISTER_TAG_COMMAND(InsertTagCommand, "cmd_insertHR", nsGkAtoms::hr);
- NS_REGISTER_ONE_COMMAND(nsAbsolutePositioningCommand, "cmd_absPos");
- NS_REGISTER_ONE_COMMAND(nsDecreaseZIndexCommand, "cmd_decreaseZIndex");
- NS_REGISTER_ONE_COMMAND(nsIncreaseZIndexCommand, "cmd_increaseZIndex");
+ NS_REGISTER_ONE_COMMAND(AbsolutePositioningCommand, "cmd_absPos");
+ NS_REGISTER_ONE_COMMAND(DecreaseZIndexCommand, "cmd_decreaseZIndex");
+ NS_REGISTER_ONE_COMMAND(IncreaseZIndexCommand, "cmd_increaseZIndex");
return NS_OK;
}
} // namespace mozilla