From 5a379a4b15b4da55f5fda0be56c43a85e0162f05 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 17 Apr 2020 05:43:47 -0400 Subject: Bug 1371170 - Add non-virtual EditorBase::GetSelectionController Tag #1375 --- editor/libeditor/EditorBase.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'editor/libeditor/EditorBase.cpp') diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp index 9bae5dfa0..d37070849 100644 --- a/editor/libeditor/EditorBase.cpp +++ b/editor/libeditor/EditorBase.cpp @@ -629,6 +629,17 @@ EditorBase::GetSelectionController(nsISelectionController** aSel) { NS_ENSURE_TRUE(aSel, NS_ERROR_NULL_POINTER); *aSel = nullptr; // init out param + nsCOMPtr selCon = GetSelectionController(); + if (NS_WARN_IF(!selCon)) { + return NS_ERROR_NOT_INITIALIZED; + } + selCon.forget(aSel); + return NS_OK; +} + +already_AddRefed +EditorBase::GetSelectionController() +{ nsCOMPtr selCon; if (mSelConWeak) { selCon = do_QueryReferent(mSelConWeak); @@ -636,11 +647,7 @@ EditorBase::GetSelectionController(nsISelectionController** aSel) nsCOMPtr presShell = GetPresShell(); selCon = do_QueryInterface(presShell); } - if (!selCon) { - return NS_ERROR_NOT_INITIALIZED; - } - NS_ADDREF(*aSel = selCon); - return NS_OK; + return selCon.forget(); } NS_IMETHODIMP @@ -663,8 +670,7 @@ EditorBase::GetSelection(SelectionType aSelectionType, { NS_ENSURE_TRUE(aSelection, NS_ERROR_NULL_POINTER); *aSelection = nullptr; - nsCOMPtr selcon; - GetSelectionController(getter_AddRefs(selcon)); + nsCOMPtr selcon = GetSelectionController(); if (!selcon) { return NS_ERROR_NOT_INITIALIZED; } -- cgit v1.2.3