Bug 1382521 - Don't dereference a null PresShell in FocusTarget. r=kats
authorRyan Hunt <rhunt@eqrion.net>
Wed, 19 Jul 2017 23:34:59 -0400
changeset 418696 7dadc8f00628dfdc63b0e9d830e609b1f6b98147
parent 418695 6b6fb9ee1cfb4c5aa7059879db194fbf49051758
child 418697 3aefc97251ca090672029f9820243b5eb712211e
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)
reviewerskats
bugs1382521
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 1382521 - Don't dereference a null PresShell in FocusTarget. r=kats MozReview-Commit-ID: 4Zg4XrCIYZD
gfx/layers/apz/src/FocusTarget.cpp
--- a/gfx/layers/apz/src/FocusTarget.cpp
+++ b/gfx/layers/apz/src/FocusTarget.cpp
@@ -89,20 +89,28 @@ FocusTarget::FocusTarget(nsIPresShell* a
   : mSequenceNumber(aFocusSequenceNumber)
   , mFocusHasKeyEventListeners(false)
 {
   MOZ_ASSERT(aRootPresShell);
   MOZ_ASSERT(NS_IsMainThread());
 
   // Key events can be retargeted to a child PresShell when there is an iframe
   nsCOMPtr<nsIPresShell> presShell = GetRetargetEventPresShell(aRootPresShell);
-  nsCOMPtr<nsIDocument> document = presShell->GetDocument();
+
+  if (!presShell) {
+    FT_LOG("Creating nil target with seq=%" PRIu64 " (can't find retargeted presshell)\n",
+           aFocusSequenceNumber);
 
-  if (!presShell || !document) {
-    FT_LOG("Creating nil target with seq=%" PRIu64 " (can't find retargeted presshell)\n",
+    mType = FocusTarget::eNone;
+    return;
+  }
+
+  nsCOMPtr<nsIDocument> document = presShell->GetDocument();
+  if (!document) {
+    FT_LOG("Creating nil target with seq=%" PRIu64 " (no document)\n",
            aFocusSequenceNumber);
 
     mType = FocusTarget::eNone;
     return;
   }
 
   // Find the focused content and use it to determine whether there are key event
   // listeners or whether key events will be targeted at a different process