diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-10 16:32:39 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-10 16:32:39 +0000 |
commit | 25a8dba0560239d67876c4a2b70984bbc47cdd57 (patch) | |
tree | 11beaa7a35a2df3b31c8703f64a8a5d2e3481bed /chrome/browser/gtk | |
parent | 5acb90bb558ef5b698d6318d38752d997a462e47 (diff) | |
download | chromium_src-25a8dba0560239d67876c4a2b70984bbc47cdd57.zip chromium_src-25a8dba0560239d67876c4a2b70984bbc47cdd57.tar.gz chromium_src-25a8dba0560239d67876c4a2b70984bbc47cdd57.tar.bz2 |
Get window origin only once in BrowserToolbarGtk::GetPopupBounds.
This is an optimization, and also helps stability. Fixes an intermittent DCHECK
I was hitting while working on unrelated parts of code.
TEST=There are DCHECKs that make sure the new code is valid.
BUG=none
Review URL: http://codereview.chromium.org/200069
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25860 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/browser_toolbar_gtk.cc | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc index 3bced3d..cb71ed3 100644 --- a/chrome/browser/gtk/browser_toolbar_gtk.cc +++ b/chrome/browser/gtk/browser_toolbar_gtk.cc @@ -430,16 +430,18 @@ gfx::Rect BrowserToolbarGtk::GetPopupBounds() const { right = go_->widget(); } - // TODO(deanm): The go and star buttons probably share the same window, - // so this could be optimized to only one origin request. - gint right_x; - gdk_window_get_origin(right->window, &right_x, NULL); - right_x += right->allocation.x + right->allocation.width; - - gint left_x, left_y; - gdk_window_get_origin(left->window, &left_x, &left_y); - left_x += left->allocation.x; - left_y += left->allocation.y + left->allocation.height; // Bottom edge. + gint origin_x, origin_y; + DCHECK_EQ(left->window, right->window); + gdk_window_get_origin(left->window, &origin_x, &origin_y); + + gint right_x = origin_x + right->allocation.x + right->allocation.width; + + gint left_x = origin_x + left->allocation.x; + + // Bottom edge. + gint left_y = origin_y + left->allocation.y + left->allocation.height; + + DCHECK_LE(left_x, right_x); return gfx::Rect(left_x + kPopupLeftRightMargin, left_y + kPopupTopMargin, right_x - left_x - (2 * kPopupLeftRightMargin), 0); |