Bug 1371170 - Add non-virtual EditorBase::GetSelectionController

Tag #1375
This commit is contained in:
Matt A. Tobin 2020-04-17 05:43:47 -04:00 committed by Roy Tam
commit 8e7852efa2
2 changed files with 14 additions and 7 deletions

View file

@ -629,6 +629,17 @@ EditorBase::GetSelectionController(nsISelectionController** aSel)
{
NS_ENSURE_TRUE(aSel, NS_ERROR_NULL_POINTER);
*aSel = nullptr; // init out param
nsCOMPtr<nsISelectionController> selCon = GetSelectionController();
if (NS_WARN_IF(!selCon)) {
return NS_ERROR_NOT_INITIALIZED;
}
selCon.forget(aSel);
return NS_OK;
}
already_AddRefed<nsISelectionController>
EditorBase::GetSelectionController()
{
nsCOMPtr<nsISelectionController> selCon;
if (mSelConWeak) {
selCon = do_QueryReferent(mSelConWeak);
@ -636,11 +647,7 @@ EditorBase::GetSelectionController(nsISelectionController** aSel)
nsCOMPtr<nsIPresShell> 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<nsISelectionController> selcon;
GetSelectionController(getter_AddRefs(selcon));
nsCOMPtr<nsISelectionController> selcon = GetSelectionController();
if (!selcon) {
return NS_ERROR_NOT_INITIALIZED;
}