Bug 1561488 - null check document in RecvUIResolutionChanged and RecvThemeChanged, r=bdahl

These were the worrisome missing null checks I noticed, and crash-stat shows that there areactually crashes in these two places

Differential Revision: https://phabricator.services.mozilla.com/D64162

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Olli Pettay 2020-02-25 18:05:57 +00:00
Родитель 1b63bda4a8
Коммит d9972ce888
1 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -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> document(GetTopLevelDocument());
if (!document) {
return IPC_OK();
}
ScreenIntSize oldScreenSize = GetInnerSize();
if (aDpi > 0) {
mPuppetWidget->UpdateBackingScaleCache(aDpi, aRounding, aScale);
}
nsCOMPtr<Document> document(GetTopLevelDocument());
RefPtr<nsPresContext> presContext = document->GetPresContext();
if (presContext) {
presContext->UIResolutionChangedSync();
@ -3278,8 +3282,12 @@ mozilla::ipc::IPCResult BrowserChild::RecvUIResolutionChanged(
mozilla::ipc::IPCResult BrowserChild::RecvThemeChanged(
nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache) {
LookAndFeel::SetIntCache(aLookAndFeelIntCache);
nsCOMPtr<Document> document(GetTopLevelDocument());
if (!document) {
return IPC_OK();
}
LookAndFeel::SetIntCache(aLookAndFeelIntCache);
RefPtr<nsPresContext> presContext = document->GetPresContext();
if (presContext) {
presContext->ThemeChanged();