Backed out 2 changesets (bug 1908320) for causing wr failures on align-items-baseline...
[gecko.git] / editor / libeditor / EditAction.h
blob6133d82f4aebdd6ebc793206a3fb6d4db14e899d
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 #ifndef mozilla_EditAction_h
7 #define mozilla_EditAction_h
9 #include "mozilla/EventForwards.h"
10 #include "mozilla/StaticPrefs_dom.h"
12 namespace mozilla {
14 /**
15 * EditAction indicates which operation or command causes running the methods
16 * of editors.
18 enum class EditAction {
19 // eNone indicates no edit action is being handled.
20 eNone,
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,
27 // eInitializing indicates that the editor instance is being initialized.
28 eInitializing,
30 // eInsertText indicates to insert some characters.
31 eInsertText,
33 // eInsertParagraphSeparator indicates to insert a paragraph separator such
34 // as <p>, <div>.
35 eInsertParagraphSeparator,
37 // eInsertLineBreak indicates to insert \n into TextEditor or a <br> element
38 // in HTMLEditor.
39 eInsertLineBreak,
41 // eDeleteSelection indicates to delete selected content or content around
42 // caret if selection is collapsed.
43 eDeleteSelection,
45 // eDeleteBackward indicates to remove previous character element of caret.
46 // This may be set even when Selection is not collapsed.
47 eDeleteBackward,
49 // eDeleteForward indicates to remove next character or element of caret.
50 // This may be set even when Selection is not collapsed.
51 eDeleteForward,
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,
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,
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,
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,
73 // eDeleteByDrag indicates to remove selection by dragging the content
74 // to different place.
75 eDeleteByDrag,
77 // eStartComposition indicates that user starts composition.
78 eStartComposition,
80 // eUpdateComposition indicates that user updates composition with
81 // new non-empty composition string and IME selections.
82 eUpdateComposition,
84 // eUpdateCompositionToCommit indicates that user commits composition with
85 // the new data. That means that there will be no IME selections, but the
86 // composition continues until the following eCompositionEnd event.
87 eUpdateCompositionToCommit,
89 // eCommitComposition indicates that user commits composition and ends the
90 // composition.
91 eCommitComposition,
93 // eCancelComposition indicates that user cancels composition and ends the
94 // composition with empty string.
95 eCancelComposition,
97 // eUndo/eRedo indicate to undo/redo a transaction.
98 eUndo,
99 eRedo,
101 // eSetTextDirection indicates that setting text direction (LTR or RTL).
102 eSetTextDirection,
104 // eCut indicates to delete selected content and copy it to the clipboard.
105 eCut,
107 // eCopy indicates to copy selected content to the clipboard.
108 eCopy,
110 // ePaste indicates to paste clipboard data.
111 ePaste,
113 // ePasteAsQuotation indicates to paste clipboard data as quotation.
114 ePasteAsQuotation,
116 // eDrop indicates that user drops dragging item into the editor.
117 eDrop,
119 // eIndent indicates that to indent selected line(s).
120 eIndent,
122 // eOutdent indicates that to outdent selected line(s).
123 eOutdent,
125 // eReplaceText indicates to replace a part of range in editor with
126 // specific text. For example, user select a correct word in suggestions
127 // of spellchecker or a suggestion in list of autocomplete.
128 eReplaceText,
130 // eInsertTableRowElement indicates to insert table rows (i.e., <tr>
131 // elements).
132 eInsertTableRowElement,
134 // eRemoveTableRowElement indicates to remove table row elements.
135 eRemoveTableRowElement,
137 // eInsertTableColumn indicates to insert cell elements to each row.
138 eInsertTableColumn,
140 // eRemoveTableColumn indicates to remove cell elements from each row.
141 eRemoveTableColumn,
143 // eResizingElement indicates that user starts to resize or keep resizing
144 // with dragging a resizer which is provided by Gecko.
145 eResizingElement,
147 // eResizeElement indicates that user resizes an element size with finishing
148 // dragging a resizer which is provided by Gecko.
149 eResizeElement,
151 // eMovingElement indicates that user starts to move or keep moving an
152 // element with grabber which is provided by Gecko.
153 eMovingElement,
155 // eMoveElement indicates that user finishes moving an element with grabber
156 // which is provided by Gecko.
157 eMoveElement,
159 // The following edit actions are not user's operation. They are caused
160 // by if UI does something or web apps does something with JS.
162 // eUnknown indicates some special edit actions, e.g., batching of some
163 // nsI*Editor method calls. This shouldn't be set while handling a user
164 // operation.
165 eUnknown,
167 // eSetAttribute indicates to set attribute value of an element node.
168 eSetAttribute,
170 // eRemoveAttribute indicates to remove attribute from an element node.
171 eRemoveAttribute,
173 // eInsertNode indicates to insert a node into the tree.
174 eInsertNode,
176 // eDeleteNode indicates to remove a node form the tree.
177 eRemoveNode,
179 // eInsertBlockElement indicates to insert a block-level element like <div>,
180 // <pre>, <li>, <dd> etc.
181 eInsertBlockElement,
183 // eInsertHorizontalRuleElement indicates to insert a <hr> element.
184 eInsertHorizontalRuleElement,
186 // eInsertLinkElement indicates to insert an anchor element which has
187 // href attribute.
188 eInsertLinkElement,
190 // eInsertUnorderedListElement and eInsertOrderedListElement indicate to
191 // insert <ul> or <ol> element.
192 eInsertUnorderedListElement,
193 eInsertOrderedListElement,
195 // eRemoveUnorderedListElement and eRemoveOrderedListElement indicate to
196 // remove <ul> or <ol> element.
197 eRemoveUnorderedListElement,
198 eRemoveOrderedListElement,
200 // eRemoveListElement indicates to remove <ul>, <ol> and/or <dl> element.
201 eRemoveListElement,
203 // eInsertBlockquoteElement indicates to insert a <blockquote> element.
204 eInsertBlockquoteElement,
206 // eNormalizeTable indicates to normalize table. E.g., if a row does
207 // not have enough number of cells, inserts empty cells.
208 eNormalizeTable,
210 // eRemoveTableElement indicates to remove <table> element.
211 eRemoveTableElement,
213 // eRemoveTableCellContents indicates to remove any children in a table
214 // cell element.
215 eDeleteTableCellContents,
217 // eInsertTableCellElement indicates to insert table cell elements (i.e.,
218 // <td> or <th>).
219 eInsertTableCellElement,
221 // eRemoveTableCellEelement indicates to remove table cell elements.
222 eRemoveTableCellElement,
224 // eJoinTableCellElements indicates to join table cell elements.
225 eJoinTableCellElements,
227 // eSplitTableCellElement indicates to split table cell elements.
228 eSplitTableCellElement,
230 // eSetTableCellElementType indicates to set table cell element type to
231 // <td> or <th>.
232 eSetTableCellElementType,
234 // Those edit actions are mapped to the methods in nsITableEditor which
235 // access table layout information.
236 eSelectTableCell,
237 eSelectTableRow,
238 eSelectTableColumn,
239 eSelectTable,
240 eSelectAllTableCells,
241 eGetCellIndexes,
242 eGetTableSize,
243 eGetCellAt,
244 eGetCellDataAt,
245 eGetFirstRow,
246 eGetSelectedOrParentTableElement,
247 eGetSelectedCellsType,
248 eGetFirstSelectedCellInTable,
249 eGetSelectedCells,
251 // eSetInlineStyleProperty indicates to set CSS another inline style property
252 // which is not defined below.
253 eSetInlineStyleProperty,
255 // eRemoveInlineStyleProperty indicates to remove a CSS text property which
256 // is not defined below.
257 eRemoveInlineStyleProperty,
259 // <b> or font-weight.
260 eSetFontWeightProperty,
261 eRemoveFontWeightProperty,
263 // <i> or text-style: italic/oblique.
264 eSetTextStyleProperty,
265 eRemoveTextStyleProperty,
267 // <u> or text-decoration: underline.
268 eSetTextDecorationPropertyUnderline,
269 eRemoveTextDecorationPropertyUnderline,
271 // <strike> or text-decoration: line-through.
272 eSetTextDecorationPropertyLineThrough,
273 eRemoveTextDecorationPropertyLineThrough,
275 // <sup> or text-align: super.
276 eSetVerticalAlignPropertySuper,
277 eRemoveVerticalAlignPropertySuper,
279 // <sub> or text-align: sub.
280 eSetVerticalAlignPropertySub,
281 eRemoveVerticalAlignPropertySub,
283 // <font face="foo"> or font-family.
284 eSetFontFamilyProperty,
285 eRemoveFontFamilyProperty,
287 // <font color="foo"> or color.
288 eSetColorProperty,
289 eRemoveColorProperty,
291 // <span style="background-color: foo">
292 eSetBackgroundColorPropertyInline,
293 eRemoveBackgroundColorPropertyInline,
295 // eRemoveAllInlineStyleProperties indicates to remove all CSS inline
296 // style properties.
297 eRemoveAllInlineStyleProperties,
299 // eIncrementFontSize indicates to increment font-size.
300 eIncrementFontSize,
302 // eDecrementFontSize indicates to decrement font-size.
303 eDecrementFontSize,
305 // eSetAlignment indicates to set alignment of selected content but different
306 // from the following.
307 eSetAlignment,
309 // eAlign* and eJustify indicates to align contents in block with left
310 // edge, right edge, center or justify the text.
311 eAlignLeft,
312 eAlignRight,
313 eAlignCenter,
314 eJustify,
316 // eSetBackgroundColor indicates to set background color.
317 eSetBackgroundColor,
319 // eSetPositionToAbsoluteOrStatic indicates to set position property value
320 // to "absolute" or "static".
321 eSetPositionToAbsoluteOrStatic,
323 // eIncreaseOrDecreaseZIndex indicates to change z-index of an element.
324 eIncreaseOrDecreaseZIndex,
326 // eEnableOrDisableCSS indicates to enable or disable CSS mode of HTMLEditor.
327 eEnableOrDisableCSS,
329 // eEnableOrDisableAbsolutePositionEditor indicates to enable or disable
330 // absolute positioned element editing UI.
331 eEnableOrDisableAbsolutePositionEditor,
333 // eEnableOrDisableResizer indicates to enable or disable resizers of
334 // <img>, <table> and absolutely positioned element.
335 eEnableOrDisableResizer,
337 // eEnableOrDisableInlineTableEditingUI indicates to enable or disable
338 // inline table editing UI.
339 eEnableOrDisableInlineTableEditingUI,
341 // eSetCharacterSet indicates to set character-set of the document.
342 eSetCharacterSet,
344 // eSetWrapWidth indicates to set wrap width.
345 eSetWrapWidth,
347 // eRewrap indicates to rewrap for current wrap width.
348 eRewrap,
350 // eSetText indicates to set new text of TextEditor, e.g., setting
351 // HTMLInputElement.value.
352 eSetText,
354 // eSetHTML indicates to set body of HTMLEditor.
355 eSetHTML,
357 // eInsertHTML indicates to insert HTML source code.
358 eInsertHTML,
360 // eHidePassword indicates that editor hides password with mask characters.
361 eHidePassword,
363 // eCreatePaddingBRElementForEmptyEditor indicates that editor wants to
364 // create a padding <br> element for empty editor after it modifies its
365 // content.
366 eCreatePaddingBRElementForEmptyEditor,
369 // This is int32_t instead of int16_t because nsIInlineSpellChecker.idl's
370 // spellCheckAfterEditorChange is defined to take it as a long.
371 // TODO: Make each name eFoo and investigate whether the numeric values
372 // still have some meaning.
373 enum class EditSubAction : int32_t {
374 // eNone indicates not edit sub-action is being handled. This is useful
375 // of initial value of member variables.
376 eNone,
378 // eUndo and eRedo indicate entire actions of undo/redo operation.
379 eUndo,
380 eRedo,
382 // eInsertNode indicates to insert a new node into the DOM tree.
383 eInsertNode,
385 // eCreateNode indicates to create a new node and insert it into the DOM tree.
386 eCreateNode,
388 // eDeleteNode indicates to remove a node from the DOM tree.
389 eDeleteNode,
391 // eMoveNode indicates to move a node connected in the DOM tree to different
392 // place.
393 eMoveNode,
395 // eSplitNode indicates to split a node to 2 nodes.
396 eSplitNode,
398 // eJoinNodes indicates to join 2 nodes.
399 eJoinNodes,
401 // eDeleteText indicates to delete some characters form a text node.
402 eDeleteText,
404 // eInsertText indicates to insert some characters.
405 eInsertText,
407 // eInsertTextComingFromIME indicates to insert or update composition string
408 // with new text which is new composition string or commit string.
409 eInsertTextComingFromIME,
411 // eDeleteSelectedContent indicates to remove selected content.
412 eDeleteSelectedContent,
414 // eSetTextProperty indicates to set a style from text.
415 eSetTextProperty,
417 // eRemoveTextProperty indicates to remove a style from text.
418 eRemoveTextProperty,
420 // eRemoveAllTextProperties indicate to remove all styles from text.
421 eRemoveAllTextProperties,
423 // eComputeTextToOutput indicates to compute the editor value as plain text
424 // or something requested format.
425 eComputeTextToOutput,
427 // eSetText indicates to set editor value to new value.
428 eSetText,
430 // eInsertLineBreak indicates to insert a line break, <br> or \n to break
431 // current line.
432 eInsertLineBreak,
434 // eInsertParagraphSeparator indicates to insert paragraph separator, <br> or
435 // \n at least to break current line in HTMLEditor.
436 eInsertParagraphSeparator,
438 // eCreateOrChangeList indicates to create new list or change existing list
439 // type.
440 eCreateOrChangeList,
442 // eIndent and eOutdent indicates to indent or outdent the target with
443 // using <blockquote>, <ul>, <ol> or just margin of start edge.
444 eIndent,
445 eOutdent,
447 // eSetOrClearAlignment aligns content or clears alignment with align
448 // attribute or text-align.
449 eSetOrClearAlignment,
451 // eCreateOrRemoveBlock creates new block or removes existing block and
452 // move its descendants to where the block was.
453 eCreateOrRemoveBlock,
455 // eFormatBlockForHTMLCommand wraps selected lines into format block, replaces
456 // format blocks around selection with new format block or deletes format
457 // blocks around selection.
458 eFormatBlockForHTMLCommand,
460 // eMergeBlockContents is not an actual sub-action, but this is used by
461 // HTMLEditor::MoveBlock() to request special handling in
462 // HTMLEditor::MaybeSplitElementsAtEveryBRElement().
463 eMergeBlockContents,
465 // eRemoveList removes specific type of list but keep its content.
466 eRemoveList,
468 // eCreateOrChangeDefinitionListItem indicates to format current hard line(s)
469 // `<dd>` or `<dt>`. This may cause creating or changing existing list
470 // element to new `<dl>` element.
471 eCreateOrChangeDefinitionListItem,
473 // eInsertElement indicates to insert an element.
474 eInsertElement,
476 // eInsertQuotation indicates to insert an element and make it "quoted text".
477 eInsertQuotation,
479 // eInsertQuotedText indicates to insert text which has already been quoted.
480 eInsertQuotedText,
482 // ePasteHTMLContent indicates to paste HTML content in clipboard.
483 ePasteHTMLContent,
485 // eInsertHTMLSource indicates to create a document fragment from given HTML
486 // source and insert into the DOM tree. So, this is similar to innerHTML.
487 eInsertHTMLSource,
489 // eReplaceHeadWithHTMLSource indicates to create a document fragment from
490 // given HTML source and replace content of <head> with it.
491 eReplaceHeadWithHTMLSource,
493 // eSetPositionToAbsolute and eSetPositionToStatic indicates to set position
494 // property to absolute or static.
495 eSetPositionToAbsolute,
496 eSetPositionToStatic,
498 // eDecreaseZIndex and eIncreaseZIndex indicate to decrease and increase
499 // z-index value.
500 eDecreaseZIndex,
501 eIncreaseZIndex,
503 // eCreatePaddingBRElementForEmptyEditor indicates to create a padding <br>
504 // element for empty editor.
505 eCreatePaddingBRElementForEmptyEditor,
508 // You can use this macro as:
509 // case NS_EDIT_ACTION_CASES_ACCESSING_TABLE_DATA_WITHOUT_EDITING:
510 // clang-format off
511 #define NS_EDIT_ACTION_CASES_ACCESSING_TABLE_DATA_WITHOUT_EDITING \
512 mozilla::EditAction::eSelectTableCell: \
513 case mozilla::EditAction::eSelectTableRow: \
514 case mozilla::EditAction::eSelectTableColumn: \
515 case mozilla::EditAction::eSelectTable: \
516 case mozilla::EditAction::eSelectAllTableCells: \
517 case mozilla::EditAction::eGetCellIndexes: \
518 case mozilla::EditAction::eGetTableSize: \
519 case mozilla::EditAction::eGetCellAt: \
520 case mozilla::EditAction::eGetCellDataAt: \
521 case mozilla::EditAction::eGetFirstRow: \
522 case mozilla::EditAction::eGetSelectedOrParentTableElement: \
523 case mozilla::EditAction::eGetSelectedCellsType: \
524 case mozilla::EditAction::eGetFirstSelectedCellInTable: \
525 case mozilla::EditAction::eGetSelectedCells
526 // clang-format on
528 inline EditorInputType ToInputType(EditAction aEditAction) {
529 switch (aEditAction) {
530 case EditAction::eInsertText:
531 return EditorInputType::eInsertText;
532 case EditAction::eReplaceText:
533 return EditorInputType::eInsertReplacementText;
534 case EditAction::eInsertLineBreak:
535 return EditorInputType::eInsertLineBreak;
536 case EditAction::eInsertParagraphSeparator:
537 return EditorInputType::eInsertParagraph;
538 case EditAction::eInsertOrderedListElement:
539 case EditAction::eRemoveOrderedListElement:
540 return EditorInputType::eInsertOrderedList;
541 case EditAction::eInsertUnorderedListElement:
542 case EditAction::eRemoveUnorderedListElement:
543 return EditorInputType::eInsertUnorderedList;
544 case EditAction::eInsertHorizontalRuleElement:
545 return EditorInputType::eInsertHorizontalRule;
546 case EditAction::eDrop:
547 return EditorInputType::eInsertFromDrop;
548 case EditAction::ePaste:
549 return EditorInputType::eInsertFromPaste;
550 case EditAction::ePasteAsQuotation:
551 return EditorInputType::eInsertFromPasteAsQuotation;
552 case EditAction::eUpdateComposition:
553 case EditAction::eUpdateCompositionToCommit:
554 return EditorInputType::eInsertCompositionText;
555 case EditAction::eCommitComposition:
556 if (StaticPrefs::dom_input_events_conform_to_level_1()) {
557 return EditorInputType::eInsertCompositionText;
559 return EditorInputType::eInsertFromComposition;
560 case EditAction::eCancelComposition:
561 if (StaticPrefs::dom_input_events_conform_to_level_1()) {
562 return EditorInputType::eInsertCompositionText;
564 return EditorInputType::eDeleteCompositionText;
565 case EditAction::eInsertLinkElement:
566 return EditorInputType::eInsertLink;
567 case EditAction::eDeleteWordBackward:
568 return EditorInputType::eDeleteWordBackward;
569 case EditAction::eDeleteWordForward:
570 return EditorInputType::eDeleteWordForward;
571 case EditAction::eDeleteToBeginningOfSoftLine:
572 return EditorInputType::eDeleteSoftLineBackward;
573 case EditAction::eDeleteToEndOfSoftLine:
574 return EditorInputType::eDeleteSoftLineForward;
575 case EditAction::eDeleteByDrag:
576 return EditorInputType::eDeleteByDrag;
577 case EditAction::eCut:
578 return EditorInputType::eDeleteByCut;
579 case EditAction::eDeleteSelection:
580 case EditAction::eRemoveTableRowElement:
581 case EditAction::eRemoveTableColumn:
582 case EditAction::eRemoveTableElement:
583 case EditAction::eDeleteTableCellContents:
584 case EditAction::eRemoveTableCellElement:
585 return EditorInputType::eDeleteContent;
586 case EditAction::eDeleteBackward:
587 return EditorInputType::eDeleteContentBackward;
588 case EditAction::eDeleteForward:
589 return EditorInputType::eDeleteContentForward;
590 case EditAction::eUndo:
591 return EditorInputType::eHistoryUndo;
592 case EditAction::eRedo:
593 return EditorInputType::eHistoryRedo;
594 case EditAction::eSetFontWeightProperty:
595 case EditAction::eRemoveFontWeightProperty:
596 return EditorInputType::eFormatBold;
597 case EditAction::eSetTextStyleProperty:
598 case EditAction::eRemoveTextStyleProperty:
599 return EditorInputType::eFormatItalic;
600 case EditAction::eSetTextDecorationPropertyUnderline:
601 case EditAction::eRemoveTextDecorationPropertyUnderline:
602 return EditorInputType::eFormatUnderline;
603 case EditAction::eSetTextDecorationPropertyLineThrough:
604 case EditAction::eRemoveTextDecorationPropertyLineThrough:
605 return EditorInputType::eFormatStrikeThrough;
606 case EditAction::eSetVerticalAlignPropertySuper:
607 case EditAction::eRemoveVerticalAlignPropertySuper:
608 return EditorInputType::eFormatSuperscript;
609 case EditAction::eSetVerticalAlignPropertySub:
610 case EditAction::eRemoveVerticalAlignPropertySub:
611 return EditorInputType::eFormatSubscript;
612 case EditAction::eJustify:
613 return EditorInputType::eFormatJustifyFull;
614 case EditAction::eAlignCenter:
615 return EditorInputType::eFormatJustifyCenter;
616 case EditAction::eAlignRight:
617 return EditorInputType::eFormatJustifyRight;
618 case EditAction::eAlignLeft:
619 return EditorInputType::eFormatJustifyLeft;
620 case EditAction::eIndent:
621 return EditorInputType::eFormatIndent;
622 case EditAction::eOutdent:
623 return EditorInputType::eFormatOutdent;
624 case EditAction::eRemoveAllInlineStyleProperties:
625 return EditorInputType::eFormatRemove;
626 case EditAction::eSetTextDirection:
627 return EditorInputType::eFormatSetBlockTextDirection;
628 case EditAction::eSetBackgroundColorPropertyInline:
629 case EditAction::eRemoveBackgroundColorPropertyInline:
630 return EditorInputType::eFormatBackColor;
631 case EditAction::eSetColorProperty:
632 case EditAction::eRemoveColorProperty:
633 return EditorInputType::eFormatFontColor;
634 case EditAction::eSetFontFamilyProperty:
635 case EditAction::eRemoveFontFamilyProperty:
636 return EditorInputType::eFormatFontName;
637 default:
638 return EditorInputType::eUnknown;
642 inline bool MayEditActionDeleteAroundCollapsedSelection(
643 const EditAction aEditAction) {
644 switch (aEditAction) {
645 case EditAction::eCut:
646 case EditAction::eDeleteSelection:
647 case EditAction::eDeleteBackward:
648 case EditAction::eDeleteForward:
649 case EditAction::eDeleteWordBackward:
650 case EditAction::eDeleteWordForward:
651 case EditAction::eDeleteToBeginningOfSoftLine:
652 case EditAction::eDeleteToEndOfSoftLine:
653 return true;
654 default:
655 return false;
659 inline bool IsEditActionInOrderToEditSomething(const EditAction aEditAction) {
660 switch (aEditAction) {
661 case EditAction::eNotEditing:
662 case NS_EDIT_ACTION_CASES_ACCESSING_TABLE_DATA_WITHOUT_EDITING:
663 return false;
664 default:
665 return true;
669 inline bool IsEditActionTableEditing(const EditAction aEditAction) {
670 switch (aEditAction) {
671 case EditAction::eInsertTableRowElement:
672 case EditAction::eRemoveTableRowElement:
673 case EditAction::eInsertTableColumn:
674 case EditAction::eRemoveTableColumn:
675 case EditAction::eRemoveTableElement:
676 case EditAction::eRemoveTableCellElement:
677 case EditAction::eDeleteTableCellContents:
678 case EditAction::eInsertTableCellElement:
679 case EditAction::eJoinTableCellElements:
680 case EditAction::eSplitTableCellElement:
681 case EditAction::eSetTableCellElementType:
682 return true;
683 default:
684 return false;
688 inline bool MayEditActionDeleteSelection(const EditAction aEditAction) {
689 switch (aEditAction) {
690 case EditAction::eNone:
691 case EditAction::eNotEditing:
692 case EditAction::eInitializing:
693 case NS_EDIT_ACTION_CASES_ACCESSING_TABLE_DATA_WITHOUT_EDITING:
694 return false;
696 // EditActions modifying around selection.
697 case EditAction::eInsertText:
698 case EditAction::eInsertParagraphSeparator:
699 case EditAction::eInsertLineBreak:
700 case EditAction::eDeleteSelection:
701 case EditAction::eDeleteBackward:
702 case EditAction::eDeleteForward:
703 case EditAction::eDeleteWordBackward:
704 case EditAction::eDeleteWordForward:
705 case EditAction::eDeleteToBeginningOfSoftLine:
706 case EditAction::eDeleteToEndOfSoftLine:
707 case EditAction::eDeleteByDrag:
708 return true;
710 case EditAction::eStartComposition:
711 return false;
713 case EditAction::eUpdateComposition:
714 case EditAction::eUpdateCompositionToCommit:
715 case EditAction::eCommitComposition:
716 case EditAction::eCancelComposition:
717 return true;
719 case EditAction::eUndo:
720 case EditAction::eRedo:
721 case EditAction::eSetTextDirection:
722 return false;
724 case EditAction::eCut:
725 return true;
727 case EditAction::eCopy:
728 return false;
730 case EditAction::ePaste:
731 case EditAction::ePasteAsQuotation:
732 return true;
734 case EditAction::eDrop:
735 return false; // Not deleting selection at drop.
737 // EditActions changing format around selection.
738 case EditAction::eIndent:
739 case EditAction::eOutdent:
740 return false;
742 // EditActions inserting or deleting something at specified position.
743 case EditAction::eInsertTableRowElement:
744 case EditAction::eRemoveTableRowElement:
745 case EditAction::eInsertTableColumn:
746 case EditAction::eRemoveTableColumn:
747 case EditAction::eResizingElement:
748 case EditAction::eResizeElement:
749 case EditAction::eMovingElement:
750 case EditAction::eMoveElement:
751 case EditAction::eUnknown:
752 case EditAction::eSetAttribute:
753 case EditAction::eRemoveAttribute:
754 case EditAction::eRemoveNode:
755 case EditAction::eInsertBlockElement:
756 return false;
758 // EditActions inserting someting around selection or replacing selection
759 // with something.
760 case EditAction::eReplaceText:
761 case EditAction::eInsertNode:
762 case EditAction::eInsertHorizontalRuleElement:
763 return true;
765 // EditActions changing format around selection or inserting or deleting
766 // something at specific position.
767 case EditAction::eInsertLinkElement:
768 case EditAction::eInsertUnorderedListElement:
769 case EditAction::eInsertOrderedListElement:
770 case EditAction::eRemoveUnorderedListElement:
771 case EditAction::eRemoveOrderedListElement:
772 case EditAction::eRemoveListElement:
773 case EditAction::eInsertBlockquoteElement:
774 case EditAction::eNormalizeTable:
775 case EditAction::eRemoveTableElement:
776 case EditAction::eRemoveTableCellElement:
777 case EditAction::eDeleteTableCellContents:
778 case EditAction::eInsertTableCellElement:
779 case EditAction::eJoinTableCellElements:
780 case EditAction::eSplitTableCellElement:
781 case EditAction::eSetTableCellElementType:
782 case EditAction::eSetInlineStyleProperty:
783 case EditAction::eRemoveInlineStyleProperty:
784 case EditAction::eSetFontWeightProperty:
785 case EditAction::eRemoveFontWeightProperty:
786 case EditAction::eSetTextStyleProperty:
787 case EditAction::eRemoveTextStyleProperty:
788 case EditAction::eSetTextDecorationPropertyUnderline:
789 case EditAction::eRemoveTextDecorationPropertyUnderline:
790 case EditAction::eSetTextDecorationPropertyLineThrough:
791 case EditAction::eRemoveTextDecorationPropertyLineThrough:
792 case EditAction::eSetVerticalAlignPropertySuper:
793 case EditAction::eRemoveVerticalAlignPropertySuper:
794 case EditAction::eSetVerticalAlignPropertySub:
795 case EditAction::eRemoveVerticalAlignPropertySub:
796 case EditAction::eSetFontFamilyProperty:
797 case EditAction::eRemoveFontFamilyProperty:
798 case EditAction::eSetColorProperty:
799 case EditAction::eRemoveColorProperty:
800 case EditAction::eSetBackgroundColorPropertyInline:
801 case EditAction::eRemoveBackgroundColorPropertyInline:
802 case EditAction::eRemoveAllInlineStyleProperties:
803 case EditAction::eIncrementFontSize:
804 case EditAction::eDecrementFontSize:
805 case EditAction::eSetAlignment:
806 case EditAction::eAlignLeft:
807 case EditAction::eAlignRight:
808 case EditAction::eAlignCenter:
809 case EditAction::eJustify:
810 case EditAction::eSetBackgroundColor:
811 case EditAction::eSetPositionToAbsoluteOrStatic:
812 case EditAction::eIncreaseOrDecreaseZIndex:
813 return false;
815 // EditActions controlling editor feature or state.
816 case EditAction::eEnableOrDisableCSS:
817 case EditAction::eEnableOrDisableAbsolutePositionEditor:
818 case EditAction::eEnableOrDisableResizer:
819 case EditAction::eEnableOrDisableInlineTableEditingUI:
820 case EditAction::eSetCharacterSet:
821 case EditAction::eSetWrapWidth:
822 return false;
824 case EditAction::eRewrap:
825 case EditAction::eSetText:
826 case EditAction::eSetHTML:
827 case EditAction::eInsertHTML:
828 return true;
830 case EditAction::eHidePassword:
831 case EditAction::eCreatePaddingBRElementForEmptyEditor:
832 return false;
834 return false;
837 inline bool MayEditActionRequireLayout(const EditAction aEditAction) {
838 switch (aEditAction) {
839 // Table editing require layout information for referring table cell data
840 // such as row/column number and rowspan/colspan.
841 case EditAction::eInsertTableRowElement:
842 case EditAction::eRemoveTableRowElement:
843 case EditAction::eInsertTableColumn:
844 case EditAction::eRemoveTableColumn:
845 case EditAction::eRemoveTableElement:
846 case EditAction::eRemoveTableCellElement:
847 case EditAction::eDeleteTableCellContents:
848 case EditAction::eInsertTableCellElement:
849 case EditAction::eJoinTableCellElements:
850 case EditAction::eSplitTableCellElement:
851 case EditAction::eSetTableCellElementType:
852 case NS_EDIT_ACTION_CASES_ACCESSING_TABLE_DATA_WITHOUT_EDITING:
853 return true;
854 default:
855 return false;
859 } // namespace mozilla
861 inline bool operator!(const mozilla::EditSubAction& aEditSubAction) {
862 return aEditSubAction == mozilla::EditSubAction::eNone;
865 #endif // #ifdef mozilla_EditAction_h