Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Issue 200069: Get window origin only once in BrowserToolbarGtk::GetPopupBounds. (Closed)

Created:
11 years, 3 months ago by Paweł Hajdan Jr.
Modified:
9 years, 7 months ago
CC:
chromium-reviews_googlegroups.com
Visibility:
Public.

Description

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 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=25860

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+12 lines, -10 lines) Patch
M chrome/browser/gtk/browser_toolbar_gtk.cc View 1 chunk +12 lines, -10 lines 0 comments Download

Messages

Total messages: 2 (0 generated)
Paweł Hajdan Jr.
Please review. I don't know what was happening, but while working on a new browser_tests ...
11 years, 3 months ago (2009-09-10 00:46:57 UTC) #1
Elliot Glaysher
11 years, 3 months ago (2009-09-10 01:19:53 UTC) #2
LGTM.

On Wed, Sep 9, 2009 at 5:46 PM, <phajdan.jr@chromium.org> wrote:
> Reviewers: Dean McNamee, Elliot Glaysher,
>
> Message:
> Please review. I don't know what was happening, but while working on a ne=
w
> browser_tests for autocomplete left_x was waaay bigger than right_x.
> Intermittently, but very often.
>
> After this change, the problem is fixed. It seems to only manifest inside
> browser_tests. I think that with added DCHECKs the code remains valid. I
> verified it my running chrome and experimenting with the omnibox.
>
> Description:
> 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=3DThere are DCHECKs that make sure the new code is valid.
> BUG=3Dnone
>
> Please review this at http://codereview.chromium.org/200069
>
> Affected files:
> =A0M chrome/browser/gtk/browser_toolbar_gtk.cc
>
>
> Index: chrome/browser/gtk/browser_toolbar_gtk.cc
> diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc
> b/chrome/browser/gtk/browser_toolbar_gtk.cc
> index
> 24fbf7a868efe812d34c141a8c53490644c33b24..8f4c00c1612cba4ecac8e0ef4ab61af=
6caac5d5f
> 100644
> --- a/chrome/browser/gtk/browser_toolbar_gtk.cc
> +++ b/chrome/browser/gtk/browser_toolbar_gtk.cc
> @@ -431,16 +431,18 @@ gfx::Rect BrowserToolbarGtk::GetPopupBounds() const=
 {
> =A0 =A0 right =3D go_->widget();
> =A0 }
>
> - =A0// TODO(deanm): The go and star buttons probably share the same wind=
ow,
> - =A0// so this could be optimized to only one origin request.
> - =A0gint right_x;
> - =A0gdk_window_get_origin(right->window, &right_x, NULL);
> - =A0right_x +=3D right->allocation.x + right->allocation.width;
> -
> - =A0gint left_x, left_y;
> - =A0gdk_window_get_origin(left->window, &left_x, &left_y);
> - =A0left_x +=3D left->allocation.x;
> - =A0left_y +=3D left->allocation.y + left->allocation.height; =A0// Bott=
om edge.
> + =A0gint origin_x, origin_y;
> + =A0DCHECK_EQ(left->window, right->window);
> + =A0gdk_window_get_origin(left->window, &origin_x, &origin_y);
> +
> + =A0gint right_x =3D origin_x + right->allocation.x + right->allocation.=
width;
> +
> + =A0gint left_x =3D origin_x + left->allocation.x;
> +
> + =A0// Bottom edge.
> + =A0gint left_y =3D origin_y + left->allocation.y + left->allocation.hei=
ght;
> +
> + =A0DCHECK_LE(left_x, right_x);
>
> =A0 return gfx::Rect(left_x + kPopupLeftRightMargin, left_y + kPopupTopMa=
rgin,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0right_x - left_x - (2 * kPopupLeft=
RightMargin), 0);
>
>
>

Powered by Google App Engine
This is Rietveld 408576698