Bug 1432186 part 17. Remove nsIDOMNode's parentNode attribute. r=mccr8
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 29 Jan 2018 23:10:52 -0500
changeset 456397 6a4d5ceffed34887ea5ac3d2d18c2fae4fe9845f
parent 456396 f2734b328291e796a9d9ab398b14c906c725bc62
child 456398 59b0998fd7a85bc49bb81e5567b702dd0e648811
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1432186
milestone60.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 1432186 part 17. Remove nsIDOMNode's parentNode attribute. r=mccr8 MozReview-Commit-ID: 4xzDwwEqnvE
dom/base/nsDocumentEncoder.cpp
dom/base/nsINode.cpp
dom/base/nsINode.h
dom/interfaces/core/nsIDOMNode.idl
editor/libeditor/EditorBase.cpp
editor/libeditor/HTMLEditRules.cpp
editor/libeditor/HTMLEditRules.h
editor/libeditor/HTMLEditUtils.cpp
editor/libeditor/HTMLEditUtils.h
editor/libeditor/HTMLEditor.cpp
editor/libeditor/HTMLEditor.h
editor/libeditor/HTMLEditorDataTransfer.cpp
editor/libeditor/HTMLTableEditor.cpp
layout/base/nsDocumentViewer.cpp
toolkit/components/find/nsFind.cpp
toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
--- a/dom/base/nsDocumentEncoder.cpp
+++ b/dom/base/nsDocumentEncoder.cpp
@@ -1545,21 +1545,21 @@ nsHTMLCopyEncoder::PromoteAncestorChain(
 
   //save the editable state of the ioNode, so we don't promote an ancestor if it has different editable state
   nsCOMPtr<nsINode> node = do_QueryInterface(*ioNode);
   bool isEditable = node->IsEditable();
 
   // loop for as long as we can promote both endpoints
   while (!done)
   {
-    rv = (*ioNode)->GetParentNode(getter_AddRefs(parent));
-    if ((NS_FAILED(rv)) || !parent)
+    node = do_QueryInterface(*ioNode);
+    parent = do_QueryInterface(node->GetParentNode());
+    if (!parent) {
       done = true;
-    else
-    {
+    } else {
       // passing parent as last param to GetPromotedPoint() allows it to promote only one level
       // up the hierarchy.
       rv = GetPromotedPoint( kStart, *ioNode, *ioStartOffset, address_of(frontNode), &frontOffset, parent);
       NS_ENSURE_SUCCESS(rv, rv);
       // then we make the same attempt with the endpoint
       rv = GetPromotedPoint( kEnd, *ioNode, *ioEndOffset, address_of(endNode), &endOffset, parent);
       NS_ENSURE_SUCCESS(rv, rv);
 
@@ -1786,31 +1786,33 @@ nsHTMLCopyEncoder::IsMozBR(Element* aEle
 }
 
 nsresult
 nsHTMLCopyEncoder::GetNodeLocation(nsIDOMNode *inChild,
                                    nsCOMPtr<nsIDOMNode> *outParent,
                                    int32_t *outOffset)
 {
   NS_ASSERTION((inChild && outParent && outOffset), "bad args");
-  nsresult result = NS_ERROR_NULL_POINTER;
   if (inChild && outParent && outOffset)
   {
-    result = inChild->GetParentNode(getter_AddRefs(*outParent));
-    if ((NS_SUCCEEDED(result)) && (*outParent))
-    {
-      nsCOMPtr<nsIContent> content = do_QueryInterface(*outParent);
-      nsCOMPtr<nsIContent> cChild = do_QueryInterface(inChild);
-      if (!cChild || !content)
-        return NS_ERROR_NULL_POINTER;
+    nsCOMPtr<nsIContent> child = do_QueryInterface(inChild);
+    if (!child) {
+      return NS_ERROR_NULL_POINTER;
+    }
 
-      *outOffset = content->ComputeIndexOf(cChild);
+    nsIContent* parent = child->GetParent();
+    if (!parent) {
+      return NS_ERROR_NULL_POINTER;
     }
+
+    *outParent = do_QueryInterface(parent);
+    *outOffset = parent->ComputeIndexOf(child);
+    return NS_OK;
   }
-  return result;
+  return NS_ERROR_NULL_POINTER;
 }
 
 bool
 nsHTMLCopyEncoder::IsRoot(nsIDOMNode* aNode)
 {
   nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
   if (!content) {
     return false;
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -509,26 +509,16 @@ bool
 nsINode::IsAnonymousContentInSVGUseSubtree() const
 {
   MOZ_ASSERT(IsInAnonymousSubtree());
   nsIContent* parent = AsContent()->GetBindingParent();
   // Watch out for parentless native-anonymous subtrees.
   return parent && parent->IsSVGElement(nsGkAtoms::use);
 }
 
-nsresult
-nsINode::GetParentNode(nsIDOMNode** aParentNode)
-{
-  *aParentNode = nullptr;
-
-  nsINode *parent = GetParentNode();
-
-  return parent ? CallQueryInterface(parent, aParentNode) : NS_OK;
-}
-
 void
 nsINode::GetNodeValueInternal(nsAString& aNodeValue)
 {
   SetDOMStringToNull(aNodeValue);
 }
 
 nsINode*
 nsINode::RemoveChild(nsINode& aOldChild, ErrorResult& aError)
--- a/dom/base/nsINode.h
+++ b/dom/base/nsINode.h
@@ -2069,20 +2069,16 @@ protected:
   }
 
 #ifdef DEBUG
   // Note: virtual so that IsInNativeAnonymousSubtree can be called accross
   // module boundaries.
   virtual void CheckNotNativeAnonymous() const;
 #endif
 
-  // These are just used to implement nsIDOMNode using
-  // NS_FORWARD_NSIDOMNODE_TO_NSINODE_HELPER and for quickstubs.
-  nsresult GetParentNode(nsIDOMNode** aParentNode);
-
   void EnsurePreInsertionValidity1(nsINode& aNewChild, nsINode* aRefChild,
                                    mozilla::ErrorResult& aError);
   void EnsurePreInsertionValidity2(bool aReplace, nsINode& aNewChild,
                                    nsINode* aRefChild,
                                    mozilla::ErrorResult& aError);
   nsINode* ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
                                  nsINode* aRefChild,
                                  mozilla::ErrorResult& aError);
@@ -2257,21 +2253,13 @@ ToSupports(nsINode* aPointer)
 }
 
 inline nsISupports*
 ToCanonicalSupports(nsINode* aPointer)
 {
   return aPointer;
 }
 
-#define NS_FORWARD_NSIDOMNODE_TO_NSINODE_HELPER(...) \
-  NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode) __VA_ARGS__ override \
-  { \
-    return nsINode::GetParentNode(aParentNode); \
-  }
+#define NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
-#define NS_FORWARD_NSIDOMNODE_TO_NSINODE \
-  NS_FORWARD_NSIDOMNODE_TO_NSINODE_HELPER(final)
-
-#define NS_FORWARD_NSIDOMNODE_TO_NSINODE_OVERRIDABLE \
-  NS_FORWARD_NSIDOMNODE_TO_NSINODE_HELPER()
+#define NS_FORWARD_NSIDOMNODE_TO_NSINODE_OVERRIDABLE
 
 #endif /* nsINode_h___ */
--- a/dom/interfaces/core/nsIDOMNode.idl
+++ b/dom/interfaces/core/nsIDOMNode.idl
@@ -26,11 +26,9 @@ interface nsIDOMNode : nsISupports
   const unsigned short      ENTITY_REFERENCE_NODE = 5;
   const unsigned short      ENTITY_NODE        = 6;
   const unsigned short      PROCESSING_INSTRUCTION_NODE = 7;
   const unsigned short      COMMENT_NODE       = 8;
   const unsigned short      DOCUMENT_NODE      = 9;
   const unsigned short      DOCUMENT_TYPE_NODE = 10;
   const unsigned short      DOCUMENT_FRAGMENT_NODE = 11;
   const unsigned short      NOTATION_NODE      = 12;
-
-  readonly attribute nsIDOMNode       parentNode;
 };
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -3555,19 +3555,19 @@ EditorBase::GetChildOffset(nsINode* aChi
 already_AddRefed<nsIDOMNode>
 EditorBase::GetNodeLocation(nsIDOMNode* aChild,
                             int32_t* outOffset)
 {
   MOZ_ASSERT(aChild && outOffset);
   NS_ENSURE_TRUE(aChild && outOffset, nullptr);
   *outOffset = -1;
 
-  nsCOMPtr<nsIDOMNode> parent;
-
-  MOZ_ALWAYS_SUCCEEDS(aChild->GetParentNode(getter_AddRefs(parent)));
+  nsCOMPtr<nsINode> child = do_QueryInterface(aChild);
+  nsCOMPtr<nsIDOMNode> parent = do_QueryInterface(child->GetParentNode());
+
   if (parent) {
     *outOffset = GetChildOffset(aChild, parent);
   }
 
   return parent.forget();
 }
 
 nsINode*
@@ -4978,26 +4978,25 @@ EditorBase::CreateRange(nsIDOMNode* aSta
 
 nsresult
 EditorBase::AppendNodeToSelectionAsRange(nsIDOMNode* aNode)
 {
   NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
 
-  nsCOMPtr<nsIDOMNode> parentNode;
-  nsresult rv = aNode->GetParentNode(getter_AddRefs(parentNode));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
+  nsCOMPtr<nsIDOMNode> parentNode = do_QueryInterface(node->GetParentNode());
   NS_ENSURE_TRUE(parentNode, NS_ERROR_NULL_POINTER);
 
   int32_t offset = GetChildOffset(aNode, parentNode);
 
   RefPtr<nsRange> range;
-  rv = CreateRange(parentNode, offset, parentNode, offset + 1,
-                   getter_AddRefs(range));
+  nsresult rv = CreateRange(parentNode, offset, parentNode, offset + 1,
+                            getter_AddRefs(range));
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(range, NS_ERROR_NULL_POINTER);
 
   return selection->AddRange(range);
 }
 
 nsresult
 EditorBase::ClearSelection()
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -999,17 +999,17 @@ HTMLEditRules::GetIndentState(bool* aCan
   NS_ENSURE_SUCCESS(rv, rv);
 
   // examine nodes in selection for blockquotes or list elements;
   // these we can outdent.  Note that we return true for canOutdent
   // if *any* of the selection is outdentable, rather than all of it.
   NS_ENSURE_STATE(mHTMLEditor);
   bool useCSS = mHTMLEditor->IsCSSEnabled();
   for (auto& curNode : Reversed(arrayOfNodes)) {
-    if (HTMLEditUtils::IsNodeThatCanOutdent(GetAsDOMNode(curNode))) {
+    if (HTMLEditUtils::IsNodeThatCanOutdent(curNode)) {
       *aCanOutdent = true;
       break;
     } else if (useCSS) {
       // we are in CSS mode, indentation is done using the margin-left (or margin-right) property
       NS_ENSURE_STATE(mHTMLEditor);
       nsAtom& marginProperty =
         MarginPropertyAtomForIndent(*mHTMLEditor->mCSSEditUtils, curNode);
       nsAutoString value;
@@ -1032,47 +1032,45 @@ HTMLEditRules::GetIndentState(bool* aCan
 
   if (!*aCanOutdent) {
     // if we haven't found something to outdent yet, also check the parents
     // of selection endpoints.  We might have a blockquote or list item
     // in the parent hierarchy.
 
     // gather up info we need for test
     NS_ENSURE_STATE(mHTMLEditor);
-    nsCOMPtr<nsIDOMNode> parent, tmp, root = do_QueryInterface(mHTMLEditor->GetRoot());
+    nsCOMPtr<nsINode> parent, root = mHTMLEditor->GetRoot();
     NS_ENSURE_TRUE(root, NS_ERROR_NULL_POINTER);
     int32_t selOffset;
     NS_ENSURE_STATE(mHTMLEditor);
     RefPtr<Selection> selection = mHTMLEditor->GetSelection();
     NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
     // test start parent hierarchy
     rv = EditorBase::GetStartNodeAndOffset(selection, getter_AddRefs(parent),
                                            &selOffset);
     NS_ENSURE_SUCCESS(rv, rv);
     while (parent && parent != root) {
       if (HTMLEditUtils::IsNodeThatCanOutdent(parent)) {
         *aCanOutdent = true;
         break;
       }
-      tmp = parent;
-      tmp->GetParentNode(getter_AddRefs(parent));
+      parent = parent->GetParentNode();
     }
 
     // test end parent hierarchy
     rv = EditorBase::GetEndNodeAndOffset(selection, getter_AddRefs(parent),
                                          &selOffset);
     NS_ENSURE_SUCCESS(rv, rv);
     while (parent && parent != root) {
       if (HTMLEditUtils::IsNodeThatCanOutdent(parent)) {
         *aCanOutdent = true;
         break;
       }
-      tmp = parent;
-      tmp->GetParentNode(getter_AddRefs(parent));
+      parent = parent->GetParentNode();
     }
   }
   return NS_OK;
 }
 
 
 nsresult
 HTMLEditRules::GetParagraphState(bool* aMixed,
@@ -1118,45 +1116,43 @@ HTMLEditRules::GetParagraphState(bool* a
                                            &selOffset);
     NS_ENSURE_SUCCESS(rv, rv);
     NS_ENSURE_TRUE(selNode, NS_ERROR_NULL_POINTER);
     arrayOfNodes.AppendElement(*selNode);
   }
 
   // remember root node
   NS_ENSURE_STATE(mHTMLEditor);
-  nsCOMPtr<nsIDOMElement> rootElem = do_QueryInterface(mHTMLEditor->GetRoot());
+  nsCOMPtr<Element> rootElem = mHTMLEditor->GetRoot();
   NS_ENSURE_TRUE(rootElem, NS_ERROR_NULL_POINTER);
 
   // loop through the nodes in selection and examine their paragraph format
   for (auto& curNode : Reversed(arrayOfNodes)) {
     nsAutoString format;
     // if it is a known format node we have it easy
     if (HTMLEditUtils::IsFormatNode(curNode)) {
-      GetFormatString(GetAsDOMNode(curNode), format);
+      GetFormatString(curNode, format);
     } else if (IsBlockNode(curNode)) {
       // this is a div or some other non-format block.
       // we should ignore it.  Its children were appended to this list
       // by AppendInnerFormatNodes() call above.  We will get needed
       // info when we examine them instead.
       continue;
     } else {
-      nsCOMPtr<nsIDOMNode> node, tmp = GetAsDOMNode(curNode);
-      tmp->GetParentNode(getter_AddRefs(node));
+      nsINode* node = curNode->GetParentNode();
       while (node) {
         if (node == rootElem) {
           format.Truncate(0);
           break;
         } else if (HTMLEditUtils::IsFormatNode(node)) {
           GetFormatString(node, format);
           break;
         }
         // else keep looking up
-        tmp = node;
-        tmp->GetParentNode(getter_AddRefs(node));
+        node = node->GetParentNode();
       }
     }
 
     // if this is the first node, we've found, remember it as the format
     if (formatStr.EqualsLiteral("x")) {
       formatStr = format;
     }
     // else make sure it matches previously found format
@@ -1197,24 +1193,23 @@ HTMLEditRules::AppendInnerFormatNodes(ns
       foundInline = true;
       aArray.AppendElement(*child);
     }
   }
   return NS_OK;
 }
 
 nsresult
-HTMLEditRules::GetFormatString(nsIDOMNode* aNode,
+HTMLEditRules::GetFormatString(nsINode* aNode,
                                nsAString& outFormat)
 {
   NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
 
   if (HTMLEditUtils::IsFormatNode(aNode)) {
-    RefPtr<nsAtom> atom = EditorBase::GetTag(aNode);
-    atom->ToString(outFormat);
+    aNode->NodeInfo()->NameAtom()->ToString(outFormat);
   } else {
     outFormat.Truncate();
   }
   return NS_OK;
 }
 
 void
 HTMLEditRules::WillInsert(Selection& aSelection,
@@ -1859,18 +1854,18 @@ HTMLEditRules::InsertBRElement(Selection
     }
     wsObj.NextVisibleNode(pointToBreak.GetContainer(), pointToBreak.Offset(),
                           address_of(visNode), &visOffset, &wsType);
     if (wsType & WSType::block) {
       brElementIsBeforeBlock = true;
     }
     // If the container of the break is a link, we need to split it and
     // insert new <br> between the split links.
-    nsCOMPtr<nsIDOMNode> linkDOMNode;
-    if (htmlEditor->IsInLink(pointToBreak.GetContainerAsDOMNode(),
+    nsCOMPtr<nsINode> linkDOMNode;
+    if (htmlEditor->IsInLink(pointToBreak.GetContainer(),
                              address_of(linkDOMNode))) {
       nsCOMPtr<Element> linkNode = do_QueryInterface(linkDOMNode);
       if (NS_WARN_IF(!linkNode)) {
         return NS_ERROR_FAILURE;
       }
       SplitNodeResult splitLinkNodeResult =
         htmlEditor->SplitNodeDeep(*linkNode, pointToBreak.AsRaw(),
                                   SplitAtEdges::eDoNotCreateEmptyContainer);
--- a/editor/libeditor/HTMLEditRules.h
+++ b/editor/libeditor/HTMLEditRules.h
@@ -276,17 +276,17 @@ protected:
   nsresult MakeBasicBlock(Selection& aSelection, nsAtom& aBlockType);
   nsresult DidMakeBasicBlock(Selection* aSelection, RulesInfo* aInfo,
                              nsresult aResult);
   nsresult DidAbsolutePosition();
   nsresult AlignInnerBlocks(nsINode& aNode, const nsAString* alignType);
   nsresult AlignBlockContents(nsIDOMNode* aNode, const nsAString* alignType);
   nsresult AppendInnerFormatNodes(nsTArray<OwningNonNull<nsINode>>& aArray,
                                   nsINode* aNode);
-  nsresult GetFormatString(nsIDOMNode* aNode, nsAString &outFormat);
+  nsresult GetFormatString(nsINode* aNode, nsAString &outFormat);
   enum class Lists { no, yes };
   enum class Tables { no, yes };
   void GetInnerContent(nsINode& aNode,
                        nsTArray<OwningNonNull<nsINode>>& aOutArrayOfNodes,
                        int32_t* aIndex, Lists aLists = Lists::yes,
                        Tables aTables = Tables::yes);
   Element* IsInListItem(nsINode* aNode);
   nsAtom& DefaultParagraphSeparator();
--- a/editor/libeditor/HTMLEditUtils.cpp
+++ b/editor/libeditor/HTMLEditUtils.cpp
@@ -80,27 +80,26 @@ HTMLEditUtils::IsFormatNode(nsINode* aNo
                                     nsGkAtoms::address);
 }
 
 /**
  * IsNodeThatCanOutdent() returns true if aNode is a list, list item or
  * blockquote.
  */
 bool
-HTMLEditUtils::IsNodeThatCanOutdent(nsIDOMNode* aNode)
+HTMLEditUtils::IsNodeThatCanOutdent(nsINode* aNode)
 {
   MOZ_ASSERT(aNode);
-  RefPtr<nsAtom> nodeAtom = EditorBase::GetTag(aNode);
-  return (nodeAtom == nsGkAtoms::ul)
-      || (nodeAtom == nsGkAtoms::ol)
-      || (nodeAtom == nsGkAtoms::dl)
-      || (nodeAtom == nsGkAtoms::li)
-      || (nodeAtom == nsGkAtoms::dd)
-      || (nodeAtom == nsGkAtoms::dt)
-      || (nodeAtom == nsGkAtoms::blockquote);
+  return aNode->IsAnyOfHTMLElements(nsGkAtoms::ul,
+                                    nsGkAtoms::ol,
+                                    nsGkAtoms::dl,
+                                    nsGkAtoms::li,
+                                    nsGkAtoms::dd,
+                                    nsGkAtoms::dt,
+                                    nsGkAtoms::blockquote);
 }
 
 /**
  * IsHeader() returns true if aNode is an html header.
  */
 bool
 HTMLEditUtils::IsHeader(nsINode& aNode)
 {
--- a/editor/libeditor/HTMLEditUtils.h
+++ b/editor/libeditor/HTMLEditUtils.h
@@ -15,17 +15,17 @@ namespace mozilla {
 
 class HTMLEditUtils final
 {
 public:
   static bool IsInlineStyle(nsINode* aNode);
   static bool IsInlineStyle(nsIDOMNode *aNode);
   static bool IsFormatNode(nsINode* aNode);
   static bool IsFormatNode(nsIDOMNode* aNode);
-  static bool IsNodeThatCanOutdent(nsIDOMNode* aNode);
+  static bool IsNodeThatCanOutdent(nsINode* aNode);
   static bool IsHeader(nsINode& aNode);
   static bool IsHeader(nsIDOMNode* aNode);
   static bool IsParagraph(nsIDOMNode* aNode);
   static bool IsListItem(nsINode* aNode);
   static bool IsListItem(nsIDOMNode* aNode);
   static bool IsTable(nsIDOMNode* aNode);
   static bool IsTable(nsINode* aNode);
   static bool IsTableRow(nsIDOMNode* aNode);
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -1623,19 +1623,17 @@ HTMLEditor::SetCaretAfterElement(nsIDOME
 
   // Be sure the element is contained in the document body
   if (!aElement || !IsDescendantOfEditorRoot(element)) {
     return NS_ERROR_NULL_POINTER;
   }
 
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
-  nsCOMPtr<nsIDOMNode>parent;
-  nsresult rv = aElement->GetParentNode(getter_AddRefs(parent));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsINode> parent = element->GetParentNode();
   NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
   // Collapse selection to just after desired element,
   EditorRawDOMPoint afterElement(element);
   if (NS_WARN_IF(!afterElement.AdvanceOffset())) {
     return NS_ERROR_FAILURE;
   }
   return selection->Collapse(afterElement);
 }
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -721,17 +721,17 @@ protected:
                                           nsIDOMDocument* aSourceDoc,
                                           nsIDOMNode* aDestinationNode,
                                           int32_t aDestOffset,
                                           bool aDoDeleteSelection) override;
   bool HavePrivateHTMLFlavor(nsIClipboard* clipboard );
   nsresult ParseCFHTML(nsCString& aCfhtml, char16_t** aStuffToPaste,
                        char16_t** aCfcontext);
 
-  bool IsInLink(nsIDOMNode* aNode, nsCOMPtr<nsIDOMNode>* outLink = nullptr);
+  bool IsInLink(nsINode* aNode, nsCOMPtr<nsINode>* outLink = nullptr);
   nsresult StripFormattingNodes(nsIContent& aNode, bool aOnlyList = false);
   nsresult CreateDOMFragmentFromPaste(const nsAString& aInputString,
                                       const nsAString& aContextStr,
                                       const nsAString& aInfoStr,
                                       nsCOMPtr<nsINode>* outFragNode,
                                       nsCOMPtr<nsINode>* outStartNode,
                                       nsCOMPtr<nsINode>* outEndNode,
                                       int32_t* outStartOffset,
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -355,17 +355,17 @@ HTMLEditor::DoInsertHTMLWithContext(cons
         TextEditUtils::IsBreak(wsObj.mEndReasonNode) &&
         !IsVisibleBRElement(wsObj.mEndReasonNode)) {
       AutoEditorDOMPointChildInvalidator lockOffset(pointToInsert);
       rv = DeleteNode(wsObj.mEndReasonNode);
       NS_ENSURE_SUCCESS(rv, rv);
     }
 
     // Remember if we are in a link.
-    bool bStartedInLink = IsInLink(pointToInsert.GetContainerAsDOMNode());
+    bool bStartedInLink = IsInLink(pointToInsert.GetContainer());
 
     // Are we in a text node? If so, split it.
     if (pointToInsert.IsInTextNode()) {
       SplitNodeResult splitNodeResult =
         SplitNodeDeep(*pointToInsert.GetContainerAsContent(),
                       pointToInsert.AsRaw(),
                       SplitAtEdges::eAllowToCreateEmptyContainer);
       if (NS_WARN_IF(splitNodeResult.Failed())) {
@@ -653,19 +653,19 @@ HTMLEditor::DoInsertHTMLWithContext(cons
             selNode = atStartReasonNode.GetContainer();
             selOffset = atStartReasonNode.Offset() + 1;
           }
         }
       }
       selection->Collapse(selNode, selOffset);
 
       // if we just pasted a link, discontinue link style
-      nsCOMPtr<nsIDOMNode> link;
+      nsCOMPtr<nsINode> link;
       if (!bStartedInLink &&
-          IsInLink(GetAsDOMNode(selNode), address_of(link))) {
+          IsInLink(selNode, address_of(link))) {
         // so, if we just pasted a link, I split it.  Why do that instead of just
         // nudging selection point beyond it?  Because it might have ended in a BR
         // that is not visible.  If so, the code above just placed selection
         // inside that.  So I split it instead.
         nsCOMPtr<nsIContent> linkContent = do_QueryInterface(link);
         NS_ENSURE_STATE(linkContent || !link);
         SplitNodeResult splitLinkResult =
           SplitNodeDeep(*linkContent, EditorRawDOMPoint(selNode, selOffset),
@@ -681,33 +681,32 @@ HTMLEditor::DoInsertHTMLWithContext(cons
       }
     }
   }
 
   return rules->DidDoAction(selection, &ruleInfo, rv);
 }
 
 bool
-HTMLEditor::IsInLink(nsIDOMNode* aNode,
-                     nsCOMPtr<nsIDOMNode>* outLink)
+HTMLEditor::IsInLink(nsINode* aNode,
+                     nsCOMPtr<nsINode>* outLink)
 {
   NS_ENSURE_TRUE(aNode, false);
   if (outLink) {
     *outLink = nullptr;
   }
-  nsCOMPtr<nsIDOMNode> tmp, node = aNode;
+  nsINode* node = aNode;
   while (node) {
     if (HTMLEditUtils::IsLink(node)) {
       if (outLink) {
         *outLink = node;
       }
       return true;
     }
-    tmp = node;
-    tmp->GetParentNode(getter_AddRefs(node));
+    node = node->GetParentNode();
   }
   return false;
 }
 
 nsresult
 HTMLEditor::StripFormattingNodes(nsIContent& aNode,
                                  bool aListOnly)
 {
--- a/editor/libeditor/HTMLTableEditor.cpp
+++ b/editor/libeditor/HTMLTableEditor.cpp
@@ -2859,28 +2859,27 @@ HTMLEditor::GetCellContext(Selection** a
     if (aRowIndex) {
       *aRowIndex = rowIndex;
     }
     if (aColIndex) {
       *aColIndex = colIndex;
     }
   }
   if (aCellParent) {
-    nsCOMPtr <nsIDOMNode> cellParent;
+    nsCOMPtr<nsINode> cellNode = do_QueryInterface(cell);
     // Get the immediate parent of the cell
-    rv = cell->GetParentNode(getter_AddRefs(cellParent));
-    NS_ENSURE_SUCCESS(rv, rv);
+    nsINode* cellParent = cellNode->GetParentNode();
     // Cell has to have a parent, so fail if not found
     NS_ENSURE_TRUE(cellParent, NS_ERROR_FAILURE);
 
-    *aCellParent = cellParent.get();
+    *aCellParent = cellParent->AsDOMNode();
     NS_ADDREF(*aCellParent);
 
     if (aCellOffset) {
-      *aCellOffset = GetChildOffset(cell, cellParent);
+      *aCellOffset = GetChildOffset(cell, cellParent->AsDOMNode());
     }
   }
 
   return NS_OK;
 }
 
 nsresult
 HTMLEditor::GetCellFromRange(nsRange* aRange,
@@ -3127,19 +3126,18 @@ HTMLEditor::SetSelectionAfterTableEdit(n
         break;
       default:
         done = true;
     }
   } while (!done);
 
   // We didn't find a cell
   // Set selection to just before the table
-  nsCOMPtr<nsIDOMNode> tableParent;
-  nsresult rv = aTable->GetParentNode(getter_AddRefs(tableParent));
-  if (NS_SUCCEEDED(rv) && tableParent) {
+  nsCOMPtr<nsINode> table = do_QueryInterface(aTable);
+  if (table->GetParentNode()) {
     nsCOMPtr<nsIContent> table = do_QueryInterface(aTable);
     if (NS_WARN_IF(!table)) {
       return;
     }
     EditorRawDOMPoint atTable(table);
     if (NS_WARN_IF(!atTable.IsSetAndValid())) {
       return;
     }
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -3663,37 +3663,36 @@ nsresult
 nsDocumentViewer::GetPopupLinkNode(nsIDOMNode** aNode)
 {
   NS_ENSURE_ARG_POINTER(aNode);
 
   // you get null unless i say so
   *aNode = nullptr;
 
   // find popup node
-  nsCOMPtr<nsIDOMNode> node;
-  nsresult rv = GetPopupNode(getter_AddRefs(node));
+  nsCOMPtr<nsIDOMNode> domNode;
+  nsresult rv = GetPopupNode(getter_AddRefs(domNode));
   NS_ENSURE_SUCCESS(rv, rv);
 
+  nsCOMPtr<nsINode> node = do_QueryInterface(domNode);
+
   // find out if we have a link in our ancestry
   while (node) {
-
     nsCOMPtr<nsIContent> content(do_QueryInterface(node));
     if (content) {
       nsCOMPtr<nsIURI> hrefURI = content->GetHrefURI();
       if (hrefURI) {
-        *aNode = node;
+        *aNode = node->AsDOMNode();
         NS_IF_ADDREF(*aNode); // addref
         return NS_OK;
       }
     }
 
     // get our parent and keep trying...
-    nsCOMPtr<nsIDOMNode> parentNode;
-    node->GetParentNode(getter_AddRefs(parentNode));
-    node = parentNode;
+    node = node->GetParentNode();
   }
 
   // if we have no node, fail
   return NS_ERROR_FAILURE;
 }
 
 // GetPopupLinkNode: return popup image node or fail
 nsresult
--- a/toolkit/components/find/nsFind.cpp
+++ b/toolkit/components/find/nsFind.cpp
@@ -894,27 +894,28 @@ nsFind::SkipNode(nsIContent* aContent)
 
   return false;
 #endif /* HAVE_BIDI_ITERATOR */
 }
 
 nsresult
 nsFind::GetBlockParent(nsIDOMNode* aNode, nsIDOMNode** aParent)
 {
-  while (aNode) {
-    nsCOMPtr<nsIDOMNode> parent;
-    nsresult rv = aNode->GetParentNode(getter_AddRefs(parent));
-    NS_ENSURE_SUCCESS(rv, rv);
-    nsCOMPtr<nsIContent> content(do_QueryInterface(parent));
-    if (content && IsBlockNode(content)) {
-      *aParent = parent;
+  nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
+  // non-nsCOMPtr temporary so we don't keep addrefing/releasing as we
+  // go up the tree.
+  nsINode* curNode = node;
+  while (curNode) {
+    nsIContent* parent = curNode->GetParent();
+    if (parent && IsBlockNode(parent)) {
+      *aParent = parent->AsDOMNode();
       NS_ADDREF(*aParent);
       return NS_OK;
     }
-    aNode = parent;
+    curNode = parent;
   }
   return NS_ERROR_FAILURE;
 }
 
 // Call ResetAll before returning, to remove all references to external objects.
 void
 nsFind::ResetAll()
 {
--- a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
+++ b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
@@ -564,18 +564,19 @@ nsTypeAheadFind::FindItNow(nsIPresShell 
                 shouldFocusEditableElement = true;
             }
           }
         }
 
         // We may be inside an editable element, and therefore the selection
         // may be controlled by a different selection controller.  Walk up the
         // chain of parent nodes to see if we find one.
-        nsCOMPtr<nsIDOMNode> node;
-        returnRange->GetStartContainer(getter_AddRefs(node));
+        nsCOMPtr<nsIDOMNode> domNode;
+        returnRange->GetStartContainer(getter_AddRefs(domNode));
+        nsCOMPtr<nsINode> node = do_QueryInterface(domNode);
         while (node) {
           nsCOMPtr<nsIDOMNSEditableElement> editable = do_QueryInterface(node);
           if (editable) {
             // Inside an editable element.  Get the correct selection
             // controller and selection.
             nsCOMPtr<nsIEditor> editor;
             editable->GetEditor(getter_AddRefs(editor));
             NS_ASSERTION(editor, "Editable element has no editor!");
@@ -594,18 +595,17 @@ nsTypeAheadFind::FindItNow(nsIPresShell 
             if (!shouldFocusEditableElement)
               break;
 
             // Otherwise move focus/caret to editable element
             if (fm)
               fm->SetFocus(mFoundEditable, 0);
             break;
           }
-          nsIDOMNode* tmp = node;
-          tmp->GetParentNode(getter_AddRefs(node));
+          node = node->GetParentNode();
         }
 
         // If we reach here without setting mFoundEditable, then something
         // besides editable elements can cause us to have an independent
         // selection controller.  I don't know whether this is possible.
         // Currently, we simply fall back to grabbing the document's selection
         // controller in this case.  Perhaps we should reject this find match
         // and search again.