| Index: components/constrained_window/constrained_window_views.cc
|
| diff --git a/components/constrained_window/constrained_window_views.cc b/components/constrained_window/constrained_window_views.cc
|
| index 3ed86ce06852a9da707d5868000e19a7103a8b7d..07c27e603a4586c91bfcfe5e82d9df8449155726 100644
|
| --- a/components/constrained_window/constrained_window_views.cc
|
| +++ b/components/constrained_window/constrained_window_views.cc
|
| @@ -87,18 +87,6 @@ void UpdateModalDialogPosition(views::Widget* widget,
|
| if (widget->HasCapture())
|
| return;
|
|
|
| - views::Widget* host_widget =
|
| - views::Widget::GetWidgetForNativeView(dialog_host->GetHostView());
|
| -
|
| - // If the host view is not backed by a Views::Widget, just update the widget
|
| - // size. This can happen on MacViews under the Cocoa browser where the window
|
| - // modal dialogs are displayed as sheets, and their position is managed by a
|
| - // ConstrainedWindowSheetController instance.
|
| - if (!host_widget) {
|
| - widget->SetSize(size);
|
| - return;
|
| - }
|
| -
|
| gfx::Point position = dialog_host->GetDialogPosition(size);
|
| views::Border* border = widget->non_client_view()->frame_view()->border();
|
| // Border may be null during widget initialization.
|
| @@ -109,7 +97,7 @@ void UpdateModalDialogPosition(views::Widget* widget,
|
| }
|
|
|
| if (widget->is_top_level())
|
| - position += host_widget->GetClientAreaBoundsInScreen().OffsetFromOrigin();
|
| + position += dialog_host->GetHostPosition().OffsetFromOrigin();
|
|
|
| widget->SetBounds(gfx::Rect(position, size));
|
| }
|
| @@ -209,13 +197,6 @@ views::Widget* CreateBrowserModalDialogViews(views::DialogDelegate* dialog,
|
| views::DialogDelegate::CreateDialogWidget(dialog, nullptr, parent_view);
|
|
|
| bool requires_positioning = dialog->ShouldUseCustomFrame();
|
| -
|
| -#if defined(OS_MACOSX)
|
| - // On Mac, window modal dialogs are displayed as sheets, so their position is
|
| - // managed by the parent window.
|
| - requires_positioning = false;
|
| -#endif
|
| -
|
| if (!requires_positioning)
|
| return widget;
|
|
|
| @@ -223,7 +204,14 @@ views::Widget* CreateBrowserModalDialogViews(views::DialogDelegate* dialog,
|
| parent ? constrained_window_views_client->GetModalDialogHost(parent)
|
| : nullptr;
|
| if (host) {
|
| +#if !defined(OS_MACOSX)
|
| + // On Mac, the host view for tab-modal dialogs may differ from the host view
|
| + // for window-modal dialogs. There is only one ModalDialogHost per window,
|
| + // designed for tab-modal dialogs, but suitable for positioning window-
|
| + // modal dialogs as well.
|
| + // On other platforms, the gfx::NativeView should match.
|
| DCHECK_EQ(parent_view, host->GetHostView());
|
| +#endif
|
| ModalDialogHostObserver* dialog_host_observer =
|
| new WidgetModalDialogHostObserverViews(
|
| host, widget, kWidgetModalDialogHostObserverViewsKey);
|
|
|