| 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 37d580988a66721c7a47080dc5be34df2daf7d23..ca4e8edc2e9ff882f525ec6fcda9ab5bb6d1ad30 100644
|
| --- a/components/constrained_window/constrained_window_views.cc
|
| +++ b/components/constrained_window/constrained_window_views.cc
|
| @@ -18,6 +18,11 @@
|
| #include "ui/views/widget/widget_observer.h"
|
| #include "ui/views/window/dialog_delegate.h"
|
|
|
| +#if defined(USE_AURA)
|
| +#include "ui/aura/window.h"
|
| +#include "ui/aura/window_targeter.h"
|
| +#endif
|
| +
|
| using web_modal::ModalDialogHost;
|
| using web_modal::ModalDialogHostObserver;
|
|
|
| @@ -96,6 +101,20 @@ void UpdateModalDialogPosition(views::Widget* widget,
|
| position +=
|
| views::Widget::GetWidgetForNativeView(dialog_host->GetHostView())->
|
| GetClientAreaBoundsInScreen().OffsetFromOrigin();
|
| + } else {
|
| +#if defined(USE_AURA)
|
| + // Prevents widgets that extend outside the parent window from having their
|
| + // horizontal position centered on the center of the parent window. Instead,
|
| + // positions top left corner in parent top left corner so widget extends
|
| + // below and to the right of the parent window.
|
| + if (widget->GetNativeWindowProperty(aura::kHasIndependentBoundsKey)) {
|
| + gfx::Rect bound = dialog_host->GetHostView()->GetBoundsInScreen();
|
| + if (bound.width() - border->GetInsets().left() < size.width()) {
|
| + position.set_x(position.x() + (size.width() - bound.width()) / 2 +
|
| + border->GetInsets().left());
|
| + }
|
| + }
|
| +#endif
|
| }
|
|
|
| widget->SetBounds(gfx::Rect(position, size));
|
| @@ -122,7 +141,15 @@ void UpdateWebContentsModalDialogPosition(
|
| // Border may be null during widget initialization.
|
| if (border)
|
| max_size.Enlarge(0, border->GetInsets().top());
|
| - size.SetToMin(max_size);
|
| +#if defined(USE_AURA)
|
| + bool has_independent_bounds =
|
| + widget->GetNativeWindowProperty(aura::kHasIndependentBoundsKey) !=
|
| + nullptr;
|
| +#else
|
| + bool has_independent_bounds = false;
|
| +#endif
|
| + if (!has_independent_bounds)
|
| + size.SetToMin(max_size);
|
| UpdateModalDialogPosition(widget, dialog_host, size);
|
| }
|
|
|
| @@ -145,6 +172,19 @@ views::Widget* ShowWebModalDialogViews(
|
| return widget;
|
| }
|
|
|
| +views::Widget* ShowNonClippedWebModalDialogViews(
|
| + views::WidgetDelegate* dialog,
|
| + content::WebContents* initiator_web_contents) {
|
| + DCHECK(constrained_window_views_client);
|
| + // For embedded WebContents, use the embedder's WebContents for constrained
|
| + // window.
|
| + content::WebContents* web_contents =
|
| + guest_view::GuestViewBase::GetTopLevelWebContents(initiator_web_contents);
|
| + views::Widget* widget = CreateWebModalDialogViews(dialog, web_contents);
|
| + ShowNonClippedModalDialog(widget->GetNativeWindow(), web_contents);
|
| + return widget;
|
| +}
|
| +
|
| views::Widget* CreateWebModalDialogViews(views::WidgetDelegate* dialog,
|
| content::WebContents* web_contents) {
|
| DCHECK_EQ(ui::MODAL_TYPE_CHILD, dialog->GetModalType());
|
| @@ -191,4 +231,4 @@ views::Widget* CreateBrowserModalDialogViews(views::DialogDelegate* dialog,
|
| return widget;
|
| }
|
|
|
| -} // namespace constrained window
|
| +} // namespace constrained_window
|
|
|