Bug 1931736. Add missing braces around if/loop statements in layout/xul/. r=layout...
[gecko.git] / editor / libeditor / HTMLEditorController.cpp
blobea795b920bb240af1cda8db5a2566b139d390eb6
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")
40 NS_REGISTER_COMMAND(SetDocumentStateCommand,
41 "cmd_enableCompatibleJoinSplitNodeDirection")
43 return NS_OK;
46 // static
47 nsresult HTMLEditorController::RegisterHTMLEditorCommands(
48 nsControllerCommandTable* aCommandTable) {
49 // Edit menu
50 NS_REGISTER_COMMAND(PasteNoFormattingCommand, "cmd_pasteNoFormatting");
52 // indent/outdent
53 NS_REGISTER_COMMAND(IndentCommand, "cmd_indent");
54 NS_REGISTER_COMMAND(OutdentCommand, "cmd_outdent");
56 // Styles
57 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_bold");
58 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_italic");
59 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_underline");
60 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_tt");
62 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_strikethrough");
63 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_superscript");
64 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_subscript");
65 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_nobreak");
67 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_em");
68 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_strong");
69 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_cite");
70 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_abbr");
71 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_acronym");
72 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_code");
73 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_samp");
74 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_var");
75 NS_REGISTER_COMMAND(StyleUpdatingCommand, "cmd_removeLinks");
77 // lists
78 NS_REGISTER_COMMAND(ListCommand, "cmd_ol");
79 NS_REGISTER_COMMAND(ListCommand, "cmd_ul");
80 NS_REGISTER_COMMAND(ListItemCommand, "cmd_dt");
81 NS_REGISTER_COMMAND(ListItemCommand, "cmd_dd");
82 NS_REGISTER_COMMAND(RemoveListCommand, "cmd_removeList");
84 // format stuff
85 NS_REGISTER_COMMAND(FormatBlockStateCommand, "cmd_formatBlock");
86 NS_REGISTER_COMMAND(ParagraphStateCommand, "cmd_paragraphState");
87 NS_REGISTER_COMMAND(FontFaceStateCommand, "cmd_fontFace");
88 NS_REGISTER_COMMAND(FontSizeStateCommand, "cmd_fontSize");
89 NS_REGISTER_COMMAND(FontColorStateCommand, "cmd_fontColor");
90 NS_REGISTER_COMMAND(BackgroundColorStateCommand, "cmd_backgroundColor");
91 NS_REGISTER_COMMAND(HighlightColorStateCommand, "cmd_highlight");
93 NS_REGISTER_COMMAND(AlignCommand, "cmd_align");
94 NS_REGISTER_COMMAND(RemoveStylesCommand, "cmd_removeStyles");
96 NS_REGISTER_COMMAND(IncreaseFontSizeCommand, "cmd_increaseFont");
97 NS_REGISTER_COMMAND(DecreaseFontSizeCommand, "cmd_decreaseFont");
99 // Insert content
100 NS_REGISTER_COMMAND(InsertHTMLCommand, "cmd_insertHTML");
101 NS_REGISTER_COMMAND(InsertTagCommand, "cmd_insertLinkNoUI");
102 NS_REGISTER_COMMAND(InsertTagCommand, "cmd_insertImageNoUI");
103 NS_REGISTER_COMMAND(InsertTagCommand, "cmd_insertHR");
105 NS_REGISTER_COMMAND(AbsolutePositioningCommand, "cmd_absPos");
106 NS_REGISTER_COMMAND(DecreaseZIndexCommand, "cmd_decreaseZIndex");
107 NS_REGISTER_COMMAND(IncreaseZIndexCommand, "cmd_increaseZIndex");
109 return NS_OK;
112 // static
113 void HTMLEditorController::Shutdown() {
114 // EditorDocStateCommands
115 DocumentStateCommand::Shutdown();
116 SetDocumentStateCommand::Shutdown();
118 // HTMLEditorCommands
119 PasteNoFormattingCommand::Shutdown();
120 IndentCommand::Shutdown();
121 OutdentCommand::Shutdown();
122 StyleUpdatingCommand::Shutdown();
123 ListCommand::Shutdown();
124 ListItemCommand::Shutdown();
125 RemoveListCommand::Shutdown();
126 FormatBlockStateCommand::Shutdown();
127 ParagraphStateCommand::Shutdown();
128 FontFaceStateCommand::Shutdown();
129 FontSizeStateCommand::Shutdown();
130 FontColorStateCommand::Shutdown();
131 BackgroundColorStateCommand::Shutdown();
132 HighlightColorStateCommand::Shutdown();
133 AlignCommand::Shutdown();
134 RemoveStylesCommand::Shutdown();
135 IncreaseFontSizeCommand::Shutdown();
136 DecreaseFontSizeCommand::Shutdown();
137 InsertHTMLCommand::Shutdown();
138 InsertTagCommand::Shutdown();
139 AbsolutePositioningCommand::Shutdown();
140 DecreaseZIndexCommand::Shutdown();
141 IncreaseZIndexCommand::Shutdown();
144 } // namespace mozilla