Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / editor / libeditor / EditAction.h
blob98620bd6dc2717da72119f8955c12cd5ce74a71e
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,
507 // eMaintainWhiteSpaceVisibility indicates that editor updates `Text` nodes
508 // to make visible white-spaces keep visible even if web apps deletes padding
509 // <br>s for the preceding white-space.
510 eMaintainWhiteSpaceVisibility,
513 // You can use this macro as:
514 // case NS_EDIT_ACTION_CASES_ACCESSING_TABLE_DATA_WITHOUT_EDITING:
515 // clang-format off
516 #define NS_EDIT_ACTION_CASES_ACCESSING_TABLE_DATA_WITHOUT_EDITING \
517 mozilla::EditAction::eSelectTableCell: \
518 case mozilla::EditAction::eSelectTableRow: \
519 case mozilla::EditAction::eSelectTableColumn: \
520 case mozilla::EditAction::eSelectTable: \
521 case mozilla::EditAction::eSelectAllTableCells: \
522 case mozilla::EditAction::eGetCellIndexes: \
523 case mozilla::EditAction::eGetTableSize: \
524 case mozilla::EditAction::eGetCellAt: \
525 case mozilla::EditAction::eGetCellDataAt: \
526 case mozilla::EditAction::eGetFirstRow: \
527 case mozilla::EditAction::eGetSelectedOrParentTableElement: \
528 case mozilla::EditAction::eGetSelectedCellsType: \
529 case mozilla::EditAction::eGetFirstSelectedCellInTable: \
530 case mozilla::EditAction::eGetSelectedCells
531 // clang-format on
533 inline EditorInputType ToInputType(EditAction aEditAction) {
534 switch (aEditAction) {
535 case EditAction::eInsertText:
536 return EditorInputType::eInsertText;
537 case EditAction::eReplaceText:
538 return EditorInputType::eInsertReplacementText;
539 case EditAction::eInsertLineBreak:
540 return EditorInputType::eInsertLineBreak;
541 case EditAction::eInsertParagraphSeparator:
542 return EditorInputType::eInsertParagraph;
543 case EditAction::eInsertOrderedListElement:
544 case EditAction::eRemoveOrderedListElement:
545 return EditorInputType::eInsertOrderedList;
546 case EditAction::eInsertUnorderedListElement:
547 case EditAction::eRemoveUnorderedListElement:
548 return EditorInputType::eInsertUnorderedList;
549 case EditAction::eInsertHorizontalRuleElement:
550 return EditorInputType::eInsertHorizontalRule;
551 case EditAction::eDrop:
552 return EditorInputType::eInsertFromDrop;
553 case EditAction::ePaste:
554 return EditorInputType::eInsertFromPaste;
555 case EditAction::ePasteAsQuotation:
556 return EditorInputType::eInsertFromPasteAsQuotation;
557 case EditAction::eUpdateComposition:
558 case EditAction::eUpdateCompositionToCommit:
559 return EditorInputType::eInsertCompositionText;
560 case EditAction::eCommitComposition:
561 if (StaticPrefs::dom_input_events_conform_to_level_1()) {
562 return EditorInputType::eInsertCompositionText;
564 return EditorInputType::eInsertFromComposition;
565 case EditAction::eCancelComposition:
566 if (StaticPrefs::dom_input_events_conform_to_level_1()) {
567 return EditorInputType::eInsertCompositionText;
569 return EditorInputType::eDeleteCompositionText;
570 case EditAction::eInsertLinkElement:
571 return EditorInputType::eInsertLink;
572 case EditAction::eDeleteWordBackward:
573 return EditorInputType::eDeleteWordBackward;
574 case EditAction::eDeleteWordForward:
575 return EditorInputType::eDeleteWordForward;
576 case EditAction::eDeleteToBeginningOfSoftLine:
577 return EditorInputType::eDeleteSoftLineBackward;
578 case EditAction::eDeleteToEndOfSoftLine:
579 return EditorInputType::eDeleteSoftLineForward;
580 case EditAction::eDeleteByDrag:
581 return EditorInputType::eDeleteByDrag;
582 case EditAction::eCut:
583 return EditorInputType::eDeleteByCut;
584 case EditAction::eDeleteSelection:
585 case EditAction::eRemoveTableRowElement:
586 case EditAction::eRemoveTableColumn:
587 case EditAction::eRemoveTableElement:
588 case EditAction::eDeleteTableCellContents:
589 case EditAction::eRemoveTableCellElement:
590 return EditorInputType::eDeleteContent;
591 case EditAction::eDeleteBackward:
592 return EditorInputType::eDeleteContentBackward;
593 case EditAction::eDeleteForward:
594 return EditorInputType::eDeleteContentForward;
595 case EditAction::eUndo:
596 return EditorInputType::eHistoryUndo;
597 case EditAction::eRedo:
598 return EditorInputType::eHistoryRedo;
599 case EditAction::eSetFontWeightProperty:
600 case EditAction::eRemoveFontWeightProperty:
601 return EditorInputType::eFormatBold;
602 case EditAction::eSetTextStyleProperty:
603 case EditAction::eRemoveTextStyleProperty:
604 return EditorInputType::eFormatItalic;
605 case EditAction::eSetTextDecorationPropertyUnderline:
606 case EditAction::eRemoveTextDecorationPropertyUnderline:
607 return EditorInputType::eFormatUnderline;
608 case EditAction::eSetTextDecorationPropertyLineThrough:
609 case EditAction::eRemoveTextDecorationPropertyLineThrough:
610 return EditorInputType::eFormatStrikeThrough;
611 case EditAction::eSetVerticalAlignPropertySuper:
612 case EditAction::eRemoveVerticalAlignPropertySuper:
613 return EditorInputType::eFormatSuperscript;
614 case EditAction::eSetVerticalAlignPropertySub:
615 case EditAction::eRemoveVerticalAlignPropertySub:
616 return EditorInputType::eFormatSubscript;
617 case EditAction::eJustify:
618 return EditorInputType::eFormatJustifyFull;
619 case EditAction::eAlignCenter:
620 return EditorInputType::eFormatJustifyCenter;
621 case EditAction::eAlignRight:
622 return EditorInputType::eFormatJustifyRight;
623 case EditAction::eAlignLeft:
624 return EditorInputType::eFormatJustifyLeft;
625 case EditAction::eIndent:
626 return EditorInputType::eFormatIndent;
627 case EditAction::eOutdent:
628 return EditorInputType::eFormatOutdent;
629 case EditAction::eRemoveAllInlineStyleProperties:
630 return EditorInputType::eFormatRemove;
631 case EditAction::eSetTextDirection:
632 return EditorInputType::eFormatSetBlockTextDirection;
633 case EditAction::eSetBackgroundColorPropertyInline:
634 case EditAction::eRemoveBackgroundColorPropertyInline:
635 return EditorInputType::eFormatBackColor;
636 case EditAction::eSetColorProperty:
637 case EditAction::eRemoveColorProperty:
638 return EditorInputType::eFormatFontColor;
639 case EditAction::eSetFontFamilyProperty:
640 case EditAction::eRemoveFontFamilyProperty:
641 return EditorInputType::eFormatFontName;
642 default:
643 return EditorInputType::eUnknown;
647 inline bool MayEditActionDeleteAroundCollapsedSelection(
648 const EditAction aEditAction) {
649 switch (aEditAction) {
650 case EditAction::eCut:
651 case EditAction::eDeleteSelection:
652 case EditAction::eDeleteBackward:
653 case EditAction::eDeleteForward:
654 case EditAction::eDeleteWordBackward:
655 case EditAction::eDeleteWordForward:
656 case EditAction::eDeleteToBeginningOfSoftLine:
657 case EditAction::eDeleteToEndOfSoftLine:
658 return true;
659 default:
660 return false;
664 inline bool IsEditActionInOrderToEditSomething(const EditAction aEditAction) {
665 switch (aEditAction) {
666 case EditAction::eNotEditing:
667 case NS_EDIT_ACTION_CASES_ACCESSING_TABLE_DATA_WITHOUT_EDITING:
668 return false;
669 default:
670 return true;
674 inline bool IsEditActionTableEditing(const EditAction aEditAction) {
675 switch (aEditAction) {
676 case EditAction::eInsertTableRowElement:
677 case EditAction::eRemoveTableRowElement:
678 case EditAction::eInsertTableColumn:
679 case EditAction::eRemoveTableColumn:
680 case EditAction::eRemoveTableElement:
681 case EditAction::eRemoveTableCellElement:
682 case EditAction::eDeleteTableCellContents:
683 case EditAction::eInsertTableCellElement:
684 case EditAction::eJoinTableCellElements:
685 case EditAction::eSplitTableCellElement:
686 case EditAction::eSetTableCellElementType:
687 return true;
688 default:
689 return false;
693 inline bool MayEditActionDeleteSelection(const EditAction aEditAction) {
694 switch (aEditAction) {
695 case EditAction::eNone:
696 case EditAction::eNotEditing:
697 case EditAction::eInitializing:
698 case NS_EDIT_ACTION_CASES_ACCESSING_TABLE_DATA_WITHOUT_EDITING:
699 return false;
701 // EditActions modifying around selection.
702 case EditAction::eInsertText:
703 case EditAction::eInsertParagraphSeparator:
704 case EditAction::eInsertLineBreak:
705 case EditAction::eDeleteSelection:
706 case EditAction::eDeleteBackward:
707 case EditAction::eDeleteForward:
708 case EditAction::eDeleteWordBackward:
709 case EditAction::eDeleteWordForward:
710 case EditAction::eDeleteToBeginningOfSoftLine:
711 case EditAction::eDeleteToEndOfSoftLine:
712 case EditAction::eDeleteByDrag:
713 return true;
715 case EditAction::eStartComposition:
716 return false;
718 case EditAction::eUpdateComposition:
719 case EditAction::eUpdateCompositionToCommit:
720 case EditAction::eCommitComposition:
721 case EditAction::eCancelComposition:
722 return true;
724 case EditAction::eUndo:
725 case EditAction::eRedo:
726 case EditAction::eSetTextDirection:
727 return false;
729 case EditAction::eCut:
730 return true;
732 case EditAction::eCopy:
733 return false;
735 case EditAction::ePaste:
736 case EditAction::ePasteAsQuotation:
737 return true;
739 case EditAction::eDrop:
740 return false; // Not deleting selection at drop.
742 // EditActions changing format around selection.
743 case EditAction::eIndent:
744 case EditAction::eOutdent:
745 return false;
747 // EditActions inserting or deleting something at specified position.
748 case EditAction::eInsertTableRowElement:
749 case EditAction::eRemoveTableRowElement:
750 case EditAction::eInsertTableColumn:
751 case EditAction::eRemoveTableColumn:
752 case EditAction::eResizingElement:
753 case EditAction::eResizeElement:
754 case EditAction::eMovingElement:
755 case EditAction::eMoveElement:
756 case EditAction::eUnknown:
757 case EditAction::eSetAttribute:
758 case EditAction::eRemoveAttribute:
759 case EditAction::eRemoveNode:
760 case EditAction::eInsertBlockElement:
761 return false;
763 // EditActions inserting someting around selection or replacing selection
764 // with something.
765 case EditAction::eReplaceText:
766 case EditAction::eInsertNode:
767 case EditAction::eInsertHorizontalRuleElement:
768 return true;
770 // EditActions changing format around selection or inserting or deleting
771 // something at specific position.
772 case EditAction::eInsertLinkElement:
773 case EditAction::eInsertUnorderedListElement:
774 case EditAction::eInsertOrderedListElement:
775 case EditAction::eRemoveUnorderedListElement:
776 case EditAction::eRemoveOrderedListElement:
777 case EditAction::eRemoveListElement:
778 case EditAction::eInsertBlockquoteElement:
779 case EditAction::eNormalizeTable:
780 case EditAction::eRemoveTableElement:
781 case EditAction::eRemoveTableCellElement:
782 case EditAction::eDeleteTableCellContents:
783 case EditAction::eInsertTableCellElement:
784 case EditAction::eJoinTableCellElements:
785 case EditAction::eSplitTableCellElement:
786 case EditAction::eSetTableCellElementType:
787 case EditAction::eSetInlineStyleProperty:
788 case EditAction::eRemoveInlineStyleProperty:
789 case EditAction::eSetFontWeightProperty:
790 case EditAction::eRemoveFontWeightProperty:
791 case EditAction::eSetTextStyleProperty:
792 case EditAction::eRemoveTextStyleProperty:
793 case EditAction::eSetTextDecorationPropertyUnderline:
794 case EditAction::eRemoveTextDecorationPropertyUnderline:
795 case EditAction::eSetTextDecorationPropertyLineThrough:
796 case EditAction::eRemoveTextDecorationPropertyLineThrough:
797 case EditAction::eSetVerticalAlignPropertySuper:
798 case EditAction::eRemoveVerticalAlignPropertySuper:
799 case EditAction::eSetVerticalAlignPropertySub:
800 case EditAction::eRemoveVerticalAlignPropertySub:
801 case EditAction::eSetFontFamilyProperty:
802 case EditAction::eRemoveFontFamilyProperty:
803 case EditAction::eSetColorProperty:
804 case EditAction::eRemoveColorProperty:
805 case EditAction::eSetBackgroundColorPropertyInline:
806 case EditAction::eRemoveBackgroundColorPropertyInline:
807 case EditAction::eRemoveAllInlineStyleProperties:
808 case EditAction::eIncrementFontSize:
809 case EditAction::eDecrementFontSize:
810 case EditAction::eSetAlignment:
811 case EditAction::eAlignLeft:
812 case EditAction::eAlignRight:
813 case EditAction::eAlignCenter:
814 case EditAction::eJustify:
815 case EditAction::eSetBackgroundColor:
816 case EditAction::eSetPositionToAbsoluteOrStatic:
817 case EditAction::eIncreaseOrDecreaseZIndex:
818 return false;
820 // EditActions controlling editor feature or state.
821 case EditAction::eEnableOrDisableCSS:
822 case EditAction::eEnableOrDisableAbsolutePositionEditor:
823 case EditAction::eEnableOrDisableResizer:
824 case EditAction::eEnableOrDisableInlineTableEditingUI:
825 case EditAction::eSetCharacterSet:
826 case EditAction::eSetWrapWidth:
827 return false;
829 case EditAction::eRewrap:
830 case EditAction::eSetText:
831 case EditAction::eSetHTML:
832 case EditAction::eInsertHTML:
833 return true;
835 case EditAction::eHidePassword:
836 case EditAction::eCreatePaddingBRElementForEmptyEditor:
837 return false;
839 return false;
842 inline bool MayEditActionRequireLayout(const EditAction aEditAction) {
843 switch (aEditAction) {
844 // Table editing require layout information for referring table cell data
845 // such as row/column number and rowspan/colspan.
846 case EditAction::eInsertTableRowElement:
847 case EditAction::eRemoveTableRowElement:
848 case EditAction::eInsertTableColumn:
849 case EditAction::eRemoveTableColumn:
850 case EditAction::eRemoveTableElement:
851 case EditAction::eRemoveTableCellElement:
852 case EditAction::eDeleteTableCellContents:
853 case EditAction::eInsertTableCellElement:
854 case EditAction::eJoinTableCellElements:
855 case EditAction::eSplitTableCellElement:
856 case EditAction::eSetTableCellElementType:
857 case NS_EDIT_ACTION_CASES_ACCESSING_TABLE_DATA_WITHOUT_EDITING:
858 return true;
859 default:
860 return false;
864 } // namespace mozilla
866 inline bool operator!(const mozilla::EditSubAction& aEditSubAction) {
867 return aEditSubAction == mozilla::EditSubAction::eNone;
870 #endif // #ifdef mozilla_EditAction_h