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

Side by Side Diff: chrome/browser/ui/views/constrained_window_views.cc

Issue 22903022: Limit constrained windows to the size of the parent view. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added GetMaximumDialogSize Created 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/constrained_window_views.h" 5 #include "chrome/browser/ui/views/constrained_window_views.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "chrome/browser/themes/theme_properties.h" 9 #include "chrome/browser/themes/theme_properties.h"
10 #include "chrome/browser/ui/browser_finder.h" 10 #include "chrome/browser/ui/browser_finder.h"
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 563 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
564 title_font_ = &rb.GetFont(ui::ResourceBundle::MediumFont); 564 title_font_ = &rb.GetFont(ui::ResourceBundle::MediumFont);
565 #endif 565 #endif
566 initialized = true; 566 initialized = true;
567 } 567 }
568 } 568 }
569 569
570 void UpdateWebContentsModalDialogPosition( 570 void UpdateWebContentsModalDialogPosition(
571 views::Widget* widget, 571 views::Widget* widget,
572 web_modal::WebContentsModalDialogHost* dialog_host) { 572 web_modal::WebContentsModalDialogHost* dialog_host) {
573 gfx::Size size = widget->GetWindowBoundsInScreen().size(); 573 gfx::Size size = widget->non_client_view()->GetPreferredSize();
574 gfx::Point position = dialog_host->GetDialogPosition(size);
575 views::Border* border = 574 views::Border* border =
576 widget->non_client_view()->frame_view()->border(); 575 widget->non_client_view()->frame_view()->border();
576 gfx::Size max_size = dialog_host->GetMaximumDialogSize();
577 // Border may be null during widget initialization. 577 // Border may be null during widget initialization.
578 if (border)
579 max_size.set_height(max_size.height() + border->GetInsets().top());
580 size.SetToMin(max_size);
581
582 gfx::Point position = dialog_host->GetDialogPosition(size);
Mike Wittman 2013/08/22 17:46:10 Have you tested on other web contents modal dialog
Rune Fevang 2013/08/23 02:57:43 Yeah, works fine for all dialogs I tested on up to
578 if (border) { 583 if (border) {
579 // Align the first row of pixels inside the border. This is the apparent 584 // Align the first row of pixels inside the border. This is the apparent
580 // top of the dialog. 585 // top of the dialog.
581 position.set_y(position.y() - border->GetInsets().top()); 586 position.set_y(position.y() - border->GetInsets().top());
582 } 587 }
583 588
584 if (widget->is_top_level()) { 589 if (widget->is_top_level()) {
585 position += 590 position +=
586 views::Widget::GetWidgetForNativeView(dialog_host->GetHostView())-> 591 views::Widget::GetWidgetForNativeView(dialog_host->GetHostView())->
587 GetClientAreaBoundsInScreen().OffsetFromOrigin(); 592 GetClientAreaBoundsInScreen().OffsetFromOrigin();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 #if defined(USE_ASH) 631 #if defined(USE_ASH)
627 ash::CustomFrameViewAsh* frame = new ash::CustomFrameViewAsh; 632 ash::CustomFrameViewAsh* frame = new ash::CustomFrameViewAsh;
628 frame->Init(widget); 633 frame->Init(widget);
629 // Always use "active" look. 634 // Always use "active" look.
630 frame->SetInactiveRenderingDisabled(true); 635 frame->SetInactiveRenderingDisabled(true);
631 return frame; 636 return frame;
632 #endif 637 #endif
633 return new ConstrainedWindowFrameView(widget, 638 return new ConstrainedWindowFrameView(widget,
634 browser_context->IsOffTheRecord()); 639 browser_context->IsOffTheRecord());
635 } 640 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698