Bug 1382917 - Avoid AddRef()ing the Range object in IMEContentObserver::InitWithEditor(); r=smaug
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 20 Jul 2017 22:55:46 -0400
changeset 419034 f39688016fcb6f5a406f34d693b9004dd37fab62
parent 419033 00e1e1732521b5c28e3ace0562f2c7cb939f353e
child 419035 abd1b9db490509a1d029ab438fe8714d28328fe4
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1382917
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1382917 - Avoid AddRef()ing the Range object in IMEContentObserver::InitWithEditor(); r=smaug
dom/events/IMEContentObserver.cpp
--- a/dom/events/IMEContentObserver.cpp
+++ b/dom/events/IMEContentObserver.cpp
@@ -11,16 +11,17 @@
 #include "mozilla/AsyncEventDispatcher.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/EventStateManager.h"
 #include "mozilla/IMEStateManager.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/TextComposition.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/dom/Element.h"
+#include "mozilla/dom/Selection.h"
 #include "nsContentUtils.h"
 #include "nsGkAtoms.h"
 #include "nsIAtom.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMRange.h"
 #include "nsIFrame.h"
@@ -328,20 +329,19 @@ IMEContentObserver::InitWithEditor(nsPre
   }
 
   selCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
                        getter_AddRefs(mSelection));
   if (NS_WARN_IF(!mSelection)) {
     return false;
   }
 
-  nsCOMPtr<nsIDOMRange> selDomRange;
-  if (NS_SUCCEEDED(mSelection->GetRangeAt(0, getter_AddRefs(selDomRange)))) {
-    nsRange* selRange = static_cast<nsRange*>(selDomRange.get());
-    if (NS_WARN_IF(!selRange) || NS_WARN_IF(!selRange->GetStartContainer())) {
+  auto selection = static_cast<mozilla::dom::Selection*>(mSelection.get());
+  if (nsRange* selRange = selection->GetRangeAt(0)) {
+    if (NS_WARN_IF(!selRange->GetStartContainer())) {
       return false;
     }
 
     mRootContent = selRange->GetStartContainer()->
                      GetSelectionRootContent(presShell);
   } else {
     mRootContent = mEditableNode->GetSelectionRootContent(presShell);
   }