Bug 1713756 - Make editor command classes treat EditorBase instead of TextEditor r=m_kato
`TextEditor` will be not a parent class of `HTMLEditor`. Therefore, editor command classes should use `EditorBase` class instead. Depends on D117116 Differential Revision: https://phabricator.services.mozilla.com/D117117
This commit is contained in:
@@ -7,11 +7,11 @@
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/EditorBase.h"
|
||||
#include "mozilla/FlushType.h"
|
||||
#include "mozilla/HTMLEditor.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/MozPromise.h" // for mozilla::detail::Any
|
||||
#include "mozilla/TextEditor.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "nsCommandParams.h"
|
||||
@@ -47,9 +47,9 @@ NS_IMETHODIMP EditorCommand::IsCommandEnabled(const char* aCommandName,
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
|
||||
TextEditor* textEditor = editor ? editor->AsTextEditor() : nullptr;
|
||||
EditorBase* editorBase = editor ? editor->AsEditorBase() : nullptr;
|
||||
*aIsEnabled = IsCommandEnabled(GetInternalCommand(aCommandName),
|
||||
MOZ_KnownLive(textEditor));
|
||||
MOZ_KnownLive(editorBase));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ NS_IMETHODIMP EditorCommand::DoCommand(const char* aCommandName,
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
nsresult rv = DoCommand(GetInternalCommand(aCommandName),
|
||||
MOZ_KnownLive(*editor->AsTextEditor()), nullptr);
|
||||
MOZ_KnownLive(*editor->AsEditorBase()), nullptr);
|
||||
NS_WARNING_ASSERTION(
|
||||
NS_SUCCEEDED(rv),
|
||||
"Failed to do command from nsIControllerCommand::DoCommand()");
|
||||
@@ -85,7 +85,7 @@ NS_IMETHODIMP EditorCommand::DoCommandParams(const char* aCommandName,
|
||||
EditorCommandParamType paramType = EditorCommand::GetParamType(command);
|
||||
if (paramType == EditorCommandParamType::None) {
|
||||
nsresult rv = DoCommandParam(
|
||||
command, MOZ_KnownLive(*editor->AsTextEditor()), nullptr);
|
||||
command, MOZ_KnownLive(*editor->AsEditorBase()), nullptr);
|
||||
NS_WARNING_ASSERTION(
|
||||
NS_SUCCEEDED(rv),
|
||||
"Failed to do command from nsIControllerCommand::DoCommandParams()");
|
||||
@@ -103,7 +103,7 @@ NS_IMETHODIMP EditorCommand::DoCommandParams(const char* aCommandName,
|
||||
}
|
||||
}
|
||||
nsresult rv = DoCommandParam(
|
||||
command, boolParam, MOZ_KnownLive(*editor->AsTextEditor()), nullptr);
|
||||
command, boolParam, MOZ_KnownLive(*editor->AsEditorBase()), nullptr);
|
||||
NS_WARNING_ASSERTION(
|
||||
NS_SUCCEEDED(rv),
|
||||
"Failed to do command from nsIControllerCommand::DoCommandParams()");
|
||||
@@ -120,7 +120,7 @@ NS_IMETHODIMP EditorCommand::DoCommandParams(const char* aCommandName,
|
||||
if (!params) {
|
||||
nsresult rv =
|
||||
DoCommandParam(command, VoidString(),
|
||||
MOZ_KnownLive(*editor->AsTextEditor()), nullptr);
|
||||
MOZ_KnownLive(*editor->AsEditorBase()), nullptr);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"Failed to do command from "
|
||||
"nsIControllerCommand::DoCommandParams()");
|
||||
@@ -133,7 +133,7 @@ NS_IMETHODIMP EditorCommand::DoCommandParams(const char* aCommandName,
|
||||
NS_ConvertUTF8toUTF16 stringParam(cStringParam);
|
||||
nsresult rv =
|
||||
DoCommandParam(command, stringParam,
|
||||
MOZ_KnownLive(*editor->AsTextEditor()), nullptr);
|
||||
MOZ_KnownLive(*editor->AsEditorBase()), nullptr);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"Failed to do command from "
|
||||
"nsIControllerCommand::DoCommandParams()");
|
||||
@@ -145,7 +145,7 @@ NS_IMETHODIMP EditorCommand::DoCommandParams(const char* aCommandName,
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
|
||||
"Failed to get string from STATE_ATTRIBUTE");
|
||||
rv = DoCommandParam(command, stringParam,
|
||||
MOZ_KnownLive(*editor->AsTextEditor()), nullptr);
|
||||
MOZ_KnownLive(*editor->AsEditorBase()), nullptr);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"Failed to do command from "
|
||||
"nsIControllerCommand::DoCommandParams()");
|
||||
@@ -159,7 +159,7 @@ NS_IMETHODIMP EditorCommand::DoCommandParams(const char* aCommandName,
|
||||
if (!params) {
|
||||
nsresult rv =
|
||||
DoCommandParam(command, VoidCString(),
|
||||
MOZ_KnownLive(*editor->AsTextEditor()), nullptr);
|
||||
MOZ_KnownLive(*editor->AsEditorBase()), nullptr);
|
||||
NS_WARNING_ASSERTION(
|
||||
NS_SUCCEEDED(rv),
|
||||
"Failed to do command from nsIControllerCommand::DoCommandParams()");
|
||||
@@ -172,7 +172,7 @@ NS_IMETHODIMP EditorCommand::DoCommandParams(const char* aCommandName,
|
||||
return rv;
|
||||
}
|
||||
rv = DoCommandParam(command, cStringParam,
|
||||
MOZ_KnownLive(*editor->AsTextEditor()), nullptr);
|
||||
MOZ_KnownLive(*editor->AsEditorBase()), nullptr);
|
||||
NS_WARNING_ASSERTION(
|
||||
NS_SUCCEEDED(rv),
|
||||
"Failed to do command from nsIControllerCommand::DoCommandParams()");
|
||||
@@ -186,7 +186,7 @@ NS_IMETHODIMP EditorCommand::DoCommandParams(const char* aCommandName,
|
||||
if (!params) {
|
||||
nsresult rv =
|
||||
DoCommandParam(command, VoidString(),
|
||||
MOZ_KnownLive(*editor->AsTextEditor()), nullptr);
|
||||
MOZ_KnownLive(*editor->AsEditorBase()), nullptr);
|
||||
NS_WARNING_ASSERTION(
|
||||
NS_SUCCEEDED(rv),
|
||||
"Failed to do command from nsIControllerCommand::DoCommandParams()");
|
||||
@@ -208,7 +208,7 @@ NS_IMETHODIMP EditorCommand::DoCommandParams(const char* aCommandName,
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
nsresult rv = DoCommandParam(
|
||||
command, stringParam, MOZ_KnownLive(*editor->AsTextEditor()), nullptr);
|
||||
command, stringParam, MOZ_KnownLive(*editor->AsEditorBase()), nullptr);
|
||||
NS_WARNING_ASSERTION(
|
||||
NS_SUCCEEDED(rv),
|
||||
"Failed to do command from nsIControllerCommand::DoCommandParams()");
|
||||
@@ -222,7 +222,7 @@ NS_IMETHODIMP EditorCommand::DoCommandParams(const char* aCommandName,
|
||||
transferable = do_QueryInterface(supports);
|
||||
}
|
||||
nsresult rv = DoCommandParam(
|
||||
command, transferable, MOZ_KnownLive(*editor->AsTextEditor()), nullptr);
|
||||
command, transferable, MOZ_KnownLive(*editor->AsEditorBase()), nullptr);
|
||||
NS_WARNING_ASSERTION(
|
||||
NS_SUCCEEDED(rv),
|
||||
"Failed to do command from nsIControllerCommand::DoCommandParams()");
|
||||
@@ -243,7 +243,7 @@ NS_IMETHODIMP EditorCommand::GetCommandStateParams(
|
||||
if (editor) {
|
||||
return GetCommandStateParams(GetInternalCommand(aCommandName),
|
||||
MOZ_KnownLive(*aParams->AsCommandParams()),
|
||||
MOZ_KnownLive(editor->AsTextEditor()),
|
||||
MOZ_KnownLive(editor->AsEditorBase()),
|
||||
nullptr);
|
||||
}
|
||||
nsCOMPtr<nsIEditingSession> editingSession =
|
||||
@@ -265,25 +265,25 @@ NS_IMETHODIMP EditorCommand::GetCommandStateParams(
|
||||
StaticRefPtr<UndoCommand> UndoCommand::sInstance;
|
||||
|
||||
bool UndoCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
return aTextEditor->IsSelectionEditable() && aTextEditor->CanUndo();
|
||||
return aEditorBase->IsSelectionEditable() && aEditorBase->CanUndo();
|
||||
}
|
||||
|
||||
nsresult UndoCommand::DoCommand(Command aCommand, TextEditor& aTextEditor,
|
||||
nsresult UndoCommand::DoCommand(Command aCommand, EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
nsresult rv = aTextEditor.UndoAsAction(1, aPrincipal);
|
||||
nsresult rv = aEditorBase.UndoAsAction(1, aPrincipal);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "EditorBase::UndoAsAction() failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult UndoCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -293,25 +293,25 @@ nsresult UndoCommand::GetCommandStateParams(
|
||||
StaticRefPtr<RedoCommand> RedoCommand::sInstance;
|
||||
|
||||
bool RedoCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
return aTextEditor->IsSelectionEditable() && aTextEditor->CanRedo();
|
||||
return aEditorBase->IsSelectionEditable() && aEditorBase->CanRedo();
|
||||
}
|
||||
|
||||
nsresult RedoCommand::DoCommand(Command aCommand, TextEditor& aTextEditor,
|
||||
nsresult RedoCommand::DoCommand(Command aCommand, EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
nsresult rv = aTextEditor.RedoAsAction(1, aPrincipal);
|
||||
nsresult rv = aEditorBase.RedoAsAction(1, aPrincipal);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "EditorBase::RedoAsAction() failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult RedoCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -321,26 +321,26 @@ nsresult RedoCommand::GetCommandStateParams(
|
||||
StaticRefPtr<CutCommand> CutCommand::sInstance;
|
||||
|
||||
bool CutCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
return aTextEditor->IsSelectionEditable() &&
|
||||
aTextEditor->IsCutCommandEnabled();
|
||||
return aEditorBase->IsSelectionEditable() &&
|
||||
aEditorBase->IsCutCommandEnabled();
|
||||
}
|
||||
|
||||
nsresult CutCommand::DoCommand(Command aCommand, TextEditor& aTextEditor,
|
||||
nsresult CutCommand::DoCommand(Command aCommand, EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
nsresult rv = aTextEditor.CutAsAction(aPrincipal);
|
||||
nsresult rv = aEditorBase.CutAsAction(aPrincipal);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "EditorBase::CutAsAction() failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult CutCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -350,34 +350,34 @@ nsresult CutCommand::GetCommandStateParams(
|
||||
StaticRefPtr<CutOrDeleteCommand> CutOrDeleteCommand::sInstance;
|
||||
|
||||
bool CutOrDeleteCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
return aTextEditor->IsSelectionEditable();
|
||||
return aEditorBase->IsSelectionEditable();
|
||||
}
|
||||
|
||||
nsresult CutOrDeleteCommand::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
dom::Selection* selection = aTextEditor.GetSelection();
|
||||
dom::Selection* selection = aEditorBase.GetSelection();
|
||||
if (selection && selection->IsCollapsed()) {
|
||||
nsresult rv = aTextEditor.DeleteSelectionAsAction(
|
||||
nsresult rv = aEditorBase.DeleteSelectionAsAction(
|
||||
nsIEditor::eNext, nsIEditor::eStrip, aPrincipal);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"EditorBase::DeleteSelectionAsAction() failed");
|
||||
return rv;
|
||||
}
|
||||
nsresult rv = aTextEditor.CutAsAction(aPrincipal);
|
||||
nsresult rv = aEditorBase.CutAsAction(aPrincipal);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "EditorBase::CutAsAction() failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult CutOrDeleteCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -387,25 +387,25 @@ nsresult CutOrDeleteCommand::GetCommandStateParams(
|
||||
StaticRefPtr<CopyCommand> CopyCommand::sInstance;
|
||||
|
||||
bool CopyCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
return aTextEditor->IsCopyCommandEnabled();
|
||||
return aEditorBase->IsCopyCommandEnabled();
|
||||
}
|
||||
|
||||
nsresult CopyCommand::DoCommand(Command aCommand, TextEditor& aTextEditor,
|
||||
nsresult CopyCommand::DoCommand(Command aCommand, EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
// Shouldn't cause "beforeinput" event so that we don't need to specify
|
||||
// the given principal.
|
||||
return aTextEditor.Copy();
|
||||
return aEditorBase.Copy();
|
||||
}
|
||||
|
||||
nsresult CopyCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -415,19 +415,19 @@ nsresult CopyCommand::GetCommandStateParams(
|
||||
StaticRefPtr<CopyOrDeleteCommand> CopyOrDeleteCommand::sInstance;
|
||||
|
||||
bool CopyOrDeleteCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
return aTextEditor->IsSelectionEditable();
|
||||
return aEditorBase->IsSelectionEditable();
|
||||
}
|
||||
|
||||
nsresult CopyOrDeleteCommand::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
dom::Selection* selection = aTextEditor.GetSelection();
|
||||
dom::Selection* selection = aEditorBase.GetSelection();
|
||||
if (selection && selection->IsCollapsed()) {
|
||||
nsresult rv = aTextEditor.DeleteSelectionAsAction(
|
||||
nsresult rv = aEditorBase.DeleteSelectionAsAction(
|
||||
nsIEditor::eNextWord, nsIEditor::eStrip, aPrincipal);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"EditorBase::DeleteSelectionAsAction() failed");
|
||||
@@ -435,16 +435,16 @@ nsresult CopyOrDeleteCommand::DoCommand(Command aCommand,
|
||||
}
|
||||
// Shouldn't cause "beforeinput" event so that we don't need to specify
|
||||
// the given principal.
|
||||
nsresult rv = aTextEditor.Copy();
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "TextEditor::Copy() failed");
|
||||
nsresult rv = aEditorBase.Copy();
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "EditorBase::Copy() failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult CopyOrDeleteCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -454,27 +454,27 @@ nsresult CopyOrDeleteCommand::GetCommandStateParams(
|
||||
StaticRefPtr<PasteCommand> PasteCommand::sInstance;
|
||||
|
||||
bool PasteCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
return aTextEditor->IsSelectionEditable() &&
|
||||
aTextEditor->CanPaste(nsIClipboard::kGlobalClipboard);
|
||||
return aEditorBase->IsSelectionEditable() &&
|
||||
aEditorBase->CanPaste(nsIClipboard::kGlobalClipboard);
|
||||
}
|
||||
|
||||
nsresult PasteCommand::DoCommand(Command aCommand, TextEditor& aTextEditor,
|
||||
nsresult PasteCommand::DoCommand(Command aCommand, EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
nsresult rv = aTextEditor.PasteAsAction(nsIClipboard::kGlobalClipboard, true,
|
||||
nsresult rv = aEditorBase.PasteAsAction(nsIClipboard::kGlobalClipboard, true,
|
||||
aPrincipal);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "EditorBase::PasteAsAction() failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult PasteCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -484,37 +484,37 @@ nsresult PasteCommand::GetCommandStateParams(
|
||||
StaticRefPtr<PasteTransferableCommand> PasteTransferableCommand::sInstance;
|
||||
|
||||
bool PasteTransferableCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
return aTextEditor->IsSelectionEditable() &&
|
||||
aTextEditor->CanPasteTransferable(nullptr);
|
||||
return aEditorBase->IsSelectionEditable() &&
|
||||
aEditorBase->CanPasteTransferable(nullptr);
|
||||
}
|
||||
|
||||
nsresult PasteTransferableCommand::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult PasteTransferableCommand::DoCommandParam(
|
||||
Command aCommand, nsITransferable* aTransferableParam,
|
||||
TextEditor& aTextEditor, nsIPrincipal* aPrincipal) const {
|
||||
EditorBase& aEditorBase, nsIPrincipal* aPrincipal) const {
|
||||
if (NS_WARN_IF(!aTransferableParam)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
nsresult rv =
|
||||
aTextEditor.PasteTransferableAsAction(aTransferableParam, aPrincipal);
|
||||
aEditorBase.PasteTransferableAsAction(aTransferableParam, aPrincipal);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"EditorBase::PasteTransferableAsAction() failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult PasteTransferableCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
if (NS_WARN_IF(!aTextEditor)) {
|
||||
if (NS_WARN_IF(!aEditorBase)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
@@ -530,7 +530,7 @@ nsresult PasteTransferableCommand::GetCommandStateParams(
|
||||
}
|
||||
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
aTextEditor->CanPasteTransferable(trans));
|
||||
aEditorBase->CanPasteTransferable(trans));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -540,27 +540,27 @@ nsresult PasteTransferableCommand::GetCommandStateParams(
|
||||
StaticRefPtr<SwitchTextDirectionCommand> SwitchTextDirectionCommand::sInstance;
|
||||
|
||||
bool SwitchTextDirectionCommand::IsCommandEnabled(
|
||||
Command aCommand, TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
Command aCommand, EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
return aTextEditor->IsSelectionEditable();
|
||||
return aEditorBase->IsSelectionEditable();
|
||||
}
|
||||
|
||||
nsresult SwitchTextDirectionCommand::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
nsresult rv = aTextEditor.ToggleTextDirectionAsAction(aPrincipal);
|
||||
nsresult rv = aEditorBase.ToggleTextDirectionAsAction(aPrincipal);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"EditorBase::ToggleTextDirectionAsAction() failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult SwitchTextDirectionCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -570,22 +570,22 @@ nsresult SwitchTextDirectionCommand::GetCommandStateParams(
|
||||
StaticRefPtr<DeleteCommand> DeleteCommand::sInstance;
|
||||
|
||||
bool DeleteCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
// We can generally delete whenever the selection is editable. However,
|
||||
// cmd_delete doesn't make sense if the selection is collapsed because it's
|
||||
// directionless.
|
||||
bool isEnabled = aTextEditor->IsSelectionEditable();
|
||||
bool isEnabled = aEditorBase->IsSelectionEditable();
|
||||
|
||||
if (aCommand == Command::Delete && isEnabled) {
|
||||
return aTextEditor->CanDeleteSelection();
|
||||
return aEditorBase->CanDeleteSelection();
|
||||
}
|
||||
return isEnabled;
|
||||
}
|
||||
|
||||
nsresult DeleteCommand::DoCommand(Command aCommand, TextEditor& aTextEditor,
|
||||
nsresult DeleteCommand::DoCommand(Command aCommand, EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
nsIEditor::EDirection deleteDir = nsIEditor::eNone;
|
||||
switch (aCommand) {
|
||||
@@ -616,7 +616,7 @@ nsresult DeleteCommand::DoCommand(Command aCommand, TextEditor& aTextEditor,
|
||||
default:
|
||||
MOZ_CRASH("Unrecognized nsDeleteCommand");
|
||||
}
|
||||
nsresult rv = aTextEditor.DeleteSelectionAsAction(
|
||||
nsresult rv = aEditorBase.DeleteSelectionAsAction(
|
||||
deleteDir, nsIEditor::eStrip, aPrincipal);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"EditorBase::DeleteSelectionAsAction() failed");
|
||||
@@ -624,10 +624,10 @@ nsresult DeleteCommand::DoCommand(Command aCommand, TextEditor& aTextEditor,
|
||||
}
|
||||
|
||||
nsresult DeleteCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -637,31 +637,31 @@ nsresult DeleteCommand::GetCommandStateParams(
|
||||
StaticRefPtr<SelectAllCommand> SelectAllCommand::sInstance;
|
||||
|
||||
bool SelectAllCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
EditorBase* aEditorBase) const {
|
||||
// You can always select all, unless the selection is editable,
|
||||
// and the editable region is empty!
|
||||
if (!aTextEditor) {
|
||||
if (!aEditorBase) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// You can select all if there is an editor which is non-empty
|
||||
return !aTextEditor->IsEmpty();
|
||||
return !aEditorBase->IsEmpty();
|
||||
}
|
||||
|
||||
nsresult SelectAllCommand::DoCommand(Command aCommand, TextEditor& aTextEditor,
|
||||
nsresult SelectAllCommand::DoCommand(Command aCommand, EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
// Shouldn't cause "beforeinput" event so that we don't need to specify
|
||||
// aPrincipal.
|
||||
nsresult rv = aTextEditor.SelectAll();
|
||||
nsresult rv = aEditorBase.SelectAll();
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "EditorBase::SelectAll() failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult SelectAllCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -671,11 +671,11 @@ nsresult SelectAllCommand::GetCommandStateParams(
|
||||
StaticRefPtr<SelectionMoveCommands> SelectionMoveCommands::sInstance;
|
||||
|
||||
bool SelectionMoveCommands::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
return aTextEditor->IsSelectionEditable();
|
||||
return aEditorBase->IsSelectionEditable();
|
||||
}
|
||||
|
||||
static const struct ScrollCommand {
|
||||
@@ -731,9 +731,9 @@ static const struct PhysicalCommand {
|
||||
nsISelectionController::MOVE_DOWN, 1}};
|
||||
|
||||
nsresult SelectionMoveCommands::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
RefPtr<dom::Document> document = aTextEditor.GetDocument();
|
||||
RefPtr<dom::Document> document = aEditorBase.GetDocument();
|
||||
if (document) {
|
||||
// Most of the commands below (possibly all of them) need layout to
|
||||
// be up to date.
|
||||
@@ -741,7 +741,7 @@ nsresult SelectionMoveCommands::DoCommand(Command aCommand,
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISelectionController> selectionController =
|
||||
aTextEditor.GetSelectionController();
|
||||
aEditorBase.GetSelectionController();
|
||||
if (NS_WARN_IF(!selectionController)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -799,10 +799,10 @@ nsresult SelectionMoveCommands::DoCommand(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult SelectionMoveCommands::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -812,15 +812,15 @@ nsresult SelectionMoveCommands::GetCommandStateParams(
|
||||
StaticRefPtr<InsertPlaintextCommand> InsertPlaintextCommand::sInstance;
|
||||
|
||||
bool InsertPlaintextCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
return aTextEditor->IsSelectionEditable();
|
||||
return aEditorBase->IsSelectionEditable();
|
||||
}
|
||||
|
||||
nsresult InsertPlaintextCommand::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
// XXX InsertTextAsAction() is not same as OnInputText(). However, other
|
||||
// commands to insert line break or paragraph separator use OnInput*().
|
||||
@@ -829,14 +829,14 @@ nsresult InsertPlaintextCommand::DoCommand(Command aCommand,
|
||||
// transactions to the top transaction since its name may not be
|
||||
// nsGkAtoms::TypingTxnName.
|
||||
DebugOnly<nsresult> rvIgnored =
|
||||
aTextEditor.InsertTextAsAction(u""_ns, aPrincipal);
|
||||
aEditorBase.InsertTextAsAction(u""_ns, aPrincipal);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
|
||||
"EditorBase::InsertTextAsAction() failed, but ignored");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult InsertPlaintextCommand::DoCommandParam(
|
||||
Command aCommand, const nsAString& aStringParam, TextEditor& aTextEditor,
|
||||
Command aCommand, const nsAString& aStringParam, EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
if (NS_WARN_IF(aStringParam.IsVoid())) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
@@ -849,17 +849,17 @@ nsresult InsertPlaintextCommand::DoCommandParam(
|
||||
// transactions to the top transaction since its name may not be
|
||||
// nsGkAtoms::TypingTxnName.
|
||||
DebugOnly<nsresult> rvIgnored =
|
||||
aTextEditor.InsertTextAsAction(aStringParam, aPrincipal);
|
||||
aEditorBase.InsertTextAsAction(aStringParam, aPrincipal);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
|
||||
"EditorBase::InsertTextAsAction() failed, but ignored");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult InsertPlaintextCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -869,38 +869,38 @@ nsresult InsertPlaintextCommand::GetCommandStateParams(
|
||||
StaticRefPtr<InsertParagraphCommand> InsertParagraphCommand::sInstance;
|
||||
|
||||
bool InsertParagraphCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor || aTextEditor->IsSingleLineEditor()) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase || aEditorBase->IsSingleLineEditor()) {
|
||||
return false;
|
||||
}
|
||||
return aTextEditor->IsSelectionEditable();
|
||||
return aEditorBase->IsSelectionEditable();
|
||||
}
|
||||
|
||||
nsresult InsertParagraphCommand::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
if (aTextEditor.IsSingleLineEditor()) {
|
||||
if (aEditorBase.IsSingleLineEditor()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (aTextEditor.IsHTMLEditor()) {
|
||||
nsresult rv = MOZ_KnownLive(aTextEditor.AsHTMLEditor())
|
||||
if (aEditorBase.IsHTMLEditor()) {
|
||||
nsresult rv = MOZ_KnownLive(aEditorBase.AsHTMLEditor())
|
||||
->InsertParagraphSeparatorAsAction(aPrincipal);
|
||||
NS_WARNING_ASSERTION(
|
||||
NS_SUCCEEDED(rv),
|
||||
"HTMLEditor::InsertParagraphSeparatorAsAction() failed");
|
||||
return rv;
|
||||
}
|
||||
nsresult rv = aTextEditor.InsertLineBreakAsAction(aPrincipal);
|
||||
nsresult rv = aEditorBase.InsertLineBreakAsAction(aPrincipal);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"EditorBase::InsertLineBreakAsAction() failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult InsertParagraphCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -910,30 +910,30 @@ nsresult InsertParagraphCommand::GetCommandStateParams(
|
||||
StaticRefPtr<InsertLineBreakCommand> InsertLineBreakCommand::sInstance;
|
||||
|
||||
bool InsertLineBreakCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor || aTextEditor->IsSingleLineEditor()) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase || aEditorBase->IsSingleLineEditor()) {
|
||||
return false;
|
||||
}
|
||||
return aTextEditor->IsSelectionEditable();
|
||||
return aEditorBase->IsSelectionEditable();
|
||||
}
|
||||
|
||||
nsresult InsertLineBreakCommand::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
if (aTextEditor.IsSingleLineEditor()) {
|
||||
if (aEditorBase.IsSingleLineEditor()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsresult rv = aTextEditor.InsertLineBreakAsAction(aPrincipal);
|
||||
nsresult rv = aEditorBase.InsertLineBreakAsAction(aPrincipal);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"EditorBase::InsertLineBreakAsAction() failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult InsertLineBreakCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -943,18 +943,18 @@ nsresult InsertLineBreakCommand::GetCommandStateParams(
|
||||
StaticRefPtr<PasteQuotationCommand> PasteQuotationCommand::sInstance;
|
||||
|
||||
bool PasteQuotationCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
return !aTextEditor->IsSingleLineEditor() &&
|
||||
aTextEditor->CanPaste(nsIClipboard::kGlobalClipboard);
|
||||
return !aEditorBase->IsSingleLineEditor() &&
|
||||
aEditorBase->CanPaste(nsIClipboard::kGlobalClipboard);
|
||||
}
|
||||
|
||||
nsresult PasteQuotationCommand::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
nsresult rv = aTextEditor.PasteAsQuotationAsAction(
|
||||
nsresult rv = aEditorBase.PasteAsQuotationAsAction(
|
||||
nsIClipboard::kGlobalClipboard, true, aPrincipal);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"EditorBase::PasteAsQuotationAsAction() failed");
|
||||
@@ -962,13 +962,13 @@ nsresult PasteQuotationCommand::DoCommand(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult PasteQuotationCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
if (!aTextEditor) {
|
||||
if (!aEditorBase) {
|
||||
return NS_OK;
|
||||
}
|
||||
aParams.SetBool(STATE_ENABLED,
|
||||
aTextEditor->CanPaste(nsIClipboard::kGlobalClipboard));
|
||||
aEditorBase->CanPaste(nsIClipboard::kGlobalClipboard));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ class nsStaticAtom;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class EditorBase;
|
||||
class HTMLEditor;
|
||||
class TextEditor;
|
||||
|
||||
/**
|
||||
* EditorCommandParamType tells you that EditorCommand subclasses refer
|
||||
@@ -339,13 +339,13 @@ class EditorCommand : public nsIControllerCommand {
|
||||
nsISupports* aCommandRefCon) final;
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT virtual bool IsCommandEnabled(
|
||||
Command aCommand, TextEditor* aTextEditor) const = 0;
|
||||
Command aCommand, EditorBase* aEditorBase) const = 0;
|
||||
MOZ_CAN_RUN_SCRIPT virtual nsresult DoCommand(
|
||||
Command aCommand, TextEditor& aTextEditor,
|
||||
Command aCommand, EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const = 0;
|
||||
|
||||
/**
|
||||
* @param aTextEditor If the context is an editor, should be set to
|
||||
* @param aEditorBase If the context is an editor, should be set to
|
||||
* it. Otherwise, nullptr.
|
||||
* @param aEditingSession If the context is an editing session, should be
|
||||
* set to it. This usually occurs if editor has
|
||||
@@ -353,7 +353,7 @@ class EditorCommand : public nsIControllerCommand {
|
||||
* Otherwise, nullptr.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT virtual nsresult GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const = 0;
|
||||
|
||||
/**
|
||||
@@ -361,7 +361,7 @@ class EditorCommand : public nsIControllerCommand {
|
||||
* EditorCommandParamType::None.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT virtual nsresult DoCommandParam(
|
||||
Command aCommand, TextEditor& aTextEditor,
|
||||
Command aCommand, EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
MOZ_ASSERT_UNREACHABLE("Wrong overload is called");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
@@ -373,7 +373,7 @@ class EditorCommand : public nsIControllerCommand {
|
||||
* means that given param was nullptr.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT virtual nsresult DoCommandParam(
|
||||
Command aCommand, const Maybe<bool>& aBoolParam, TextEditor& aTextEditor,
|
||||
Command aCommand, const Maybe<bool>& aBoolParam, EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
MOZ_ASSERT_UNREACHABLE("Wrong overload is called");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
@@ -386,7 +386,7 @@ class EditorCommand : public nsIControllerCommand {
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT virtual nsresult DoCommandParam(
|
||||
Command aCommand, const nsACString& aCStringParam,
|
||||
TextEditor& aTextEditor, nsIPrincipal* aPrincipal) const {
|
||||
EditorBase& aEditorBase, nsIPrincipal* aPrincipal) const {
|
||||
MOZ_ASSERT_UNREACHABLE("Wrong overload is called");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
@@ -397,7 +397,7 @@ class EditorCommand : public nsIControllerCommand {
|
||||
* means that given param was nullptr.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT virtual nsresult DoCommandParam(
|
||||
Command aCommand, const nsAString& aStringParam, TextEditor& aTextEditor,
|
||||
Command aCommand, const nsAString& aStringParam, EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
MOZ_ASSERT_UNREACHABLE("Wrong overload is called");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
@@ -410,7 +410,7 @@ class EditorCommand : public nsIControllerCommand {
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT virtual nsresult DoCommandParam(
|
||||
Command aCommand, nsITransferable* aTransferableParam,
|
||||
TextEditor& aTextEditor, nsIPrincipal* aPrincipal) const {
|
||||
EditorBase& aEditorBase, nsIPrincipal* aPrincipal) const {
|
||||
MOZ_ASSERT_UNREACHABLE("Wrong overload is called");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
@@ -423,14 +423,14 @@ class EditorCommand : public nsIControllerCommand {
|
||||
#define NS_DECL_EDITOR_COMMAND_COMMON_METHODS \
|
||||
public: \
|
||||
MOZ_CAN_RUN_SCRIPT virtual bool IsCommandEnabled( \
|
||||
Command aCommand, TextEditor* aTextEditor) const final; \
|
||||
Command aCommand, EditorBase* aEditorBase) const final; \
|
||||
using EditorCommand::IsCommandEnabled; \
|
||||
MOZ_CAN_RUN_SCRIPT virtual nsresult DoCommand( \
|
||||
Command aCommand, TextEditor& aTextEditor, nsIPrincipal* aPrincipal) \
|
||||
Command aCommand, EditorBase& aEditorBase, nsIPrincipal* aPrincipal) \
|
||||
const final; \
|
||||
using EditorCommand::DoCommand; \
|
||||
MOZ_CAN_RUN_SCRIPT virtual nsresult GetCommandStateParams( \
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor, \
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase, \
|
||||
nsIEditingSession* aEditingSession) const final; \
|
||||
using EditorCommand::GetCommandStateParams; \
|
||||
using EditorCommand::DoCommandParam;
|
||||
@@ -438,34 +438,34 @@ class EditorCommand : public nsIControllerCommand {
|
||||
#define NS_DECL_DO_COMMAND_PARAM_DELEGATE_TO_DO_COMMAND \
|
||||
public: \
|
||||
MOZ_CAN_RUN_SCRIPT virtual nsresult DoCommandParam( \
|
||||
Command aCommand, TextEditor& aTextEditor, nsIPrincipal* aPrincipal) \
|
||||
Command aCommand, EditorBase& aEditorBase, nsIPrincipal* aPrincipal) \
|
||||
const final { \
|
||||
return DoCommand(aCommand, aTextEditor, aPrincipal); \
|
||||
return DoCommand(aCommand, aEditorBase, aPrincipal); \
|
||||
}
|
||||
|
||||
#define NS_DECL_DO_COMMAND_PARAM_FOR_BOOL_PARAM \
|
||||
public: \
|
||||
MOZ_CAN_RUN_SCRIPT virtual nsresult DoCommandParam( \
|
||||
Command aCommand, const Maybe<bool>& aBoolParam, \
|
||||
TextEditor& aTextEditor, nsIPrincipal* aPrincipal) const final;
|
||||
EditorBase& aEditorBase, nsIPrincipal* aPrincipal) const final;
|
||||
|
||||
#define NS_DECL_DO_COMMAND_PARAM_FOR_CSTRING_PARAM \
|
||||
public: \
|
||||
MOZ_CAN_RUN_SCRIPT virtual nsresult DoCommandParam( \
|
||||
Command aCommand, const nsACString& aCStringParam, \
|
||||
TextEditor& aTextEditor, nsIPrincipal* aPrincipal) const final;
|
||||
EditorBase& aEditorBase, nsIPrincipal* aPrincipal) const final;
|
||||
|
||||
#define NS_DECL_DO_COMMAND_PARAM_FOR_STRING_PARAM \
|
||||
public: \
|
||||
MOZ_CAN_RUN_SCRIPT virtual nsresult DoCommandParam( \
|
||||
Command aCommand, const nsAString& aStringParam, \
|
||||
TextEditor& aTextEditor, nsIPrincipal* aPrincipal) const final;
|
||||
EditorBase& aEditorBase, nsIPrincipal* aPrincipal) const final;
|
||||
|
||||
#define NS_DECL_DO_COMMAND_PARAM_FOR_TRANSFERABLE_PARAM \
|
||||
public: \
|
||||
MOZ_CAN_RUN_SCRIPT virtual nsresult DoCommandParam( \
|
||||
Command aCommand, nsITransferable* aTransferableParam, \
|
||||
TextEditor& aTextEditor, nsIPrincipal* aPrincipal) const final;
|
||||
EditorBase& aEditorBase, nsIPrincipal* aPrincipal) const final;
|
||||
|
||||
#define NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON(_cmd) \
|
||||
public: \
|
||||
|
||||
@@ -47,11 +47,11 @@ static nsresult GetListState(HTMLEditor* aHTMLEditor, bool* aMixed,
|
||||
*****************************************************************************/
|
||||
|
||||
bool StateUpdatingCommandBase::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (!htmlEditor) {
|
||||
return false;
|
||||
}
|
||||
@@ -65,9 +65,9 @@ bool StateUpdatingCommandBase::IsCommandEnabled(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult StateUpdatingCommandBase::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase.AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -83,12 +83,12 @@ nsresult StateUpdatingCommandBase::DoCommand(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult StateUpdatingCommandBase::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
if (!aTextEditor) {
|
||||
if (!aEditorBase) {
|
||||
return NS_OK;
|
||||
}
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -110,11 +110,11 @@ nsresult StateUpdatingCommandBase::GetCommandStateParams(
|
||||
StaticRefPtr<PasteNoFormattingCommand> PasteNoFormattingCommand::sInstance;
|
||||
|
||||
bool PasteNoFormattingCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (!htmlEditor) {
|
||||
return false;
|
||||
}
|
||||
@@ -122,9 +122,9 @@ bool PasteNoFormattingCommand::IsCommandEnabled(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult PasteNoFormattingCommand::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase.AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -138,10 +138,10 @@ nsresult PasteNoFormattingCommand::DoCommand(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult PasteNoFormattingCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -361,12 +361,12 @@ nsresult ListItemCommand::ToggleState(nsStaticAtom& aTagName,
|
||||
StaticRefPtr<RemoveListCommand> RemoveListCommand::sInstance;
|
||||
|
||||
bool RemoveListCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (!htmlEditor) {
|
||||
return false;
|
||||
}
|
||||
@@ -383,9 +383,9 @@ bool RemoveListCommand::IsCommandEnabled(Command aCommand,
|
||||
return NS_SUCCEEDED(rv) && (bMixed || !localName.IsEmpty());
|
||||
}
|
||||
|
||||
nsresult RemoveListCommand::DoCommand(Command aCommand, TextEditor& aTextEditor,
|
||||
nsresult RemoveListCommand::DoCommand(Command aCommand, EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase.AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -398,10 +398,10 @@ nsresult RemoveListCommand::DoCommand(Command aCommand, TextEditor& aTextEditor,
|
||||
}
|
||||
|
||||
nsresult RemoveListCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -411,20 +411,20 @@ nsresult RemoveListCommand::GetCommandStateParams(
|
||||
StaticRefPtr<IndentCommand> IndentCommand::sInstance;
|
||||
|
||||
bool IndentCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (!htmlEditor) {
|
||||
return false;
|
||||
}
|
||||
return htmlEditor->IsSelectionEditable();
|
||||
}
|
||||
|
||||
nsresult IndentCommand::DoCommand(Command aCommand, TextEditor& aTextEditor,
|
||||
nsresult IndentCommand::DoCommand(Command aCommand, EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase.AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -434,10 +434,10 @@ nsresult IndentCommand::DoCommand(Command aCommand, TextEditor& aTextEditor,
|
||||
}
|
||||
|
||||
nsresult IndentCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -447,20 +447,20 @@ nsresult IndentCommand::GetCommandStateParams(
|
||||
StaticRefPtr<OutdentCommand> OutdentCommand::sInstance;
|
||||
|
||||
bool OutdentCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (!htmlEditor) {
|
||||
return false;
|
||||
}
|
||||
return htmlEditor->IsSelectionEditable();
|
||||
}
|
||||
|
||||
nsresult OutdentCommand::DoCommand(Command aCommand, TextEditor& aTextEditor,
|
||||
nsresult OutdentCommand::DoCommand(Command aCommand, EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase.AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -471,10 +471,10 @@ nsresult OutdentCommand::DoCommand(Command aCommand, TextEditor& aTextEditor,
|
||||
}
|
||||
|
||||
nsresult OutdentCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -482,11 +482,11 @@ nsresult OutdentCommand::GetCommandStateParams(
|
||||
*****************************************************************************/
|
||||
|
||||
bool MultiStateCommandBase::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (!htmlEditor) {
|
||||
return false;
|
||||
}
|
||||
@@ -495,7 +495,7 @@ bool MultiStateCommandBase::IsCommandEnabled(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult MultiStateCommandBase::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
NS_WARNING(
|
||||
"who is calling MultiStateCommandBase::DoCommand (no implementation)?");
|
||||
@@ -504,12 +504,12 @@ nsresult MultiStateCommandBase::DoCommand(Command aCommand,
|
||||
|
||||
nsresult MultiStateCommandBase::DoCommandParam(Command aCommand,
|
||||
const nsAString& aStringParam,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
NS_WARNING_ASSERTION(aCommand != Command::FormatJustify,
|
||||
"Command::FormatJustify should be used only for "
|
||||
"IsCommandEnabled() and GetCommandStateParams()");
|
||||
HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase.AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -520,12 +520,12 @@ nsresult MultiStateCommandBase::DoCommandParam(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult MultiStateCommandBase::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
if (!aTextEditor) {
|
||||
if (!aEditorBase) {
|
||||
return NS_OK;
|
||||
}
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -941,11 +941,11 @@ nsresult AbsolutePositioningCommand::ToggleState(
|
||||
StaticRefPtr<DecreaseZIndexCommand> DecreaseZIndexCommand::sInstance;
|
||||
|
||||
bool DecreaseZIndexCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
RefPtr<HTMLEditor> htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
RefPtr<HTMLEditor> htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (!htmlEditor) {
|
||||
return false;
|
||||
}
|
||||
@@ -960,9 +960,9 @@ bool DecreaseZIndexCommand::IsCommandEnabled(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult DecreaseZIndexCommand::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase.AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -973,10 +973,10 @@ nsresult DecreaseZIndexCommand::DoCommand(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult DecreaseZIndexCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -986,11 +986,11 @@ nsresult DecreaseZIndexCommand::GetCommandStateParams(
|
||||
StaticRefPtr<IncreaseZIndexCommand> IncreaseZIndexCommand::sInstance;
|
||||
|
||||
bool IncreaseZIndexCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (!htmlEditor) {
|
||||
return false;
|
||||
}
|
||||
@@ -1001,9 +1001,9 @@ bool IncreaseZIndexCommand::IsCommandEnabled(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult IncreaseZIndexCommand::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase.AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -1014,10 +1014,10 @@ nsresult IncreaseZIndexCommand::DoCommand(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult IncreaseZIndexCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -1027,11 +1027,11 @@ nsresult IncreaseZIndexCommand::GetCommandStateParams(
|
||||
StaticRefPtr<RemoveStylesCommand> RemoveStylesCommand::sInstance;
|
||||
|
||||
bool RemoveStylesCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (!htmlEditor) {
|
||||
return false;
|
||||
}
|
||||
@@ -1040,9 +1040,9 @@ bool RemoveStylesCommand::IsCommandEnabled(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult RemoveStylesCommand::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase.AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1055,10 +1055,10 @@ nsresult RemoveStylesCommand::DoCommand(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult RemoveStylesCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -1068,11 +1068,11 @@ nsresult RemoveStylesCommand::GetCommandStateParams(
|
||||
StaticRefPtr<IncreaseFontSizeCommand> IncreaseFontSizeCommand::sInstance;
|
||||
|
||||
bool IncreaseFontSizeCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (!htmlEditor) {
|
||||
return false;
|
||||
}
|
||||
@@ -1081,9 +1081,9 @@ bool IncreaseFontSizeCommand::IsCommandEnabled(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult IncreaseFontSizeCommand::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase.AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1094,10 +1094,10 @@ nsresult IncreaseFontSizeCommand::DoCommand(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult IncreaseFontSizeCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -1107,11 +1107,11 @@ nsresult IncreaseFontSizeCommand::GetCommandStateParams(
|
||||
StaticRefPtr<DecreaseFontSizeCommand> DecreaseFontSizeCommand::sInstance;
|
||||
|
||||
bool DecreaseFontSizeCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (!htmlEditor) {
|
||||
return false;
|
||||
}
|
||||
@@ -1120,9 +1120,9 @@ bool DecreaseFontSizeCommand::IsCommandEnabled(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult DecreaseFontSizeCommand::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase.AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1133,10 +1133,10 @@ nsresult DecreaseFontSizeCommand::DoCommand(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult DecreaseFontSizeCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -1146,23 +1146,23 @@ nsresult DecreaseFontSizeCommand::GetCommandStateParams(
|
||||
StaticRefPtr<InsertHTMLCommand> InsertHTMLCommand::sInstance;
|
||||
|
||||
bool InsertHTMLCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (!htmlEditor) {
|
||||
return false;
|
||||
}
|
||||
return htmlEditor->IsSelectionEditable();
|
||||
}
|
||||
|
||||
nsresult InsertHTMLCommand::DoCommand(Command aCommand, TextEditor& aTextEditor,
|
||||
nsresult InsertHTMLCommand::DoCommand(Command aCommand, EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
// If InsertHTMLCommand 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
|
||||
HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase.AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -1175,13 +1175,13 @@ nsresult InsertHTMLCommand::DoCommand(Command aCommand, TextEditor& aTextEditor,
|
||||
|
||||
nsresult InsertHTMLCommand::DoCommandParam(Command aCommand,
|
||||
const nsAString& aStringParam,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
if (NS_WARN_IF(aStringParam.IsVoid())) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase.AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -1193,10 +1193,10 @@ nsresult InsertHTMLCommand::DoCommandParam(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult InsertHTMLCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -1206,11 +1206,11 @@ nsresult InsertHTMLCommand::GetCommandStateParams(
|
||||
StaticRefPtr<InsertTagCommand> InsertTagCommand::sInstance;
|
||||
|
||||
bool InsertTagCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor) {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (!aEditorBase) {
|
||||
return false;
|
||||
}
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (!htmlEditor) {
|
||||
return false;
|
||||
}
|
||||
@@ -1218,14 +1218,14 @@ bool InsertTagCommand::IsCommandEnabled(Command aCommand,
|
||||
}
|
||||
|
||||
// corresponding STATE_ATTRIBUTE is: src (img) and href (a)
|
||||
nsresult InsertTagCommand::DoCommand(Command aCommand, TextEditor& aTextEditor,
|
||||
nsresult InsertTagCommand::DoCommand(Command aCommand, EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
nsAtom* tagName = GetTagName(aCommand);
|
||||
if (NS_WARN_IF(tagName != nsGkAtoms::hr)) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase.AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -1246,7 +1246,7 @@ nsresult InsertTagCommand::DoCommand(Command aCommand, TextEditor& aTextEditor,
|
||||
|
||||
nsresult InsertTagCommand::DoCommandParam(Command aCommand,
|
||||
const nsAString& aStringParam,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
MOZ_ASSERT(aCommand != Command::InsertHorizontalRule);
|
||||
|
||||
@@ -1258,7 +1258,7 @@ nsresult InsertTagCommand::DoCommandParam(Command aCommand,
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase.AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -1308,10 +1308,10 @@ nsresult InsertTagCommand::DoCommandParam(Command aCommand,
|
||||
}
|
||||
|
||||
nsresult InsertTagCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
return aParams.SetBool(STATE_ENABLED,
|
||||
IsCommandEnabled(aCommand, aTextEditor));
|
||||
IsCommandEnabled(aCommand, aEditorBase));
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
#include "mozilla/EditorCommands.h"
|
||||
|
||||
#include "mozilla/EditorBase.h" // for EditorBase
|
||||
#include "mozilla/HTMLEditor.h" // for HTMLEditor
|
||||
#include "mozilla/TextEditor.h" // for TextEditor
|
||||
#include "mozilla/dom/Element.h" // for Element
|
||||
#include "mozilla/dom/Document.h" // for Document
|
||||
#include "mozilla/dom/HTMLInputElement.h" // for HTMLInputElement
|
||||
@@ -42,48 +42,48 @@ using namespace dom;
|
||||
StaticRefPtr<SetDocumentStateCommand> SetDocumentStateCommand::sInstance;
|
||||
|
||||
bool SetDocumentStateCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
EditorBase* aEditorBase) const {
|
||||
if (aCommand == Command::SetDocumentReadOnly) {
|
||||
return !!aTextEditor;
|
||||
return !!aEditorBase;
|
||||
}
|
||||
// The other commands are always enabled if given editor is an HTMLEditor.
|
||||
return aTextEditor && aTextEditor->AsHTMLEditor();
|
||||
return aEditorBase && aEditorBase->AsHTMLEditor();
|
||||
}
|
||||
|
||||
nsresult SetDocumentStateCommand::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult SetDocumentStateCommand::DoCommandParam(
|
||||
Command aCommand, const Maybe<bool>& aBoolParam, TextEditor& aTextEditor,
|
||||
Command aCommand, const Maybe<bool>& aBoolParam, EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
if (NS_WARN_IF(aBoolParam.isNothing())) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (aCommand != Command::SetDocumentReadOnly &&
|
||||
NS_WARN_IF(!aTextEditor.IsHTMLEditor())) {
|
||||
NS_WARN_IF(!aEditorBase.IsHTMLEditor())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
switch (aCommand) {
|
||||
case Command::SetDocumentModified: {
|
||||
if (aBoolParam.value()) {
|
||||
nsresult rv = aTextEditor.IncrementModificationCount(1);
|
||||
nsresult rv = aEditorBase.IncrementModificationCount(1);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"EditorBase::IncrementModificationCount() failed");
|
||||
return rv;
|
||||
}
|
||||
nsresult rv = aTextEditor.ResetModificationCount();
|
||||
nsresult rv = aEditorBase.ResetModificationCount();
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"EditorBase::ResetModificationCount() failed");
|
||||
return rv;
|
||||
}
|
||||
case Command::SetDocumentReadOnly: {
|
||||
if (aTextEditor.IsTextEditor()) {
|
||||
Element* inputOrTextArea = aTextEditor.GetExposedRoot();
|
||||
if (aEditorBase.IsTextEditor()) {
|
||||
Element* inputOrTextArea = aEditorBase.GetExposedRoot();
|
||||
if (NS_WARN_IF(!inputOrTextArea)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -117,20 +117,20 @@ nsresult SetDocumentStateCommand::DoCommandParam(
|
||||
}
|
||||
ErrorResult error;
|
||||
if (aBoolParam.value()) {
|
||||
nsresult rv = aTextEditor.AddFlags(nsIEditor::eEditorReadonlyMask);
|
||||
nsresult rv = aEditorBase.AddFlags(nsIEditor::eEditorReadonlyMask);
|
||||
NS_WARNING_ASSERTION(
|
||||
NS_SUCCEEDED(rv),
|
||||
"EditorBase::AddFlags(nsIEditor::eEditorReadonlyMask) failed");
|
||||
return rv;
|
||||
}
|
||||
nsresult rv = aTextEditor.RemoveFlags(nsIEditor::eEditorReadonlyMask);
|
||||
nsresult rv = aEditorBase.RemoveFlags(nsIEditor::eEditorReadonlyMask);
|
||||
NS_WARNING_ASSERTION(
|
||||
NS_SUCCEEDED(rv),
|
||||
"EditorBase::RemoveFlags(nsIEditor::eEditorReadonlyMask) failed");
|
||||
return rv;
|
||||
}
|
||||
case Command::SetDocumentUseCSS: {
|
||||
nsresult rv = MOZ_KnownLive(aTextEditor.AsHTMLEditor())
|
||||
nsresult rv = MOZ_KnownLive(aEditorBase.AsHTMLEditor())
|
||||
->SetIsCSSEnabled(aBoolParam.value());
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"HTMLEditor::SetIsCSSEnabled() failed");
|
||||
@@ -138,7 +138,7 @@ nsresult SetDocumentStateCommand::DoCommandParam(
|
||||
}
|
||||
case Command::SetDocumentInsertBROnEnterKeyPress: {
|
||||
nsresult rv =
|
||||
aTextEditor.AsHTMLEditor()->SetReturnInParagraphCreatesNewParagraph(
|
||||
aEditorBase.AsHTMLEditor()->SetReturnInParagraphCreatesNewParagraph(
|
||||
!aBoolParam.value());
|
||||
NS_WARNING_ASSERTION(
|
||||
NS_SUCCEEDED(rv),
|
||||
@@ -146,17 +146,17 @@ nsresult SetDocumentStateCommand::DoCommandParam(
|
||||
return rv;
|
||||
}
|
||||
case Command::ToggleObjectResizers: {
|
||||
MOZ_KnownLive(aTextEditor.AsHTMLEditor())
|
||||
MOZ_KnownLive(aEditorBase.AsHTMLEditor())
|
||||
->EnableObjectResizer(aBoolParam.value());
|
||||
return NS_OK;
|
||||
}
|
||||
case Command::ToggleInlineTableEditor: {
|
||||
MOZ_KnownLive(aTextEditor.AsHTMLEditor())
|
||||
MOZ_KnownLive(aEditorBase.AsHTMLEditor())
|
||||
->EnableInlineTableEditor(aBoolParam.value());
|
||||
return NS_OK;
|
||||
}
|
||||
case Command::ToggleAbsolutePositionEditor: {
|
||||
MOZ_KnownLive(aTextEditor.AsHTMLEditor())
|
||||
MOZ_KnownLive(aEditorBase.AsHTMLEditor())
|
||||
->EnableAbsolutePositionEditor(aBoolParam.value());
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -166,31 +166,31 @@ nsresult SetDocumentStateCommand::DoCommandParam(
|
||||
}
|
||||
|
||||
nsresult SetDocumentStateCommand::DoCommandParam(
|
||||
Command aCommand, const nsACString& aCStringParam, TextEditor& aTextEditor,
|
||||
Command aCommand, const nsACString& aCStringParam, EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
if (NS_WARN_IF(aCStringParam.IsVoid())) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!aTextEditor.AsHTMLEditor())) {
|
||||
if (NS_WARN_IF(!aEditorBase.IsHTMLEditor())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
switch (aCommand) {
|
||||
case Command::SetDocumentDefaultParagraphSeparator: {
|
||||
if (aCStringParam.LowerCaseEqualsLiteral("div")) {
|
||||
aTextEditor.AsHTMLEditor()->SetDefaultParagraphSeparator(
|
||||
aEditorBase.AsHTMLEditor()->SetDefaultParagraphSeparator(
|
||||
ParagraphSeparator::div);
|
||||
return NS_OK;
|
||||
}
|
||||
if (aCStringParam.LowerCaseEqualsLiteral("p")) {
|
||||
aTextEditor.AsHTMLEditor()->SetDefaultParagraphSeparator(
|
||||
aEditorBase.AsHTMLEditor()->SetDefaultParagraphSeparator(
|
||||
ParagraphSeparator::p);
|
||||
return NS_OK;
|
||||
}
|
||||
if (aCStringParam.LowerCaseEqualsLiteral("br")) {
|
||||
// Mozilla extension for backwards compatibility
|
||||
aTextEditor.AsHTMLEditor()->SetDefaultParagraphSeparator(
|
||||
aEditorBase.AsHTMLEditor()->SetDefaultParagraphSeparator(
|
||||
ParagraphSeparator::br);
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -207,24 +207,24 @@ nsresult SetDocumentStateCommand::DoCommandParam(
|
||||
}
|
||||
|
||||
nsresult SetDocumentStateCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
// If the result is set to STATE_ATTRIBUTE as CString value,
|
||||
// queryCommandValue() returns the string value.
|
||||
// Otherwise, ignored.
|
||||
|
||||
// The base editor owns most state info
|
||||
if (NS_WARN_IF(!aTextEditor)) {
|
||||
if (NS_WARN_IF(!aEditorBase)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!aTextEditor->AsHTMLEditor())) {
|
||||
if (NS_WARN_IF(!aEditorBase->IsHTMLEditor())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Always get the enabled state
|
||||
nsresult rv =
|
||||
aParams.SetBool(STATE_ENABLED, IsCommandEnabled(aCommand, aTextEditor));
|
||||
aParams.SetBool(STATE_ENABLED, IsCommandEnabled(aCommand, aEditorBase));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@@ -232,7 +232,7 @@ nsresult SetDocumentStateCommand::GetCommandStateParams(
|
||||
switch (aCommand) {
|
||||
case Command::SetDocumentModified: {
|
||||
bool modified;
|
||||
rv = aTextEditor->GetDocumentModified(&modified);
|
||||
rv = aEditorBase->GetDocumentModified(&modified);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("EditorBase::GetDocumentModified() failed");
|
||||
return rv;
|
||||
@@ -245,13 +245,13 @@ nsresult SetDocumentStateCommand::GetCommandStateParams(
|
||||
}
|
||||
case Command::SetDocumentReadOnly: {
|
||||
// XXX Nobody refers this result due to wrong type.
|
||||
rv = aParams.SetBool(STATE_ATTRIBUTE, aTextEditor->IsReadonly());
|
||||
rv = aParams.SetBool(STATE_ATTRIBUTE, aEditorBase->IsReadonly());
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"nsCommandParams::SetBool(STATE_ATTRIBUTE) failed");
|
||||
return rv;
|
||||
}
|
||||
case Command::SetDocumentUseCSS: {
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
@@ -261,7 +261,7 @@ nsresult SetDocumentStateCommand::GetCommandStateParams(
|
||||
return rv;
|
||||
}
|
||||
case Command::SetDocumentInsertBROnEnterKeyPress: {
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
@@ -278,7 +278,7 @@ nsresult SetDocumentStateCommand::GetCommandStateParams(
|
||||
return rv;
|
||||
}
|
||||
case Command::SetDocumentDefaultParagraphSeparator: {
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
@@ -310,7 +310,7 @@ nsresult SetDocumentStateCommand::GetCommandStateParams(
|
||||
}
|
||||
}
|
||||
case Command::ToggleObjectResizers: {
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
@@ -324,7 +324,7 @@ nsresult SetDocumentStateCommand::GetCommandStateParams(
|
||||
return rv;
|
||||
}
|
||||
case Command::ToggleInlineTableEditor: {
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
@@ -338,7 +338,7 @@ nsresult SetDocumentStateCommand::GetCommandStateParams(
|
||||
return rv;
|
||||
}
|
||||
case Command::ToggleAbsolutePositionEditor: {
|
||||
HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
|
||||
HTMLEditor* htmlEditor = aEditorBase->AsHTMLEditor();
|
||||
if (NS_WARN_IF(!htmlEditor)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
@@ -390,19 +390,19 @@ nsresult SetDocumentStateCommand::GetCommandStateParams(
|
||||
StaticRefPtr<DocumentStateCommand> DocumentStateCommand::sInstance;
|
||||
|
||||
bool DocumentStateCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
EditorBase* aEditorBase) const {
|
||||
// Always return false to discourage callers from using DoCommand()
|
||||
return false;
|
||||
}
|
||||
|
||||
nsresult DocumentStateCommand::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
EditorBase& aEditorBase,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult DocumentStateCommand::GetCommandStateParams(
|
||||
Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
|
||||
Command aCommand, nsCommandParams& aParams, EditorBase* aEditorBase,
|
||||
nsIEditingSession* aEditingSession) const {
|
||||
switch (aCommand) {
|
||||
case Command::EditorObserverDocumentCreated: {
|
||||
@@ -417,7 +417,7 @@ nsresult DocumentStateCommand::GetCommandStateParams(
|
||||
NS_WARNING("nsIEditingSession::GetEditorStatus() failed");
|
||||
return rv;
|
||||
}
|
||||
} else if (aTextEditor) {
|
||||
} else if (aEditorBase) {
|
||||
// If current context is an editor, then everything started up OK!
|
||||
editorStatus = nsIEditingSession::eEditorOK;
|
||||
}
|
||||
@@ -430,10 +430,10 @@ nsresult DocumentStateCommand::GetCommandStateParams(
|
||||
return NS_OK;
|
||||
}
|
||||
case Command::EditorObserverDocumentLocationChanged: {
|
||||
if (!aTextEditor) {
|
||||
if (!aEditorBase) {
|
||||
return NS_OK;
|
||||
}
|
||||
Document* document = aTextEditor->GetDocument();
|
||||
Document* document = aEditorBase->GetDocument();
|
||||
if (NS_WARN_IF(!document)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user