Bug 1156062 part 1b - Convert some callers of nsEditor::SplitNodeDeep; r=ehsan
authorAryeh Gregor <ayg@aryeh.name>
Wed, 05 Aug 2015 18:10:09 +0300
changeset 287976 18664c635ae04af51345029c39f856cfb2537cb3
parent 287975 7323c5f4a3526ee83a28708911d964a4a6f4fb25
child 287977 1ada2f33f5a889507d7d86b45bf0651e818bf858
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1156062
milestone42.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 1156062 part 1b - Convert some callers of nsEditor::SplitNodeDeep; r=ehsan
editor/libeditor/nsHTMLDataTransfer.cpp
editor/libeditor/nsHTMLEditRules.cpp
editor/libeditor/nsHTMLEditRules.h
--- a/editor/libeditor/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/nsHTMLDataTransfer.cpp
@@ -397,19 +397,22 @@ nsHTMLEditor::DoInsertHTMLWithContext(co
     }
 
     // Remember if we are in a link.
     bool bStartedInLink = IsInLink(parentNode);
 
     // Are we in a text node? If so, split it.
     if (IsTextNode(parentNode))
     {
+      nsCOMPtr<nsIContent> parentContent = do_QueryInterface(parentNode);
+      NS_ENSURE_STATE(parentContent || !parentNode);
+      offsetOfNewNode = SplitNodeDeep(*parentContent, *parentContent,
+                                      offsetOfNewNode);
+      NS_ENSURE_STATE(offsetOfNewNode != -1);
       nsCOMPtr<nsIDOMNode> temp;
-      rv = SplitNodeDeep(parentNode, parentNode, offsetOfNewNode, &offsetOfNewNode);
-      NS_ENSURE_SUCCESS(rv, rv);
       rv = parentNode->GetParentNode(getter_AddRefs(temp));
       NS_ENSURE_SUCCESS(rv, rv);
       parentNode = temp;
     }
 
     // build up list of parents of first node in list that are either
     // lists or tables.  First examine front of paste node list.
     nsTArray<OwningNonNull<Element>> startListAndTableArray;
@@ -679,22 +682,25 @@ nsHTMLEditor::DoInsertHTMLWithContext(co
       // if we just pasted a link, discontinue link style
       nsCOMPtr<nsIDOMNode> link;
       if (!bStartedInLink && 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<nsIDOMNode> leftLink;
-        int32_t linkOffset;
-        rv = SplitNodeDeep(link, selNode, selOffset, &linkOffset, true, address_of(leftLink));
-        NS_ENSURE_SUCCESS(rv, rv);
+        nsCOMPtr<nsIContent> linkContent = do_QueryInterface(link);
+        NS_ENSURE_STATE(linkContent || !link);
+        nsCOMPtr<nsIContent> selContent = do_QueryInterface(selNode);
+        NS_ENSURE_STATE(selContent || !selNode);
+        nsCOMPtr<nsIContent> leftLink;
+        SplitNodeDeep(*linkContent, *selContent, selOffset,
+                      EmptyContainers::no, getter_AddRefs(leftLink));
         if (leftLink) {
-          selNode = GetNodeLocation(leftLink, &selOffset);
+          selNode = GetNodeLocation(GetAsDOMNode(leftLink), &selOffset);
           selection->Collapse(selNode, selOffset+1);
         }
       }
     }
   }
 
   return mRules->DidDoAction(selection, &ruleInfo, rv);
 }
--- a/editor/libeditor/nsHTMLEditRules.cpp
+++ b/editor/libeditor/nsHTMLEditRules.cpp
@@ -1645,17 +1645,17 @@ nsHTMLEditRules::StandardBreakImpl(nsIDO
   nsCOMPtr<nsIDOMNode> node(aNode);
 
   if (IsPlaintextEditor()) {
     NS_ENSURE_STATE(mHTMLEditor);
     res = mHTMLEditor->CreateBR(node, aOffset, address_of(brNode));
   } else {
     NS_ENSURE_STATE(mHTMLEditor);
     nsWSRunObject wsObj(mHTMLEditor, node, aOffset);
-    int32_t visOffset = 0, newOffset;
+    int32_t visOffset = 0;
     WSType wsType;
     nsCOMPtr<nsINode> node_(do_QueryInterface(node)), visNode;
     wsObj.PriorVisibleNode(node_, aOffset, address_of(visNode),
                            &visOffset, &wsType);
     if (wsType & WSType::block) {
       bAfterBlock = true;
     }
     wsObj.NextVisibleNode(node_, aOffset, address_of(visNode),
@@ -1666,22 +1666,22 @@ nsHTMLEditRules::StandardBreakImpl(nsIDO
     NS_ENSURE_STATE(mHTMLEditor);
     nsCOMPtr<nsIDOMNode> linkNode;
     if (mHTMLEditor->IsInLink(node, address_of(linkNode))) {
       // split the link
       nsCOMPtr<nsIDOMNode> linkParent;
       res = linkNode->GetParentNode(getter_AddRefs(linkParent));
       NS_ENSURE_SUCCESS(res, res);
       NS_ENSURE_STATE(mHTMLEditor);
-      res = mHTMLEditor->SplitNodeDeep(linkNode, node, aOffset,
-                                       &newOffset, true);
-      NS_ENSURE_SUCCESS(res, res);
-      // reset {node,aOffset} to the point where link was split
+      nsCOMPtr<nsIContent> linkNodeContent = do_QueryInterface(linkNode);
+      NS_ENSURE_STATE(linkNodeContent || !linkNode);
+      aOffset = mHTMLEditor->SplitNodeDeep(*linkNodeContent,
+          *node_->AsContent(), aOffset, nsHTMLEditor::EmptyContainers::no);
+      NS_ENSURE_STATE(aOffset != -1);
       node = linkParent;
-      aOffset = newOffset;
     }
     node_ = do_QueryInterface(node);
     nsCOMPtr<Element> br =
       wsObj.InsertBreak(address_of(node_), &aOffset, nsIEditor::eNone);
     node = GetAsDOMNode(node_);
     brNode = GetAsDOMNode(br);
     NS_ENSURE_TRUE(brNode, NS_ERROR_FAILURE);
   }
@@ -1743,20 +1743,20 @@ nsHTMLEditRules::DidInsertBreak(Selectio
   return NS_OK;
 }
 
 
 nsresult
 nsHTMLEditRules::SplitMailCites(Selection* aSelection, bool* aHandled)
 {
   NS_ENSURE_TRUE(aSelection && aHandled, NS_ERROR_NULL_POINTER);
-  nsCOMPtr<nsIDOMNode> leftCite, rightCite;
+  nsCOMPtr<nsIContent> leftCite, rightCite;
   nsCOMPtr<nsINode> selNode;
   nsCOMPtr<Element> citeNode;
-  int32_t selOffset, newOffset;
+  int32_t selOffset;
   NS_ENSURE_STATE(mHTMLEditor);
   nsresult res = mHTMLEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(selNode), &selOffset);
   NS_ENSURE_SUCCESS(res, res);
   citeNode = GetTopEnclosingMailCite(*selNode);
   NS_ENSURE_SUCCESS(res, res);
   if (citeNode)
   {
     // If our selection is just before a break, nudge it to be
@@ -1780,21 +1780,21 @@ nsHTMLEditRules::SplitMailCites(Selectio
         // it is.  so lets reset our selection to be just after it.
         NS_ENSURE_STATE(mHTMLEditor);
         selNode = mHTMLEditor->GetNodeLocation(visNode, &selOffset);
         ++selOffset;
       }
     }
 
     NS_ENSURE_STATE(mHTMLEditor);
-    res = mHTMLEditor->SplitNodeDeep(GetAsDOMNode(citeNode),
-                                     GetAsDOMNode(selNode), selOffset,
-                                     &newOffset, true, address_of(leftCite),
-                                     address_of(rightCite));
-    NS_ENSURE_SUCCESS(res, res);
+    NS_ENSURE_STATE(selNode->IsContent());
+    int32_t newOffset = mHTMLEditor->SplitNodeDeep(*citeNode,
+        *selNode->AsContent(), selOffset, nsHTMLEditor::EmptyContainers::no,
+        getter_AddRefs(leftCite), getter_AddRefs(rightCite));
+    NS_ENSURE_STATE(newOffset != -1);
     selNode = citeNode->GetParentNode();
     NS_ENSURE_STATE(mHTMLEditor);
     nsCOMPtr<Element> brNode = mHTMLEditor->CreateBR(selNode, newOffset);
     NS_ENSURE_STATE(brNode);
     // want selection before the break, and on same line
     aSelection->SetInterlinePosition(true);
     res = aSelection->Collapse(selNode, newOffset);
     NS_ENSURE_SUCCESS(res, res);
@@ -3452,25 +3452,26 @@ nsHTMLEditRules::WillMakeBasicBlock(Sele
     // get selection location
     NS_ENSURE_STATE(aSelection->RangeCount());
     nsCOMPtr<nsINode> parent = aSelection->GetRangeAt(0)->GetStartParent();
     int32_t offset = aSelection->GetRangeAt(0)->StartOffset();
     NS_ENSURE_STATE(parent);
     if (tString.EqualsLiteral("normal") ||
         tString.IsEmpty() ) // we are removing blocks (going to "body text")
     {
-      nsCOMPtr<nsIDOMNode> curBlock = parent->AsDOMNode();
-      if (!IsBlockNode(curBlock)) {
+      nsCOMPtr<Element> curBlock;
+      if (IsBlockNode(GetAsDOMNode(parent))) {
+        curBlock = parent->AsElement();
+      } else {
         NS_ENSURE_STATE(mHTMLEditor);
-        curBlock = dont_AddRef(GetAsDOMNode(
-          mHTMLEditor->GetBlockNodeParent(parent).take()));
-      }
-      nsCOMPtr<nsIDOMNode> curBlockPar;
+        curBlock = mHTMLEditor->GetBlockNodeParent(parent);
+      }
       NS_ENSURE_TRUE(curBlock, NS_ERROR_NULL_POINTER);
-      curBlock->GetParentNode(getter_AddRefs(curBlockPar));
+      nsCOMPtr<nsIDOMNode> curBlockPar =
+        GetAsDOMNode(curBlock->GetParentNode());
       if (nsHTMLEditUtils::IsFormatNode(curBlock))
       {
         // if the first editable node after selection is a br, consume it.  Otherwise
         // it gets pushed into a following block after the split, which is visually bad.
         nsCOMPtr<nsIDOMNode> brNode;
         NS_ENSURE_STATE(mHTMLEditor);
         res = mHTMLEditor->GetNextHTMLNode(parent->AsDOMNode(), offset,
                                            address_of(brNode));
@@ -3478,19 +3479,20 @@ nsHTMLEditRules::WillMakeBasicBlock(Sele
         if (brNode && nsTextEditUtils::IsBreak(brNode))
         {
           NS_ENSURE_STATE(mHTMLEditor);
           res = mHTMLEditor->DeleteNode(brNode);
           NS_ENSURE_SUCCESS(res, res);
         }
         // do the splits!
         NS_ENSURE_STATE(mHTMLEditor);
-        res = mHTMLEditor->SplitNodeDeep(curBlock, parent->AsDOMNode(), offset,
-                                         &offset, true);
-        NS_ENSURE_SUCCESS(res, res);
+        offset = mHTMLEditor->SplitNodeDeep(*curBlock, *parent->AsContent(),
+                                            offset,
+                                            nsHTMLEditor::EmptyContainers::no);
+        NS_ENSURE_STATE(offset != -1);
         // put a br at the split point
         NS_ENSURE_STATE(mHTMLEditor);
         res = mHTMLEditor->CreateBR(curBlockPar, offset, address_of(brNode));
         NS_ENSURE_SUCCESS(res, res);
         // put selection at the split point
         res = aSelection->Collapse(curBlockPar, offset);
         selectionResetter.Abort();  // to prevent selection reseter from overriding us.
         *aHandled = true;
@@ -4331,48 +4333,59 @@ nsHTMLEditRules::SplitBlock(nsIDOMNode *
                             nsIDOMNode *aStartChild,
                             nsIDOMNode *aEndChild,
                             nsCOMPtr<nsIDOMNode> *aLeftNode,
                             nsCOMPtr<nsIDOMNode> *aRightNode,
                             nsCOMPtr<nsIDOMNode> *aMiddleNode)
 {
   NS_ENSURE_TRUE(aBlock && aStartChild && aEndChild, NS_ERROR_NULL_POINTER);
 
-  nsCOMPtr<nsIDOMNode> leftNode, rightNode;
-  int32_t startOffset, endOffset, offset;
-  nsresult res;
+  nsCOMPtr<nsIContent> leftNode, rightNode;
+  int32_t startOffset, endOffset;
 
   // get split point location
   nsCOMPtr<nsIDOMNode> startParent = nsEditor::GetNodeLocation(aStartChild, &startOffset);
 
   // do the splits!
+  nsCOMPtr<nsIContent> block = do_QueryInterface(aBlock);
+  NS_ENSURE_STATE(block || !aBlock);
+  nsCOMPtr<nsIContent> startParentContent = do_QueryInterface(startParent);
+  NS_ENSURE_STATE(startParentContent || !startParent);
   NS_ENSURE_STATE(mHTMLEditor);
-  res = mHTMLEditor->SplitNodeDeep(aBlock, startParent, startOffset, &offset,
-                                   true, address_of(leftNode), address_of(rightNode));
-  NS_ENSURE_SUCCESS(res, res);
-  if (rightNode)  aBlock = rightNode;
+  mHTMLEditor->SplitNodeDeep(*block, *startParentContent, startOffset,
+                             nsHTMLEditor::EmptyContainers::no,
+                             getter_AddRefs(leftNode),
+                             getter_AddRefs(rightNode));
+  if (rightNode) {
+    aBlock = GetAsDOMNode(rightNode);
+  }
 
   // remember left portion of block if caller requested
   if (aLeftNode)
-    *aLeftNode = leftNode;
+    *aLeftNode = GetAsDOMNode(leftNode);
 
   // get split point location
   nsCOMPtr<nsIDOMNode> endParent = nsEditor::GetNodeLocation(aEndChild, &endOffset);
   endOffset++;  // want to be after lastBQChild
 
   // do the splits!
+  nsCOMPtr<nsIContent> endParentContent = do_QueryInterface(endParent);
+  NS_ENSURE_STATE(endParentContent || !endParent);
   NS_ENSURE_STATE(mHTMLEditor);
-  res = mHTMLEditor->SplitNodeDeep(aBlock, endParent, endOffset, &offset,
-                                   true, address_of(leftNode), address_of(rightNode));
-  NS_ENSURE_SUCCESS(res, res);
-  if (leftNode)  aBlock = leftNode;
+  mHTMLEditor->SplitNodeDeep(*block, *endParentContent, endOffset,
+                             nsHTMLEditor::EmptyContainers::no,
+                             getter_AddRefs(leftNode),
+                             getter_AddRefs(rightNode));
+  if (leftNode) {
+    aBlock = GetAsDOMNode(leftNode);
+  }
 
   // remember right portion of block if caller requested
   if (aRightNode)
-    *aRightNode = rightNode;
+    *aRightNode = GetAsDOMNode(rightNode);
 
   if (aMiddleNode)
     *aMiddleNode = aBlock;
 
   return NS_OK;
 }
 
 nsresult
@@ -4537,18 +4550,20 @@ nsHTMLEditRules::CreateStyleForInsertTex
   item = mHTMLEditor->mTypeInState->TakeSetProperty();
 
   if (item || relFontSize) {
     // we have at least one style to add; make a new text node to insert style
     // nodes above.
     if (mHTMLEditor->IsTextNode(node)) {
       // if we are in a text node, split it
       NS_ENSURE_STATE(mHTMLEditor);
-      res = mHTMLEditor->SplitNodeDeep(node, node, offset, &offset);
-      NS_ENSURE_SUCCESS(res, res);
+      nsCOMPtr<nsIContent> content = do_QueryInterface(node);
+      NS_ENSURE_STATE(content || !node);
+      offset = mHTMLEditor->SplitNodeDeep(*content, *content, offset);
+      NS_ENSURE_STATE(offset != -1);
       node->GetParentNode(getter_AddRefs(tmp));
       node = tmp;
     }
     if (!mHTMLEditor->IsContainer(node)) {
       return NS_OK;
     }
     nsCOMPtr<nsIDOMNode> newNode;
     nsCOMPtr<nsIDOMText> nodeAsText;
@@ -4701,48 +4716,48 @@ nsHTMLEditRules::WillAlign(Selection* aS
     int32_t offset = aSelection->GetRangeAt(0)->StartOffset();
     NS_ENSURE_STATE(parent);
 
     res = SplitAsNeeded(*nsGkAtoms::div, parent, offset);
     NS_ENSURE_SUCCESS(res, res);
     // consume a trailing br, if any.  This is to keep an alignment from
     // creating extra lines, if possible.
     NS_ENSURE_STATE(mHTMLEditor);
-    res = mHTMLEditor->GetNextHTMLNode(parent->AsDOMNode(), offset,
+    res = mHTMLEditor->GetNextHTMLNode(GetAsDOMNode(parent), offset,
                                        address_of(brNode));
     NS_ENSURE_SUCCESS(res, res);
     if (brNode && nsTextEditUtils::IsBreak(brNode))
     {
       // making use of html structure... if next node after where
       // we are putting our div is not a block, then the br we
       // found is in same block we are, so its safe to consume it.
       NS_ENSURE_STATE(mHTMLEditor);
-      res = mHTMLEditor->GetNextHTMLSibling(parent->AsDOMNode(), offset,
+      res = mHTMLEditor->GetNextHTMLSibling(GetAsDOMNode(parent), offset,
                                             address_of(sib));
       NS_ENSURE_SUCCESS(res, res);
       if (!IsBlockNode(sib))
       {
         NS_ENSURE_STATE(mHTMLEditor);
         res = mHTMLEditor->DeleteNode(brNode);
         NS_ENSURE_SUCCESS(res, res);
       }
     }
     NS_ENSURE_STATE(mHTMLEditor);
     nsCOMPtr<Element> theDiv = mHTMLEditor->CreateNode(nsGkAtoms::div, parent,
                                                        offset);
     NS_ENSURE_STATE(theDiv);
     // remember our new block for postprocessing
-    mNewBlock = theDiv->AsDOMNode();
+    mNewBlock = GetAsDOMNode(theDiv);
     // set up the alignment on the div, using HTML or CSS
     nsCOMPtr<nsIDOMElement> divElem = do_QueryInterface(theDiv);
     res = AlignBlock(divElem, alignType, true);
     NS_ENSURE_SUCCESS(res, res);
     *aHandled = true;
     // put in a moz-br so that it won't get deleted
-    res = CreateMozBR(theDiv->AsDOMNode(), 0);
+    res = CreateMozBR(GetAsDOMNode(theDiv), 0);
     NS_ENSURE_SUCCESS(res, res);
     res = aSelection->Collapse(theDiv, 0);
     selectionResetter.Abort();  // don't reset our selection in this case.
     return res;
   }
 
   // Next we detect all the transitions in the array, where a transition
   // means that adjacent nodes in the array don't have the same parent.
@@ -4831,17 +4846,17 @@ nsHTMLEditRules::WillAlign(Selection* aS
       }
 
       res = SplitAsNeeded(*nsGkAtoms::div, curParent, offset);
       NS_ENSURE_SUCCESS(res, res);
       NS_ENSURE_STATE(mHTMLEditor);
       curDiv = mHTMLEditor->CreateNode(nsGkAtoms::div, curParent, offset);
       NS_ENSURE_STATE(curDiv);
       // remember our new block for postprocessing
-      mNewBlock = curDiv->AsDOMNode();
+      mNewBlock = GetAsDOMNode(curDiv);
       // set up the alignment on the div
       nsCOMPtr<nsIDOMElement> divElem = do_QueryInterface(curDiv);
       res = AlignBlock(divElem, alignType, true);
       //nsAutoString attr(NS_LITERAL_STRING("align"));
       //res = mHTMLEditor->SetAttribute(divElem, attr, *alignType);
       //NS_ENSURE_SUCCESS(res, res);
       // curDiv is now the correct thing to put curNode in
     }
@@ -4867,17 +4882,17 @@ nsHTMLEditRules::AlignInnerBlocks(nsINod
   // Gather list of table cells or list items
   nsTArray<OwningNonNull<nsINode>> nodeArray;
   nsTableCellAndListItemFunctor functor;
   nsDOMIterator iter(aNode);
   iter.AppendList(functor, nodeArray);
 
   // Now that we have the list, align their contents as requested
   for (auto& node : nodeArray) {
-    nsresult res = AlignBlockContents(node->AsDOMNode(), alignType);
+    nsresult res = AlignBlockContents(GetAsDOMNode(node), alignType);
     NS_ENSURE_SUCCESS(res, res);
   }
 
   return NS_OK;
 }
 
 
 ///////////////////////////////////////////////////////////////////////////
@@ -5857,17 +5872,17 @@ nsHTMLEditRules::GetNodesForOperation(ns
       aOperationType == EditAction::indent ||
       aOperationType == EditAction::outdent) {
     for (int32_t i = aOutArrayOfNodes.Length() - 1; i >= 0; i--) {
       OwningNonNull<nsINode> node = aOutArrayOfNodes[i];
       if (aTouchContent == TouchContent::yes &&
           IsInlineNode(GetAsDOMNode(node)) && mHTMLEditor->IsContainer(node) &&
           !mHTMLEditor->IsTextNode(node)) {
         nsTArray<OwningNonNull<nsINode>> arrayOfInlines;
-        res = BustUpInlinesAtBRs(*node, arrayOfInlines);
+        res = BustUpInlinesAtBRs(*node->AsContent(), arrayOfInlines);
         NS_ENSURE_SUCCESS(res, res);
 
         // Put these nodes in aOutArrayOfNodes, replacing the current node
         aOutArrayOfNodes.RemoveElementAt(i);
         aOutArrayOfNodes.InsertElementsAt(i, arrayOfInlines);
       }
     }
   }
@@ -6069,62 +6084,61 @@ nsHTMLEditRules::GetParagraphFormatNodes
 
 
 ///////////////////////////////////////////////////////////////////////////
 // BustUpInlinesAtRangeEndpoints:
 //
 nsresult
 nsHTMLEditRules::BustUpInlinesAtRangeEndpoints(nsRangeStore &item)
 {
-  nsresult res = NS_OK;
   bool isCollapsed = ((item.startNode == item.endNode) && (item.startOffset == item.endOffset));
 
-  nsCOMPtr<nsIDOMNode> endInline =
-    GetHighestInlineParent(GetAsDOMNode(item.endNode));
+  nsCOMPtr<nsIContent> endInline =
+    do_QueryInterface(GetHighestInlineParent(GetAsDOMNode(item.endNode)));
 
   // if we have inline parents above range endpoints, split them
   if (endInline && !isCollapsed)
   {
-    nsCOMPtr<nsIDOMNode> resultEndNode;
-    int32_t resultEndOffset;
-    endInline->GetParentNode(getter_AddRefs(resultEndNode));
-    NS_ENSURE_STATE(mHTMLEditor);
-    res = mHTMLEditor->SplitNodeDeep(endInline, GetAsDOMNode(item.endNode),
-                                     item.endOffset, &resultEndOffset, true);
-    NS_ENSURE_SUCCESS(res, res);
+    nsCOMPtr<nsINode> resultEndNode = endInline->GetParentNode();
+    NS_ENSURE_STATE(mHTMLEditor);
+    // item.endNode must be content if endInline isn't null
+    int32_t resultEndOffset =
+      mHTMLEditor->SplitNodeDeep(*endInline, *item.endNode->AsContent(),
+                                 item.endOffset,
+                                 nsEditor::EmptyContainers::no);
+    NS_ENSURE_TRUE(resultEndOffset != -1, NS_ERROR_FAILURE);
     // reset range
-    item.endNode = do_QueryInterface(resultEndNode);
+    item.endNode = resultEndNode;
     item.endOffset = resultEndOffset;
   }
 
-  nsCOMPtr<nsIDOMNode> startInline =
-    GetHighestInlineParent(GetAsDOMNode(item.startNode));
+  nsCOMPtr<nsIContent> startInline =
+    do_QueryInterface(GetHighestInlineParent(GetAsDOMNode(item.startNode)));
 
   if (startInline)
   {
-    nsCOMPtr<nsIDOMNode> resultStartNode;
-    int32_t resultStartOffset;
-    startInline->GetParentNode(getter_AddRefs(resultStartNode));
-    NS_ENSURE_STATE(mHTMLEditor);
-    res = mHTMLEditor->SplitNodeDeep(startInline, GetAsDOMNode(item.startNode),
-                                     item.startOffset, &resultStartOffset,
-                                     true);
-    NS_ENSURE_SUCCESS(res, res);
+    nsCOMPtr<nsINode> resultStartNode = startInline->GetParentNode();
+    NS_ENSURE_STATE(mHTMLEditor);
+    int32_t resultStartOffset =
+      mHTMLEditor->SplitNodeDeep(*startInline, *item.startNode->AsContent(),
+                                 item.startOffset,
+                                 nsEditor::EmptyContainers::no);
+    NS_ENSURE_TRUE(resultStartOffset != -1, NS_ERROR_FAILURE);
     // reset range
-    item.startNode = do_QueryInterface(resultStartNode);
+    item.startNode = resultStartNode;
     item.startOffset = resultStartOffset;
   }
 
-  return res;
+  return NS_OK;
 }
 
 
 
 nsresult
-nsHTMLEditRules::BustUpInlinesAtBRs(nsINode& aNode,
+nsHTMLEditRules::BustUpInlinesAtBRs(nsIContent& aNode,
                                     nsTArray<OwningNonNull<nsINode>>& aOutArrayOfNodes)
 {
   NS_ENSURE_STATE(mHTMLEditor);
   nsCOMPtr<nsIEditor> kungFuDeathGrip(mHTMLEditor);
 
   // First build up a list of all the break nodes inside the inline container.
   nsTArray<OwningNonNull<nsINode>> arrayOfBreaks;
   nsBRNodeFunctor functor;
@@ -6134,53 +6148,51 @@ nsHTMLEditRules::BustUpInlinesAtBRs(nsIN
   // If there aren't any breaks, just put inNode itself in the array
   if (!arrayOfBreaks.Length()) {
     aOutArrayOfNodes.AppendElement(aNode);
     return NS_OK;
   }
 
   // Else we need to bust up inNode along all the breaks
   nsCOMPtr<nsINode> inlineParentNode = aNode.GetParentNode();
-  nsCOMPtr<nsIDOMNode> splitDeepNode = GetAsDOMNode(&aNode);
-  nsCOMPtr<nsIDOMNode> leftDOMNode, rightDOMNode;
+  nsCOMPtr<nsIContent> splitDeepNode = &aNode;
+  nsCOMPtr<nsIContent> leftNode, rightNode;
 
   for (uint32_t i = 0; i < arrayOfBreaks.Length(); i++) {
     OwningNonNull<Element> breakNode = *arrayOfBreaks[i]->AsElement();
     NS_ENSURE_TRUE(splitDeepNode, NS_ERROR_NULL_POINTER);
-    nsCOMPtr<nsINode> splitParentNode = breakNode->GetParentNode();
-    int32_t splitOffset = splitParentNode ?
-      splitParentNode->IndexOf(breakNode) : -1;
-
-    int32_t resultOffset;
-    nsresult res = mHTMLEditor->SplitNodeDeep(splitDeepNode,
-        GetAsDOMNode(splitParentNode), splitOffset, &resultOffset, false,
-        address_of(leftDOMNode), address_of(rightDOMNode));
-    NS_ENSURE_SUCCESS(res, res);
+    NS_ENSURE_TRUE(breakNode->GetParent(), NS_ERROR_NULL_POINTER);
+    OwningNonNull<nsIContent> splitParentNode = *breakNode->GetParent();
+    int32_t splitOffset = splitParentNode->IndexOf(breakNode);
+
+    int32_t resultOffset =
+      mHTMLEditor->SplitNodeDeep(*splitDeepNode, splitParentNode, splitOffset,
+                                 nsHTMLEditor::EmptyContainers::yes,
+                                 getter_AddRefs(leftNode),
+                                 getter_AddRefs(rightNode));
+    NS_ENSURE_STATE(resultOffset != -1);
 
     // Put left node in node list
-    if (leftDOMNode) {
+    if (leftNode) {
       // Might not be a left node.  A break might have been at the very
       // beginning of inline container, in which case SplitNodeDeep would not
       // actually split anything
-      nsCOMPtr<nsINode> leftNode = do_QueryInterface(leftDOMNode);
-      NS_ENSURE_STATE(leftNode);
       aOutArrayOfNodes.AppendElement(*leftNode);
     }
     // Move break outside of container and also put in node list
-    res = mHTMLEditor->MoveNode(breakNode, inlineParentNode, resultOffset);
+    nsresult res = mHTMLEditor->MoveNode(breakNode, inlineParentNode,
+                                         resultOffset);
     NS_ENSURE_SUCCESS(res, res);
     aOutArrayOfNodes.AppendElement(*breakNode);
 
     // Now rightNode becomes the new node to split
-    splitDeepNode = rightDOMNode;
+    splitDeepNode = rightNode;
   }
   // Now tack on remaining rightNode, if any, to the list
-  if (rightDOMNode) {
-    nsCOMPtr<nsINode> rightNode = do_QueryInterface(rightDOMNode);
-    NS_ENSURE_STATE(rightNode);
+  if (rightNode) {
     aOutArrayOfNodes.AppendElement(*rightNode);
   }
   return NS_OK;
 }
 
 
 nsCOMPtr<nsIDOMNode>
 nsHTMLEditRules::GetHighestInlineParent(nsIDOMNode* aNode)
--- a/editor/libeditor/nsHTMLEditRules.h
+++ b/editor/libeditor/nsHTMLEditRules.h
@@ -287,17 +287,17 @@ protected:
                               EntireList aEntireList,
                               TouchContent aTouchContent = TouchContent::yes);
   void GetDefinitionListItemTypes(mozilla::dom::Element* aElement, bool* aDT, bool* aDD);
   nsresult GetParagraphFormatNodes(
       nsTArray<mozilla::OwningNonNull<nsINode>>& outArrayOfNodes,
       TouchContent aTouchContent = TouchContent::yes);
   void LookInsideDivBQandList(nsTArray<mozilla::OwningNonNull<nsINode>>& aNodeArray);
   nsresult BustUpInlinesAtRangeEndpoints(nsRangeStore &inRange);
-  nsresult BustUpInlinesAtBRs(nsINode& aNode,
+  nsresult BustUpInlinesAtBRs(nsIContent& aNode,
                               nsTArray<mozilla::OwningNonNull<nsINode>>& aOutArrayOfNodes);
   nsCOMPtr<nsIDOMNode> GetHighestInlineParent(nsIDOMNode* aNode);
   void MakeTransitionList(nsTArray<mozilla::OwningNonNull<nsINode>>& aNodeArray,
                           nsTArray<bool>& aTransitionArray);
   nsresult RemoveBlockStyle(nsTArray<mozilla::OwningNonNull<nsINode>>& aNodeArray);
   nsresult ApplyBlockStyle(nsTArray<mozilla::OwningNonNull<nsINode>>& aNodeArray,
                            nsIAtom& aBlockTag);
   nsresult MakeBlockquote(nsTArray<mozilla::OwningNonNull<nsINode>>& aNodeArray);