diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 17:57:12 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 17:57:12 +0000 |
commit | e561e20e4220751a8eb243ea5da7eb154180c6da (patch) | |
tree | 21cb95f4ed21f8f753b3768af2920b1f96b01418 | |
parent | 4def84918982a6c01649b5e4eadfac4904c1c847 (diff) | |
download | chromium_src-e561e20e4220751a8eb243ea5da7eb154180c6da.zip chromium_src-e561e20e4220751a8eb243ea5da7eb154180c6da.tar.gz chromium_src-e561e20e4220751a8eb243ea5da7eb154180c6da.tar.bz2 |
Revert "Fix browser side handling of moveTo by resizing the content area; not the window."
This reverts commit 2ce3ea80b627f58acb97802b0cc182b3a2bdf809 (r40386).
This seems to tickle some weird race condition where the renderer and the
browser process disagree about the size of the window. I'm reverting this
change as 38685 is scarier then 27365.
TEST=none
BUG=38785,27365
Review URL: http://codereview.chromium.org/1259004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42494 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browser.cc | 6 | ||||
-rw-r--r-- | chrome/browser/browser_window.h | 12 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.h | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.mm | 22 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.h | 3 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 6 | ||||
-rw-r--r-- | chrome/browser/dom_ui/filebrowse_ui.cc | 9 | ||||
-rw-r--r-- | chrome/browser/dom_ui/mediaplayer_ui.cc | 6 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_tabs_module.cc | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_titlebar.cc | 3 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 12 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.h | 7 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 17 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.h | 2 | ||||
-rw-r--r-- | chrome/test/test_browser_window.h | 2 |
15 files changed, 35 insertions, 78 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 4e37d4c..7c71b72 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -1934,8 +1934,7 @@ void Browser::DuplicateContentsAt(int index) { // been given an offset by the OS, so we shouldn't copy the old bounds. BrowserWindow* new_window = browser->window(); new_window->SetBounds(gfx::Rect(new_window->GetRestoredBounds().origin(), - window()->GetRestoredBounds().size()), - BrowserWindow::WINDOW_BOUNDS); + window()->GetRestoredBounds().size())); // We need to show the browser now. Otherwise ContainerWin assumes the // TabContents is invisible and won't size it. @@ -2276,8 +2275,7 @@ void Browser::MoveContents(TabContents* source, const gfx::Rect& pos) { NOTREACHED() << "moving invalid browser type"; return; } - - window_->SetBounds(pos, BrowserWindow::CONTENT_BOUNDS); + window_->SetBounds(pos); } void Browser::DetachContents(TabContents* source) { diff --git a/chrome/browser/browser_window.h b/chrome/browser/browser_window.h index a4ff572..484e6bb 100644 --- a/chrome/browser/browser_window.h +++ b/chrome/browser/browser_window.h @@ -37,19 +37,11 @@ class Rect; // NOTE: All getters may return NULL. class BrowserWindow { public: - enum BoundsType { - WINDOW_BOUNDS = 0, - CONTENT_BOUNDS - }; - // Show the window, or activates it if it's already visible. virtual void Show() = 0; - // Sets the window's size and position to the specified values. SetBounds - // will always move the window so its window origin is bounds.origin(), but - // will change either the size of the window or the content area based on - // |bounds_type|. - virtual void SetBounds(const gfx::Rect& bounds, BoundsType bounds_type) = 0; + // Sets the window's size and position to the specified values. + virtual void SetBounds(const gfx::Rect& bounds) = 0; // Closes the frame as soon as possible. If the frame is not in a drag // session, it will close immediately; otherwise, it will move offscreen (so diff --git a/chrome/browser/cocoa/browser_window_cocoa.h b/chrome/browser/cocoa/browser_window_cocoa.h index b0ace80..dde965e 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.h +++ b/chrome/browser/cocoa/browser_window_cocoa.h @@ -30,7 +30,7 @@ class BrowserWindowCocoa : public BrowserWindow, // Overridden from BrowserWindow virtual void Show(); - virtual void SetBounds(const gfx::Rect& bounds, BoundsType bounds_type); + virtual void SetBounds(const gfx::Rect& bounds); virtual void Close(); virtual void Activate(); virtual bool IsActive() const; diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm index 01d592e..4972eae 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/cocoa/browser_window_cocoa.mm @@ -64,27 +64,13 @@ void BrowserWindowCocoa::Show() { [window() makeKeyAndOrderFront:controller_]; } -void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds, - BoundsType bounds_type) { - gfx::Rect win_bounds = bounds; - if (bounds_type == BrowserWindow::CONTENT_BOUNDS) { - // Fetch the size of the content area in the NSWindow. - NSSize content_area_size = [controller_ tabContentsFrame].size; - int width_offset = bounds.width() - content_area_size.width; - int height_offset = bounds.height() - content_area_size.height; - - // Adjust the size relative to the current frame size. - NSSize current_frame = [window() frame].size; - win_bounds.set_width(current_frame.width + width_offset); - win_bounds.set_height(current_frame.height + height_offset); - } - - NSRect cocoa_bounds = NSMakeRect(win_bounds.x(), 0, win_bounds.width(), - win_bounds.height()); +void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) { + NSRect cocoa_bounds = NSMakeRect(bounds.x(), 0, bounds.width(), + bounds.height()); // Flip coordinates based on the primary screen. NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; cocoa_bounds.origin.y = - [screen frame].size.height - win_bounds.height() - win_bounds.y(); + [screen frame].size.height - bounds.height() - bounds.y(); [window() setFrame:cocoa_bounds display:YES]; } diff --git a/chrome/browser/cocoa/browser_window_controller.h b/chrome/browser/cocoa/browser_window_controller.h index bbab2ee..817d536 100644 --- a/chrome/browser/cocoa/browser_window_controller.h +++ b/chrome/browser/cocoa/browser_window_controller.h @@ -163,9 +163,6 @@ class TabStripModelObserverBridge; // Sets whether or not the current page in the frontmost tab is bookmarked. - (void)setStarredState:(BOOL)isStarred; -// Returns the current frame of the the content area. -- (NSRect)tabContentsFrame; - // Return the rect, in WebKit coordinates (flipped), of the window's grow box // in the coordinate system of the content area of the currently selected tab. - (NSRect)selectedTabGrowBoxRect; diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index 6986885..2be2960 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -220,7 +220,7 @@ windowRect.set_origin(WindowSizer::GetDefaultPopupOrigin(size)); } - windowShim_->SetBounds(windowRect, BrowserWindow::WINDOW_BOUNDS); + windowShim_->SetBounds(windowRect); // Puts the incognito badge on the window frame, if necessary. [self installIncognitoBadge]; @@ -987,10 +987,6 @@ [toolbarController_ setStarredState:isStarred]; } -- (NSRect)tabContentsFrame { - return [[self tabContentArea] frame]; -} - // Return the rect, in WebKit coordinates (flipped), of the window's grow box // in the coordinate system of the content area of the currently selected tab. // |windowGrowBox| needs to be in the window's coordinate system. diff --git a/chrome/browser/dom_ui/filebrowse_ui.cc b/chrome/browser/dom_ui/filebrowse_ui.cc index c1e69c7..fb1fc4b 100644 --- a/chrome/browser/dom_ui/filebrowse_ui.cc +++ b/chrome/browser/dom_ui/filebrowse_ui.cc @@ -650,11 +650,9 @@ void FilebrowseHandler::OpenNewWindow(const Value* value, bool popup) { if (popup) { // TODO(dhg): Remove these from being hardcoded. Allow javascript // to specify. - browser->window()->SetBounds(gfx::Rect(0, 0, 400, 300), - BrowserWindow::WINDOW_BOUNDS); + browser->window()->SetBounds(gfx::Rect(0, 0, 400, 300)); } else { - browser->window()->SetBounds(gfx::Rect(0, 0, 800, 600), - BrowserWindow::WINDOW_BOUNDS); + browser->window()->SetBounds(gfx::Rect(0, 0, 800, 600)); } browser->window()->Show(); } else { @@ -979,8 +977,7 @@ Browser* FileBrowseUI::OpenPopup(Profile* profile, browser->window()->SetBounds(gfx::Rect(kPopupLeft, kPopupTop, kPopupWidth, - kPopupHeight), - BrowserWindow::WINDOW_BOUNDS); + kPopupHeight)); browser->window()->Show(); } diff --git a/chrome/browser/dom_ui/mediaplayer_ui.cc b/chrome/browser/dom_ui/mediaplayer_ui.cc index f561603..cf02943 100644 --- a/chrome/browser/dom_ui/mediaplayer_ui.cc +++ b/chrome/browser/dom_ui/mediaplayer_ui.cc @@ -495,8 +495,7 @@ void MediaPlayer::PopupPlaylist() { playlist_browser_->window()->SetBounds(gfx::Rect(kPopupLeft, kPopupTop, kPopupWidth, - kPopupHeight), - BrowserWindow::WINDOW_BOUNDS); + kPopupHeight)); playlist_browser_->window()->Show(); } @@ -514,8 +513,7 @@ void MediaPlayer::PopupMediaPlayer() { mediaplayer_browser_->window()->SetBounds(gfx::Rect(kPopupLeft, kPopupTop, kPopupWidth, - kPopupHeight), - BrowserWindow::WINDOW_BOUNDS); + kPopupHeight)); mediaplayer_browser_->window()->Show(); } diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index 724fd9c..3d1ee4b 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -377,7 +377,7 @@ bool CreateWindowFunction::RunImpl() { new_window->AddTabWithURL(*(url.get()), GURL(), PageTransition::LINK, true, -1, false, NULL); - new_window->window()->SetBounds(bounds, BrowserWindow::WINDOW_BOUNDS); + new_window->window()->SetBounds(bounds); new_window->window()->Show(); // TODO(rafaelw): support |focused|, |zIndex| @@ -435,7 +435,7 @@ bool UpdateWindowFunction::RunImpl() { bounds.set_height(bounds_val); } - browser->window()->SetBounds(bounds, BrowserWindow::WINDOW_BOUNDS); + browser->window()->SetBounds(bounds); // TODO(rafaelw): Support |focused|. result_.reset(ExtensionTabUtil::CreateWindowValue(browser, false)); diff --git a/chrome/browser/gtk/browser_titlebar.cc b/chrome/browser/gtk/browser_titlebar.cc index 92ea4b9d..660522e 100644 --- a/chrome/browser/gtk/browser_titlebar.cc +++ b/chrome/browser/gtk/browser_titlebar.cc @@ -490,8 +490,7 @@ void BrowserTitlebar::MaximizeButtonClicked() { height = screen_rect.height; } - browser_window_->SetBounds(gfx::Rect(x, y, width, height), - BrowserWindow::WINDOW_BOUNDS); + browser_window_->SetBounds(gfx::Rect(x, y, width, height)); } gdk_event_free(event); } diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 39e6348..7c5d9ca 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -582,8 +582,7 @@ void BrowserWindowGtk::Show() { gtk_widget_set_size_request(contents_container_->widget(), -1, -1); } -void BrowserWindowGtk::SetBounds(const gfx::Rect& bounds, - BoundsType bounds_type) { +void BrowserWindowGtk::SetBoundsImpl(const gfx::Rect& bounds, bool exterior) { gint x = static_cast<gint>(bounds.x()); gint y = static_cast<gint>(bounds.y()); gint width = static_cast<gint>(bounds.width()); @@ -591,7 +590,7 @@ void BrowserWindowGtk::SetBounds(const gfx::Rect& bounds, gtk_window_move(window_, x, y); - if (bounds_type == WINDOW_BOUNDS) { + if (exterior) { SetWindowSize(window_, width, height); } else { gtk_widget_set_size_request(contents_container_->widget(), @@ -599,6 +598,10 @@ void BrowserWindowGtk::SetBounds(const gfx::Rect& bounds, } } +void BrowserWindowGtk::SetBounds(const gfx::Rect& bounds) { + SetBoundsImpl(bounds, true); +} + void BrowserWindowGtk::Close() { // We're already closing. Do nothing. if (!window_) @@ -1393,8 +1396,7 @@ void BrowserWindowGtk::SetGeometryHints() { if (browser_->bounds_overridden()) { // For popups, bounds are set in terms of the client area rather than the // entire window. - SetBounds(bounds, (browser_->type() & Browser::TYPE_POPUP) ? - BrowserWindow::CONTENT_BOUNDS : BrowserWindow::WINDOW_BOUNDS); + SetBoundsImpl(bounds, !(browser_->type() & Browser::TYPE_POPUP)); } else { // Ignore the position but obey the size. SetWindowSize(window_, bounds.width(), bounds.height()); diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h index f24e094..cbc9270 100644 --- a/chrome/browser/gtk/browser_window_gtk.h +++ b/chrome/browser/gtk/browser_window_gtk.h @@ -48,7 +48,7 @@ class BrowserWindowGtk : public BrowserWindow, // Overridden from BrowserWindow virtual void Show(); - virtual void SetBounds(const gfx::Rect& bounds, BoundsType bounds_type); + virtual void SetBounds(const gfx::Rect& bounds); virtual void Close(); virtual void Activate(); virtual bool IsActive() const; @@ -248,6 +248,11 @@ class BrowserWindowGtk : public BrowserWindow, // Save the window position in the prefs. void SaveWindowPosition(); + // Set the bounds of the current window. If |exterior| is true, set the size + // of the window itself, otherwise set the bounds of the web contents. In + // either case, set the position of the window. + void SetBoundsImpl(const gfx::Rect& bounds, bool exterior); + // Callback for when the custom frame alignment needs to be redrawn. // The content area includes the toolbar and web page but not the tab strip. static gboolean OnCustomFrameExpose(GtkWidget* widget, GdkEventExpose* event, diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 302e13f..9d62c70 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -682,21 +682,8 @@ void BrowserView::Show() { frame_->GetWindow()->Show(); } -void BrowserView::SetBounds(const gfx::Rect& bounds, BoundsType bounds_type) { - gfx::Rect new_bounds = bounds; - if (bounds_type == CONTENT_BOUNDS) { - // Caluclate how much larger the window needs to be to accomidate |bounds|. - gfx::Rect container_bounds = contents_container_->bounds(); - int width_offset = bounds.width() - container_bounds.width(); - int height_offset = bounds.height() - container_bounds.height(); - - gfx::Rect win_bounds; - GetWidget()->GetBounds(&win_bounds, true); - new_bounds.set_width(win_bounds.width() + width_offset); - new_bounds.set_height(win_bounds.height() + height_offset); - } - - GetWidget()->SetBounds(new_bounds); +void BrowserView::SetBounds(const gfx::Rect& bounds) { + GetWidget()->SetBounds(bounds); } void BrowserView::Close() { diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index bf753e9..8846787 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -245,7 +245,7 @@ class BrowserView : public BrowserBubbleHost, // Overridden from BrowserWindow: virtual void Show(); - virtual void SetBounds(const gfx::Rect& bounds, BoundsType bounds_type); + virtual void SetBounds(const gfx::Rect& bounds); virtual void Close(); virtual void Activate(); virtual bool IsActive() const; diff --git a/chrome/test/test_browser_window.h b/chrome/test/test_browser_window.h index 169afdb..c53c563 100644 --- a/chrome/test/test_browser_window.h +++ b/chrome/test/test_browser_window.h @@ -19,7 +19,7 @@ class TestBrowserWindow : public BrowserWindow { virtual void Init() {} virtual void Show() {} - virtual void SetBounds(const gfx::Rect& bounds, BoundsType bounds_type) {} + virtual void SetBounds(const gfx::Rect& bounds) {} virtual void Close() {} virtual void Activate() {} virtual bool IsActive() const { return false; } |