diff --git a/editor/libeditor/nsHTMLEditRules.cpp b/editor/libeditor/nsHTMLEditRules.cpp index d14a87190c65..0e5691d84eca 100644 --- a/editor/libeditor/nsHTMLEditRules.cpp +++ b/editor/libeditor/nsHTMLEditRules.cpp @@ -3019,7 +3019,7 @@ nsHTMLEditRules::WillMakeList(Selection* aSelection, for (auto& curNode : arrayOfNodes) { // if curNode is not a Break or empty inline, we're done if (!nsTextEditUtils::IsBreak(curNode) && - !IsEmptyInline(GetAsDOMNode(curNode))) { + !IsEmptyInline(curNode)) { bOnlyBreaks = false; break; } @@ -3087,7 +3087,7 @@ nsHTMLEditRules::WillMakeList(Selection* aSelection, // here's where we actually figure out what to do nsCOMPtr newBlock; NS_ENSURE_STATE(arrayOfNodes[i]->IsContent()); - nsCOMPtr curNode = arrayOfNodes[i]->AsContent(); + OwningNonNull curNode = *arrayOfNodes[i]->AsContent(); int32_t offset; curParent = nsEditor::GetNodeLocation(curNode, &offset); @@ -3104,7 +3104,7 @@ nsHTMLEditRules::WillMakeList(Selection* aSelection, NS_ENSURE_SUCCESS(res, res); prevListItem = 0; continue; - } else if (IsEmptyInline(GetAsDOMNode(curNode))) { + } else if (IsEmptyInline(curNode)) { // if curNode is an empty inline container, delete it NS_ENSURE_STATE(mHTMLEditor); res = mHTMLEditor->DeleteNode(curNode); @@ -7776,20 +7776,19 @@ nsHTMLEditRules::SelectionEndpointInNode(nsINode* aNode, bool* aResult) return NS_OK; } -/////////////////////////////////////////////////////////////////////////// -// IsEmptyInline: return true if aNode is an empty inline container -// -// +/** + * IsEmptyInline: Return true if aNode is an empty inline container + */ bool -nsHTMLEditRules::IsEmptyInline(nsIDOMNode *aNode) +nsHTMLEditRules::IsEmptyInline(nsINode& aNode) { - if (aNode && IsInlineNode(aNode) && mHTMLEditor && - mHTMLEditor->IsContainer(aNode)) - { - bool bEmpty; - NS_ENSURE_TRUE(mHTMLEditor, false); - mHTMLEditor->IsEmptyNode(aNode, &bEmpty); - return bEmpty; + NS_ENSURE_TRUE(mHTMLEditor, false); + nsCOMPtr kungFuDeathGrip(mHTMLEditor); + + if (IsInlineNode(aNode.AsDOMNode()) && mHTMLEditor->IsContainer(&aNode)) { + bool isEmpty = true; + mHTMLEditor->IsEmptyNode(&aNode, &isEmpty); + return isEmpty; } return false; } @@ -7818,7 +7817,7 @@ nsHTMLEditRules::ListIsEmptyLine(nsTArray>& aArrayOfNodes return false; } brCount++; - } else if (IsEmptyInline(GetAsDOMNode(node))) { + } else if (IsEmptyInline(node)) { // Empty inline, keep looking } else { return false; diff --git a/editor/libeditor/nsHTMLEditRules.h b/editor/libeditor/nsHTMLEditRules.h index 2bd93d0a50cc..0aa162913024 100644 --- a/editor/libeditor/nsHTMLEditRules.h +++ b/editor/libeditor/nsHTMLEditRules.h @@ -339,7 +339,7 @@ protected: nsresult UpdateDocChangeRange(nsRange* aRange); nsresult ConfirmSelectionInBody(); nsresult InsertMozBRIfNeeded(nsINode& aNode); - bool IsEmptyInline(nsIDOMNode *aNode); + bool IsEmptyInline(nsINode& aNode); bool ListIsEmptyLine(nsTArray>& arrayOfNodes); nsresult RemoveAlignment(nsIDOMNode * aNode, const nsAString & aAlignType, bool aChildrenOnly); nsresult MakeSureElemStartsOrEndsOnCR(nsIDOMNode *aNode, bool aStarts);