summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/browser.cc15
-rw-r--r--chrome/browser/constrained_window.h6
-rw-r--r--chrome/browser/tab_contents.cc10
-rw-r--r--chrome/browser/views/constrained_window_impl.cc70
-rw-r--r--webkit/port/bindings/v8/v8_custom.cpp23
5 files changed, 35 insertions, 89 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 2768b65..7a0bbb0 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -85,7 +85,7 @@ static const int kBrowserReleaseMemoryInterval = 30; // In seconds.
// How much horizontal and vertical offset there is between newly opened
// windows.
-static const int kWindowTilePixels = 10;
+static const int kWindowTilePixels = 20;
// How frequently we check for hung plugin windows.
static const int kDefaultHungPluginDetectFrequency = 2000;
@@ -1623,15 +1623,22 @@ void Browser::BuildPopupWindow(TabContents* source,
browser->AddNewContents(source, new_contents,
NEW_FOREGROUND_TAB, gfx::Rect(), true);
- // TODO(erg): Need to move all popup sizing logic here, instead of
- // having it spread across three files.
-
// For newly opened popup windows, the incoming width/height
// numbers are for the content area, but x/y are for the actual
// window position. Thus we can't just call MoveContents().
gfx::Rect window_rect =
browser->window()->GetBoundsForContentBounds(initial_pos);
window_rect.set_origin(initial_pos.origin());
+
+ // When we are given x/y coordinates of 0 on a created popup window,
+ // assume none were given by the window.open() command.
+ if (window_rect.x() == 0 && window_rect.y() == 0) {
+ gfx::Point origin = window()->GetNormalBounds().origin();
+ origin.set_x(origin.x() + kWindowTilePixels);
+ origin.set_y(origin.y() + kWindowTilePixels);
+ window_rect.set_origin(origin);
+ }
+
::SetWindowPos(browser->GetTopLevelHWND(), NULL,
window_rect.x(), window_rect.y(),
window_rect.width(), window_rect.height(), 0);
diff --git a/chrome/browser/constrained_window.h b/chrome/browser/constrained_window.h
index 47caf94..32fa071 100644
--- a/chrome/browser/constrained_window.h
+++ b/chrome/browser/constrained_window.h
@@ -121,12 +121,6 @@ class ConstrainedWindow {
const gfx::Rect& initial_bounds,
TabContents* constrained_contents);
- // Generates the bounds for a window when one/both of the
- // initial_bounds are invalid.
- static void GenerateInitialBounds(const gfx::Rect& initial_bounds,
- TabContents* parent,
- gfx::Rect* window_bounds);
-
// Activates the Constrained Window, which has the effect of detaching it if
// it contains a WebContents, otherwise just brings it to the front of the
// z-order.
diff --git a/chrome/browser/tab_contents.cc b/chrome/browser/tab_contents.cc
index 7f6c9e8..24bae60 100644
--- a/chrome/browser/tab_contents.cc
+++ b/chrome/browser/tab_contents.cc
@@ -234,15 +234,7 @@ void TabContents::AddNewContents(TabContents* new_contents,
if ((disposition == NEW_POPUP) && !delegate_->IsPopup(this)) {
if (user_gesture) {
- // TODO(erg): Need a better policy about initial placement of
- // popup windows.
- gfx::Rect initial_bounds = initial_pos;
- if (initial_bounds.x() == 0 || initial_bounds.y() == 0) {
- ConstrainedWindow::GenerateInitialBounds(
- initial_pos, this, &initial_bounds);
- }
-
- delegate_->AddNewContents(this, new_contents, disposition, initial_bounds,
+ delegate_->AddNewContents(this, new_contents, disposition, initial_pos,
user_gesture);
} else {
AddConstrainedPopup(new_contents, initial_pos);
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);
diff --git a/webkit/port/bindings/v8/v8_custom.cpp b/webkit/port/bindings/v8/v8_custom.cpp
index 63b9d24..866c0cd 100644
--- a/webkit/port/bindings/v8/v8_custom.cpp
+++ b/webkit/port/bindings/v8/v8_custom.cpp
@@ -1184,8 +1184,13 @@ CALLBACK_FUNC_DECL(DOMWindowOpen) {
// In the case of a named frame or a new window, we'll use the createWindow()
// helper.
- WindowFeatures window_features(
+
+ // Parse the values, and then work with a copy of the parsed values
+ // so we can restore the values we may not want to overwrite after
+ // we do the multiple monitor fixes.
+ WindowFeatures raw_features(
valueToStringWithNullOrUndefinedCheck(args[2]));
+ WindowFeatures window_features(raw_features);
FloatRect screen_rect = screenAvailableRect(page->mainFrame()->view());
// Set default size and location near parent window if none were specified.
@@ -1215,12 +1220,22 @@ CALLBACK_FUNC_DECL(DOMWindowOpen) {
window_rect.move(screen_rect.x(), screen_rect.y());
WebCore::DOMWindow::adjustWindowRect(screen_rect, window_rect, window_rect);
- // createWindow expects the location to be specified relative to the parent.
- window_features.x = window_rect.x() - parent->screenX();
- window_features.y = window_rect.y() - parent->screenY();
+ window_features.x = window_rect.x();
+ window_features.y = window_rect.y();
window_features.height = window_rect.height();
window_features.width = window_rect.width();
+ // If either of the origin coordinates weren't set in the original
+ // string, make sure they aren't set now.
+ if (!raw_features.xSet) {
+ window_features.x = 0;
+ window_features.xSet = false;
+ }
+ if (!raw_features.ySet) {
+ window_features.y = 0;
+ window_features.ySet = false;
+ }
+
frame = createWindow(frame, url_string, frame_name,
window_features, v8::Local<v8::Value>());