diff --git a/widget/CommandList.h b/widget/CommandList.h index ef811082fd42..88244b0c383e 100644 --- a/widget/CommandList.h +++ b/widget/CommandList.h @@ -8,10 +8,22 @@ * @param aName The name useful in C++ of the command. * @param aCommandStr The command string in JS. * + * Define NS_DEFINE_COMMAND_WITH_PARAM(aName, aCommandStr, aParam) before + * including this. + * @param aName The name useful in C++ of the command. + * @param aCommandStr The command string in JS, but this may be shared with + * other aName values. I.e., cannot map aName and + * aCommandStr 1:1. + * @param aParam Additional param value. When aCommandStr is executed, + * this value is also specified. I.e., aName becomes + * unique when you look for with both aCommandStr and + * aParam. + * * Define NS_DEFINE_COMMAND_NO_EXEC_COMMAND(aName) before including this. * @param aName The name useful in C++ of the command. */ +// Mapped from commands of some platforms NS_DEFINE_COMMAND(BeginLine, cmd_beginLine) NS_DEFINE_COMMAND(CharNext, cmd_charNext) NS_DEFINE_COMMAND(CharPrevious, cmd_charPrevious) @@ -56,7 +68,88 @@ NS_DEFINE_COMMAND(SelectWordPrevious, cmd_selectWordPrevious) NS_DEFINE_COMMAND(WordNext, cmd_wordNext) NS_DEFINE_COMMAND(WordPrevious, cmd_wordPrevious) +// We don't have corresponding commands for them, but some platforms have them. NS_DEFINE_COMMAND_NO_EXEC_COMMAND(CancelOperation) NS_DEFINE_COMMAND_NO_EXEC_COMMAND(Complete) NS_DEFINE_COMMAND_NO_EXEC_COMMAND(InsertBacktab) NS_DEFINE_COMMAND_NO_EXEC_COMMAND(InsertTab) + +// Commands mapped from HTMLDocument.execCommand() +NS_DEFINE_COMMAND(FormatBold, cmd_bold) +NS_DEFINE_COMMAND(FormatItalic, cmd_italic) +NS_DEFINE_COMMAND(FormatUnderline, cmd_underline) +NS_DEFINE_COMMAND(FormatStrikeThrough, cmd_strikethrough) +NS_DEFINE_COMMAND(FormatSubscript, cmd_subscript) +NS_DEFINE_COMMAND(FormatSuperscript, cmd_superscript) +NS_DEFINE_COMMAND(HistoryUndo, cmd_undo) +NS_DEFINE_COMMAND(HistoryRedo, cmd_redo) +NS_DEFINE_COMMAND(FormatBlock, cmd_paragraphState) +NS_DEFINE_COMMAND(FormatIndent, cmd_indent) +NS_DEFINE_COMMAND(FormatOutdent, cmd_outdent) +NS_DEFINE_COMMAND_WITH_PARAM(FormatJustifyLeft, cmd_align, left) +NS_DEFINE_COMMAND_WITH_PARAM(FormatJustifyRight, cmd_align, right) +NS_DEFINE_COMMAND_WITH_PARAM(FormatJustifyCenter, cmd_align, center) +NS_DEFINE_COMMAND_WITH_PARAM(FormatJustifyFull, cmd_align, justify) +NS_DEFINE_COMMAND(FormatBackColor, cmd_highlight) +NS_DEFINE_COMMAND(FormatFontColor, cmd_fontColor) +NS_DEFINE_COMMAND(FormatFontName, cmd_fontFace) +NS_DEFINE_COMMAND(FormatFontSize, cmd_fontSize) +NS_DEFINE_COMMAND(FormatIncreaseFontSize, cmd_increaseFont) +NS_DEFINE_COMMAND(FormatDecreaseFontSize, cmd_decreaseFont) +NS_DEFINE_COMMAND(InsertHorizontalRule, cmd_insertHR) +NS_DEFINE_COMMAND(InsertLink, cmd_insertLinkNoUI) +NS_DEFINE_COMMAND(InsertImage, cmd_insertImageNoUI) +NS_DEFINE_COMMAND(InsertHTML, cmd_insertHTML) +NS_DEFINE_COMMAND(InsertText, cmd_insertText) +NS_DEFINE_COMMAND(InsertOrderedList, cmd_ol) +NS_DEFINE_COMMAND(InsertUnorderedList, cmd_ul) +NS_DEFINE_COMMAND(GetHTML, cmd_getContents) +NS_DEFINE_COMMAND(FormatRemove, cmd_removeStyles) +NS_DEFINE_COMMAND(FormatRemoveLink, cmd_removeLinks) +NS_DEFINE_COMMAND(SetDocumentUseCSS, cmd_setDocumentUseCSS) +NS_DEFINE_COMMAND(SetDocumentReadOnly, cmd_setDocumentReadOnly) +NS_DEFINE_COMMAND(SetDocumentInsertBROnEnterKeyPress, cmd_insertBrOnReturn) +NS_DEFINE_COMMAND(SetDocumentDefaultParagraphSeparator, + cmd_defaultParagraphSeparator) +NS_DEFINE_COMMAND(ToggleObjectResizers, cmd_enableObjectResizing) +NS_DEFINE_COMMAND(ToggleInlineTableEditor, cmd_enableInlineTableEditing) +NS_DEFINE_COMMAND(ToggleAbsolutePositionEditor, + cmd_enableAbsolutePositionEditing) + +// Commands not mapped from HTMLDocument.execCommand() but available with +// command dispatcher and handled in editor. +NS_DEFINE_COMMAND(EditorObserverDocumentCreated, obs_documentCreated) +NS_DEFINE_COMMAND(EditorObserverDocumentLocationChanged, + obs_documentLocationChanged) +NS_DEFINE_COMMAND(EditorObserverDocumentWillBeDestroyed, + obs_documentWillBeDestroyed) +NS_DEFINE_COMMAND(FormatAbbreviation, cmd_abbr) +NS_DEFINE_COMMAND(FormatAbsolutePosition, cmd_absPos) +NS_DEFINE_COMMAND(FormatAcronym, cmd_acronym) +NS_DEFINE_COMMAND(FormatCitation, cmd_cite) +NS_DEFINE_COMMAND(FormatCode, cmd_code) +NS_DEFINE_COMMAND(FormatEmphasis, cmd_em) +NS_DEFINE_COMMAND(FormatNoBreak, cmd_nobreak) +NS_DEFINE_COMMAND(FormatSample, cmd_samp) +NS_DEFINE_COMMAND(FormatStrong, cmd_strong) +NS_DEFINE_COMMAND(FormatTeletypeText, cmd_tt) +NS_DEFINE_COMMAND(FormatVariable, cmd_var) +NS_DEFINE_COMMAND(InsertDefinitionDetails, cmd_dd) +NS_DEFINE_COMMAND(InsertDefinitionTerm, cmd_dt) +NS_DEFINE_COMMAND(MoveDown, cmd_moveDown) +NS_DEFINE_COMMAND(MoveDown2, cmd_moveDown2) +NS_DEFINE_COMMAND(MoveLeft, cmd_moveLeft) +NS_DEFINE_COMMAND(MoveLeft2, cmd_moveLeft2) +NS_DEFINE_COMMAND(MoveRight, cmd_moveRight) +NS_DEFINE_COMMAND(MoveRight2, cmd_moveRight2) +NS_DEFINE_COMMAND(MoveUp, cmd_moveUp) +NS_DEFINE_COMMAND(MoveUp2, cmd_moveUp2) +NS_DEFINE_COMMAND(SelectDown, cmd_selectDown) +NS_DEFINE_COMMAND(SelectDown2, cmd_selectDown2) +NS_DEFINE_COMMAND(SelectLeft, cmd_selectLeft) +NS_DEFINE_COMMAND(SelectLeft2, cmd_selectLeft2) +NS_DEFINE_COMMAND(SelectRight, cmd_selectRight) +NS_DEFINE_COMMAND(SelectRight2, cmd_selectRight2) +NS_DEFINE_COMMAND(SelectUp, cmd_selectUp) +NS_DEFINE_COMMAND(SelectUp2, cmd_selectUp2) +NS_DEFINE_COMMAND(SetDocumentModified, cmd_setDocumentModified) diff --git a/widget/EventForwards.h b/widget/EventForwards.h index 135effa0fef0..bda77f63906c 100644 --- a/widget/EventForwards.h +++ b/widget/EventForwards.h @@ -203,6 +203,7 @@ inline bool IsDataTransferAvailableOnHTMLEditor(EditorInputType aInputType) { } #define NS_DEFINE_COMMAND(aName, aCommandStr) , aName +#define NS_DEFINE_COMMAND_WITH_PARAM(aName, aCommandStr, aParam) , aName #define NS_DEFINE_COMMAND_NO_EXEC_COMMAND(aName) , aName typedef int8_t CommandInt; @@ -212,6 +213,7 @@ enum class Command : CommandInt { #include "mozilla/CommandList.h" }; #undef NS_DEFINE_COMMAND +#undef NS_DEFINE_COMMAND_WITH_PARAM #undef NS_DEFINE_COMMAND_NO_EXEC_COMMAND const char* ToChar(Command aCommand); diff --git a/widget/WidgetEventImpl.cpp b/widget/WidgetEventImpl.cpp index b98320f7c58b..f53b45fbbc25 100644 --- a/widget/WidgetEventImpl.cpp +++ b/widget/WidgetEventImpl.cpp @@ -84,6 +84,9 @@ const char* ToChar(Command aCommand) { #define NS_DEFINE_COMMAND(aName, aCommandStr) \ case Command::aName: \ return "Command::" #aName; +#define NS_DEFINE_COMMAND_WITH_PARAM(aName, aCommandStr, aParam) \ + case Command::aName: \ + return "Command::" #aName; #define NS_DEFINE_COMMAND_NO_EXEC_COMMAND(aName) \ case Command::aName: \ return "Command::" #aName; @@ -91,6 +94,7 @@ const char* ToChar(Command aCommand) { #include "mozilla/CommandList.h" #undef NS_DEFINE_COMMAND +#undef NS_DEFINE_COMMAND_WITH_PARAM #undef NS_DEFINE_COMMAND_NO_EXEC_COMMAND default: @@ -1098,12 +1102,14 @@ uint32_t WidgetKeyboardEvent::GetFallbackKeyCodeOfPunctuationKey( /* static */ const char* WidgetKeyboardEvent::GetCommandStr(Command aCommand) { #define NS_DEFINE_COMMAND(aName, aCommandStr) , #aCommandStr +#define NS_DEFINE_COMMAND_WITH_PARAM(aName, aCommandStr, aParam) , #aCommandStr #define NS_DEFINE_COMMAND_NO_EXEC_COMMAND(aName) static const char* const kCommands[] = { "" // DoNothing #include "mozilla/CommandList.h" }; #undef NS_DEFINE_COMMAND +#undef NS_DEFINE_COMMAND_WITH_PARAM #undef NS_DEFINE_COMMAND_NO_EXEC_COMMAND MOZ_RELEASE_ASSERT(static_cast(aCommand) < ArrayLength(kCommands),