From 62391376b5c86eea70af0d8e429ffc8a4b56e60d Mon Sep 17 00:00:00 2001 From: "estade@chromium.org" Date: Mon, 31 Aug 2009 18:31:05 +0000 Subject: Don't resize the renderer while opening the bookmark bar or an infobar. This is just a performance optimization. Previously this code was added for closing bookmark bars as a bit of visual polish.Doing the same thing for opening bookmark bars should reduce CPU usage but it won't look any different (for fast computers anyway). BUG=17133 Review URL: http://codereview.chromium.org/183011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24911 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/gtk/bookmark_bar_gtk.cc | 4 ++-- chrome/browser/gtk/bookmark_bar_gtk.h | 4 ++-- chrome/browser/gtk/browser_window_gtk.cc | 7 +++---- chrome/browser/gtk/infobar_container_gtk.cc | 10 +++++----- chrome/browser/gtk/infobar_container_gtk.h | 4 ++-- chrome/browser/gtk/infobar_gtk.cc | 4 ++-- chrome/browser/gtk/infobar_gtk.h | 4 ++-- chrome/browser/gtk/slide_animator_gtk.cc | 4 ++++ chrome/browser/gtk/slide_animator_gtk.h | 4 ++++ 9 files changed, 26 insertions(+), 19 deletions(-) (limited to 'chrome') diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc index 373ce0f..867d39e 100644 --- a/chrome/browser/gtk/bookmark_bar_gtk.cc +++ b/chrome/browser/gtk/bookmark_bar_gtk.cc @@ -252,8 +252,8 @@ int BookmarkBarGtk::GetHeight() { return event_box_->allocation.height; } -bool BookmarkBarGtk::IsClosing() { - return slide_animation_->IsClosing(); +bool BookmarkBarGtk::IsAnimating() { + return slide_animation_->IsAnimating(); } bool BookmarkBarGtk::OnNewTabPage() { diff --git a/chrome/browser/gtk/bookmark_bar_gtk.h b/chrome/browser/gtk/bookmark_bar_gtk.h index 4d453fd..f779a52 100644 --- a/chrome/browser/gtk/bookmark_bar_gtk.h +++ b/chrome/browser/gtk/bookmark_bar_gtk.h @@ -69,8 +69,8 @@ class BookmarkBarGtk : public AnimationDelegate, // Get the current height of the bookmark bar. int GetHeight(); - // Returns true if the bookmark bar is showing the close animation. - bool IsClosing(); + // Returns true if the bookmark bar is showing an animation. + bool IsAnimating(); // Returns true if the bookmarks bar preference is set to 'always show'. bool IsAlwaysShown(); diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index e9fb7210..1d593f9 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -1045,12 +1045,11 @@ void BrowserWindowGtk::UserChangedTheme() { } int BrowserWindowGtk::GetExtraRenderViewHeight() const { - int sum = infobar_container_->TotalHeightOfClosingBars(); - if (bookmark_bar_->IsClosing()) + int sum = infobar_container_->TotalHeightOfAnimatingBars(); + if (bookmark_bar_->IsAnimating()) sum += bookmark_bar_->GetHeight(); - if (download_shelf_.get() && download_shelf_->IsClosing()) { + if (download_shelf_.get() && download_shelf_->IsClosing()) sum += download_shelf_->GetHeight(); - } return sum; } diff --git a/chrome/browser/gtk/infobar_container_gtk.cc b/chrome/browser/gtk/infobar_container_gtk.cc index 667a72e..4723903 100644 --- a/chrome/browser/gtk/infobar_container_gtk.cc +++ b/chrome/browser/gtk/infobar_container_gtk.cc @@ -50,12 +50,12 @@ void ClosingForDelegate(GtkWidget* infobar_widget, gpointer info_bar_delegate) { } // Get the height of the widget and add it to |userdata|, but only if it is in -// the process of closing. -void SumClosingBarHeight(GtkWidget* widget, gpointer userdata) { +// the process of animating. +void SumAnimatingBarHeight(GtkWidget* widget, gpointer userdata) { int* height_sum = static_cast(userdata); InfoBar* infobar = reinterpret_cast( g_object_get_data(G_OBJECT(widget), "info-bar")); - if (infobar->IsClosing()) + if (infobar->IsAnimating()) *height_sum += widget->allocation.height; } @@ -99,9 +99,9 @@ void InfoBarContainerGtk::RemoveDelegate(InfoBarDelegate* delegate) { tab_contents_->RemoveInfoBar(delegate); } -int InfoBarContainerGtk::TotalHeightOfClosingBars() const { +int InfoBarContainerGtk::TotalHeightOfAnimatingBars() const { int sum = 0; - gtk_container_foreach(GTK_CONTAINER(widget()), SumClosingBarHeight, &sum); + gtk_container_foreach(GTK_CONTAINER(widget()), SumAnimatingBarHeight, &sum); return sum; } diff --git a/chrome/browser/gtk/infobar_container_gtk.h b/chrome/browser/gtk/infobar_container_gtk.h index e620b2e..e8a3c7c 100644 --- a/chrome/browser/gtk/infobar_container_gtk.h +++ b/chrome/browser/gtk/infobar_container_gtk.h @@ -34,8 +34,8 @@ class InfoBarContainerGtk : public NotificationObserver { void RemoveDelegate(InfoBarDelegate* delegate); // Returns the total pixel height of all infobars in this container that - // are currently closing. - int TotalHeightOfClosingBars() const; + // are currently animating. + int TotalHeightOfAnimatingBars() const; private: // Overridden from NotificationObserver: diff --git a/chrome/browser/gtk/infobar_gtk.cc b/chrome/browser/gtk/infobar_gtk.cc index b3c0da0..52d9844 100644 --- a/chrome/browser/gtk/infobar_gtk.cc +++ b/chrome/browser/gtk/infobar_gtk.cc @@ -136,8 +136,8 @@ void InfoBar::Close() { delete this; } -bool InfoBar::IsClosing() { - return slide_widget_->IsClosing(); +bool InfoBar::IsAnimating() { + return slide_widget_->IsAnimating(); } void InfoBar::RemoveInfoBar() const { diff --git a/chrome/browser/gtk/infobar_gtk.h b/chrome/browser/gtk/infobar_gtk.h index 98d14bc..9fea78b 100644 --- a/chrome/browser/gtk/infobar_gtk.h +++ b/chrome/browser/gtk/infobar_gtk.h @@ -43,8 +43,8 @@ class InfoBar : public SlideAnimatorGtk::Delegate { // is called. void Close(); - // Returns true if the infobar is showing the close animation. - bool IsClosing(); + // Returns true if the infobar is showing the its open or close animation. + bool IsAnimating(); // SlideAnimatorGtk::Delegate implementation. virtual void Closed(); diff --git a/chrome/browser/gtk/slide_animator_gtk.cc b/chrome/browser/gtk/slide_animator_gtk.cc index 866aca5..0508f6f 100644 --- a/chrome/browser/gtk/slide_animator_gtk.cc +++ b/chrome/browser/gtk/slide_animator_gtk.cc @@ -106,6 +106,10 @@ bool SlideAnimatorGtk::IsClosing() { return animation_->IsClosing(); } +bool SlideAnimatorGtk::IsAnimating() { + return animation_->IsAnimating(); +} + void SlideAnimatorGtk::AnimationProgressed(const Animation* animation) { int showing_height = child_->allocation.height * animation_->GetCurrentValue(); diff --git a/chrome/browser/gtk/slide_animator_gtk.h b/chrome/browser/gtk/slide_animator_gtk.h index a4cf657..b2f6677 100644 --- a/chrome/browser/gtk/slide_animator_gtk.h +++ b/chrome/browser/gtk/slide_animator_gtk.h @@ -74,6 +74,10 @@ class SlideAnimatorGtk : public AnimationDelegate { // Returns whether the widget is currently showing the close animation. bool IsClosing(); + // Returns whether the widget is currently showing the open or close + // animation. + bool IsAnimating(); + // AnimationDelegate implementation. void AnimationProgressed(const Animation* animation); void AnimationEnded(const Animation* animation); -- cgit v1.1