diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index a2e2c7919adf..90a9eee4115d 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -6982,12 +6982,20 @@ nsresult PresShell::HandleEvent(nsIFrame* aFrameForPresShell, RefPtr rootPresShell = mPresContext->IsRoot() ? this : GetRootPresShell(); if (rootPresShell && rootPresShell->mSynthMouseMoveEvent.IsPending()) { + AutoWeakFrame frameForPresShellWeak(aFrameForPresShell); RefPtr synthMouseMoveEvent = rootPresShell->mSynthMouseMoveEvent.get(); synthMouseMoveEvent->Run(); - } - if (IsDestroying()) { - return NS_OK; + if (IsDestroying()) { + return NS_OK; + } + // XXX If the frame or "this" is reframed, it might be better to + // recompute the frame. However, it could treat the user input on + // unexpected element. Therefore, we should not do that until we'd + // get a bug report caused by that. + if (MOZ_UNLIKELY(!frameForPresShellWeak.IsAlive())) { + return NS_OK; + } } break; }