summaryrefslogtreecommitdiffstats
path: root/editor
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-04-17 05:43:47 -0400
committerMatt A. Tobin <email@mattatobin.com>2020-04-17 05:43:47 -0400
commit5a379a4b15b4da55f5fda0be56c43a85e0162f05 (patch)
treee6c9a862adf91d324d739c0c36ab6dc51b34138e /editor
parent516fd67d506b8dd3c2721dfd1aa1bbef4a2eda6f (diff)
downloadUXP-5a379a4b15b4da55f5fda0be56c43a85e0162f05.tar
UXP-5a379a4b15b4da55f5fda0be56c43a85e0162f05.tar.gz
UXP-5a379a4b15b4da55f5fda0be56c43a85e0162f05.tar.lz
UXP-5a379a4b15b4da55f5fda0be56c43a85e0162f05.tar.xz
UXP-5a379a4b15b4da55f5fda0be56c43a85e0162f05.zip
Bug 1371170 - Add non-virtual EditorBase::GetSelectionController
Tag #1375
Diffstat (limited to 'editor')
-rw-r--r--editor/libeditor/EditorBase.cpp20
-rw-r--r--editor/libeditor/EditorBase.h1
2 files changed, 14 insertions, 7 deletions
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<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;
}
diff --git a/editor/libeditor/EditorBase.h b/editor/libeditor/EditorBase.h
index 157623287..83917c150 100644
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -453,6 +453,7 @@ protected:
*/
bool EnsureComposition(WidgetCompositionEvent* aCompositionEvent);
+ already_AddRefed<nsISelectionController> GetSelectionController();
nsresult GetSelection(SelectionType aSelectionType,
nsISelection** aSelection);