diff --git a/ui/views/widget/widget_delegate.h b/ui/views/widget/widget_delegate.h index 07ba390764528..f12ce62c31afe 100644 --- a/ui/views/widget/widget_delegate.h +++ b/ui/views/widget/widget_delegate.h @@ -322,7 +322,13 @@ class VIEWS_EXPORT WidgetDelegate { // The widget's initially focused view, if any. This can only be set before // this WidgetDelegate is used to initialize a Widget. - std::optional initially_focused_view; + // raw_ptr (not bare View*) so BackupRefPtr quarantines the slot if the + // referenced View is destroyed before all GetInitiallyFocusedView() + // callers (e.g. F6/RotatePaneFocus) stop reading it. The optional wrapper + // only records "explicitly set" vs. "defaulted"; nothing observes the + // referenced View's lifetime. + std::optional> + initially_focused_view; // This is used by modal dialogs to override and constrain desired bounds // calculations.