2016-06-24 05:45:22 +03:00
|
|
|
/* -*- 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/. */
|
|
|
|
|
2019-04-26 05:20:22 +03:00
|
|
|
#ifndef mozilla_EditorCommands_h
|
|
|
|
#define mozilla_EditorCommands_h
|
2016-06-24 05:45:22 +03:00
|
|
|
|
2019-04-15 10:49:46 +03:00
|
|
|
#include "mozilla/StaticPtr.h"
|
2016-06-24 05:45:22 +03:00
|
|
|
#include "nsIControllerCommand.h"
|
|
|
|
#include "nsISupportsImpl.h"
|
2019-04-26 05:20:22 +03:00
|
|
|
#include "nsRefPtrHashtable.h"
|
|
|
|
#include "nsStringFwd.h"
|
2016-06-24 05:45:22 +03:00
|
|
|
|
2019-04-26 05:20:22 +03:00
|
|
|
class nsAtom;
|
2016-06-24 05:45:22 +03:00
|
|
|
class nsICommandParams;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2019-04-26 05:20:22 +03:00
|
|
|
class HTMLEditor;
|
2019-04-26 16:11:24 +03:00
|
|
|
class TextEditor;
|
2019-04-26 05:20:22 +03:00
|
|
|
|
2016-06-24 05:45:22 +03:00
|
|
|
/**
|
2019-04-15 10:49:46 +03:00
|
|
|
* This is a base class for commands registered with the editor controller.
|
|
|
|
* Note that such commands are designed as singleton classes. So, MUST be
|
|
|
|
* stateless. Any state must be stored via the refCon (an nsIEditor).
|
2016-06-24 05:45:22 +03:00
|
|
|
*/
|
|
|
|
|
2019-04-26 06:20:02 +03:00
|
|
|
class EditorCommand : public nsIControllerCommand {
|
2016-06-24 05:45:22 +03:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2019-04-26 16:11:24 +03:00
|
|
|
// nsIControllerCommand methods. Use EditorCommand specific methods instead
|
|
|
|
// for internal use.
|
|
|
|
NS_IMETHOD IsCommandEnabled(const char* aCommandName,
|
|
|
|
nsISupports* aCommandRefCon,
|
|
|
|
bool* aIsEnabled) final;
|
2019-04-26 17:00:47 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
NS_IMETHOD DoCommand(const char* aCommandName,
|
|
|
|
nsISupports* aCommandRefCon) final;
|
2019-04-26 16:11:24 +03:00
|
|
|
|
|
|
|
virtual bool IsCommandEnabled(const char* aCommandName,
|
|
|
|
TextEditor* aTextEditor) const = 0;
|
2019-04-26 17:00:47 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
virtual nsresult DoCommand(const char* aCommandName,
|
|
|
|
TextEditor& aTextEditor) const = 0;
|
2019-04-26 16:11:24 +03:00
|
|
|
|
2016-06-24 05:45:22 +03:00
|
|
|
protected:
|
2019-04-26 06:20:02 +03:00
|
|
|
EditorCommand() = default;
|
|
|
|
virtual ~EditorCommand() = default;
|
2016-06-24 05:45:22 +03:00
|
|
|
};
|
|
|
|
|
2019-04-26 17:00:47 +03:00
|
|
|
#define NS_DECL_EDITOR_COMMAND_METHODS(_cmd) \
|
|
|
|
public: \
|
|
|
|
virtual bool IsCommandEnabled(const char* aCommandName, \
|
|
|
|
TextEditor* aTextEditor) const final; \
|
|
|
|
using EditorCommand::IsCommandEnabled; \
|
|
|
|
MOZ_CAN_RUN_SCRIPT \
|
|
|
|
virtual nsresult DoCommand(const char* aCommandName, \
|
|
|
|
TextEditor& aTextEditor) const final; \
|
|
|
|
using EditorCommand::DoCommand; \
|
|
|
|
MOZ_CAN_RUN_SCRIPT \
|
|
|
|
NS_IMETHOD DoCommandParams(const char* aCommandName, \
|
|
|
|
nsICommandParams* aParams, \
|
|
|
|
nsISupports* aCommandRefCon) final; \
|
|
|
|
NS_IMETHOD GetCommandStateParams(const char* aCommandName, \
|
|
|
|
nsICommandParams* aParams, \
|
2019-04-26 14:06:45 +03:00
|
|
|
nsISupports* aCommandRefCon) final;
|
2019-04-26 06:20:02 +03:00
|
|
|
|
|
|
|
#define NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON(_cmd) \
|
|
|
|
public: \
|
|
|
|
static _cmd* GetInstance() { \
|
|
|
|
if (!sInstance) { \
|
|
|
|
sInstance = new _cmd(); \
|
|
|
|
} \
|
|
|
|
return sInstance; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static void Shutdown() { sInstance = nullptr; } \
|
|
|
|
\
|
|
|
|
private: \
|
|
|
|
static StaticRefPtr<_cmd> sInstance;
|
|
|
|
|
|
|
|
#define NS_DECL_EDITOR_COMMAND(_cmd) \
|
|
|
|
class _cmd final : public EditorCommand { \
|
|
|
|
NS_DECL_EDITOR_COMMAND_METHODS(_cmd) \
|
|
|
|
NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON(_cmd) \
|
|
|
|
\
|
|
|
|
protected: \
|
|
|
|
_cmd() = default; \
|
|
|
|
virtual ~_cmd() = default; \
|
2016-06-24 05:45:22 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// basic editor commands
|
|
|
|
NS_DECL_EDITOR_COMMAND(UndoCommand)
|
|
|
|
NS_DECL_EDITOR_COMMAND(RedoCommand)
|
|
|
|
|
|
|
|
NS_DECL_EDITOR_COMMAND(CutCommand)
|
|
|
|
NS_DECL_EDITOR_COMMAND(CutOrDeleteCommand)
|
|
|
|
NS_DECL_EDITOR_COMMAND(CopyCommand)
|
|
|
|
NS_DECL_EDITOR_COMMAND(CopyOrDeleteCommand)
|
|
|
|
NS_DECL_EDITOR_COMMAND(PasteCommand)
|
|
|
|
NS_DECL_EDITOR_COMMAND(PasteTransferableCommand)
|
|
|
|
NS_DECL_EDITOR_COMMAND(SwitchTextDirectionCommand)
|
|
|
|
NS_DECL_EDITOR_COMMAND(DeleteCommand)
|
|
|
|
NS_DECL_EDITOR_COMMAND(SelectAllCommand)
|
|
|
|
|
|
|
|
NS_DECL_EDITOR_COMMAND(SelectionMoveCommands)
|
|
|
|
|
|
|
|
// Insert content commands
|
|
|
|
NS_DECL_EDITOR_COMMAND(InsertPlaintextCommand)
|
2016-08-21 16:33:07 +03:00
|
|
|
NS_DECL_EDITOR_COMMAND(InsertParagraphCommand)
|
|
|
|
NS_DECL_EDITOR_COMMAND(InsertLineBreakCommand)
|
2016-06-24 05:45:22 +03:00
|
|
|
NS_DECL_EDITOR_COMMAND(PasteQuotationCommand)
|
|
|
|
|
2019-04-26 05:20:22 +03:00
|
|
|
/******************************************************************************
|
|
|
|
* Commands for HTML editor
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
// virtual base class for commands that need to save and update Boolean state
|
|
|
|
// (like styles etc)
|
2019-04-26 06:20:02 +03:00
|
|
|
class StateUpdatingCommandBase : public EditorCommand {
|
2019-04-26 05:20:22 +03:00
|
|
|
public:
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_INLINE_DECL_REFCOUNTING_INHERITED(StateUpdatingCommandBase, EditorCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_DECL_EDITOR_COMMAND_METHODS(StateUpdatingCommandBase)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
StateUpdatingCommandBase() = default;
|
|
|
|
virtual ~StateUpdatingCommandBase() { sTagNameTable.Clear(); }
|
|
|
|
|
|
|
|
// get the current state (on or off) for this style or block format
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
|
|
|
virtual nsresult
|
|
|
|
GetCurrentState(nsAtom* aTagName, HTMLEditor* aHTMLEditor,
|
2019-04-26 17:00:47 +03:00
|
|
|
nsICommandParams* aParams) const = 0;
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
// add/remove the style
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2019-04-26 17:00:47 +03:00
|
|
|
virtual nsresult ToggleState(nsAtom* aTagName,
|
|
|
|
HTMLEditor* aHTMLEditor) const = 0;
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
static already_AddRefed<nsAtom> TagName(const char* aCommandName) {
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(aCommandName);
|
|
|
|
if (NS_WARN_IF(!aCommandName)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
if (!sTagNameTable.Count()) {
|
|
|
|
sTagNameTable.Put("cmd_bold", nsGkAtoms::b);
|
|
|
|
sTagNameTable.Put("cmd_italic", nsGkAtoms::i);
|
|
|
|
sTagNameTable.Put("cmd_underline", nsGkAtoms::u);
|
|
|
|
sTagNameTable.Put("cmd_tt", nsGkAtoms::tt);
|
|
|
|
sTagNameTable.Put("cmd_strikethrough", nsGkAtoms::strike);
|
|
|
|
sTagNameTable.Put("cmd_superscript", nsGkAtoms::sup);
|
|
|
|
sTagNameTable.Put("cmd_subscript", nsGkAtoms::sub);
|
|
|
|
sTagNameTable.Put("cmd_nobreak", nsGkAtoms::nobr);
|
|
|
|
sTagNameTable.Put("cmd_em", nsGkAtoms::em);
|
|
|
|
sTagNameTable.Put("cmd_strong", nsGkAtoms::strong);
|
|
|
|
sTagNameTable.Put("cmd_cite", nsGkAtoms::cite);
|
|
|
|
sTagNameTable.Put("cmd_abbr", nsGkAtoms::abbr);
|
|
|
|
sTagNameTable.Put("cmd_acronym", nsGkAtoms::acronym);
|
|
|
|
sTagNameTable.Put("cmd_code", nsGkAtoms::code);
|
|
|
|
sTagNameTable.Put("cmd_samp", nsGkAtoms::samp);
|
|
|
|
sTagNameTable.Put("cmd_var", nsGkAtoms::var);
|
|
|
|
sTagNameTable.Put("cmd_removeLinks", nsGkAtoms::href);
|
|
|
|
sTagNameTable.Put("cmd_ol", nsGkAtoms::ol);
|
|
|
|
sTagNameTable.Put("cmd_ul", nsGkAtoms::ul);
|
|
|
|
sTagNameTable.Put("cmd_dt", nsGkAtoms::dt);
|
|
|
|
sTagNameTable.Put("cmd_dd", nsGkAtoms::dd);
|
|
|
|
sTagNameTable.Put("cmd_absPos", nsGkAtoms::_empty);
|
|
|
|
}
|
|
|
|
RefPtr<nsAtom> tagName = sTagNameTable.Get(aCommandName);
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(tagName);
|
|
|
|
return tagName.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsRefPtrHashtable<nsCharPtrHashKey, nsAtom> sTagNameTable;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Shared class for the various style updating commands like bold, italics etc.
|
|
|
|
// Suitable for commands whose state is either 'on' or 'off'.
|
|
|
|
class StyleUpdatingCommand final : public StateUpdatingCommandBase {
|
|
|
|
public:
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON(StyleUpdatingCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
StyleUpdatingCommand() = default;
|
|
|
|
virtual ~StyleUpdatingCommand() = default;
|
|
|
|
|
|
|
|
// get the current state (on or off) for this style or block format
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
|
|
|
nsresult
|
|
|
|
GetCurrentState(nsAtom* aTagName, HTMLEditor* aHTMLEditor,
|
2019-04-26 17:00:47 +03:00
|
|
|
nsICommandParams* aParams) const final;
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
// add/remove the style
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2019-04-26 17:00:47 +03:00
|
|
|
nsresult ToggleState(nsAtom* aTagName, HTMLEditor* aHTMLEditor) const final;
|
2019-04-26 05:20:22 +03:00
|
|
|
};
|
|
|
|
|
2019-04-26 06:20:02 +03:00
|
|
|
class InsertTagCommand final : public EditorCommand {
|
2019-04-26 05:20:22 +03:00
|
|
|
public:
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_INLINE_DECL_REFCOUNTING_INHERITED(InsertTagCommand, EditorCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_DECL_EDITOR_COMMAND_METHODS(InsertTagCommand)
|
|
|
|
NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON(InsertTagCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
InsertTagCommand() = default;
|
|
|
|
virtual ~InsertTagCommand() { sTagNameTable.Clear(); }
|
|
|
|
|
|
|
|
static already_AddRefed<nsAtom> TagName(const char* aCommandName) {
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(aCommandName);
|
|
|
|
if (NS_WARN_IF(!aCommandName)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
if (!sTagNameTable.Count()) {
|
|
|
|
sTagNameTable.Put("cmd_insertLinkNoUI", nsGkAtoms::a);
|
|
|
|
sTagNameTable.Put("cmd_insertImageNoUI", nsGkAtoms::img);
|
|
|
|
sTagNameTable.Put("cmd_insertHR", nsGkAtoms::hr);
|
|
|
|
}
|
|
|
|
RefPtr<nsAtom> tagName = sTagNameTable.Get(aCommandName);
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(tagName);
|
|
|
|
return tagName.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsRefPtrHashtable<nsCharPtrHashKey, nsAtom> sTagNameTable;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ListCommand final : public StateUpdatingCommandBase {
|
|
|
|
public:
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON(ListCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
ListCommand() = default;
|
|
|
|
virtual ~ListCommand() = default;
|
|
|
|
|
|
|
|
// get the current state (on or off) for this style or block format
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
|
|
|
nsresult
|
|
|
|
GetCurrentState(nsAtom* aTagName, HTMLEditor* aHTMLEditor,
|
2019-04-26 17:00:47 +03:00
|
|
|
nsICommandParams* aParams) const final;
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
// add/remove the style
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2019-04-26 17:00:47 +03:00
|
|
|
nsresult ToggleState(nsAtom* aTagName, HTMLEditor* aHTMLEditor) const final;
|
2019-04-26 05:20:22 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class ListItemCommand final : public StateUpdatingCommandBase {
|
|
|
|
public:
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON(ListItemCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
ListItemCommand() = default;
|
|
|
|
virtual ~ListItemCommand() = default;
|
|
|
|
|
|
|
|
// get the current state (on or off) for this style or block format
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
|
|
|
nsresult
|
|
|
|
GetCurrentState(nsAtom* aTagName, HTMLEditor* aHTMLEditor,
|
2019-04-26 17:00:47 +03:00
|
|
|
nsICommandParams* aParams) const final;
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
// add/remove the style
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2019-04-26 17:00:47 +03:00
|
|
|
nsresult ToggleState(nsAtom* aTagName, HTMLEditor* aHTMLEditor) const final;
|
2019-04-26 05:20:22 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// Base class for commands whose state consists of a string (e.g. para format)
|
2019-04-26 06:20:02 +03:00
|
|
|
class MultiStateCommandBase : public EditorCommand {
|
2019-04-26 05:20:22 +03:00
|
|
|
public:
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_INLINE_DECL_REFCOUNTING_INHERITED(MultiStateCommandBase, EditorCommand)
|
|
|
|
NS_DECL_EDITOR_COMMAND_METHODS(MultiStateCommandBase)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
MultiStateCommandBase() = default;
|
|
|
|
virtual ~MultiStateCommandBase() = default;
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
|
|
|
virtual nsresult
|
2019-04-26 17:00:47 +03:00
|
|
|
GetCurrentState(HTMLEditor* aHTMLEditor,
|
|
|
|
nsICommandParams* aParams) const = 0;
|
2019-04-26 05:20:22 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
virtual nsresult SetState(HTMLEditor* aHTMLEditor,
|
|
|
|
const nsString& newState) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ParagraphStateCommand final : public MultiStateCommandBase {
|
|
|
|
public:
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON(ParagraphStateCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
ParagraphStateCommand() = default;
|
|
|
|
virtual ~ParagraphStateCommand() = default;
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
|
|
|
nsresult
|
2019-04-26 17:00:47 +03:00
|
|
|
GetCurrentState(HTMLEditor* aHTMLEditor,
|
|
|
|
nsICommandParams* aParams) const final;
|
2019-04-26 05:20:22 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FontFaceStateCommand final : public MultiStateCommandBase {
|
|
|
|
public:
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON(FontFaceStateCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
FontFaceStateCommand() = default;
|
|
|
|
virtual ~FontFaceStateCommand() = default;
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
|
|
|
nsresult
|
2019-04-26 17:00:47 +03:00
|
|
|
GetCurrentState(HTMLEditor* aHTMLEditor,
|
|
|
|
nsICommandParams* aParams) const final;
|
2019-04-26 05:20:22 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FontSizeStateCommand final : public MultiStateCommandBase {
|
|
|
|
public:
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON(FontSizeStateCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
FontSizeStateCommand() = default;
|
|
|
|
virtual ~FontSizeStateCommand() = default;
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
|
|
|
nsresult
|
2019-04-26 17:00:47 +03:00
|
|
|
GetCurrentState(HTMLEditor* aHTMLEditor,
|
|
|
|
nsICommandParams* aParams) const final;
|
2019-04-26 05:20:22 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
|
|
|
|
};
|
|
|
|
|
|
|
|
class HighlightColorStateCommand final : public MultiStateCommandBase {
|
|
|
|
public:
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON(HighlightColorStateCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
HighlightColorStateCommand() = default;
|
|
|
|
virtual ~HighlightColorStateCommand() = default;
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
|
|
|
nsresult
|
2019-04-26 17:00:47 +03:00
|
|
|
GetCurrentState(HTMLEditor* aHTMLEditor,
|
|
|
|
nsICommandParams* aParams) const final;
|
2019-04-26 05:20:22 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FontColorStateCommand final : public MultiStateCommandBase {
|
|
|
|
public:
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON(FontColorStateCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
FontColorStateCommand() = default;
|
|
|
|
virtual ~FontColorStateCommand() = default;
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
|
|
|
nsresult
|
2019-04-26 17:00:47 +03:00
|
|
|
GetCurrentState(HTMLEditor* aHTMLEditor,
|
|
|
|
nsICommandParams* aParams) const final;
|
2019-04-26 05:20:22 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
|
|
|
|
};
|
|
|
|
|
|
|
|
class AlignCommand final : public MultiStateCommandBase {
|
|
|
|
public:
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON(AlignCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
AlignCommand() = default;
|
|
|
|
virtual ~AlignCommand() = default;
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
|
|
|
nsresult
|
2019-04-26 17:00:47 +03:00
|
|
|
GetCurrentState(HTMLEditor* aHTMLEditor,
|
|
|
|
nsICommandParams* aParams) const final;
|
2019-04-26 05:20:22 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
|
|
|
|
};
|
|
|
|
|
|
|
|
class BackgroundColorStateCommand final : public MultiStateCommandBase {
|
|
|
|
public:
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON(BackgroundColorStateCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
BackgroundColorStateCommand() = default;
|
|
|
|
virtual ~BackgroundColorStateCommand() = default;
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
|
|
|
nsresult
|
2019-04-26 17:00:47 +03:00
|
|
|
GetCurrentState(HTMLEditor* aHTMLEditor,
|
|
|
|
nsICommandParams* aParams) const final;
|
2019-04-26 05:20:22 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult SetState(HTMLEditor* aHTMLEditor, const nsString& newState) final;
|
|
|
|
};
|
|
|
|
|
|
|
|
class AbsolutePositioningCommand final : public StateUpdatingCommandBase {
|
|
|
|
public:
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON(AbsolutePositioningCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
AbsolutePositioningCommand() = default;
|
|
|
|
virtual ~AbsolutePositioningCommand() = default;
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY // XXX Needs to change nsIControllerCommand.idl
|
|
|
|
nsresult
|
|
|
|
GetCurrentState(nsAtom* aTagName, HTMLEditor* aHTMLEditor,
|
2019-04-26 17:00:47 +03:00
|
|
|
nsICommandParams* aParams) const final;
|
2019-04-26 05:20:22 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2019-04-26 17:00:47 +03:00
|
|
|
nsresult ToggleState(nsAtom* aTagName, HTMLEditor* aHTMLEditor) const final;
|
2019-04-26 05:20:22 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// composer commands
|
|
|
|
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_DECL_EDITOR_COMMAND(DocumentStateCommand)
|
|
|
|
NS_DECL_EDITOR_COMMAND(SetDocumentStateCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_DECL_EDITOR_COMMAND(DecreaseZIndexCommand)
|
|
|
|
NS_DECL_EDITOR_COMMAND(IncreaseZIndexCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
// Generic commands
|
|
|
|
|
|
|
|
// Edit menu
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_DECL_EDITOR_COMMAND(PasteNoFormattingCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
// Block transformations
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_DECL_EDITOR_COMMAND(IndentCommand)
|
|
|
|
NS_DECL_EDITOR_COMMAND(OutdentCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_DECL_EDITOR_COMMAND(RemoveListCommand)
|
|
|
|
NS_DECL_EDITOR_COMMAND(RemoveStylesCommand)
|
|
|
|
NS_DECL_EDITOR_COMMAND(IncreaseFontSizeCommand)
|
|
|
|
NS_DECL_EDITOR_COMMAND(DecreaseFontSizeCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
// Insert content commands
|
2019-04-26 06:20:02 +03:00
|
|
|
NS_DECL_EDITOR_COMMAND(InsertHTMLCommand)
|
2019-04-26 05:20:22 +03:00
|
|
|
|
|
|
|
#undef NS_DECL_EDITOR_COMMAND
|
2019-04-26 06:20:02 +03:00
|
|
|
#undef NS_DECL_EDITOR_COMMAND_METHODS
|
|
|
|
#undef NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON
|
2016-06-24 05:45:22 +03:00
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2019-04-26 05:20:22 +03:00
|
|
|
#endif // #ifndef mozilla_EditorCommands_h
|