Bug 1772588 [wpt PR 34302] - [wpt] Add test for block-in-inline offsetParent., a...
[gecko.git] / editor / libeditor / HTMLEditorController.cpp
blobaeef68249fc8815343dd3af29a81efa8be9b6ec5
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "mozilla/HTMLEditorController.h"
8 #include "mozilla/EditorCommands.h" // for StyleUpdatingCommand, etc
9 #include "mozilla/mozalloc.h" // for operator new
10 #include "nsControllerCommandTable.h" // for nsControllerCommandTable
11 #include "nsError.h" // for NS_OK
13 namespace mozilla {
15 #define NS_REGISTER_COMMAND(_cmdClass, _cmdName) \
16 { \
17 aCommandTable->RegisterCommand( \
18 _cmdName, \
19 static_cast<nsIControllerCommand*>(_cmdClass::GetInstance())); \
22 // static
23 nsresult HTMLEditorController::RegisterEditorDocStateCommands(
24 nsControllerCommandTable* aCommandTable) {
25 // observer commands for document state
26 NS_REGISTER_COMMAND(DocumentStateCommand, "obs_documentCreated")
27 NS_REGISTER_COMMAND(DocumentStateCommand, "obs_documentWillBeDestroyed")
28 NS_REGISTER_COMMAND(DocumentStateCommand, "obs_documentLocationChanged")
30 // commands that may get or change state
31 NS_REGISTER_COMMAND(SetDocumentStateCommand, "cmd_setDocumentModified")
32 NS_REGISTER_COMMAND(SetDocumentStateCommand, "cmd_setDocumentUseCSS")
33 NS_REGISTER_COMMAND(SetDocumentStateCommand, "cmd_setDocumentReadOnly")
34 NS_REGISTER_COMMAND(SetDocumentStateCommand, "cmd_insertBrOnReturn")
35 NS_REGISTER_COMMAND(SetDocumentStateCommand, "cmd_defaultParagraphSeparator")
36 NS_REGISTER_COMMAND(SetDocumentStateCommand, "cmd_enableObjectResizing")
37 NS_REGISTER_COMMAND(SetDocumentStateCommand, "cmd_enableInlineTableEditing")
38 NS_REGISTER_COMMAND(SetDocumentStateCommand,
39 "cmd_enableAbsolutePositionEditing")
41 return NS_OK;
44 // static
45 nsresult HTMLEditorController::RegisterHTMLEditorCommands(
46 nsControllerCommandTable* aCommandTable) {
47 // Edit menu
48 NS_REGISTER_COMMAND(PasteNoFormattingCommand, "cmd_pasteNoFormatting");
50 // indent/outdent
51 NS_REGISTER_COMMAND(IndentCommand, "cmd_indent");
52 NS_REGISTER_COMMAND(OutdentCommand, "cmd_outdent");
54 // Styles
55 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_bold");
56 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_italic");
57 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_underline");
58 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_tt");
60 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_strikethrough");
61 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_superscript");
62 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_subscript");
63 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_nobreak");
65 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_em");
66 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_strong");
67 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_cite");
68 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_abbr");
69 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_acronym");
70 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_code");
71 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_samp");
72 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_var");
73 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_removeLinks");
75 // lists
76 NS_REGISTER_COMMAND(ListCommand, "cmd_ol");
77 NS_REGISTER_COMMAND(ListCommand, "cmd_ul");
78 NS_REGISTER_COMMAND(ListItemCommand, "cmd_dt");
79 NS_REGISTER_COMMAND(ListItemCommand, "cmd_dd");
80 NS_REGISTER_COMMAND(RemoveListCommand, "cmd_removeList");
82 // format stuff
83 NS_REGISTER_COMMAND(ParagraphStateCommand, "cmd_paragraphState");
84 NS_REGISTER_COMMAND(FontFaceStateCommand, "cmd_fontFace");
85 NS_REGISTER_COMMAND(FontSizeStateCommand, "cmd_fontSize");
86 NS_REGISTER_COMMAND(FontColorStateCommand, "cmd_fontColor");
87 NS_REGISTER_COMMAND(BackgroundColorStateCommand, "cmd_backgroundColor");
88 NS_REGISTER_COMMAND(HighlightColorStateCommand, "cmd_highlight");
90 NS_REGISTER_COMMAND(AlignCommand, "cmd_align");
91 NS_REGISTER_COMMAND(RemoveStylesCommand, "cmd_removeStyles");
93 NS_REGISTER_COMMAND(IncreaseFontSizeCommand, "cmd_increaseFont");
94 NS_REGISTER_COMMAND(DecreaseFontSizeCommand, "cmd_decreaseFont");
96 // Insert content
97 NS_REGISTER_COMMAND(InsertHTMLCommand, "cmd_insertHTML");
98 NS_REGISTER_COMMAND(InsertTagCommand, "cmd_insertLinkNoUI");
99 NS_REGISTER_COMMAND(InsertTagCommand, "cmd_insertImageNoUI");
100 NS_REGISTER_COMMAND(InsertTagCommand, "cmd_insertHR");
102 NS_REGISTER_COMMAND(AbsolutePositioningCommand, "cmd_absPos");
103 NS_REGISTER_COMMAND(DecreaseZIndexCommand, "cmd_decreaseZIndex");
104 NS_REGISTER_COMMAND(IncreaseZIndexCommand, "cmd_increaseZIndex");
106 return NS_OK;
109 // static
110 void HTMLEditorController::Shutdown() {
111 // EditorDocStateCommands
112 DocumentStateCommand::Shutdown();
113 SetDocumentStateCommand::Shutdown();
115 // HTMLEditorCommands
116 PasteNoFormattingCommand::Shutdown();
117 IndentCommand::Shutdown();
118 OutdentCommand::Shutdown();
119 StyleUpdatingCommand::Shutdown();
120 ListCommand::Shutdown();
121 ListItemCommand::Shutdown();
122 RemoveListCommand::Shutdown();
123 ParagraphStateCommand::Shutdown();
124 FontFaceStateCommand::Shutdown();
125 FontSizeStateCommand::Shutdown();
126 FontColorStateCommand::Shutdown();
127 BackgroundColorStateCommand::Shutdown();
128 HighlightColorStateCommand::Shutdown();
129 AlignCommand::Shutdown();
130 RemoveStylesCommand::Shutdown();
131 IncreaseFontSizeCommand::Shutdown();
132 DecreaseFontSizeCommand::Shutdown();
133 InsertHTMLCommand::Shutdown();
134 InsertTagCommand::Shutdown();
135 AbsolutePositioningCommand::Shutdown();
136 DecreaseZIndexCommand::Shutdown();
137 IncreaseZIndexCommand::Shutdown();
140 } // namespace mozilla