Bug 1390626 - Part 2: Avoid using QueryInterface() to convert nsIDocument to nsIDOMDocument; r=smaug
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 15 Aug 2017 16:48:42 -0400
changeset 374850 479d2103841e154147b5509cb5ade7f2ecbacc44
parent 374849 230847d248d2235fb1c2ba4ef52d3aca434527df
child 374851 4c956cbe4e5fc00f5650b902b3d551cab2728828
push id93783
push usereakhgari@mozilla.com
push dateTue, 15 Aug 2017 21:10:41 +0000
treeherdermozilla-inbound@479d2103841e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1390626
milestone57.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 1390626 - Part 2: Avoid using QueryInterface() to convert nsIDocument to nsIDOMDocument; r=smaug
dom/base/Selection.cpp
--- a/dom/base/Selection.cpp
+++ b/dom/base/Selection.cpp
@@ -3782,17 +3782,18 @@ Selection::NotifySelectionListeners()
     return NS_OK;
   }
   AutoTArray<nsCOMPtr<nsISelectionListener>, 8>
     selectionListeners(mSelectionListeners);
 
   nsCOMPtr<nsIDOMDocument> domdoc;
   nsIPresShell* ps = GetPresShell();
   if (ps) {
-    domdoc = do_QueryInterface(ps->GetDocument());
+    // Avoid using QueryInterface() here because it can be expensive.
+    domdoc = static_cast<nsIDOMDocument*>(ps->GetDocument()->AsDOMNode());
   }
 
   short reason = frameSelection->PopReason();
   for (auto& listener : selectionListeners) {
     listener->NotifySelectionChanged(domdoc, this, reason);
   }
   return NS_OK;
 }