diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 49967ff637a5..2ac428660b0d 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -9824,14 +9824,14 @@ nsGlobalWindow::ActivateOrDeactivate(bool aActivate) // Set / unset mIsActive on the top level window, which is used for the // :-moz-window-inactive pseudoclass, and its sheet (if any). nsCOMPtr mainWidget = GetMainWidget(); - if (!mainWidget) - return; - - // Get the top level widget (if the main widget is a sheet, this will - // be the sheet's top (non-sheet) parent). - nsCOMPtr topLevelWidget = mainWidget->GetSheetWindowParent(); - if (!topLevelWidget) { - topLevelWidget = mainWidget; + nsCOMPtr topLevelWidget; + if (mainWidget) { + // Get the top level widget (if the main widget is a sheet, this will + // be the sheet's top (non-sheet) parent). + topLevelWidget = mainWidget->GetSheetWindowParent(); + if (!topLevelWidget) { + topLevelWidget = mainWidget; + } } nsCOMPtr piMainWindow(