Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Unified Diff: components/constrained_window/constrained_window_views.cc

Issue 2172363002: Created min size for print preview dialog and modified to allow the Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix targeting and missing widget on unit tests. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 def5232fc9782603559d380c6499264f1c8ac6b5..f1865218e882a9d55b1bd50457400fecc7a4e4ac 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) != NULL);
Mike Wittman 2016/08/18 19:22:54 nits: no need for the enclosing parens, and compar
rbpotter 2016/08/19 01:59:09 Done.
+#else
+ bool has_independent_bounds = false;
+#endif
+ if (!has_independent_bounds) {
+ size.SetToMin(max_size);
+ }
UpdateModalDialogPosition(widget, dialog_host, size);
}
@@ -146,6 +173,20 @@ 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);
+ web_modal::WebContentsModalDialogManager::FromWebContents(web_contents)
+ ->ShowNonClippedModalDialog(widget->GetNativeWindow());
+ return widget;
+}
+
views::Widget* CreateWebModalDialogViews(views::WidgetDelegate* dialog,
content::WebContents* web_contents) {
DCHECK_EQ(ui::MODAL_TYPE_CHILD, dialog->GetModalType());
@@ -192,4 +233,4 @@ views::Widget* CreateBrowserModalDialogViews(views::DialogDelegate* dialog,
return widget;
}
-} // namespace constrained window
+} // namespace constrained_window

Powered by Google App Engine
This is Rietveld 408576698