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
parent 5acb90bb
...@@ -430,16 +430,18 @@ gfx::Rect BrowserToolbarGtk::GetPopupBounds() const { ...@@ -430,16 +430,18 @@ gfx::Rect BrowserToolbarGtk::GetPopupBounds() const {
right = go_->widget(); right = go_->widget();
} }
// TODO(deanm): The go and star buttons probably share the same window, gint origin_x, origin_y;
// so this could be optimized to only one origin request. DCHECK_EQ(left->window, right->window);
gint right_x; gdk_window_get_origin(left->window, &origin_x, &origin_y);
gdk_window_get_origin(right->window, &right_x, NULL);
right_x += right->allocation.x + right->allocation.width; gint right_x = origin_x + right->allocation.x + right->allocation.width;
gint left_x, left_y; gint left_x = origin_x + left->allocation.x;
gdk_window_get_origin(left->window, &left_x, &left_y);
left_x += left->allocation.x; // Bottom edge.
left_y += left->allocation.y + left->allocation.height; // 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, return gfx::Rect(left_x + kPopupLeftRightMargin, left_y + kPopupTopMargin,
right_x - left_x - (2 * kPopupLeftRightMargin), 0); right_x - left_x - (2 * kPopupLeftRightMargin), 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