diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-26 22:31:24 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-26 22:31:24 +0000 |
commit | 1c6c2fe3c88098d58f725ea1aa6f9a82dd66cae9 (patch) | |
tree | 397edd7865f0a6920d9480341e8a28ea6790887a /chrome/browser | |
parent | 0dc1f496cd4ddd8a55f6e5d12d0b7ee38411239f (diff) | |
download | chromium_src-1c6c2fe3c88098d58f725ea1aa6f9a82dd66cae9.zip chromium_src-1c6c2fe3c88098d58f725ea1aa6f9a82dd66cae9.tar.gz chromium_src-1c6c2fe3c88098d58f725ea1aa6f9a82dd66cae9.tar.bz2 |
GTK: Don't reposition the findbar when it's not visible.
This gives us ~8ms of startup improvement that we lost previously from r22012.
Review URL: http://codereview.chromium.org/173510
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24546 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/gtk/find_bar_gtk.cc | 23 | ||||
-rw-r--r-- | chrome/browser/gtk/find_bar_gtk.h | 3 |
2 files changed, 18 insertions, 8 deletions
diff --git a/chrome/browser/gtk/find_bar_gtk.cc b/chrome/browser/gtk/find_bar_gtk.cc index 1d097e4..ac67614 100644 --- a/chrome/browser/gtk/find_bar_gtk.cc +++ b/chrome/browser/gtk/find_bar_gtk.cc @@ -290,6 +290,7 @@ GtkWidget* FindBarGtk::slide_widget() { void FindBarGtk::Show() { slide_widget_->Open(); + Reposition(); if (container_->window) gdk_window_raise(container_->window); } @@ -414,7 +415,7 @@ void FindBarGtk::SetDialogPosition(const gfx::Rect& new_pos, bool no_redraw) { } bool FindBarGtk::IsFindBarVisible() { - return GTK_WIDGET_VISIBLE(widget()); + return GTK_WIDGET_VISIBLE(slide_widget()); } void FindBarGtk::RestoreSavedFocus() { @@ -518,6 +519,18 @@ void FindBarGtk::UpdateMatchLabelAppearance(bool failure) { (use_gtk ? NULL : &kFindSuccessTextColor)); } +void FindBarGtk::Reposition() { + if (!IsFindBarVisible()) + return; + + int xposition = GetDialogPosition(gfx::Rect()).x(); + if (xposition == slide_widget()->allocation.x) { + return; + } else { + gtk_fixed_move(GTK_FIXED(widget()), slide_widget(), xposition, 0); + } +} + void FindBarGtk::StoreOutsideFocus() { // |text_entry_| is the only widget in the find bar that can be focused, // so it's the only one we have to check. @@ -616,13 +629,7 @@ void FindBarGtk::OnFixedSizeAllocate(GtkWidget* fixed, gtk_widget_set_size_request(findbar->border_, allocation->width, allocation->height); - // Reposition the dialog. - int xposition = findbar->GetDialogPosition(gfx::Rect()).x(); - if (xposition == findbar->slide_widget()->allocation.x) { - return; - } else { - gtk_fixed_move(GTK_FIXED(fixed), findbar->slide_widget(), xposition, 0); - } + findbar->Reposition(); } // Used to handle custom painting of |container_|. diff --git a/chrome/browser/gtk/find_bar_gtk.h b/chrome/browser/gtk/find_bar_gtk.h index 407e86f..e26fd07 100644 --- a/chrome/browser/gtk/find_bar_gtk.h +++ b/chrome/browser/gtk/find_bar_gtk.h @@ -91,6 +91,9 @@ class FindBarGtk : public FindBar, void UpdateMatchLabelAppearance(bool failure); + // Repositions the dialog without worrying about overlapping search results. + void Reposition(); + // Callback when the entry text changes. static gboolean OnChanged(GtkWindow* window, FindBarGtk* find_bar); |