Bug 1451672 - part 4: Rename EditorBase::SplitNodeImpl() to EditorBase::DoSplitNode() r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 10 Apr 2018 02:32:33 +0900
changeset 786087 7353775dea5561e0ee37aeb6f324a5f428e4c085
parent 786086 f6b7456eb2df85c8fd2601aeb480e9ada9491c28
child 786088 57a9b50d25f4838c710cf26645e74dd5441ff5a2
push id107393
push usermasayuki@d-toybox.com
push dateSat, 21 Apr 2018 04:40:12 +0000
reviewersm_kato
bugs1451672
milestone61.0a1
Bug 1451672 - part 4: Rename EditorBase::SplitNodeImpl() to EditorBase::DoSplitNode() r?m_kato EditorBase::SplitNodeImpl() is called by SplitNodeTransaction::DoTransaction() for actually splitting a node. However, "WithoutTransaction" postfix is really redundant. Perhaps, just naming DoSplitNode() is better since "Impl" isn't unclear and not useful if somebody wants to use it as a utility method and there has already been EditorBase::SplitNode() which is an override of nsIEditor::SplitNode(). It must not be good to use same name for different purpose (EditorBase::SplitNode() creates a transaction). MozReview-Commit-ID: Akjeyp52vVv
editor/libeditor/EditorBase.cpp
editor/libeditor/EditorBase.h
editor/libeditor/SplitNodeTransaction.cpp
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -3080,19 +3080,19 @@ struct SavedRange final
   RefPtr<Selection> mSelection;
   nsCOMPtr<nsINode> mStartContainer;
   nsCOMPtr<nsINode> mEndContainer;
   int32_t mStartOffset;
   int32_t mEndOffset;
 };
 
 void
-EditorBase::SplitNodeImpl(const EditorDOMPoint& aStartOfRightNode,
-                          nsIContent& aNewLeftNode,
-                          ErrorResult& aError)
+EditorBase::DoSplitNode(const EditorDOMPoint& aStartOfRightNode,
+                        nsIContent& aNewLeftNode,
+                        ErrorResult& aError)
 {
   if (NS_WARN_IF(aError.Failed())) {
     return;
   }
 
   // XXX Perhaps, aStartOfRightNode may be invalid if this is a redo
   //     operation after modifying DOM node with JS.
   if (NS_WARN_IF(!aStartOfRightNode.IsSet())) {
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -775,17 +775,17 @@ public:
    * various editor actions.
    */
   bool ArePreservingSelection();
   void PreserveSelectionAcrossActions(Selection* aSel);
   nsresult RestorePreservedSelection(Selection* aSel);
   void StopPreservingSelection();
 
   /**
-   * SplitNodeImpl() creates a new node (left node) identical to an existing
+   * DoSplitNode() creates a new node (left node) identical to an existing
    * node (right node), and split the contents between the same point in both
    * nodes.
    *
    * @param aStartOfRightNode   The point to split.  Its container will be
    *                            the right node, i.e., become the new node's
    *                            next sibling.  And the point will be start
    *                            of the right node.
    * @param aNewLeftNode        The new node called as left node, so, this
@@ -793,19 +793,19 @@ public:
    *                            previous sibling.
    * @param aError              Must have not already failed.
    *                            If succeed to insert aLeftNode before the
    *                            right node and remove unnecessary contents
    *                            (and collapse selection at end of the left
    *                            node if necessary), returns no error.
    *                            Otherwise, an error.
    */
-  void SplitNodeImpl(const EditorDOMPoint& aStartOfRightNode,
-                     nsIContent& aNewLeftNode,
-                     ErrorResult& aError);
+  void DoSplitNode(const EditorDOMPoint& aStartOfRightNode,
+                   nsIContent& aNewLeftNode,
+                   ErrorResult& aError);
 
   /**
    * JoinNodes() takes 2 nodes and merge their content|children.
    * @param aNodeToKeep   The node that will remain after the join.
    * @param aNodeToJoin   The node that will be joined with aNodeToKeep.
    *                      There is no requirement that the two nodes be of the
    *                      same type.
    * @param aParent       The parent of aNodeToKeep
--- a/editor/libeditor/SplitNodeTransaction.cpp
+++ b/editor/libeditor/SplitNodeTransaction.cpp
@@ -89,19 +89,19 @@ SplitNodeTransaction::DoTransaction()
 
   // Get the parent node
   mParent = mStartOfRightNode.GetContainer()->GetParentNode();
   if (NS_WARN_IF(!mParent)) {
     return NS_ERROR_FAILURE;
   }
 
   // Insert the new node
-  mEditorBase->SplitNodeImpl(EditorDOMPoint(mStartOfRightNode),
-                             *mNewLeftNode, error);
-  // XXX Really odd.  The result of SplitNodeImpl() is respected only when
+  mEditorBase->DoSplitNode(EditorDOMPoint(mStartOfRightNode),
+                           *mNewLeftNode, error);
+  // XXX Really odd.  The result of DoSplitNode() is respected only when
   //     we shouldn't set selection.  Otherwise, it's overridden by the
   //     result of Selection.Collapse().
   if (mEditorBase->GetShouldTxnSetSelection()) {
     NS_WARNING_ASSERTION(!mEditorBase->Destroyed(),
       "The editor has gone but SplitNodeTransaction keeps trying to modify "
       "Selection");
     RefPtr<Selection> selection = mEditorBase->GetSelection();
     if (NS_WARN_IF(!selection)) {