Bug 1411687 - part 0: Get rid of HTMLEditor::GetBlockNodeParent(nsIDOMNode*) r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 26 Oct 2017 22:37:45 +0900
changeset 688511 aee86cd0a8bab6b95db1243b120f046cc2b5a27c
parent 688510 56ed2824490b132bac5a64d0f1ce51b6cd000a85
child 688512 93c2eec593eb00f9e17631ac97b94dad97245b88
push id86761
push usermasayuki@d-toybox.com
push dateMon, 30 Oct 2017 05:49:37 +0000
reviewersm_kato
bugs1411687
milestone58.0a1
Bug 1411687 - part 0: Get rid of HTMLEditor::GetBlockNodeParent(nsIDOMNode*) r?m_kato Currently, HTMLEditor::GetBlockNodeParent(nsIDOMNode*) is used only by HTMLEditor::DoInsertHTMLWithContext() and there is a variable of nsINode*. So, we don't need to keep it anymore. MozReview-Commit-ID: LEWaiR5BEB9
editor/libeditor/HTMLEditor.cpp
editor/libeditor/HTMLEditor.h
editor/libeditor/HTMLEditorDataTransfer.cpp
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -759,29 +759,16 @@ HTMLEditor::GetBlockNodeParent(nsINode* 
       return p->AsElement();
     }
     p = p->GetParentNode();
   }
 
   return nullptr;
 }
 
-nsIDOMNode*
-HTMLEditor::GetBlockNodeParent(nsIDOMNode* aNode)
-{
-  nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
-
-  if (!node) {
-    NS_NOTREACHED("null node passed to GetBlockNodeParent()");
-    return nullptr;
-  }
-
-  return GetAsDOMNode(GetBlockNodeParent(node));
-}
-
 /**
  * Returns the node if it's a block, otherwise GetBlockNodeParent
  */
 Element*
 HTMLEditor::GetBlock(nsINode& aNode)
 {
   if (NodeIsBlockStatic(&aNode)) {
     return aNode.AsElement();
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -182,17 +182,16 @@ public:
    * This sets background on the appropriate container element (table, cell,)
    * or calls into nsTextEditor to set the page background.
    */
   nsresult SetCSSBackgroundColor(const nsAString& aColor);
   nsresult SetHTMLBackgroundColor(const nsAString& aColor);
 
   // Block methods moved from EditorBase
   static Element* GetBlockNodeParent(nsINode* aNode);
-  static nsIDOMNode* GetBlockNodeParent(nsIDOMNode* aNode);
   static Element* GetBlock(nsINode& aNode);
 
   void IsNextCharInNodeWhitespace(nsIContent* aContent,
                                   int32_t aOffset,
                                   bool* outIsSpace,
                                   bool* outIsNBSP,
                                   nsIContent** outNode = nullptr,
                                   int32_t* outOffset = 0);
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -421,18 +421,18 @@ HTMLEditor::DoInsertHTMLWithContext(cons
     }
 
     // Loop over the node list and paste the nodes:
     nsCOMPtr<nsIDOMNode> parentBlock, lastInsertNode, insertedContextParent;
     nsCOMPtr<nsINode> parentNodeNode = do_QueryInterface(parentNode);
     NS_ENSURE_STATE(parentNodeNode || !parentNode);
     if (IsBlockNode(parentNodeNode)) {
       parentBlock = parentNode;
-    } else {
-      parentBlock = GetBlockNodeParent(parentNode);
+    } else if (parentNodeNode) {
+      parentBlock = GetAsDOMNode(GetBlockNodeParent(parentNodeNode));
     }
 
     int32_t listCount = nodeList.Length();
     for (int32_t j = 0; j < listCount; j++) {
       bool bDidInsert = false;
       nsCOMPtr<nsIDOMNode> curNode = nodeList[j]->AsDOMNode();
 
       NS_ENSURE_TRUE(curNode, NS_ERROR_FAILURE);