mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-30 21:55:31 +00:00
d2149ed47c
--HG-- rename : editor/composer/src/crashtests/351236-1.html => editor/composer/crashtests/351236-1.html rename : editor/composer/src/crashtests/407062-1.html => editor/composer/crashtests/407062-1.html rename : editor/composer/src/crashtests/419563-1.xhtml => editor/composer/crashtests/419563-1.xhtml rename : editor/composer/src/crashtests/428844-1-inner.xhtml => editor/composer/crashtests/428844-1-inner.xhtml rename : editor/composer/src/crashtests/428844-1.html => editor/composer/crashtests/428844-1.html rename : editor/composer/src/crashtests/461049-1.html => editor/composer/crashtests/461049-1.html rename : editor/composer/src/crashtests/crashtests.list => editor/composer/crashtests/crashtests.list rename : editor/composer/src/crashtests/removing-editable-xslt-inner.xhtml => editor/composer/crashtests/removing-editable-xslt-inner.xhtml rename : editor/composer/src/crashtests/removing-editable-xslt.html => editor/composer/crashtests/removing-editable-xslt.html rename : editor/composer/src/nsComposeTxtSrvFilter.cpp => editor/composer/nsComposeTxtSrvFilter.cpp rename : editor/composer/src/nsComposeTxtSrvFilter.h => editor/composer/nsComposeTxtSrvFilter.h rename : editor/composer/src/nsComposerCommands.cpp => editor/composer/nsComposerCommands.cpp rename : editor/composer/src/nsComposerCommands.h => editor/composer/nsComposerCommands.h rename : editor/composer/src/nsComposerCommandsUpdater.cpp => editor/composer/nsComposerCommandsUpdater.cpp rename : editor/composer/src/nsComposerCommandsUpdater.h => editor/composer/nsComposerCommandsUpdater.h rename : editor/composer/src/nsComposerController.cpp => editor/composer/nsComposerController.cpp rename : editor/composer/src/nsComposerController.h => editor/composer/nsComposerController.h rename : editor/composer/src/nsComposerDocumentCommands.cpp => editor/composer/nsComposerDocumentCommands.cpp rename : editor/composer/src/nsComposerRegistration.cpp => editor/composer/nsComposerRegistration.cpp rename : editor/composer/src/nsEditingSession.cpp => editor/composer/nsEditingSession.cpp rename : editor/composer/src/nsEditingSession.h => editor/composer/nsEditingSession.h rename : editor/composer/src/nsEditorSpellCheck.cpp => editor/composer/nsEditorSpellCheck.cpp rename : editor/composer/src/nsEditorSpellCheck.h => editor/composer/nsEditorSpellCheck.h rename : editor/composer/public/nsIEditingSession.idl => editor/composer/nsIEditingSession.idl rename : editor/composer/src/res/EditorOverride.css => editor/composer/res/EditorOverride.css rename : editor/composer/src/res/grabber.gif => editor/composer/res/grabber.gif rename : editor/composer/src/res/table-add-column-after-active.gif => editor/composer/res/table-add-column-after-active.gif rename : editor/composer/src/res/table-add-column-after-hover.gif => editor/composer/res/table-add-column-after-hover.gif rename : editor/composer/src/res/table-add-column-after.gif => editor/composer/res/table-add-column-after.gif rename : editor/composer/src/res/table-add-column-before-active.gif => editor/composer/res/table-add-column-before-active.gif rename : editor/composer/src/res/table-add-column-before-hover.gif => editor/composer/res/table-add-column-before-hover.gif rename : editor/composer/src/res/table-add-column-before.gif => editor/composer/res/table-add-column-before.gif rename : editor/composer/src/res/table-add-row-after-active.gif => editor/composer/res/table-add-row-after-active.gif rename : editor/composer/src/res/table-add-row-after-hover.gif => editor/composer/res/table-add-row-after-hover.gif rename : editor/composer/src/res/table-add-row-after.gif => editor/composer/res/table-add-row-after.gif rename : editor/composer/src/res/table-add-row-before-active.gif => editor/composer/res/table-add-row-before-active.gif rename : editor/composer/src/res/table-add-row-before-hover.gif => editor/composer/res/table-add-row-before-hover.gif rename : editor/composer/src/res/table-add-row-before.gif => editor/composer/res/table-add-row-before.gif rename : editor/composer/src/res/table-remove-column-active.gif => editor/composer/res/table-remove-column-active.gif rename : editor/composer/src/res/table-remove-column-hover.gif => editor/composer/res/table-remove-column-hover.gif rename : editor/composer/src/res/table-remove-column.gif => editor/composer/res/table-remove-column.gif rename : editor/composer/src/res/table-remove-row-active.gif => editor/composer/res/table-remove-row-active.gif rename : editor/composer/src/res/table-remove-row-hover.gif => editor/composer/res/table-remove-row-hover.gif rename : editor/composer/src/res/table-remove-row.gif => editor/composer/res/table-remove-row.gif rename : editor/composer/src/res/text_caret.png => editor/composer/res/text_caret.png rename : editor/composer/src/res/text_caret@1.5x.png => editor/composer/res/text_caret@1.5x.png rename : editor/composer/src/res/text_caret@2.25x.png => editor/composer/res/text_caret@2.25x.png rename : editor/composer/src/res/text_caret@2x.png => editor/composer/res/text_caret@2x.png rename : editor/composer/src/res/text_caret_tilt_left.png => editor/composer/res/text_caret_tilt_left.png rename : editor/composer/src/res/text_caret_tilt_left@1.5x.png => editor/composer/res/text_caret_tilt_left@1.5x.png rename : editor/composer/src/res/text_caret_tilt_left@2.25x.png => editor/composer/res/text_caret_tilt_left@2.25x.png rename : editor/composer/src/res/text_caret_tilt_left@2x.png => editor/composer/res/text_caret_tilt_left@2x.png rename : editor/composer/src/res/text_caret_tilt_right.png => editor/composer/res/text_caret_tilt_right.png rename : editor/composer/src/res/text_caret_tilt_right@1.5x.png => editor/composer/res/text_caret_tilt_right@1.5x.png rename : editor/composer/src/res/text_caret_tilt_right@2.25x.png => editor/composer/res/text_caret_tilt_right@2.25x.png rename : editor/composer/src/res/text_caret_tilt_right@2x.png => editor/composer/res/text_caret_tilt_right@2x.png rename : editor/composer/src/res/text_selection_handle.png => editor/composer/res/text_selection_handle.png rename : editor/composer/src/res/text_selection_handle@1.5.png => editor/composer/res/text_selection_handle@1.5.png rename : editor/composer/src/res/text_selection_handle@2.png => editor/composer/res/text_selection_handle@2.png
141 lines
7.0 KiB
C++
141 lines
7.0 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "mozilla/mozalloc.h" // for operator new
|
|
#include "nsComposerCommands.h" // for nsStyleUpdatingCommand, etc
|
|
#include "nsComposerController.h"
|
|
#include "nsError.h" // for NS_OK
|
|
#include "nsGkAtoms.h" // for nsGkAtoms, nsGkAtoms::a, etc
|
|
#include "nsIControllerCommandTable.h" // for nsIControllerCommandTable
|
|
|
|
class nsIControllerCommand;
|
|
|
|
#define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName) \
|
|
{ \
|
|
_cmdClass* theCmd = new _cmdClass(); \
|
|
inCommandTable->RegisterCommand(_cmdName, \
|
|
static_cast<nsIControllerCommand *>(theCmd)); \
|
|
}
|
|
|
|
#define NS_REGISTER_FIRST_COMMAND(_cmdClass, _cmdName) \
|
|
{ \
|
|
_cmdClass* theCmd = new _cmdClass(); \
|
|
inCommandTable->RegisterCommand(_cmdName, \
|
|
static_cast<nsIControllerCommand *>(theCmd));
|
|
|
|
#define NS_REGISTER_NEXT_COMMAND(_cmdClass, _cmdName) \
|
|
inCommandTable->RegisterCommand(_cmdName, \
|
|
static_cast<nsIControllerCommand *>(theCmd));
|
|
|
|
#define NS_REGISTER_LAST_COMMAND(_cmdClass, _cmdName) \
|
|
inCommandTable->RegisterCommand(_cmdName, \
|
|
static_cast<nsIControllerCommand *>(theCmd)); \
|
|
}
|
|
|
|
#define NS_REGISTER_STYLE_COMMAND(_cmdClass, _cmdName, _styleTag) \
|
|
{ \
|
|
_cmdClass* theCmd = new _cmdClass(_styleTag); \
|
|
inCommandTable->RegisterCommand(_cmdName, \
|
|
static_cast<nsIControllerCommand *>(theCmd)); \
|
|
}
|
|
|
|
#define NS_REGISTER_TAG_COMMAND(_cmdClass, _cmdName, _tagName) \
|
|
{ \
|
|
_cmdClass* theCmd = new _cmdClass(_tagName); \
|
|
inCommandTable->RegisterCommand(_cmdName, \
|
|
static_cast<nsIControllerCommand *>(theCmd)); \
|
|
}
|
|
|
|
|
|
// static
|
|
nsresult
|
|
nsComposerController::RegisterEditorDocStateCommands(
|
|
nsIControllerCommandTable *inCommandTable)
|
|
{
|
|
// observer commands for document state
|
|
NS_REGISTER_FIRST_COMMAND(nsDocumentStateCommand, "obs_documentCreated")
|
|
NS_REGISTER_NEXT_COMMAND(nsDocumentStateCommand, "obs_documentWillBeDestroyed")
|
|
NS_REGISTER_LAST_COMMAND(nsDocumentStateCommand, "obs_documentLocationChanged")
|
|
|
|
// commands that may get or change state
|
|
NS_REGISTER_FIRST_COMMAND(nsSetDocumentStateCommand, "cmd_setDocumentModified")
|
|
NS_REGISTER_NEXT_COMMAND(nsSetDocumentStateCommand, "cmd_setDocumentUseCSS")
|
|
NS_REGISTER_NEXT_COMMAND(nsSetDocumentStateCommand, "cmd_setDocumentReadOnly")
|
|
NS_REGISTER_NEXT_COMMAND(nsSetDocumentStateCommand, "cmd_insertBrOnReturn")
|
|
NS_REGISTER_NEXT_COMMAND(nsSetDocumentStateCommand, "cmd_enableObjectResizing")
|
|
NS_REGISTER_LAST_COMMAND(nsSetDocumentStateCommand, "cmd_enableInlineTableEditing")
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsSetDocumentOptionsCommand, "cmd_setDocumentOptions")
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
// static
|
|
nsresult
|
|
nsComposerController::RegisterHTMLEditorCommands(
|
|
nsIControllerCommandTable *inCommandTable)
|
|
{
|
|
// Edit menu
|
|
NS_REGISTER_ONE_COMMAND(nsPasteNoFormattingCommand, "cmd_pasteNoFormatting");
|
|
|
|
// indent/outdent
|
|
NS_REGISTER_ONE_COMMAND(nsIndentCommand, "cmd_indent");
|
|
NS_REGISTER_ONE_COMMAND(nsOutdentCommand, "cmd_outdent");
|
|
|
|
// Styles
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_bold", nsGkAtoms::b);
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_italic", nsGkAtoms::i);
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_underline", nsGkAtoms::u);
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_tt", nsGkAtoms::tt);
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_strikethrough", nsGkAtoms::strike);
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_superscript", nsGkAtoms::sup);
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_subscript", nsGkAtoms::sub);
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_nobreak", nsGkAtoms::nobr);
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_em", nsGkAtoms::em);
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_strong", nsGkAtoms::strong);
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_cite", nsGkAtoms::cite);
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_abbr", nsGkAtoms::abbr);
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_acronym", nsGkAtoms::acronym);
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_code", nsGkAtoms::code);
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_samp", nsGkAtoms::samp);
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_var", nsGkAtoms::var);
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_removeLinks", nsGkAtoms::href);
|
|
|
|
// lists
|
|
NS_REGISTER_STYLE_COMMAND(nsListCommand, "cmd_ol", nsGkAtoms::ol);
|
|
NS_REGISTER_STYLE_COMMAND(nsListCommand, "cmd_ul", nsGkAtoms::ul);
|
|
NS_REGISTER_STYLE_COMMAND(nsListItemCommand, "cmd_dt", nsGkAtoms::dt);
|
|
NS_REGISTER_STYLE_COMMAND(nsListItemCommand, "cmd_dd", nsGkAtoms::dd);
|
|
NS_REGISTER_ONE_COMMAND(nsRemoveListCommand, "cmd_removeList");
|
|
|
|
// format stuff
|
|
NS_REGISTER_ONE_COMMAND(nsParagraphStateCommand, "cmd_paragraphState");
|
|
NS_REGISTER_ONE_COMMAND(nsFontFaceStateCommand, "cmd_fontFace");
|
|
NS_REGISTER_ONE_COMMAND(nsFontSizeStateCommand, "cmd_fontSize");
|
|
NS_REGISTER_ONE_COMMAND(nsFontColorStateCommand, "cmd_fontColor");
|
|
NS_REGISTER_ONE_COMMAND(nsBackgroundColorStateCommand, "cmd_backgroundColor");
|
|
NS_REGISTER_ONE_COMMAND(nsHighlightColorStateCommand, "cmd_highlight");
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsAlignCommand, "cmd_align");
|
|
NS_REGISTER_ONE_COMMAND(nsRemoveStylesCommand, "cmd_removeStyles");
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsIncreaseFontSizeCommand, "cmd_increaseFont");
|
|
NS_REGISTER_ONE_COMMAND(nsDecreaseFontSizeCommand, "cmd_decreaseFont");
|
|
|
|
// Insert content
|
|
NS_REGISTER_ONE_COMMAND(nsInsertHTMLCommand, "cmd_insertHTML");
|
|
NS_REGISTER_TAG_COMMAND(nsInsertTagCommand, "cmd_insertLinkNoUI", nsGkAtoms::a);
|
|
NS_REGISTER_TAG_COMMAND(nsInsertTagCommand, "cmd_insertImageNoUI", nsGkAtoms::img);
|
|
NS_REGISTER_TAG_COMMAND(nsInsertTagCommand, "cmd_insertHR", nsGkAtoms::hr);
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsAbsolutePositioningCommand, "cmd_absPos");
|
|
NS_REGISTER_ONE_COMMAND(nsDecreaseZIndexCommand, "cmd_decreaseZIndex");
|
|
NS_REGISTER_ONE_COMMAND(nsIncreaseZIndexCommand, "cmd_increaseZIndex");
|
|
|
|
return NS_OK;
|
|
}
|