diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 31743a9e8278..4ad726b22e61 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -1787,8 +1787,10 @@ nsPresContext::ThemeChangedInternal() // Recursively notify all remote leaf descendants that the // system theme has changed. - nsContentUtils::CallOnAllRemoteChildren(mDocument->GetWindow(), - NotifyThemeChanged, nullptr); + if (nsPIDOMWindowOuter* window = mDocument->GetWindow()) { + nsContentUtils::CallOnAllRemoteChildren(window, + NotifyThemeChanged, nullptr); + } } void @@ -2118,9 +2120,11 @@ NotifyTabSizeModeChanged(TabParent* aTab, void* aArg) void nsPresContext::SizeModeChanged(nsSizeMode aSizeMode) { - nsContentUtils::CallOnAllRemoteChildren(mDocument->GetWindow(), - NotifyTabSizeModeChanged, - &aSizeMode); + if (nsPIDOMWindowOuter* window = mDocument->GetWindow()) { + nsContentUtils::CallOnAllRemoteChildren(window, + NotifyTabSizeModeChanged, + &aSizeMode); + } MediaFeatureValuesChangedAllDocuments({ MediaFeatureChangeReason::SizeModeChange }); }