Bug 1463985 - part 18: Rename EditSubAction::makeBasicBlock to EditSubAction::eCreateOrRemoveBlock r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 28 May 2018 23:01:19 +0900
changeset 801988 ed774287d875e58117244fdce7f7032d4f8ce1c2
parent 801987 e08bd3e2366189fa5134f982095d23a9a54db90c
child 801989 f2c61371dcbd897b4113feec3c188d9b23eaa0cf
push id111796
push usermasayuki@d-toybox.com
push dateThu, 31 May 2018 06:40:56 +0000
reviewersm_kato
bugs1463985
milestone62.0a1
Bug 1463985 - part 18: Rename EditSubAction::makeBasicBlock to EditSubAction::eCreateOrRemoveBlock r?m_kato MozReview-Commit-ID: 3GuscIcaWe9
editor/libeditor/EditAction.h
editor/libeditor/HTMLEditRules.cpp
editor/libeditor/HTMLEditor.cpp
editor/libeditor/TextEditRules.h
--- a/editor/libeditor/EditAction.h
+++ b/editor/libeditor/EditAction.h
@@ -77,17 +77,20 @@ enum class EditSubAction : int32_t
   // using <blockquote>, <ul>, <ol> or just margin of start edge.
   eIndent,
   eOutdent,
 
   // eSetOrClearAlignment aligns content or clears alignment with align
   // attribute or text-align.
   eSetOrClearAlignment,
 
-  makeBasicBlock,
+  // eCreateOrRemoveBlock creates new block or removes existing block and
+  // move its descendants to where the block was.
+  eCreateOrRemoveBlock,
+
   removeList,
   makeDefListItem,
   insertElement,
   insertQuotation,
 
   htmlPaste = 3012,
   loadHTML,
   resetTextProperties,
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -85,17 +85,17 @@ static bool
 IsStyleCachePreservingSubAction(EditSubAction aEditSubAction)
 {
   return aEditSubAction == EditSubAction::eDeleteSelectedContent ||
          aEditSubAction == EditSubAction::eInsertParagraphSeparator ||
          aEditSubAction == EditSubAction::eCreateOrChangeList ||
          aEditSubAction == EditSubAction::eIndent ||
          aEditSubAction == EditSubAction::eOutdent ||
          aEditSubAction == EditSubAction::eSetOrClearAlignment ||
-         aEditSubAction == EditSubAction::makeBasicBlock ||
+         aEditSubAction == EditSubAction::eCreateOrRemoveBlock ||
          aEditSubAction == EditSubAction::removeList ||
          aEditSubAction == EditSubAction::makeDefListItem ||
          aEditSubAction == EditSubAction::insertElement ||
          aEditSubAction == EditSubAction::insertQuotation;
 }
 
 static nsAtom&
 ParagraphSeparatorElement(ParagraphSeparator separator)
@@ -703,17 +703,17 @@ HTMLEditRules::WillDoAction(Selection* a
     case EditSubAction::eOutdent:
       return WillOutdent(aCancel, aHandled);
     case EditSubAction::setAbsolutePosition:
       return WillAbsolutePosition(aCancel, aHandled);
     case EditSubAction::removeAbsolutePosition:
       return WillRemoveAbsolutePosition(aCancel, aHandled);
     case EditSubAction::eSetOrClearAlignment:
       return WillAlign(*aInfo.alignType, aCancel, aHandled);
-    case EditSubAction::makeBasicBlock:
+    case EditSubAction::eCreateOrRemoveBlock:
       return WillMakeBasicBlock(*aInfo.blockType, aCancel, aHandled);
     case EditSubAction::removeList: {
       nsresult rv = WillRemoveList(aCancel, aHandled);
       if (NS_WARN_IF(rv == NS_ERROR_EDITOR_DESTROYED) ||
           NS_WARN_IF(!CanHandleEditAction())) {
         return NS_ERROR_EDITOR_DESTROYED;
       }
       if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -758,17 +758,17 @@ HTMLEditRules::DidDoAction(Selection* aS
 
   switch (aInfo.mEditSubAction) {
     case EditSubAction::eInsertText:
     case EditSubAction::eInsertParagraphSeparator:
     case EditSubAction::eInsertTextComingFromIME:
       return NS_OK;
     case EditSubAction::eDeleteSelectedContent:
       return DidDeleteSelection();
-    case EditSubAction::makeBasicBlock:
+    case EditSubAction::eCreateOrRemoveBlock:
     case EditSubAction::eIndent:
     case EditSubAction::eOutdent:
     case EditSubAction::eSetOrClearAlignment:
       return DidMakeBasicBlock();
     case EditSubAction::setAbsolutePosition: {
       nsresult rv = DidMakeBasicBlock();
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
@@ -4608,17 +4608,17 @@ HTMLEditRules::MakeBasicBlock(nsAtom& bl
     return rv;
   }
 
   AutoSelectionRestorer selectionRestorer(&SelectionRef(), &HTMLEditorRef());
   AutoTransactionsConserveSelection dontChangeMySelection(&HTMLEditorRef());
 
   // Contruct a list of nodes to act on.
   nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
-  rv = GetNodesFromSelection(EditSubAction::makeBasicBlock, arrayOfNodes,
+  rv = GetNodesFromSelection(EditSubAction::eCreateOrRemoveBlock, arrayOfNodes,
                              TouchContent::yes);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   // If nothing visible in list, make an empty block
   if (ListIsEmptyLine(arrayOfNodes)) {
     nsRange* firstRange = SelectionRef().GetRangeAt(0);
@@ -7216,17 +7216,17 @@ HTMLEditRules::GetPromotedPoint(RulesEnd
       // Don't walk past the editable section. Note that we need to check
       // before walking up to a parent because we need to return the parent
       // object, so the parent itself might not be in the editable area, but
       // it's OK if we're not performing a block-level action.
       bool blockLevelAction =
         aEditSubAction == EditSubAction::eIndent ||
         aEditSubAction == EditSubAction::eOutdent ||
         aEditSubAction == EditSubAction::eSetOrClearAlignment ||
-        aEditSubAction == EditSubAction::makeBasicBlock;
+        aEditSubAction == EditSubAction::eCreateOrRemoveBlock;
       if (!HTMLEditorRef().IsDescendantOfEditorRoot(
                              point.GetContainer()->GetParentNode()) &&
           (blockLevelAction ||
            !HTMLEditorRef().IsDescendantOfEditorRoot(point.GetContainer()))) {
         break;
       }
 
       point.Set(point.GetContainer());
@@ -7250,17 +7250,17 @@ HTMLEditRules::GetPromotedPoint(RulesEnd
   }
 
   // look ahead through any further inline nodes that aren't across a <br> from
   // us, and that are enclosed in the same block.
   // XXX Currently, we stop block-extending when finding visible <br> element.
   //     This might be different from "block-extend" of execCommand spec.
   //     However, the spec is really unclear.
   // XXX Probably, scanning only editable nodes is wrong for
-  //     EditSubAction::makeBasicBlock because it might be better to wrap
+  //     EditSubAction::eCreateOrRemoveBlock because it might be better to wrap
   //     existing inline elements even if it's non-editable.  For example,
   //     following examples with insertParagraph causes different result:
   //     * <div contenteditable>foo[]<b contenteditable="false">bar</b></div>
   //     * <div contenteditable>foo[]<b>bar</b></div>
   //     * <div contenteditable>foo[]<b contenteditable="false">bar</b>baz</div>
   //     Only in the first case, after the caret position isn't wrapped with
   //     new <div> element.
   nsCOMPtr<nsIContent> nextNode =
@@ -7530,17 +7530,17 @@ HTMLEditRules::GetNodesForOperation(
       nsTArray<OwningNonNull<nsINode>> nodes;
       iter.AppendList(UniqueFunctor(aOutArrayOfNodes), nodes);
       aOutArrayOfNodes.AppendElements(nodes);
     }
   }
 
   // Certain operations should not act on li's and td's, but rather inside
   // them.  Alter the list as needed.
-  if (aEditSubAction == EditSubAction::makeBasicBlock) {
+  if (aEditSubAction == EditSubAction::eCreateOrRemoveBlock) {
     for (int32_t i = aOutArrayOfNodes.Length() - 1; i >= 0; i--) {
       OwningNonNull<nsINode> node = aOutArrayOfNodes[i];
       if (HTMLEditUtils::IsListItem(node)) {
         int32_t j = i;
         aOutArrayOfNodes.RemoveElementAt(i);
         GetInnerContent(*node, aOutArrayOfNodes, &j);
       }
     }
@@ -7579,17 +7579,17 @@ HTMLEditRules::GetNodesForOperation(
         GetInnerContent(*node, aOutArrayOfNodes, &j, Lists::no, Tables::no);
       }
     }
   }
 
 
   // Post-process the list to break up inline containers that contain br's, but
   // only for operations that might care, like making lists or paragraphs
-  if (aEditSubAction == EditSubAction::makeBasicBlock ||
+  if (aEditSubAction == EditSubAction::eCreateOrRemoveBlock ||
       aEditSubAction == EditSubAction::eCreateOrChangeList ||
       aEditSubAction == EditSubAction::eSetOrClearAlignment ||
       aEditSubAction == EditSubAction::setAbsolutePosition ||
       aEditSubAction == EditSubAction::eIndent ||
       aEditSubAction == EditSubAction::eOutdent) {
     for (int32_t i = aOutArrayOfNodes.Length() - 1; i >= 0; i--) {
       OwningNonNull<nsINode> node = aOutArrayOfNodes[i];
       // XXX Why do we run this loop even when aTouchContent is "no"?
@@ -7761,17 +7761,17 @@ HTMLEditRules::GetDefinitionListItemType
 nsresult
 HTMLEditRules::GetParagraphFormatNodes(
                  nsTArray<OwningNonNull<nsINode>>& outArrayOfNodes)
 {
   MOZ_ASSERT(IsEditorDataAvailable());
 
   // Contruct a list of nodes to act on.
   nsresult rv =
-   GetNodesFromSelection(EditSubAction::makeBasicBlock,
+   GetNodesFromSelection(EditSubAction::eCreateOrRemoveBlock,
                          outArrayOfNodes, TouchContent::no);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   // Pre-process our list of nodes
   for (int32_t i = outArrayOfNodes.Length() - 1; i >= 0; i--) {
     OwningNonNull<nsINode> testNode = outArrayOfNodes[i];
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -2194,24 +2194,25 @@ HTMLEditor::InsertBasicBlockWithTransact
 
   // Protect the edit rules object from dying
   RefPtr<TextEditRules> rules(mRules);
 
   bool cancel, handled;
 
   AutoPlaceholderBatch beginBatching(this);
   AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
-                                      *this, EditSubAction::makeBasicBlock,
+                                      *this,
+                                      EditSubAction::eCreateOrRemoveBlock,
                                       nsIEditor::eNext);
 
   // pre-process
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
   nsDependentAtomString tagName(&aTagName);
-  EditSubActionInfo subActionInfo(EditSubAction::makeBasicBlock);
+  EditSubActionInfo subActionInfo(EditSubAction::eCreateOrRemoveBlock);
   subActionInfo.blockType = &tagName;
   nsresult rv =
    rules->WillDoAction(selection, subActionInfo, &cancel, &handled);
   if (cancel || NS_FAILED(rv)) {
     return rv;
   }
 
   if (!handled && selection->IsCollapsed()) {
--- a/editor/libeditor/TextEditRules.h
+++ b/editor/libeditor/TextEditRules.h
@@ -553,17 +553,17 @@ public:
 
   // EditSubAction::eCreateOrChangeList
   bool entireList;
   const nsAString* bulletType;
 
   // EditSubAction::eSetOrClearAlignment
   const nsAString* alignType;
 
-  // EditSubAction::makeBasicBlock
+  // EditSubAction::eCreateOrRemoveBlock
   const nsAString* blockType;
 };
 
 /**
  * Stack based helper class for managing TextEditRules::mLockRluesSniffing.
  * This class sets a bool letting us know to ignore any rules sniffing
  * that tries to occur reentrantly.
  */