Backed out changeset 4191b252db9b (bug 1886734) for causing build bustages @netwerk...
[gecko.git] / editor / libeditor / EditAction.h
blob6b900b058730cd6a47601435709cb78ea4bfb206
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 // eCommitComposition indicates that user commits composition.
85 eCommitComposition,
87 // eCancelComposition indicates that user cancels composition.
88 eCancelComposition,
90 // eDeleteByComposition indicates that user starts composition with
91 // empty string and there was selected content.
92 eDeleteByComposition,
94 // eUndo/eRedo indicate to undo/redo a transaction.
95 eUndo,
96 eRedo,
98 // eSetTextDirection indicates that setting text direction (LTR or RTL).
99 eSetTextDirection,
101 // eCut indicates to delete selected content and copy it to the clipboard.
102 eCut,
104 // eCopy indicates to copy selected content to the clipboard.
105 eCopy,
107 // ePaste indicates to paste clipboard data.
108 ePaste,
110 // ePasteAsQuotation indicates to paste clipboard data as quotation.
111 ePasteAsQuotation,
113 // eDrop indicates that user drops dragging item into the editor.
114 eDrop,
116 // eIndent indicates that to indent selected line(s).
117 eIndent,
119 // eOutdent indicates that to outdent selected line(s).
120 eOutdent,
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,
127 // eInsertTableRowElement indicates to insert table rows (i.e., <tr>
128 // elements).
129 eInsertTableRowElement,
131 // eRemoveTableRowElement indicates to remove table row elements.
132 eRemoveTableRowElement,
134 // eInsertTableColumn indicates to insert cell elements to each row.
135 eInsertTableColumn,
137 // eRemoveTableColumn indicates to remove cell elements from each row.
138 eRemoveTableColumn,
140 // eResizingElement indicates that user starts to resize or keep resizing
141 // with dragging a resizer which is provided by Gecko.
142 eResizingElement,
144 // eResizeElement indicates that user resizes an element size with finishing
145 // dragging a resizer which is provided by Gecko.
146 eResizeElement,
148 // eMovingElement indicates that user starts to move or keep moving an
149 // element with grabber which is provided by Gecko.
150 eMovingElement,
152 // eMoveElement indicates that user finishes moving an element with grabber
153 // which is provided by Gecko.
154 eMoveElement,
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.
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,
164 // eSetAttribute indicates to set attribute value of an element node.
165 eSetAttribute,
167 // eRemoveAttribute indicates to remove attribute from an element node.
168 eRemoveAttribute,
170 // eInsertNode indicates to insert a node into the tree.
171 eInsertNode,
173 // eDeleteNode indicates to remove a node form the tree.
174 eRemoveNode,
176 // eInsertBlockElement indicates to insert a block-level element like <div>,
177 // <pre>, <li>, <dd> etc.
178 eInsertBlockElement,
180 // eInsertHorizontalRuleElement indicates to insert a <hr> element.
181 eInsertHorizontalRuleElement,
183 // eInsertLinkElement indicates to insert an anchor element which has
184 // href attribute.
185 eInsertLinkElement,
187 // eInsertUnorderedListElement and eInsertOrderedListElement indicate to
188 // insert <ul> or <ol> element.
189 eInsertUnorderedListElement,
190 eInsertOrderedListElement,
192 // eRemoveUnorderedListElement and eRemoveOrderedListElement indicate to
193 // remove <ul> or <ol> element.
194 eRemoveUnorderedListElement,
195 eRemoveOrderedListElement,
197 // eRemoveListElement indicates to remove <ul>, <ol> and/or <dl> element.
198 eRemoveListElement,
200 // eInsertBlockquoteElement indicates to insert a <blockquote> element.
201 eInsertBlockquoteElement,
203 // eNormalizeTable indicates to normalize table. E.g., if a row does
204 // not have enough number of cells, inserts empty cells.
205 eNormalizeTable,
207 // eRemoveTableElement indicates to remove <table> element.
208 eRemoveTableElement,
210 // eRemoveTableCellContents indicates to remove any children in a table
211 // cell element.
212 eDeleteTableCellContents,
214 // eInsertTableCellElement indicates to insert table cell elements (i.e.,
215 // <td> or <th>).
216 eInsertTableCellElement,
218 // eRemoveTableCellEelement indicates to remove table cell elements.
219 eRemoveTableCellElement,
221 // eJoinTableCellElements indicates to join table cell elements.
222 eJoinTableCellElements,
224 // eSplitTableCellElement indicates to split table cell elements.
225 eSplitTableCellElement,
227 // eSetTableCellElementType indicates to set table cell element type to
228 // <td> or <th>.
229 eSetTableCellElementType,
231 // Those edit actions are mapped to the methods in nsITableEditor which
232 // access table layout information.
233 eSelectTableCell,
234 eSelectTableRow,
235 eSelectTableColumn,
236 eSelectTable,
237 eSelectAllTableCells,
238 eGetCellIndexes,
239 eGetTableSize,
240 eGetCellAt,
241 eGetCellDataAt,
242 eGetFirstRow,
243 eGetSelectedOrParentTableElement,
244 eGetSelectedCellsType,
245 eGetFirstSelectedCellInTable,
246 eGetSelectedCells,
248 // eSetInlineStyleProperty indicates to set CSS another inline style property
249 // which is not defined below.
250 eSetInlineStyleProperty,
252 // eRemoveInlineStyleProperty indicates to remove a CSS text property which
253 // is not defined below.
254 eRemoveInlineStyleProperty,
256 // <b> or font-weight.
257 eSetFontWeightProperty,
258 eRemoveFontWeightProperty,
260 // <i> or text-style: italic/oblique.
261 eSetTextStyleProperty,
262 eRemoveTextStyleProperty,
264 // <u> or text-decoration: underline.
265 eSetTextDecorationPropertyUnderline,
266 eRemoveTextDecorationPropertyUnderline,
268 // <strike> or text-decoration: line-through.
269 eSetTextDecorationPropertyLineThrough,
270 eRemoveTextDecorationPropertyLineThrough,
272 // <sup> or text-align: super.
273 eSetVerticalAlignPropertySuper,
274 eRemoveVerticalAlignPropertySuper,
276 // <sub> or text-align: sub.
277 eSetVerticalAlignPropertySub,
278 eRemoveVerticalAlignPropertySub,
280 // <font face="foo"> or font-family.
281 eSetFontFamilyProperty,
282 eRemoveFontFamilyProperty,
284 // <font color="foo"> or color.
285 eSetColorProperty,
286 eRemoveColorProperty,
288 // <span style="background-color: foo">
289 eSetBackgroundColorPropertyInline,
290 eRemoveBackgroundColorPropertyInline,
292 // eRemoveAllInlineStyleProperties indicates to remove all CSS inline
293 // style properties.
294 eRemoveAllInlineStyleProperties,
296 // eIncrementFontSize indicates to increment font-size.
297 eIncrementFontSize,
299 // eDecrementFontSize indicates to decrement font-size.
300 eDecrementFontSize,
302 // eSetAlignment indicates to set alignment of selected content but different
303 // from the following.
304 eSetAlignment,
306 // eAlign* and eJustify indicates to align contents in block with left
307 // edge, right edge, center or justify the text.
308 eAlignLeft,
309 eAlignRight,
310 eAlignCenter,
311 eJustify,
313 // eSetBackgroundColor indicates to set background color.
314 eSetBackgroundColor,
316 // eSetPositionToAbsoluteOrStatic indicates to set position property value
317 // to "absolute" or "static".
318 eSetPositionToAbsoluteOrStatic,
320 // eIncreaseOrDecreaseZIndex indicates to change z-index of an element.
321 eIncreaseOrDecreaseZIndex,
323 // eEnableOrDisableCSS indicates to enable or disable CSS mode of HTMLEditor.
324 eEnableOrDisableCSS,
326 // eEnableOrDisableAbsolutePositionEditor indicates to enable or disable
327 // absolute positioned element editing UI.
328 eEnableOrDisableAbsolutePositionEditor,
330 // eEnableOrDisableResizer indicates to enable or disable resizers of
331 // <img>, <table> and absolutely positioned element.
332 eEnableOrDisableResizer,
334 // eEnableOrDisableInlineTableEditingUI indicates to enable or disable
335 // inline table editing UI.
336 eEnableOrDisableInlineTableEditingUI,
338 // eSetCharacterSet indicates to set character-set of the document.
339 eSetCharacterSet,
341 // eSetWrapWidth indicates to set wrap width.
342 eSetWrapWidth,
344 // eRewrap indicates to rewrap for current wrap width.
345 eRewrap,
347 // eSetText indicates to set new text of TextEditor, e.g., setting
348 // HTMLInputElement.value.
349 eSetText,
351 // eSetHTML indicates to set body of HTMLEditor.
352 eSetHTML,
354 // eInsertHTML indicates to insert HTML source code.
355 eInsertHTML,
357 // eHidePassword indicates that editor hides password with mask characters.
358 eHidePassword,
360 // eCreatePaddingBRElementForEmptyEditor indicates that editor wants to
361 // create a padding <br> element for empty editor after it modifies its
362 // content.
363 eCreatePaddingBRElementForEmptyEditor,
366 // This is int32_t instead of int16_t because nsIInlineSpellChecker.idl's
367 // spellCheckAfterEditorChange is defined to take it as a long.
368 // TODO: Make each name eFoo and investigate whether the numeric values
369 // still have some meaning.
370 enum class EditSubAction : int32_t {
371 // eNone indicates not edit sub-action is being handled. This is useful
372 // of initial value of member variables.
373 eNone,
375 // eUndo and eRedo indicate entire actions of undo/redo operation.
376 eUndo,
377 eRedo,
379 // eInsertNode indicates to insert a new node into the DOM tree.
380 eInsertNode,
382 // eCreateNode indicates to create a new node and insert it into the DOM tree.
383 eCreateNode,
385 // eDeleteNode indicates to remove a node from the DOM tree.
386 eDeleteNode,
388 // eMoveNode indicates to move a node connected in the DOM tree to different
389 // place.
390 eMoveNode,
392 // eSplitNode indicates to split a node to 2 nodes.
393 eSplitNode,
395 // eJoinNodes indicates to join 2 nodes.
396 eJoinNodes,
398 // eDeleteText indicates to delete some characters form a text node.
399 eDeleteText,
401 // eInsertText indicates to insert some characters.
402 eInsertText,
404 // eInsertTextComingFromIME indicates to insert or update composition string
405 // with new text which is new composition string or commit string.
406 eInsertTextComingFromIME,
408 // eDeleteSelectedContent indicates to remove selected content.
409 eDeleteSelectedContent,
411 // eSetTextProperty indicates to set a style from text.
412 eSetTextProperty,
414 // eRemoveTextProperty indicates to remove a style from text.
415 eRemoveTextProperty,
417 // eRemoveAllTextProperties indicate to remove all styles from text.
418 eRemoveAllTextProperties,
420 // eComputeTextToOutput indicates to compute the editor value as plain text
421 // or something requested format.
422 eComputeTextToOutput,
424 // eSetText indicates to set editor value to new value.
425 eSetText,
427 // eInsertLineBreak indicates to insert a line break, <br> or \n to break
428 // current line.
429 eInsertLineBreak,
431 // eInsertParagraphSeparator indicates to insert paragraph separator, <br> or
432 // \n at least to break current line in HTMLEditor.
433 eInsertParagraphSeparator,
435 // eCreateOrChangeList indicates to create new list or change existing list
436 // type.
437 eCreateOrChangeList,
439 // eIndent and eOutdent indicates to indent or outdent the target with
440 // using <blockquote>, <ul>, <ol> or just margin of start edge.
441 eIndent,
442 eOutdent,
444 // eSetOrClearAlignment aligns content or clears alignment with align
445 // attribute or text-align.
446 eSetOrClearAlignment,
448 // eCreateOrRemoveBlock creates new block or removes existing block and
449 // move its descendants to where the block was.
450 eCreateOrRemoveBlock,
452 // eFormatBlockForHTMLCommand wraps selected lines into format block, replaces
453 // format blocks around selection with new format block or deletes format
454 // blocks around selection.
455 eFormatBlockForHTMLCommand,
457 // eMergeBlockContents is not an actual sub-action, but this is used by
458 // HTMLEditor::MoveBlock() to request special handling in
459 // HTMLEditor::MaybeSplitElementsAtEveryBRElement().
460 eMergeBlockContents,
462 // eRemoveList removes specific type of list but keep its content.
463 eRemoveList,
465 // eCreateOrChangeDefinitionListItem indicates to format current hard line(s)
466 // `<dd>` or `<dt>`. This may cause creating or changing existing list
467 // element to new `<dl>` element.
468 eCreateOrChangeDefinitionListItem,
470 // eInsertElement indicates to insert an element.
471 eInsertElement,
473 // eInsertQuotation indicates to insert an element and make it "quoted text".
474 eInsertQuotation,
476 // eInsertQuotedText indicates to insert text which has already been quoted.
477 eInsertQuotedText,
479 // ePasteHTMLContent indicates to paste HTML content in clipboard.
480 ePasteHTMLContent,
482 // eInsertHTMLSource indicates to create a document fragment from given HTML
483 // source and insert into the DOM tree. So, this is similar to innerHTML.
484 eInsertHTMLSource,
486 // eReplaceHeadWithHTMLSource indicates to create a document fragment from
487 // given HTML source and replace content of <head> with it.
488 eReplaceHeadWithHTMLSource,
490 // eSetPositionToAbsolute and eSetPositionToStatic indicates to set position
491 // property to absolute or static.
492 eSetPositionToAbsolute,
493 eSetPositionToStatic,
495 // eDecreaseZIndex and eIncreaseZIndex indicate to decrease and increase
496 // z-index value.
497 eDecreaseZIndex,
498 eIncreaseZIndex,
500 // eCreatePaddingBRElementForEmptyEditor indicates to create a padding <br>
501 // element for empty editor.
502 eCreatePaddingBRElementForEmptyEditor,
505 // You can use this macro as:
506 // case NS_EDIT_ACTION_CASES_ACCESSING_TABLE_DATA_WITHOUT_EDITING:
507 // clang-format off
508 #define NS_EDIT_ACTION_CASES_ACCESSING_TABLE_DATA_WITHOUT_EDITING \
509 mozilla::EditAction::eSelectTableCell: \
510 case mozilla::EditAction::eSelectTableRow: \
511 case mozilla::EditAction::eSelectTableColumn: \
512 case mozilla::EditAction::eSelectTable: \
513 case mozilla::EditAction::eSelectAllTableCells: \
514 case mozilla::EditAction::eGetCellIndexes: \
515 case mozilla::EditAction::eGetTableSize: \
516 case mozilla::EditAction::eGetCellAt: \
517 case mozilla::EditAction::eGetCellDataAt: \
518 case mozilla::EditAction::eGetFirstRow: \
519 case mozilla::EditAction::eGetSelectedOrParentTableElement: \
520 case mozilla::EditAction::eGetSelectedCellsType: \
521 case mozilla::EditAction::eGetFirstSelectedCellInTable: \
522 case mozilla::EditAction::eGetSelectedCells
523 // clang-format on
525 inline EditorInputType ToInputType(EditAction aEditAction) {
526 switch (aEditAction) {
527 case EditAction::eInsertText:
528 return EditorInputType::eInsertText;
529 case EditAction::eReplaceText:
530 return EditorInputType::eInsertReplacementText;
531 case EditAction::eInsertLineBreak:
532 return EditorInputType::eInsertLineBreak;
533 case EditAction::eInsertParagraphSeparator:
534 return EditorInputType::eInsertParagraph;
535 case EditAction::eInsertOrderedListElement:
536 case EditAction::eRemoveOrderedListElement:
537 return EditorInputType::eInsertOrderedList;
538 case EditAction::eInsertUnorderedListElement:
539 case EditAction::eRemoveUnorderedListElement:
540 return EditorInputType::eInsertUnorderedList;
541 case EditAction::eInsertHorizontalRuleElement:
542 return EditorInputType::eInsertHorizontalRule;
543 case EditAction::eDrop:
544 return EditorInputType::eInsertFromDrop;
545 case EditAction::ePaste:
546 return EditorInputType::eInsertFromPaste;
547 case EditAction::ePasteAsQuotation:
548 return EditorInputType::eInsertFromPasteAsQuotation;
549 case EditAction::eUpdateComposition:
550 return EditorInputType::eInsertCompositionText;
551 case EditAction::eCommitComposition:
552 if (StaticPrefs::dom_input_events_conform_to_level_1()) {
553 return EditorInputType::eInsertCompositionText;
555 return EditorInputType::eInsertFromComposition;
556 case EditAction::eCancelComposition:
557 if (StaticPrefs::dom_input_events_conform_to_level_1()) {
558 return EditorInputType::eInsertCompositionText;
560 return EditorInputType::eDeleteCompositionText;
561 case EditAction::eDeleteByComposition:
562 if (StaticPrefs::dom_input_events_conform_to_level_1()) {
563 // XXX Or EditorInputType::eDeleteContent? I don't know which IME may
564 // causes this situation.
565 return EditorInputType::eInsertCompositionText;
567 return EditorInputType::eDeleteByComposition;
568 case EditAction::eInsertLinkElement:
569 return EditorInputType::eInsertLink;
570 case EditAction::eDeleteWordBackward:
571 return EditorInputType::eDeleteWordBackward;
572 case EditAction::eDeleteWordForward:
573 return EditorInputType::eDeleteWordForward;
574 case EditAction::eDeleteToBeginningOfSoftLine:
575 return EditorInputType::eDeleteSoftLineBackward;
576 case EditAction::eDeleteToEndOfSoftLine:
577 return EditorInputType::eDeleteSoftLineForward;
578 case EditAction::eDeleteByDrag:
579 return EditorInputType::eDeleteByDrag;
580 case EditAction::eCut:
581 return EditorInputType::eDeleteByCut;
582 case EditAction::eDeleteSelection:
583 case EditAction::eRemoveTableRowElement:
584 case EditAction::eRemoveTableColumn:
585 case EditAction::eRemoveTableElement:
586 case EditAction::eDeleteTableCellContents:
587 case EditAction::eRemoveTableCellElement:
588 return EditorInputType::eDeleteContent;
589 case EditAction::eDeleteBackward:
590 return EditorInputType::eDeleteContentBackward;
591 case EditAction::eDeleteForward:
592 return EditorInputType::eDeleteContentForward;
593 case EditAction::eUndo:
594 return EditorInputType::eHistoryUndo;
595 case EditAction::eRedo:
596 return EditorInputType::eHistoryRedo;
597 case EditAction::eSetFontWeightProperty:
598 case EditAction::eRemoveFontWeightProperty:
599 return EditorInputType::eFormatBold;
600 case EditAction::eSetTextStyleProperty:
601 case EditAction::eRemoveTextStyleProperty:
602 return EditorInputType::eFormatItalic;
603 case EditAction::eSetTextDecorationPropertyUnderline:
604 case EditAction::eRemoveTextDecorationPropertyUnderline:
605 return EditorInputType::eFormatUnderline;
606 case EditAction::eSetTextDecorationPropertyLineThrough:
607 case EditAction::eRemoveTextDecorationPropertyLineThrough:
608 return EditorInputType::eFormatStrikeThrough;
609 case EditAction::eSetVerticalAlignPropertySuper:
610 case EditAction::eRemoveVerticalAlignPropertySuper:
611 return EditorInputType::eFormatSuperscript;
612 case EditAction::eSetVerticalAlignPropertySub:
613 case EditAction::eRemoveVerticalAlignPropertySub:
614 return EditorInputType::eFormatSubscript;
615 case EditAction::eJustify:
616 return EditorInputType::eFormatJustifyFull;
617 case EditAction::eAlignCenter:
618 return EditorInputType::eFormatJustifyCenter;
619 case EditAction::eAlignRight:
620 return EditorInputType::eFormatJustifyRight;
621 case EditAction::eAlignLeft:
622 return EditorInputType::eFormatJustifyLeft;
623 case EditAction::eIndent:
624 return EditorInputType::eFormatIndent;
625 case EditAction::eOutdent:
626 return EditorInputType::eFormatOutdent;
627 case EditAction::eRemoveAllInlineStyleProperties:
628 return EditorInputType::eFormatRemove;
629 case EditAction::eSetTextDirection:
630 return EditorInputType::eFormatSetBlockTextDirection;
631 case EditAction::eSetBackgroundColorPropertyInline:
632 case EditAction::eRemoveBackgroundColorPropertyInline:
633 return EditorInputType::eFormatBackColor;
634 case EditAction::eSetColorProperty:
635 case EditAction::eRemoveColorProperty:
636 return EditorInputType::eFormatFontColor;
637 case EditAction::eSetFontFamilyProperty:
638 case EditAction::eRemoveFontFamilyProperty:
639 return EditorInputType::eFormatFontName;
640 default:
641 return EditorInputType::eUnknown;
645 inline bool MayEditActionDeleteAroundCollapsedSelection(
646 const EditAction aEditAction) {
647 switch (aEditAction) {
648 case EditAction::eDeleteSelection:
649 case EditAction::eDeleteBackward:
650 case EditAction::eDeleteForward:
651 case EditAction::eDeleteWordBackward:
652 case EditAction::eDeleteWordForward:
653 case EditAction::eDeleteToBeginningOfSoftLine:
654 case EditAction::eDeleteToEndOfSoftLine:
655 return true;
656 default:
657 return false;
661 inline bool IsEditActionInOrderToEditSomething(const EditAction aEditAction) {
662 switch (aEditAction) {
663 case EditAction::eNotEditing:
664 case NS_EDIT_ACTION_CASES_ACCESSING_TABLE_DATA_WITHOUT_EDITING:
665 return false;
666 default:
667 return true;
671 inline bool IsEditActionTableEditing(const EditAction aEditAction) {
672 switch (aEditAction) {
673 case EditAction::eInsertTableRowElement:
674 case EditAction::eRemoveTableRowElement:
675 case EditAction::eInsertTableColumn:
676 case EditAction::eRemoveTableColumn:
677 case EditAction::eRemoveTableElement:
678 case EditAction::eRemoveTableCellElement:
679 case EditAction::eDeleteTableCellContents:
680 case EditAction::eInsertTableCellElement:
681 case EditAction::eJoinTableCellElements:
682 case EditAction::eSplitTableCellElement:
683 case EditAction::eSetTableCellElementType:
684 return true;
685 default:
686 return false;
690 inline bool MayEditActionDeleteSelection(const EditAction aEditAction) {
691 switch (aEditAction) {
692 case EditAction::eNone:
693 case EditAction::eNotEditing:
694 case EditAction::eInitializing:
695 case NS_EDIT_ACTION_CASES_ACCESSING_TABLE_DATA_WITHOUT_EDITING:
696 return false;
698 // EditActions modifying around selection.
699 case EditAction::eInsertText:
700 case EditAction::eInsertParagraphSeparator:
701 case EditAction::eInsertLineBreak:
702 case EditAction::eDeleteSelection:
703 case EditAction::eDeleteBackward:
704 case EditAction::eDeleteForward:
705 case EditAction::eDeleteWordBackward:
706 case EditAction::eDeleteWordForward:
707 case EditAction::eDeleteToBeginningOfSoftLine:
708 case EditAction::eDeleteToEndOfSoftLine:
709 case EditAction::eDeleteByDrag:
710 return true;
712 case EditAction::eStartComposition:
713 return false;
715 case EditAction::eUpdateComposition:
716 case EditAction::eCommitComposition:
717 case EditAction::eCancelComposition:
718 case EditAction::eDeleteByComposition:
719 return true;
721 case EditAction::eUndo:
722 case EditAction::eRedo:
723 case EditAction::eSetTextDirection:
724 return false;
726 case EditAction::eCut:
727 return true;
729 case EditAction::eCopy:
730 return false;
732 case EditAction::ePaste:
733 case EditAction::ePasteAsQuotation:
734 return true;
736 case EditAction::eDrop:
737 return false; // Not deleting selection at drop.
739 // EditActions changing format around selection.
740 case EditAction::eIndent:
741 case EditAction::eOutdent:
742 return false;
744 // EditActions inserting or deleting something at specified position.
745 case EditAction::eInsertTableRowElement:
746 case EditAction::eRemoveTableRowElement:
747 case EditAction::eInsertTableColumn:
748 case EditAction::eRemoveTableColumn:
749 case EditAction::eResizingElement:
750 case EditAction::eResizeElement:
751 case EditAction::eMovingElement:
752 case EditAction::eMoveElement:
753 case EditAction::eUnknown:
754 case EditAction::eSetAttribute:
755 case EditAction::eRemoveAttribute:
756 case EditAction::eRemoveNode:
757 case EditAction::eInsertBlockElement:
758 return false;
760 // EditActions inserting someting around selection or replacing selection
761 // with something.
762 case EditAction::eReplaceText:
763 case EditAction::eInsertNode:
764 case EditAction::eInsertHorizontalRuleElement:
765 return true;
767 // EditActions changing format around selection or inserting or deleting
768 // something at specific position.
769 case EditAction::eInsertLinkElement:
770 case EditAction::eInsertUnorderedListElement:
771 case EditAction::eInsertOrderedListElement:
772 case EditAction::eRemoveUnorderedListElement:
773 case EditAction::eRemoveOrderedListElement:
774 case EditAction::eRemoveListElement:
775 case EditAction::eInsertBlockquoteElement:
776 case EditAction::eNormalizeTable:
777 case EditAction::eRemoveTableElement:
778 case EditAction::eRemoveTableCellElement:
779 case EditAction::eDeleteTableCellContents:
780 case EditAction::eInsertTableCellElement:
781 case EditAction::eJoinTableCellElements:
782 case EditAction::eSplitTableCellElement:
783 case EditAction::eSetTableCellElementType:
784 case EditAction::eSetInlineStyleProperty:
785 case EditAction::eRemoveInlineStyleProperty:
786 case EditAction::eSetFontWeightProperty:
787 case EditAction::eRemoveFontWeightProperty:
788 case EditAction::eSetTextStyleProperty:
789 case EditAction::eRemoveTextStyleProperty:
790 case EditAction::eSetTextDecorationPropertyUnderline:
791 case EditAction::eRemoveTextDecorationPropertyUnderline:
792 case EditAction::eSetTextDecorationPropertyLineThrough:
793 case EditAction::eRemoveTextDecorationPropertyLineThrough:
794 case EditAction::eSetVerticalAlignPropertySuper:
795 case EditAction::eRemoveVerticalAlignPropertySuper:
796 case EditAction::eSetVerticalAlignPropertySub:
797 case EditAction::eRemoveVerticalAlignPropertySub:
798 case EditAction::eSetFontFamilyProperty:
799 case EditAction::eRemoveFontFamilyProperty:
800 case EditAction::eSetColorProperty:
801 case EditAction::eRemoveColorProperty:
802 case EditAction::eSetBackgroundColorPropertyInline:
803 case EditAction::eRemoveBackgroundColorPropertyInline:
804 case EditAction::eRemoveAllInlineStyleProperties:
805 case EditAction::eIncrementFontSize:
806 case EditAction::eDecrementFontSize:
807 case EditAction::eSetAlignment:
808 case EditAction::eAlignLeft:
809 case EditAction::eAlignRight:
810 case EditAction::eAlignCenter:
811 case EditAction::eJustify:
812 case EditAction::eSetBackgroundColor:
813 case EditAction::eSetPositionToAbsoluteOrStatic:
814 case EditAction::eIncreaseOrDecreaseZIndex:
815 return false;
817 // EditActions controlling editor feature or state.
818 case EditAction::eEnableOrDisableCSS:
819 case EditAction::eEnableOrDisableAbsolutePositionEditor:
820 case EditAction::eEnableOrDisableResizer:
821 case EditAction::eEnableOrDisableInlineTableEditingUI:
822 case EditAction::eSetCharacterSet:
823 case EditAction::eSetWrapWidth:
824 return false;
826 case EditAction::eRewrap:
827 case EditAction::eSetText:
828 case EditAction::eSetHTML:
829 case EditAction::eInsertHTML:
830 return true;
832 case EditAction::eHidePassword:
833 case EditAction::eCreatePaddingBRElementForEmptyEditor:
834 return false;
836 return false;
839 inline bool MayEditActionRequireLayout(const EditAction aEditAction) {
840 switch (aEditAction) {
841 // Table editing require layout information for referring table cell data
842 // such as row/column number and rowspan/colspan.
843 case EditAction::eInsertTableRowElement:
844 case EditAction::eRemoveTableRowElement:
845 case EditAction::eInsertTableColumn:
846 case EditAction::eRemoveTableColumn:
847 case EditAction::eRemoveTableElement:
848 case EditAction::eRemoveTableCellElement:
849 case EditAction::eDeleteTableCellContents:
850 case EditAction::eInsertTableCellElement:
851 case EditAction::eJoinTableCellElements:
852 case EditAction::eSplitTableCellElement:
853 case EditAction::eSetTableCellElementType:
854 case NS_EDIT_ACTION_CASES_ACCESSING_TABLE_DATA_WITHOUT_EDITING:
855 return true;
856 default:
857 return false;
861 } // namespace mozilla
863 inline bool operator!(const mozilla::EditSubAction& aEditSubAction) {
864 return aEditSubAction == mozilla::EditSubAction::eNone;
867 #endif // #ifdef mozilla_EditAction_h