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/. */
5
6 #ifndef mozilla_EditAction_h
7 #define mozilla_EditAction_h
8
9 #include "mozilla/EventForwards.h"
10 #include "mozilla/StaticPrefs_dom.h"
11
12 namespace mozilla {
13
14 /**
15 * EditAction indicates which operation or command causes running the methods
16 * of editors.
17 */
18 enum class EditAction {
19 // eNone indicates no edit action is being handled.
20 eNone,
21
22 // eNotEditing indicates that something is retrieved, doing something at
23 // destroying or focus move etc, i.e., not edit action is being handled but
24 // editor is doing something.
25 eNotEditing,
26
27 // eInitializing indicates that the editor instance is being initialized.
28 eInitializing,
29
30 // eInsertText indicates to insert some characters.
31 eInsertText,
32
33 // eInsertParagraphSeparator indicates to insert a paragraph separator such
34 // as <p>, <div>.
35 eInsertParagraphSeparator,
36
37 // eInsertLineBreak indicates to insert \n into TextEditor or a <br> element
38 // in HTMLEditor.
39 eInsertLineBreak,
40
41 // eDeleteSelection indicates to delete selected content or content around
42 // caret if selection is collapsed.
43 eDeleteSelection,
44
45 // eDeleteBackward indicates to remove previous character element of caret.
46 // This may be set even when Selection is not collapsed.
47 eDeleteBackward,
48
49 // eDeleteForward indicates to remove next character or element of caret.
50 // This may be set even when Selection is not collapsed.
51 eDeleteForward,
52
53 // eDeleteWordBackward indicates to remove previous word. If caret is in
54 // a word, remove characters between word start and caret.
55 // This may be set even when Selection is not collapsed.
56 eDeleteWordBackward,
57
58 // eDeleteWordForward indicates to remove next word. If caret is in a
59 // word, remove characters between caret and word end.
60 // This may be set even when Selection is not collapsed.
61 eDeleteWordForward,
62
63 // eDeleteToBeginningOfSoftLine indicates to remove characters between
64 // caret and previous visual line break.
65 // This may be set even when Selection is not collapsed.
66 eDeleteToBeginningOfSoftLine,
67
68 // eDeleteToEndOfSoftLine indicates to remove characters between caret and
69 // next visual line break.
70 // This may be set even when Selection is not collapsed.
71 eDeleteToEndOfSoftLine,
72
73 // eDeleteByDrag indicates to remove selection by dragging the content
74 // to different place.
75 eDeleteByDrag,
76
77 // eStartComposition indicates that user starts composition.
78 eStartComposition,
79
80 // eUpdateComposition indicates that user updates composition with
81 // new non-empty composition string and IME selections.
82 eUpdateComposition,
83
84 // eCommitComposition indicates that user commits composition.
85 eCommitComposition,
86
87 // eCancelComposition indicates that user cancels composition.
88 eCancelComposition,
89
90 // eDeleteByComposition indicates that user starts composition with
91 // empty string and there was selected content.
92 eDeleteByComposition,
93
94 // eUndo/eRedo indicate to undo/redo a transaction.
95 eUndo,
96 eRedo,
97
98 // eSetTextDirection indicates that setting text direction (LTR or RTL).
99 eSetTextDirection,
100
101 // eCut indicates to delete selected content and copy it to the clipboard.
102 eCut,
103
104 // eCopy indicates to copy selected content to the clipboard.
105 eCopy,
106
107 // ePaste indicates to paste clipboard data.
108 ePaste,
109
110 // ePasteAsQuotation indicates to paste clipboard data as quotation.
111 ePasteAsQuotation,
112
113 // eDrop indicates that user drops dragging item into the editor.
114 eDrop,
115
116 // eIndent indicates that to indent selected line(s).
117 eIndent,
118
119 // eOutdent indicates that to outdent selected line(s).
120 eOutdent,
121
122 // eReplaceText indicates to replace a part of range in editor with
123 // specific text. For example, user select a correct word in suggestions
124 // of spellchecker or a suggestion in list of autocomplete.
125 eReplaceText,
126
127 // eInsertTableRowElement indicates to insert table rows (i.e., <tr>
128 // elements).
129 eInsertTableRowElement,
130
131 // eRemoveTableRowElement indicates to remove table row elements.
132 eRemoveTableRowElement,
133
134 // eInsertTableColumn indicates to insert cell elements to each row.
135 eInsertTableColumn,
136
137 // eRemoveTableColumn indicates to remove cell elements from each row.
138 eRemoveTableColumn,
139
140 // eResizingElement indicates that user starts to resize or keep resizing
141 // with dragging a resizer which is provided by Gecko.
142 eResizingElement,
143
144 // eResizeElement indicates that user resizes an element size with finishing
145 // dragging a resizer which is provided by Gecko.
146 eResizeElement,
147
148 // eMovingElement indicates that user starts to move or keep moving an
149 // element with grabber which is provided by Gecko.
150 eMovingElement,
151
152 // eMoveElement indicates that user finishes moving an element with grabber
153 // which is provided by Gecko.
154 eMoveElement,
155
156 // The following edit actions are not user's operation. They are caused
157 // by if UI does something or web apps does something with JS.
158
159 // eUnknown indicates some special edit actions, e.g., batching of some
160 // nsI*Editor method calls. This shouldn't be set while handling a user
161 // operation.
162 eUnknown,
163
164 // eSetAttribute indicates to set attribute value of an element node.
165 eSetAttribute,
166
167 // eRemoveAttribute indicates to remove attribute from an element node.
168 eRemoveAttribute,
169
170 // eInsertNode indicates to insert a node into the tree.
171 eInsertNode,
172
173 // eDeleteNode indicates to remove a node form the tree.
174 eRemoveNode,
175
176 // eInsertBlockElement indicates to insert a block-level element like <div>,
177 // <pre>, <li>, <dd> etc.
178 eInsertBlockElement,
179
180 // eInsertHorizontalRuleElement indicates to insert a <hr> element.
181 eInsertHorizontalRuleElement,
182
183 // eInsertLinkElement indicates to insert an anchor element which has
184 // href attribute.
185 eInsertLinkElement,
186
187 // eInsertUnorderedListElement and eInsertOrderedListElement indicate to
188 // insert <ul> or <ol> element.
189 eInsertUnorderedListElement,
190 eInsertOrderedListElement,
191
192 // eRemoveUnorderedListElement and eRemoveOrderedListElement indicate to
193 // remove <ul> or <ol> element.
194 eRemoveUnorderedListElement,
195 eRemoveOrderedListElement,
196
197 // eRemoveListElement indicates to remove <ul>, <ol> and/or <dl> element.
198 eRemoveListElement,
199
200 // eInsertBlockquoteElement indicates to insert a <blockquote> element.
201 eInsertBlockquoteElement,
202
203 // eNormalizeTable indicates to normalize table. E.g., if a row does
204 // not have enough number of cells, inserts empty cells.
205 eNormalizeTable,
206
207 // eRemoveTableElement indicates to remove <table> element.
208 eRemoveTableElement,
209
210 // eRemoveTableCellContents indicates to remove any children in a table
211 // cell element.
212 eDeleteTableCellContents,
213
214 // eInsertTableCellElement indicates to insert table cell elements (i.e.,
215 // <td> or <th>).
216 eInsertTableCellElement,
217
218 // eRemoveTableCellEelement indicates to remove table cell elements.
219 eRemoveTableCellElement,
220
221 // eJoinTableCellElements indicates to join table cell elements.
222 eJoinTableCellElements,
223
224 // eSplitTableCellElement indicates to split table cell elements.
225 eSplitTableCellElement,
226
227 // eSetTableCellElementType indicates to set table cell element type to
228 // <td> or <th>.
229 eSetTableCellElementType,
230
231 // eSetInlineStyleProperty indicates to set CSS another inline style property
232 // which is not defined below.
233 eSetInlineStyleProperty,
234
235 // eRemoveInlineStyleProperty indicates to remove a CSS text property which
236 // is not defined below.
237 eRemoveInlineStyleProperty,
238
239 // <b> or font-weight.
240 eSetFontWeightProperty,
241 eRemoveFontWeightProperty,
242
243 // <i> or text-style: italic/oblique.
244 eSetTextStyleProperty,
245 eRemoveTextStyleProperty,
246
247 // <u> or text-decoration: underline.
248 eSetTextDecorationPropertyUnderline,
249 eRemoveTextDecorationPropertyUnderline,
250
251 // <strike> or text-decoration: line-through.
252 eSetTextDecorationPropertyLineThrough,
253 eRemoveTextDecorationPropertyLineThrough,
254
255 // <sup> or text-align: super.
256 eSetVerticalAlignPropertySuper,
257 eRemoveVerticalAlignPropertySuper,
258
259 // <sub> or text-align: sub.
260 eSetVerticalAlignPropertySub,
261 eRemoveVerticalAlignPropertySub,
262
263 // <font face="foo"> or font-family.
264 eSetFontFamilyProperty,
265 eRemoveFontFamilyProperty,
266
267 // <font color="foo"> or color.
268 eSetColorProperty,
269 eRemoveColorProperty,
270
271 // <span style="background-color: foo">
272 eSetBackgroundColorPropertyInline,
273 eRemoveBackgroundColorPropertyInline,
274
275 // eRemoveAllInlineStyleProperties indicates to remove all CSS inline
276 // style properties.
277 eRemoveAllInlineStyleProperties,
278
279 // eIncrementFontSize indicates to increment font-size.
280 eIncrementFontSize,
281
282 // eDecrementFontSize indicates to decrement font-size.
283 eDecrementFontSize,
284
285 // eSetAlignment indicates to set alignment of selected content but different
286 // from the following.
287 eSetAlignment,
288
289 // eAlign* and eJustify indicates to align contents in block with left
290 // edge, right edge, center or justify the text.
291 eAlignLeft,
292 eAlignRight,
293 eAlignCenter,
294 eJustify,
295
296 // eSetBackgroundColor indicates to set background color.
297 eSetBackgroundColor,
298
299 // eSetPositionToAbsoluteOrStatic indicates to set position property value
300 // to "absolute" or "static".
301 eSetPositionToAbsoluteOrStatic,
302
303 // eIncreaseOrDecreaseZIndex indicates to change z-index of an element.
304 eIncreaseOrDecreaseZIndex,
305
306 // eEnableOrDisableCSS indicates to enable or disable CSS mode of HTMLEditor.
307 eEnableOrDisableCSS,
308
309 // eEnableOrDisableAbsolutePositionEditor indicates to enable or disable
310 // absolute positioned element editing UI.
311 eEnableOrDisableAbsolutePositionEditor,
312
313 // eEnableOrDisableResizer indicates to enable or disable resizers of
314 // <img>, <table> and absolutely positioned element.
315 eEnableOrDisableResizer,
316
317 // eEnableOrDisableInlineTableEditingUI indicates to enable or disable
318 // inline table editing UI.
319 eEnableOrDisableInlineTableEditingUI,
320
321 // eSetCharacterSet indicates to set character-set of the document.
322 eSetCharacterSet,
323
324 // eSetWrapWidth indicates to set wrap width.
325 eSetWrapWidth,
326
327 // eRewrap indicates to rewrap for current wrap width.
328 eRewrap,
329
330 // eSetText indicates to set new text of TextEditor, e.g., setting
331 // HTMLInputElement.value.
332 eSetText,
333
334 // eSetHTML indicates to set body of HTMLEditor.
335 eSetHTML,
336
337 // eInsertHTML indicates to insert HTML source code.
338 eInsertHTML,
339
340 // eHidePassword indicates that editor hides password with mask characters.
341 eHidePassword,
342
343 // eCreatePaddingBRElementForEmptyEditor indicates that editor wants to
344 // create a padding <br> element for empty editor after it modifies its
345 // content.
346 eCreatePaddingBRElementForEmptyEditor,
347 };
348
349 // This is int32_t instead of int16_t because nsIInlineSpellChecker.idl's
350 // spellCheckAfterEditorChange is defined to take it as a long.
351 // TODO: Make each name eFoo and investigate whether the numeric values
352 // still have some meaning.
353 enum class EditSubAction : int32_t {
354 // eNone indicates not edit sub-action is being handled. This is useful
355 // of initial value of member variables.
356 eNone,
357
358 // eUndo and eRedo indicate entire actions of undo/redo operation.
359 eUndo,
360 eRedo,
361
362 // eInsertNode indicates to insert a new node into the DOM tree.
363 eInsertNode,
364
365 // eCreateNode indicates to create a new node and insert it into the DOM tree.
366 eCreateNode,
367
368 // eDeleteNode indicates to remove a node from the DOM tree.
369 eDeleteNode,
370
371 // eSplitNode indicates to split a node to 2 nodes.
372 eSplitNode,
373
374 // eJoinNodes indicates to join 2 nodes.
375 eJoinNodes,
376
377 // eDeleteText indicates to delete some characters form a text node.
378 eDeleteText,
379
380 // eInsertText indicates to insert some characters.
381 eInsertText,
382
383 // eInsertTextComingFromIME indicates to insert or update composition string
384 // with new text which is new composition string or commit string.
385 eInsertTextComingFromIME,
386
387 // eDeleteSelectedContent indicates to remove selected content.
388 eDeleteSelectedContent,
389
390 // eSetTextProperty indicates to set a style from text.
391 eSetTextProperty,
392
393 // eRemoveTextProperty indicates to remove a style from text.
394 eRemoveTextProperty,
395
396 // eRemoveAllTextProperties indicate to remove all styles from text.
397 eRemoveAllTextProperties,
398
399 // eComputeTextToOutput indicates to compute the editor value as plain text
400 // or something requested format.
401 eComputeTextToOutput,
402
403 // eSetText indicates to set editor value to new value.
404 eSetText,
405
406 // eInsertLineBreak indicates to insert a line break, <br> or \n to break
407 // current line.
408 eInsertLineBreak,
409
410 // eInsertParagraphSeparator indicates to insert paragraph separator, <br> or
411 // \n at least to break current line in HTMLEditor.
412 eInsertParagraphSeparator,
413
414 // eCreateOrChangeList indicates to create new list or change existing list
415 // type.
416 eCreateOrChangeList,
417
418 // eIndent and eOutdent indicates to indent or outdent the target with
419 // using <blockquote>, <ul>, <ol> or just margin of start edge.
420 eIndent,
421 eOutdent,
422
423 // eSetOrClearAlignment aligns content or clears alignment with align
424 // attribute or text-align.
425 eSetOrClearAlignment,
426
427 // eCreateOrRemoveBlock creates new block or removes existing block and
428 // move its descendants to where the block was.
429 eCreateOrRemoveBlock,
430
431 // eMergeBlockContents is not an actual sub-action, but this is used by
432 // HTMLEditor::MoveBlock() to request special handling in
433 // HTMLEditor::SplitInlinesAndCollectEditTargetNodesInOneHardLine().
434 eMergeBlockContents,
435
436 // eRemoveList removes specific type of list but keep its content.
437 eRemoveList,
438
439 // eCreateOrChangeDefinitionListItem indicates to format current hard line(s)
440 // `<dd>` or `<dt>`. This may cause creating or changing existing list
441 // element to new `<dl>` element.
442 eCreateOrChangeDefinitionListItem,
443
444 // eInsertElement indicates to insert an element.
445 eInsertElement,
446
447 // eInsertQuotation indicates to insert an element and make it "quoted text".
448 eInsertQuotation,
449
450 // eInsertQuotedText indicates to insert text which has already been quoted.
451 eInsertQuotedText,
452
453 // ePasteHTMLContent indicates to paste HTML content in clipboard.
454 ePasteHTMLContent,
455
456 // eInsertHTMLSource indicates to create a document fragment from given HTML
457 // source and insert into the DOM tree. So, this is similar to innerHTML.
458 eInsertHTMLSource,
459
460 // eReplaceHeadWithHTMLSource indicates to create a document fragment from
461 // given HTML source and replace content of <head> with it.
462 eReplaceHeadWithHTMLSource,
463
464 // eSetPositionToAbsolute and eSetPositionToStatic indicates to set position
465 // property to absolute or static.
466 eSetPositionToAbsolute,
467 eSetPositionToStatic,
468
469 // eDecreaseZIndex and eIncreaseZIndex indicate to decrease and increase
470 // z-index value.
471 eDecreaseZIndex,
472 eIncreaseZIndex,
473
474 // eCreatePaddingBRElementForEmptyEditor indicates to create a padding <br>
475 // element for empty editor.
476 eCreatePaddingBRElementForEmptyEditor,
477 };
478
ToInputType(EditAction aEditAction)479 inline EditorInputType ToInputType(EditAction aEditAction) {
480 switch (aEditAction) {
481 case EditAction::eInsertText:
482 return EditorInputType::eInsertText;
483 case EditAction::eReplaceText:
484 return EditorInputType::eInsertReplacementText;
485 case EditAction::eInsertLineBreak:
486 return EditorInputType::eInsertLineBreak;
487 case EditAction::eInsertParagraphSeparator:
488 return EditorInputType::eInsertParagraph;
489 case EditAction::eInsertOrderedListElement:
490 case EditAction::eRemoveOrderedListElement:
491 return EditorInputType::eInsertOrderedList;
492 case EditAction::eInsertUnorderedListElement:
493 case EditAction::eRemoveUnorderedListElement:
494 return EditorInputType::eInsertUnorderedList;
495 case EditAction::eInsertHorizontalRuleElement:
496 return EditorInputType::eInsertHorizontalRule;
497 case EditAction::eDrop:
498 return EditorInputType::eInsertFromDrop;
499 case EditAction::ePaste:
500 return EditorInputType::eInsertFromPaste;
501 case EditAction::ePasteAsQuotation:
502 return EditorInputType::eInsertFromPasteAsQuotation;
503 case EditAction::eUpdateComposition:
504 return EditorInputType::eInsertCompositionText;
505 case EditAction::eCommitComposition:
506 if (StaticPrefs::dom_input_events_conform_to_level_1()) {
507 return EditorInputType::eInsertCompositionText;
508 }
509 return EditorInputType::eInsertFromComposition;
510 case EditAction::eCancelComposition:
511 if (StaticPrefs::dom_input_events_conform_to_level_1()) {
512 return EditorInputType::eInsertCompositionText;
513 }
514 return EditorInputType::eDeleteCompositionText;
515 case EditAction::eDeleteByComposition:
516 if (StaticPrefs::dom_input_events_conform_to_level_1()) {
517 // XXX Or EditorInputType::eDeleteContent? I don't know which IME may
518 // causes this situation.
519 return EditorInputType::eInsertCompositionText;
520 }
521 return EditorInputType::eDeleteByComposition;
522 case EditAction::eInsertLinkElement:
523 return EditorInputType::eInsertLink;
524 case EditAction::eDeleteWordBackward:
525 return EditorInputType::eDeleteWordBackward;
526 case EditAction::eDeleteWordForward:
527 return EditorInputType::eDeleteWordForward;
528 case EditAction::eDeleteToBeginningOfSoftLine:
529 return EditorInputType::eDeleteSoftLineBackward;
530 case EditAction::eDeleteToEndOfSoftLine:
531 return EditorInputType::eDeleteSoftLineForward;
532 case EditAction::eDeleteByDrag:
533 return EditorInputType::eDeleteByDrag;
534 case EditAction::eCut:
535 return EditorInputType::eDeleteByCut;
536 case EditAction::eDeleteSelection:
537 case EditAction::eRemoveTableRowElement:
538 case EditAction::eRemoveTableColumn:
539 case EditAction::eRemoveTableElement:
540 case EditAction::eDeleteTableCellContents:
541 case EditAction::eRemoveTableCellElement:
542 return EditorInputType::eDeleteContent;
543 case EditAction::eDeleteBackward:
544 return EditorInputType::eDeleteContentBackward;
545 case EditAction::eDeleteForward:
546 return EditorInputType::eDeleteContentForward;
547 case EditAction::eUndo:
548 return EditorInputType::eHistoryUndo;
549 case EditAction::eRedo:
550 return EditorInputType::eHistoryRedo;
551 case EditAction::eSetFontWeightProperty:
552 case EditAction::eRemoveFontWeightProperty:
553 return EditorInputType::eFormatBold;
554 case EditAction::eSetTextStyleProperty:
555 case EditAction::eRemoveTextStyleProperty:
556 return EditorInputType::eFormatItalic;
557 case EditAction::eSetTextDecorationPropertyUnderline:
558 case EditAction::eRemoveTextDecorationPropertyUnderline:
559 return EditorInputType::eFormatUnderline;
560 case EditAction::eSetTextDecorationPropertyLineThrough:
561 case EditAction::eRemoveTextDecorationPropertyLineThrough:
562 return EditorInputType::eFormatStrikeThrough;
563 case EditAction::eSetVerticalAlignPropertySuper:
564 case EditAction::eRemoveVerticalAlignPropertySuper:
565 return EditorInputType::eFormatSuperscript;
566 case EditAction::eSetVerticalAlignPropertySub:
567 case EditAction::eRemoveVerticalAlignPropertySub:
568 return EditorInputType::eFormatSubscript;
569 case EditAction::eJustify:
570 return EditorInputType::eFormatJustifyFull;
571 case EditAction::eAlignCenter:
572 return EditorInputType::eFormatJustifyCenter;
573 case EditAction::eAlignRight:
574 return EditorInputType::eFormatJustifyRight;
575 case EditAction::eAlignLeft:
576 return EditorInputType::eFormatJustifyLeft;
577 case EditAction::eIndent:
578 return EditorInputType::eFormatIndent;
579 case EditAction::eOutdent:
580 return EditorInputType::eFormatOutdent;
581 case EditAction::eRemoveAllInlineStyleProperties:
582 return EditorInputType::eFormatRemove;
583 case EditAction::eSetTextDirection:
584 return EditorInputType::eFormatSetBlockTextDirection;
585 case EditAction::eSetBackgroundColorPropertyInline:
586 case EditAction::eRemoveBackgroundColorPropertyInline:
587 return EditorInputType::eFormatBackColor;
588 case EditAction::eSetColorProperty:
589 case EditAction::eRemoveColorProperty:
590 return EditorInputType::eFormatFontColor;
591 case EditAction::eSetFontFamilyProperty:
592 case EditAction::eRemoveFontFamilyProperty:
593 return EditorInputType::eFormatFontName;
594 default:
595 return EditorInputType::eUnknown;
596 }
597 }
598
MayEditActionDeleteAroundCollapsedSelection(const EditAction aEditAction)599 inline bool MayEditActionDeleteAroundCollapsedSelection(
600 const EditAction aEditAction) {
601 switch (aEditAction) {
602 case EditAction::eDeleteSelection:
603 case EditAction::eDeleteBackward:
604 case EditAction::eDeleteForward:
605 case EditAction::eDeleteWordBackward:
606 case EditAction::eDeleteWordForward:
607 case EditAction::eDeleteToBeginningOfSoftLine:
608 case EditAction::eDeleteToEndOfSoftLine:
609 return true;
610 default:
611 return false;
612 }
613 }
614
IsEditActionTableEditing(const EditAction aEditAction)615 inline bool IsEditActionTableEditing(const EditAction aEditAction) {
616 switch (aEditAction) {
617 case EditAction::eInsertTableRowElement:
618 case EditAction::eRemoveTableRowElement:
619 case EditAction::eInsertTableColumn:
620 case EditAction::eRemoveTableColumn:
621 case EditAction::eRemoveTableElement:
622 case EditAction::eRemoveTableCellElement:
623 case EditAction::eDeleteTableCellContents:
624 case EditAction::eInsertTableCellElement:
625 case EditAction::eJoinTableCellElements:
626 case EditAction::eSplitTableCellElement:
627 case EditAction::eSetTableCellElementType:
628 return true;
629 default:
630 return false;
631 }
632 }
633
MayEditActionDeleteSelection(const EditAction aEditAction)634 inline bool MayEditActionDeleteSelection(const EditAction aEditAction) {
635 switch (aEditAction) {
636 case EditAction::eNone:
637 case EditAction::eNotEditing:
638 case EditAction::eInitializing:
639 return false;
640
641 // EditActions modifying around selection.
642 case EditAction::eInsertText:
643 case EditAction::eInsertParagraphSeparator:
644 case EditAction::eInsertLineBreak:
645 case EditAction::eDeleteSelection:
646 case EditAction::eDeleteBackward:
647 case EditAction::eDeleteForward:
648 case EditAction::eDeleteWordBackward:
649 case EditAction::eDeleteWordForward:
650 case EditAction::eDeleteToBeginningOfSoftLine:
651 case EditAction::eDeleteToEndOfSoftLine:
652 case EditAction::eDeleteByDrag:
653 return true;
654
655 case EditAction::eStartComposition:
656 return false;
657
658 case EditAction::eUpdateComposition:
659 case EditAction::eCommitComposition:
660 case EditAction::eCancelComposition:
661 case EditAction::eDeleteByComposition:
662 return true;
663
664 case EditAction::eUndo:
665 case EditAction::eRedo:
666 case EditAction::eSetTextDirection:
667 return false;
668
669 case EditAction::eCut:
670 return true;
671
672 case EditAction::eCopy:
673 return false;
674
675 case EditAction::ePaste:
676 case EditAction::ePasteAsQuotation:
677 return true;
678
679 case EditAction::eDrop:
680 return false; // Not deleting selection at drop.
681
682 // EditActions changing format around selection.
683 case EditAction::eIndent:
684 case EditAction::eOutdent:
685 return false;
686
687 // EditActions inserting or deleting something at specified position.
688 case EditAction::eInsertTableRowElement:
689 case EditAction::eRemoveTableRowElement:
690 case EditAction::eInsertTableColumn:
691 case EditAction::eRemoveTableColumn:
692 case EditAction::eResizingElement:
693 case EditAction::eResizeElement:
694 case EditAction::eMovingElement:
695 case EditAction::eMoveElement:
696 case EditAction::eUnknown:
697 case EditAction::eSetAttribute:
698 case EditAction::eRemoveAttribute:
699 case EditAction::eRemoveNode:
700 case EditAction::eInsertBlockElement:
701 return false;
702
703 // EditActions inserting someting around selection or replacing selection
704 // with something.
705 case EditAction::eReplaceText:
706 case EditAction::eInsertNode:
707 case EditAction::eInsertHorizontalRuleElement:
708 return true;
709
710 // EditActions chaning format around selection or inserting or deleting
711 // something at specific position.
712 case EditAction::eInsertLinkElement:
713 case EditAction::eInsertUnorderedListElement:
714 case EditAction::eInsertOrderedListElement:
715 case EditAction::eRemoveUnorderedListElement:
716 case EditAction::eRemoveOrderedListElement:
717 case EditAction::eRemoveListElement:
718 case EditAction::eInsertBlockquoteElement:
719 case EditAction::eNormalizeTable:
720 case EditAction::eRemoveTableElement:
721 case EditAction::eRemoveTableCellElement:
722 case EditAction::eDeleteTableCellContents:
723 case EditAction::eInsertTableCellElement:
724 case EditAction::eJoinTableCellElements:
725 case EditAction::eSplitTableCellElement:
726 case EditAction::eSetTableCellElementType:
727 case EditAction::eSetInlineStyleProperty:
728 case EditAction::eRemoveInlineStyleProperty:
729 case EditAction::eSetFontWeightProperty:
730 case EditAction::eRemoveFontWeightProperty:
731 case EditAction::eSetTextStyleProperty:
732 case EditAction::eRemoveTextStyleProperty:
733 case EditAction::eSetTextDecorationPropertyUnderline:
734 case EditAction::eRemoveTextDecorationPropertyUnderline:
735 case EditAction::eSetTextDecorationPropertyLineThrough:
736 case EditAction::eRemoveTextDecorationPropertyLineThrough:
737 case EditAction::eSetVerticalAlignPropertySuper:
738 case EditAction::eRemoveVerticalAlignPropertySuper:
739 case EditAction::eSetVerticalAlignPropertySub:
740 case EditAction::eRemoveVerticalAlignPropertySub:
741 case EditAction::eSetFontFamilyProperty:
742 case EditAction::eRemoveFontFamilyProperty:
743 case EditAction::eSetColorProperty:
744 case EditAction::eRemoveColorProperty:
745 case EditAction::eSetBackgroundColorPropertyInline:
746 case EditAction::eRemoveBackgroundColorPropertyInline:
747 case EditAction::eRemoveAllInlineStyleProperties:
748 case EditAction::eIncrementFontSize:
749 case EditAction::eDecrementFontSize:
750 case EditAction::eSetAlignment:
751 case EditAction::eAlignLeft:
752 case EditAction::eAlignRight:
753 case EditAction::eAlignCenter:
754 case EditAction::eJustify:
755 case EditAction::eSetBackgroundColor:
756 case EditAction::eSetPositionToAbsoluteOrStatic:
757 case EditAction::eIncreaseOrDecreaseZIndex:
758 return false;
759
760 // EditActions controlling editor feature or state.
761 case EditAction::eEnableOrDisableCSS:
762 case EditAction::eEnableOrDisableAbsolutePositionEditor:
763 case EditAction::eEnableOrDisableResizer:
764 case EditAction::eEnableOrDisableInlineTableEditingUI:
765 case EditAction::eSetCharacterSet:
766 case EditAction::eSetWrapWidth:
767 return false;
768
769 case EditAction::eRewrap:
770 case EditAction::eSetText:
771 case EditAction::eSetHTML:
772 case EditAction::eInsertHTML:
773 return true;
774
775 case EditAction::eHidePassword:
776 case EditAction::eCreatePaddingBRElementForEmptyEditor:
777 return false;
778 }
779 return false;
780 }
781
782 } // namespace mozilla
783
784 inline bool operator!(const mozilla::EditSubAction& aEditSubAction) {
785 return aEditSubAction == mozilla::EditSubAction::eNone;
786 }
787
788 #endif // #ifdef mozilla_EditAction_h
789