diff --git a/dom/ipc/BrowserChild.cpp b/dom/ipc/BrowserChild.cpp index 986746e65d85..0f5301008820 100644 --- a/dom/ipc/BrowserChild.cpp +++ b/dom/ipc/BrowserChild.cpp @@ -3251,11 +3251,15 @@ mozilla::ipc::IPCResult BrowserChild::RecvRequestNotifyAfterRemotePaint() { mozilla::ipc::IPCResult BrowserChild::RecvUIResolutionChanged( const float& aDpi, const int32_t& aRounding, const double& aScale) { + nsCOMPtr document(GetTopLevelDocument()); + if (!document) { + return IPC_OK(); + } + ScreenIntSize oldScreenSize = GetInnerSize(); if (aDpi > 0) { mPuppetWidget->UpdateBackingScaleCache(aDpi, aRounding, aScale); } - nsCOMPtr document(GetTopLevelDocument()); RefPtr presContext = document->GetPresContext(); if (presContext) { presContext->UIResolutionChangedSync(); @@ -3278,8 +3282,12 @@ mozilla::ipc::IPCResult BrowserChild::RecvUIResolutionChanged( mozilla::ipc::IPCResult BrowserChild::RecvThemeChanged( nsTArray&& aLookAndFeelIntCache) { - LookAndFeel::SetIntCache(aLookAndFeelIntCache); nsCOMPtr document(GetTopLevelDocument()); + if (!document) { + return IPC_OK(); + } + + LookAndFeel::SetIntCache(aLookAndFeelIntCache); RefPtr presContext = document->GetPresContext(); if (presContext) { presContext->ThemeChanged();