diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-04 17:58:00 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-04 17:58:00 +0000 |
commit | eb0c1e406f837d590055021a753015feb67b6fc9 (patch) | |
tree | 68cba799e7116f4cae39bf014fe8ded65f705037 /chrome/browser/views | |
parent | 6d5168ee11a27e4db3047883eddfac80a9f98c9d (diff) | |
download | chromium_src-eb0c1e406f837d590055021a753015feb67b6fc9.zip chromium_src-eb0c1e406f837d590055021a753015feb67b6fc9.tar.gz chromium_src-eb0c1e406f837d590055021a753015feb67b6fc9.tar.bz2 |
Fix several issues with popup window locations:
1) Remove ConstrainedWindow::GenerateInitialBounds(), which is old and crufty and no longer relevant now that there are no unsuppressed, constrained popup windows.
2) Move the browser side positioning logic into Browser::BuildPopupWindow().
3) Fix the window.open() handler so that when we aren't given top=/left= coordinates, we don't set the window origin (allowing the browser to do something more intelligent).
BUG=1290758
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@325 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/constrained_window_impl.cc | 70 |
1 files changed, 4 insertions, 66 deletions
diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc index 96a63588..2755b34 100644 --- a/chrome/browser/views/constrained_window_impl.cc +++ b/chrome/browser/views/constrained_window_impl.cc @@ -1354,63 +1354,6 @@ void ConstrainedWindowImpl::OnWindowPosChanged(WINDOWPOS* window_pos) { // ConstrainedWindow, public: // static -void ConstrainedWindow::GenerateInitialBounds( - const gfx::Rect& initial_bounds, TabContents* parent, - gfx::Rect* window_bounds) { - // Calculate desired window bounds. Try to use the bounds of a - // non-maximized browser window; this matches other browsers' behavior. - // - // NOTE: The downside here is that, if we open multiple constrained popups, - // they'll all get the same window position, since WindowSizer uses the - // "last active browser window"'s bounds. Fixing this properly is hard, - // since we'd have to tell the WindowSizer about the window we're opening - // here, and figure out how the sizing memory and the clipping/offsetting - // behvaiors below interact. - std::wstring app_name; - - if (parent->delegate() && parent->delegate()->IsApplication() && - parent->AsWebContents() && parent->AsWebContents()->web_app()) { - app_name = parent->AsWebContents()->web_app()->name(); - } - bool maximized = false; - gfx::Rect empty_bounds; - WindowSizer::GetBrowserWindowBounds(app_name, empty_bounds, - window_bounds, &maximized); - if (initial_bounds.width() > 0) - window_bounds->set_width(initial_bounds.width()); - if (initial_bounds.height() > 0) - window_bounds->set_height(initial_bounds.height()); - - // Map desired window bounds from screen coordinates to our parent's - // coordinates. - CPoint window_origin(window_bounds->origin().ToPOINT()); - MapWindowPoints(HWND_DESKTOP, parent->GetContainerHWND(), &window_origin, - 1); - window_bounds->set_origin(gfx::Point(window_origin)); - - // Ensure some amount of the page is visible above and to the left of the - // popup, so it doesn't cover the whole content area (we use 30 px). - if (window_bounds->x() < 30) - window_bounds->set_x(30); - if (window_bounds->y() < 30) - window_bounds->set_y(30); - - // Clip the desired coordinates so they fit within the content area. - CRect parent_rect; - ::GetClientRect(parent->GetContainerHWND(), &parent_rect); - if (window_bounds->right() > parent_rect.right) - window_bounds->set_width(parent_rect.Width() - window_bounds->x()); - if (window_bounds->bottom() > parent_rect.bottom) - window_bounds->set_height(parent_rect.Height() - window_bounds->y()); - - // Don't let the window become too small (we use a 60x30 minimum size). - if (window_bounds->width() < 60) - window_bounds->set_width(60); - if (window_bounds->height() < 30) - window_bounds->set_height(30); -} - -// static ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( TabContents* parent, const gfx::Rect& initial_bounds, @@ -1433,15 +1376,10 @@ ConstrainedWindow* ConstrainedWindow::CreateConstrainedPopup( new ConstrainedWindowImpl(parent, d, constrained_contents); window->InitWindowForContents(constrained_contents, d); - gfx::Rect window_bounds; - if (initial_bounds.width() == 0 || initial_bounds.height() == 0) { - GenerateInitialBounds(initial_bounds, parent, &window_bounds); - } else { - window_bounds = window->non_client_view()-> - CalculateWindowBoundsForClientBounds( - initial_bounds, - parent->delegate()->ShouldDisplayURLField()); - } + gfx::Rect window_bounds = window->non_client_view()-> + CalculateWindowBoundsForClientBounds( + initial_bounds, + parent->delegate()->ShouldDisplayURLField()); window->InitSizeForContents(window_bounds); |