OLD | NEW |
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 Loading... |
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->GetRootView()->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 // Enlarge the max size by the top border, as the dialog will be shifted |
| 578 // outside the area specified by the dialog host by this amount later in the |
| 579 // function. |
577 // Border may be null during widget initialization. | 580 // Border may be null during widget initialization. |
| 581 if (border) |
| 582 max_size.Enlarge(0, border->GetInsets().top()); |
| 583 size.SetToMin(max_size); |
| 584 |
| 585 gfx::Point position = dialog_host->GetDialogPosition(size); |
578 if (border) { | 586 if (border) { |
579 // Align the first row of pixels inside the border. This is the apparent | 587 // Align the first row of pixels inside the border. This is the apparent |
580 // top of the dialog. | 588 // top of the dialog. |
581 position.set_y(position.y() - border->GetInsets().top()); | 589 position.set_y(position.y() - border->GetInsets().top()); |
582 } | 590 } |
583 | 591 |
584 if (widget->is_top_level()) { | 592 if (widget->is_top_level()) { |
585 position += | 593 position += |
586 views::Widget::GetWidgetForNativeView(dialog_host->GetHostView())-> | 594 views::Widget::GetWidgetForNativeView(dialog_host->GetHostView())-> |
587 GetClientAreaBoundsInScreen().OffsetFromOrigin(); | 595 GetClientAreaBoundsInScreen().OffsetFromOrigin(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 #if defined(USE_ASH) | 634 #if defined(USE_ASH) |
627 ash::CustomFrameViewAsh* frame = new ash::CustomFrameViewAsh; | 635 ash::CustomFrameViewAsh* frame = new ash::CustomFrameViewAsh; |
628 frame->Init(widget); | 636 frame->Init(widget); |
629 // Always use "active" look. | 637 // Always use "active" look. |
630 frame->SetInactiveRenderingDisabled(true); | 638 frame->SetInactiveRenderingDisabled(true); |
631 return frame; | 639 return frame; |
632 #endif | 640 #endif |
633 return new ConstrainedWindowFrameView(widget, | 641 return new ConstrainedWindowFrameView(widget, |
634 browser_context->IsOffTheRecord()); | 642 browser_context->IsOffTheRecord()); |
635 } | 643 } |
OLD | NEW |