diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp
index d2e5ef7ce37f..652df046067d 100644
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -954,8 +954,7 @@ HTMLEditor::TypedText(const nsAString& aString,
if (aAction == eTypedBR) {
// only inserts a br node
- nsCOMPtr brNode;
- return InsertBR(address_of(brNode));
+ return InsertBR();
}
return TextEditor::TypedText(aString, aAction);
@@ -1062,11 +1061,8 @@ HTMLEditor::CreateBR(nsIDOMNode* aNode,
}
nsresult
-HTMLEditor::InsertBR(nsCOMPtr* outBRNode)
+HTMLEditor::InsertBR()
{
- NS_ENSURE_TRUE(outBRNode, NS_ERROR_NULL_POINTER);
- *outBRNode = nullptr;
-
// calling it text insertion to trigger moz br treatment by rules
AutoRules beginRulesSniffing(this, EditAction::insertText, nsIEditor::eNext);
@@ -1078,27 +1074,18 @@ HTMLEditor::InsertBR(nsCOMPtr* outBRNode)
NS_ENSURE_SUCCESS(rv, rv);
}
- nsCOMPtr selNode;
+ nsCOMPtr selNode;
int32_t selOffset;
nsresult rv =
GetStartNodeAndOffset(selection, getter_AddRefs(selNode), &selOffset);
NS_ENSURE_SUCCESS(rv, rv);
- rv = CreateBR(selNode, selOffset, outBRNode);
- NS_ENSURE_SUCCESS(rv, rv);
-
- selection->SetInterlinePosition(true);
-
// position selection after br
- nsCOMPtr brNode = do_QueryInterface(*outBRNode);
- if (NS_WARN_IF(!brNode)) {
+ RefPtr br = CreateBR(selNode, selOffset, nsIEditor::eNext);
+ if (NS_WARN_IF(!br)) {
return NS_ERROR_FAILURE;
}
- EditorRawDOMPoint afterBrNode(brNode);
- if (NS_WARN_IF(!afterBrNode.AdvanceOffset())) {
- return NS_ERROR_FAILURE;
- }
- return selection->Collapse(afterBrNode);
+ return NS_OK;
}
void
diff --git a/editor/libeditor/HTMLEditor.h b/editor/libeditor/HTMLEditor.h
index 4cf1bfd39ff4..92146ea7106a 100644
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -477,7 +477,7 @@ protected:
nsCOMPtr* outBRNode,
nsIEditor::EDirection aSelect = nsIEditor::eNone) override;
- nsresult InsertBR(nsCOMPtr* outBRNode);
+ nsresult InsertBR();
// Table Editing (implemented in nsTableEditor.cpp)