Bug 1463985 - part 8: Rename EditSubAction::insertText to EditSubAction::eInsertText r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 28 May 2018 21:36:47 +0900
changeset 474806 666cdc7ef8e2075f7b3cce136e64c8395b6b5ccd
parent 474805 e1135fe082bcdb789cc6c73f761ec114da4c706a
child 474807 a343a1752684bb0a4867da6748a766b3baeea55f
push id9374
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:43:20 +0000
treeherdermozilla-beta@160e085dfb0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1463985
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1463985 - part 8: Rename EditSubAction::insertText to EditSubAction::eInsertText r=m_kato MozReview-Commit-ID: Bd7GMng3T1T
editor/libeditor/EditAction.h
editor/libeditor/HTMLEditRules.cpp
editor/libeditor/HTMLEditRules.h
editor/libeditor/HTMLEditor.cpp
editor/libeditor/TextEditRules.cpp
editor/libeditor/TextEditRules.h
editor/libeditor/TextEditor.cpp
extensions/spellcheck/src/mozInlineSpellChecker.cpp
--- a/editor/libeditor/EditAction.h
+++ b/editor/libeditor/EditAction.h
@@ -37,18 +37,19 @@ enum class EditSubAction : int32_t
   eSplitNode,
 
   // eJoinNodes indicates to join 2 nodes.
   eJoinNodes,
 
   // eDeleteText indicates to delete some characters form a text node.
   eDeleteText,
 
-  // Text edit commands
-  insertText = 2000,
+  // eInsertText indicates to insert some characters.
+  eInsertText,
+
   insertIMEText,
   deleteSelection,
   setTextProperty,
   removeTextProperty,
   outputText,
   setText,
 
   // HTML editor only actions
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -365,17 +365,17 @@ HTMLEditRules::BeforeEdit(EditSubAction 
       mDocChangeRange->Reset();
     }
     if (mUtilRange) {
       // Ditto for mUtilRange.
       mUtilRange->Reset();
     }
 
     // Remember current inline styles for deletion and normal insertion ops
-    if (aEditSubAction == EditSubAction::insertText ||
+    if (aEditSubAction == EditSubAction::eInsertText ||
         aEditSubAction == EditSubAction::insertIMEText ||
         aEditSubAction == EditSubAction::deleteSelection ||
         IsStyleCachePreservingSubAction(aEditSubAction)) {
       nsCOMPtr<nsINode> selNode =
         aDirection == nsIEditor::eNext ? selEndNode : selStartNode;
       nsresult rv = CacheInlineStyles(selNode);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
@@ -494,17 +494,17 @@ HTMLEditRules::AfterEditInner(EditSubAct
 
     // expand the "changed doc range" as needed
     PromoteRange(*mDocChangeRange, aEditSubAction);
 
     // if we did a ranged deletion or handling backspace key, make sure we have
     // a place to put caret.
     // Note we only want to do this if the overall operation was deletion,
     // not if deletion was done along the way for EditSubAction::loadHTML,
-    // EditSubAction::insertText, etc.  That's why this is here rather than
+    // EditSubAction::eInsertText, etc.  That's why this is here rather than
     // DidDeleteSelection().
     if (aEditSubAction == EditSubAction::deleteSelection && mDidRangedDelete) {
       nsresult rv = InsertBRIfNeeded();
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     }
 
@@ -512,17 +512,17 @@ HTMLEditRules::AfterEditInner(EditSubAct
     nsresult rv = InsertBRElementToEmptyListItemsAndTableCellsInChangedRange();
     if (NS_WARN_IF(rv == NS_ERROR_EDITOR_DESTROYED)) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
       "Failed to insert <br> elements to empty list items and table cells");
 
     // merge any adjacent text nodes
-    if (aEditSubAction != EditSubAction::insertText &&
+    if (aEditSubAction != EditSubAction::eInsertText &&
         aEditSubAction != EditSubAction::insertIMEText) {
       nsresult rv = HTMLEditorRef().CollapseAdjacentTextNodes(mDocChangeRange);
       if (NS_WARN_IF(!CanHandleEditAction())) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
@@ -530,17 +530,17 @@ HTMLEditRules::AfterEditInner(EditSubAct
 
     // clean up any empty nodes in the selection
     rv = RemoveEmptyNodesInChangedRange();
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     // attempt to transform any unneeded nbsp's into spaces after doing various operations
-    if (aEditSubAction == EditSubAction::insertText ||
+    if (aEditSubAction == EditSubAction::eInsertText ||
         aEditSubAction == EditSubAction::insertIMEText ||
         aEditSubAction == EditSubAction::deleteSelection ||
         aEditSubAction == EditSubAction::insertBreak ||
         aEditSubAction == EditSubAction::htmlPaste ||
         aEditSubAction == EditSubAction::loadHTML) {
       rv = AdjustWhitespace();
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
@@ -566,30 +566,30 @@ HTMLEditRules::AfterEditInner(EditSubAct
         return NS_ERROR_EDITOR_DESTROYED;
       }
       NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
         "Failed to pin selection to the new block");
       mNewBlock = nullptr;
     }
 
     // adjust selection for insert text, html paste, and delete actions
-    if (aEditSubAction == EditSubAction::insertText ||
+    if (aEditSubAction == EditSubAction::eInsertText ||
         aEditSubAction == EditSubAction::insertIMEText ||
         aEditSubAction == EditSubAction::deleteSelection ||
         aEditSubAction == EditSubAction::insertBreak ||
         aEditSubAction == EditSubAction::htmlPaste ||
         aEditSubAction == EditSubAction::loadHTML) {
       rv = AdjustSelection(aDirection);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     }
 
     // check for any styles which were removed inappropriately
-    if (aEditSubAction == EditSubAction::insertText ||
+    if (aEditSubAction == EditSubAction::eInsertText ||
         aEditSubAction == EditSubAction::insertIMEText ||
         aEditSubAction == EditSubAction::deleteSelection ||
         IsStyleCachePreservingSubAction(aEditSubAction)) {
       HTMLEditorRef().mTypeInState->UpdateSelState(&SelectionRef());
       rv = ReapplyCachedStyles();
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
@@ -675,17 +675,17 @@ HTMLEditRules::WillDoAction(Selection* a
     NS_ENSURE_STATE(mHTMLEditor);
     if (!HTMLEditorRef().IsModifiableNode(range->GetCommonAncestor())) {
       *aCancel = true;
       return NS_OK;
     }
   }
 
   switch (aInfo.mEditSubAction) {
-    case EditSubAction::insertText:
+    case EditSubAction::eInsertText:
     case EditSubAction::insertIMEText:
       UndefineCaretBidiLevel();
       return WillInsertText(aInfo.mEditSubAction, aCancel, aHandled,
                             aInfo.inString, aInfo.outString,
                             aInfo.maxLength);
     case EditSubAction::loadHTML:
       return WillLoadHTML();
     case EditSubAction::insertBreak:
@@ -751,17 +751,17 @@ HTMLEditRules::DidDoAction(Selection* aS
   }
   if (NS_WARN_IF(!CanHandleEditAction())) {
     return NS_ERROR_EDITOR_DESTROYED;
   }
 
   AutoSafeEditorData setData(*this, *mHTMLEditor, *aSelection);
 
   switch (aInfo.mEditSubAction) {
-    case EditSubAction::insertText:
+    case EditSubAction::eInsertText:
     case EditSubAction::insertBreak:
     case EditSubAction::insertIMEText:
       return NS_OK;
     case EditSubAction::deleteSelection:
       return DidDeleteSelection();
     case EditSubAction::makeBasicBlock:
     case EditSubAction::indent:
     case EditSubAction::outdent:
@@ -1409,17 +1409,17 @@ HTMLEditRules::WillInsert(bool* aCancel)
       }
       if (NS_WARN_IF(error.Failed())) {
         return error.StealNSResult();
       }
     }
   }
 
   if (mDidDeleteSelection &&
-      (mTopLevelEditSubAction == EditSubAction::insertText ||
+      (mTopLevelEditSubAction == EditSubAction::eInsertText ||
        mTopLevelEditSubAction == EditSubAction::insertIMEText ||
        mTopLevelEditSubAction == EditSubAction::deleteSelection)) {
     nsresult rv = ReapplyCachedStyles();
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
   // For most actions we want to clear the cached styles, but there are
@@ -7125,17 +7125,17 @@ HTMLEditRules::GetPromotedPoint(RulesEnd
                                 nsINode& aNode,
                                 int32_t aOffset,
                                 EditSubAction aEditSubAction)
 {
   MOZ_ASSERT(IsEditorDataAvailable());
 
   // we do one thing for text actions, something else entirely for other
   // actions
-  if (aEditSubAction == EditSubAction::insertText ||
+  if (aEditSubAction == EditSubAction::eInsertText ||
       aEditSubAction == EditSubAction::insertIMEText ||
       aEditSubAction == EditSubAction::insertBreak ||
       aEditSubAction == EditSubAction::eDeleteText) {
     bool isSpace, isNBSP;
     nsCOMPtr<nsIContent> content =
       aNode.IsContent() ? aNode.AsContent() : nullptr;
     nsCOMPtr<nsIContent> temp;
     int32_t newOffset = aOffset;
@@ -7374,17 +7374,17 @@ HTMLEditRules::PromoteRange(nsRange& aRa
         startNode = block;
         endNode = block;
         startOffset = 0;
         endOffset = block->Length();
       }
     }
   }
 
-  if (aEditSubAction == EditSubAction::insertText ||
+  if (aEditSubAction == EditSubAction::eInsertText ||
       aEditSubAction == EditSubAction::insertIMEText ||
       aEditSubAction == EditSubAction::insertBreak ||
       aEditSubAction == EditSubAction::eDeleteText) {
      if (!startNode->IsContent() ||
          !endNode->IsContent()) {
        // GetPromotedPoint cannot promote node when action type is text
        // operation and selected node isn't content node.
        return;
--- a/editor/libeditor/HTMLEditRules.h
+++ b/editor/libeditor/HTMLEditRules.h
@@ -183,17 +183,17 @@ protected:
   MOZ_MUST_USE nsresult WillInsert(bool* aCancel = nullptr);
 
   /**
    * Called before inserting text.
    * This method may actually inserts text into the editor.  Therefore, this
    * might cause destroying the editor.
    *
    * @param aEditSubAction      Must be EditSubAction::insertIMEText or
-   *                            EditSubAction::insertText.
+   *                            EditSubAction::eInsertText.
    * @param aCancel             Returns true if the operation is canceled.
    * @param aHandled            Returns true if the edit action is handled.
    * @param inString            String to be inserted.
    * @param outString           String actually inserted.
    * @param aMaxLength          The maximum string length which the editor
    *                            allows to set.
    */
   MOZ_MUST_USE nsresult
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -1149,18 +1149,20 @@ HTMLEditor::TabInTable(bool inIsShift,
 
   return NS_OK;
 }
 
 nsresult
 HTMLEditor::InsertBrElementAtSelectionWithTransaction()
 {
   // calling it text insertion to trigger moz br treatment by rules
+  // XXX Why do we use EditSubAction::eInsertText here?  Looks like
+  //     EditSubAction::insertBreak or EditSubAction::eInsertNode is better.
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
-                                      *this, EditSubAction::insertText,
+                                      *this, EditSubAction::eInsertText,
                                       nsIEditor::eNext);
 
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_STATE(selection);
 
   if (!selection->IsCollapsed()) {
     nsresult rv = DeleteSelectionAsAction(eNone, eStrip);
     if (NS_WARN_IF(NS_FAILED(rv))) {
--- a/editor/libeditor/TextEditRules.cpp
+++ b/editor/libeditor/TextEditRules.cpp
@@ -325,17 +325,17 @@ TextEditRules::WillDoAction(Selection* a
 
   AutoSafeEditorData setData(*this, *mTextEditor, *aSelection);
 
   // my kingdom for dynamic cast
   switch (aInfo.mEditSubAction) {
     case EditSubAction::insertBreak:
       UndefineCaretBidiLevel();
       return WillInsertBreak(aCancel, aHandled, aInfo.maxLength);
-    case EditSubAction::insertText:
+    case EditSubAction::eInsertText:
     case EditSubAction::insertIMEText:
       UndefineCaretBidiLevel();
       return WillInsertText(aInfo.mEditSubAction, aCancel, aHandled,
                             aInfo.inString, aInfo.outString,
                             aInfo.maxLength);
     case EditSubAction::setText:
       UndefineCaretBidiLevel();
       return WillSetText(aCancel, aHandled, aInfo.inString,
@@ -827,17 +827,17 @@ TextEditRules::WillInsertText(EditSubAct
                                                    betterInsertionPoint);
     if (NS_WARN_IF(!CanHandleEditAction())) {
       return NS_ERROR_EDITOR_DESTROYED;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   } else {
-    // aEditSubAction == EditSubAction::insertText
+    // aEditSubAction == EditSubAction::eInsertText
 
     // don't change my selection in subtransactions
     AutoTransactionsConserveSelection dontChangeMySelection(&TextEditorRef());
 
     EditorRawDOMPoint pointAfterStringInserted;
     rv = TextEditorRef().InsertTextWithTransaction(*doc, *outString,
                                                    atStartOfSelection,
                                                    &pointAfterStringInserted);
--- a/editor/libeditor/TextEditRules.h
+++ b/editor/libeditor/TextEditRules.h
@@ -151,17 +151,17 @@ protected:
   // TextEditRules implementation methods
 
   /**
    * Called before inserting text.
    * This method may actually inserts text into the editor.  Therefore, this
    * might cause destroying the editor.
    *
    * @param aEditSubAction      Must be EditSubAction::insertIMEText or
-   *                            EditSubAction::insertText.
+   *                            EditSubAction::eInsertText.
    * @param aCancel             Returns true if the operation is canceled.
    * @param aHandled            Returns true if the edit action is handled.
    * @param inString            String to be inserted.
    * @param outString           String actually inserted.
    * @param aMaxLength          The maximum string length which the editor
    *                            allows to set.
    */
   MOZ_MUST_USE nsresult
@@ -530,17 +530,17 @@ public:
     , entireList(false)
     , bulletType(nullptr)
     , alignType(nullptr)
     , blockType(nullptr)
   {}
 
   EditSubAction mEditSubAction;
 
-  // EditSubAction::insertText / EditSubAction::insertIMEText
+  // EditSubAction::eInsertText / EditSubAction::insertIMEText
   const nsAString* inString;
   nsAString* outString;
   const nsAString* outputFormat;
   int32_t maxLength;
 
   // EditSubAction::outputText
   uint32_t flags;
 
--- a/editor/libeditor/TextEditor.cpp
+++ b/editor/libeditor/TextEditor.cpp
@@ -943,17 +943,17 @@ TextEditor::InsertTextAsAction(const nsA
 {
   if (!mRules) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   // Protect the edit rules object from dying
   RefPtr<TextEditRules> rules(mRules);
 
-  EditSubAction editSubAction = EditSubAction::insertText;
+  EditSubAction editSubAction = EditSubAction::eInsertText;
   if (ShouldHandleIMEComposition()) {
     editSubAction = EditSubAction::insertIMEText;
   }
 
   AutoPlaceholderBatch batch(this, nullptr);
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
                                       *this, editSubAction, nsIEditor::eNext);
 
@@ -1860,17 +1860,17 @@ TextEditor::InsertAsQuotation(const nsAS
   }
 
   // get selection
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   AutoPlaceholderBatch beginBatching(this);
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
-                                      *this, EditSubAction::insertText,
+                                      *this, EditSubAction::eInsertText,
                                       nsIEditor::eNext);
 
   // give rules a chance to handle or cancel
   EditSubActionInfo subActionInfo(EditSubAction::insertElement);
   bool cancel, handled;
   rv = rules->WillDoAction(selection, subActionInfo, &cancel, &handled);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -169,18 +169,19 @@ mozInlineSpellStatus::InitForEditorChang
                                 aPreviousNode, aPreviousOffset);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
   // On insert save this range: DoSpellCheck optimizes things in this range.
   // Otherwise, just leave this nullptr.
-  if (aEditSubAction == EditSubAction::insertText)
+  if (aEditSubAction == EditSubAction::eInsertText) {
     mCreatedRange = mRange;
+  }
 
   // if we were given a range, we need to expand our range to encompass it
   if (aStartNode && aEndNode) {
     cmpResult = mRange->ComparePoint(*aStartNode, aStartOffset, errorResult);
     if (NS_WARN_IF(errorResult.Failed())) {
       return errorResult.StealNSResult();
     }
     if (cmpResult < 0) { // given range starts before