Commit 51e91497 authored by rfevang@chromium.org's avatar rfevang@chromium.org

Fix print preview size calculation.

The size of the print preview should be based off of the available
area for dialogs, not the size of the web contents view.

BUG=

Review URL: https://chromiumcodereview.appspot.com/23460022

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221957 0039d316-1c4b-4281-b951-d872f2087c98
parent e257c2ca
......@@ -27,6 +27,7 @@
#include "chrome/common/chrome_content_client.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/url_constants.h"
#include "components/web_modal/web_contents_modal_dialog_host.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/navigation_entry.h"
......@@ -124,19 +125,22 @@ void PrintPreviewDialogDelegate::GetDialogSize(gfx::Size* size) const {
DCHECK(size);
const gfx::Size kMinDialogSize(800, 480);
const int kBorder = 25;
const int kConstrainedWindowOverlap = 3;
gfx::Rect rect;
initiator_->GetView()->GetContainerBounds(&rect);
size->set_width(std::max(rect.width(), kMinDialogSize.width()) - 2 * kBorder);
size->set_height(std::max(rect.height(), kMinDialogSize.height()) - kBorder +
kConstrainedWindowOverlap);
*size = kMinDialogSize;
Browser* browser = chrome::FindBrowserWithWebContents(initiator_);
if (browser) {
web_modal::WebContentsModalDialogHost* host =
browser->window()->GetWebContentsModalDialogHost();
if (host)
size->SetToMax(host->GetMaximumDialogSize());
}
size->Enlarge(-2 * kBorder, -kBorder);
#if defined(OS_MACOSX)
// Limit the maximum size on MacOS X.
// http://crbug.com/105815
const gfx::Size kMaxDialogSize(1000, 660);
size->set_width(std::min(size->width(), kMaxDialogSize.width()));
size->set_height(std::min(size->height(), kMaxDialogSize.height()));
size->SetToMin(kMaxDialogSize);
#endif
}
......
......@@ -322,7 +322,8 @@ class BrowserWindow : public ui::BaseWindow {
virtual FindBar* CreateFindBar() = 0;
// Return the WebContentsModalDialogHost for use in positioning web contents
// modal dialogs within the browser window.
// modal dialogs within the browser window. This can sometimes be NULL (for
// instance during tab drag on Views/Win32).
virtual web_modal::WebContentsModalDialogHost*
GetWebContentsModalDialogHost() = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment