Bug 1451672 - part 22: Rename HTMLEditor::InsertNodeIntoProperAncestor() to HTMLEditor::InsertNodeIntoProperAncestorWithTransaction() r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 16 Apr 2018 23:53:46 +0900
changeset 468375 7b6165489943f380905a61ecc882b7d22dc04ce4
parent 468374 ec93f6db7e4b525495c549916a878972dfcda34d
child 468376 6ce44677c7ebdc10d467d3deb54512c8f6ea1e11
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1451672
milestone61.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 1451672 - part 22: Rename HTMLEditor::InsertNodeIntoProperAncestor() to HTMLEditor::InsertNodeIntoProperAncestorWithTransaction() r=m_kato MozReview-Commit-ID: 6O47YeSpud8
editor/libeditor/HTMLEditor.cpp
editor/libeditor/HTMLEditor.h
editor/libeditor/HTMLEditorDataTransfer.cpp
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -84,22 +84,22 @@ IsLinkTag(const nsString& s)
 
 static bool
 IsNamedAnchorTag(const nsString& s)
 {
   return s.EqualsIgnoreCase("anchor") || s.EqualsIgnoreCase("namedanchor");
 }
 
 template EditorDOMPoint
-HTMLEditor::InsertNodeIntoProperAncestor(
+HTMLEditor::InsertNodeIntoProperAncestorWithTransaction(
               nsIContent& aNode,
               const EditorDOMPoint& aPointToInsert,
               SplitAtEdges aSplitAtEdges);
 template EditorDOMPoint
-HTMLEditor::InsertNodeIntoProperAncestor(
+HTMLEditor::InsertNodeIntoProperAncestorWithTransaction(
               nsIContent& aNode,
               const EditorRawDOMPoint& aPointToInsert,
               SplitAtEdges aSplitAtEdges);
 
 HTMLEditor::HTMLEditor()
   : mCRInParagraphCreatesParagraph(false)
   , mCSSAware(false)
   , mSelectedCellIndex(0)
@@ -1573,17 +1573,17 @@ HTMLEditor::InsertElementAtSelection(nsI
       // Adjust position based on the node we are going to insert.
       EditorRawDOMPoint pointToInsert =
         GetBetterInsertionPointFor(*element, atAnchor);
       if (NS_WARN_IF(!pointToInsert.IsSet())) {
         return NS_ERROR_FAILURE;
       }
 
       EditorDOMPoint insertedPoint =
-        InsertNodeIntoProperAncestor(
+        InsertNodeIntoProperAncestorWithTransaction(
           *element, pointToInsert, SplitAtEdges::eAllowToCreateEmptyContainer);
       if (NS_WARN_IF(!insertedPoint.IsSet())) {
         return NS_ERROR_FAILURE;
       }
       // Set caret after element, but check for special case
       //  of inserting table-related elements: set in first cell instead
       if (!SetCaretInTableCell(aElement)) {
         rv = SetCaretAfterElement(aElement);
@@ -1606,17 +1606,17 @@ HTMLEditor::InsertElementAtSelection(nsI
     }
   }
   rv = rules->DidDoAction(selection, &ruleInfo, rv);
   return rv;
 }
 
 template<typename PT, typename CT>
 EditorDOMPoint
-HTMLEditor::InsertNodeIntoProperAncestor(
+HTMLEditor::InsertNodeIntoProperAncestorWithTransaction(
               nsIContent& aNode,
               const EditorDOMPointBase<PT, CT>& aPointToInsert,
               SplitAtEdges aSplitAtEdges)
 {
   if (NS_WARN_IF(!aPointToInsert.IsSet())) {
     return EditorDOMPoint();
   }
   MOZ_ASSERT(aPointToInsert.IsSetAndValid());
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -438,37 +438,38 @@ public:
 
   /**
    * OnInputLineBreak() is called when user inputs a line break with
    * Shift + Enter or something.
    */
   nsresult OnInputLineBreak();
 
   /**
-   * InsertNodeIntoProperAncestor() attempts to insert aNode into the document,
-   * at aPointToInsert.  Checks with strict dtd to see if containment is
-   * allowed.  If not allowed, will attempt to find a parent in the parent
-   * hierarchy of aPointToInsert.GetContainer() that will accept aNode as a
-   * child.  If such a parent is found, will split the document tree from
-   * aPointToInsert up to parent, and then insert aNode. aPointToInsert is then
-   * adjusted to point to the actual location that aNode was inserted at.
-   * aSplitAtEdges specifies if the splitting process is allowed to result in
-   * empty nodes.
+   * InsertNodeIntoProperAncestorWithTransaction() attempts to insert aNode
+   * into the document, at aPointToInsert.  Checks with strict dtd to see if
+   * containment is allowed.  If not allowed, will attempt to find a parent
+   * in the parent hierarchy of aPointToInsert.GetContainer() that will accept
+   * aNode as a child.  If such a parent is found, will split the document
+   * tree from aPointToInsert up to parent, and then insert aNode.
+   * aPointToInsert is then adjusted to point to the actual location that
+   * aNode was inserted at.  aSplitAtEdges specifies if the splitting process
+   * is allowed to result in empty nodes.
    *
    * @param aNode             Node to insert.
    * @param aPointToInsert    Insertion point.
    * @param aSplitAtEdges     Splitting can result in empty nodes?
    * @return                  Returns inserted point if succeeded.
    *                          Otherwise, the result is not set.
    */
   template<typename PT, typename CT>
   EditorDOMPoint
-  InsertNodeIntoProperAncestor(nsIContent& aNode,
-                               const EditorDOMPointBase<PT, CT>& aPointToInsert,
-                               SplitAtEdges aSplitAtEdges);
+  InsertNodeIntoProperAncestorWithTransaction(
+    nsIContent& aNode,
+    const EditorDOMPointBase<PT, CT>& aPointToInsert,
+    SplitAtEdges aSplitAtEdges);
 
   /**
    * Use this to assure that selection is set after attribute nodes when
    * trying to collapse selection at begining of a block node
    * e.g., when setting at beginning of a table cell
    * This will stop at a table, however, since we don't want to
    * "drill down" into nested tables.
    * @param aSelection      Optional. If null, we get current selection.
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -459,17 +459,17 @@ HTMLEditor::DoInsertHTMLWithContext(cons
       if (HTMLEditUtils::IsTableRow(curNode) &&
           HTMLEditUtils::IsTableRow(pointToInsert.GetContainer()) &&
           (HTMLEditUtils::IsTable(curNode) ||
            HTMLEditUtils::IsTable(pointToInsert.GetContainer()))) {
         for (nsCOMPtr<nsIContent> firstChild = curNode->GetFirstChild();
              firstChild;
              firstChild = curNode->GetFirstChild()) {
           EditorDOMPoint insertedPoint =
-            InsertNodeIntoProperAncestor(
+            InsertNodeIntoProperAncestorWithTransaction(
               *firstChild, pointToInsert,
               SplitAtEdges::eDoNotCreateEmptyContainer);
           if (NS_WARN_IF(!insertedPoint.IsSet())) {
             break;
           }
           bDidInsert = true;
           lastInsertNode = firstChild;
           pointToInsert = insertedPoint;
@@ -501,17 +501,17 @@ HTMLEditor::DoInsertHTMLWithContext(cons
                   // Is it an orphan node?
                 } else {
                   DeleteNodeWithTransaction(*pointToInsert.GetContainer());
                   pointToInsert.Set(pointToInsert.GetContainer());
                 }
               }
             }
             EditorDOMPoint insertedPoint =
-              InsertNodeIntoProperAncestor(
+              InsertNodeIntoProperAncestorWithTransaction(
                 *firstChild, pointToInsert,
                 SplitAtEdges::eDoNotCreateEmptyContainer);
             if (NS_WARN_IF(!insertedPoint.IsSet())) {
               break;
             }
 
             bDidInsert = true;
             lastInsertNode = firstChild;
@@ -530,17 +530,17 @@ HTMLEditor::DoInsertHTMLWithContext(cons
         }
       } else if (parentBlock && HTMLEditUtils::IsPre(parentBlock) &&
                  HTMLEditUtils::IsPre(curNode)) {
         // Check for pre's going into pre's.
         for (nsCOMPtr<nsIContent> firstChild = curNode->GetFirstChild();
              firstChild;
              firstChild = curNode->GetFirstChild()) {
           EditorDOMPoint insertedPoint =
-            InsertNodeIntoProperAncestor(
+            InsertNodeIntoProperAncestorWithTransaction(
               *firstChild, pointToInsert,
               SplitAtEdges::eDoNotCreateEmptyContainer);
           if (NS_WARN_IF(!insertedPoint.IsSet())) {
             break;
           }
 
           bDidInsert = true;
           lastInsertNode = firstChild;
@@ -549,17 +549,17 @@ HTMLEditor::DoInsertHTMLWithContext(cons
           NS_WARNING_ASSERTION(advanced,
             "Failed to advance offset from inserted point");
         }
       }
 
       if (!bDidInsert || NS_FAILED(rv)) {
         // Try to insert.
         EditorDOMPoint insertedPoint =
-          InsertNodeIntoProperAncestor(
+          InsertNodeIntoProperAncestorWithTransaction(
             *curNode->AsContent(), pointToInsert,
             SplitAtEdges::eDoNotCreateEmptyContainer);
         if (insertedPoint.IsSet()) {
           lastInsertNode = curNode->AsContent();
           pointToInsert = insertedPoint;
         }
 
         // Assume failure means no legal parent in the document hierarchy,
@@ -569,17 +569,17 @@ HTMLEditor::DoInsertHTMLWithContext(cons
              content && !insertedPoint.IsSet();
              content = content->GetParent()) {
           if (NS_WARN_IF(!content->GetParent()) ||
               NS_WARN_IF(TextEditUtils::IsBody(content->GetParent()))) {
             continue;
           }
           nsCOMPtr<nsINode> oldParent = content->GetParentNode();
           insertedPoint =
-            InsertNodeIntoProperAncestor(
+            InsertNodeIntoProperAncestorWithTransaction(
               *content->GetParent(), pointToInsert,
               SplitAtEdges::eDoNotCreateEmptyContainer);
           if (insertedPoint.IsSet()) {
             insertedContextParent = oldParent;
             pointToInsert = insertedPoint;
           }
         }
       }