Bug 1382521 - Don't dereference a null PresShell in FocusTarget. r=kats

MozReview-Commit-ID: 4Zg4XrCIYZD

--HG--
extra : rebase_source : ab7527509ac7c75f4d762554233a38d8bf43478c
extra : histedit_source : 7ebdcff0fc47ce9cfc43dff6b817944fbcf9b0fd
This commit is contained in:
Ryan Hunt 2017-07-19 23:34:59 -04:00
parent 0087743f20
commit 2cac42b189

View File

@ -94,9 +94,8 @@ FocusTarget::FocusTarget(nsIPresShell* aRootPresShell,
// Key events can be retargeted to a child PresShell when there is an iframe // Key events can be retargeted to a child PresShell when there is an iframe
nsCOMPtr<nsIPresShell> presShell = GetRetargetEventPresShell(aRootPresShell); nsCOMPtr<nsIPresShell> presShell = GetRetargetEventPresShell(aRootPresShell);
nsCOMPtr<nsIDocument> document = presShell->GetDocument();
if (!presShell || !document) { if (!presShell) {
FT_LOG("Creating nil target with seq=%" PRIu64 " (can't find retargeted presshell)\n", FT_LOG("Creating nil target with seq=%" PRIu64 " (can't find retargeted presshell)\n",
aFocusSequenceNumber); aFocusSequenceNumber);
@ -104,6 +103,15 @@ FocusTarget::FocusTarget(nsIPresShell* aRootPresShell,
return; 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 // 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 // listeners or whether key events will be targeted at a different process
// through a remote browser. // through a remote browser.