diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-17 20:37:34 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-17 20:37:34 +0000 |
commit | 96997a53442ca17ccadb816838f641b0cde568e9 (patch) | |
tree | 9778b59d7d5a5dd8bab435e38acfd860ea5b6161 | |
parent | f92977e5e3bbd7c310f64859541fbb3575b09f5e (diff) | |
download | chromium_src-96997a53442ca17ccadb816838f641b0cde568e9.zip chromium_src-96997a53442ca17ccadb816838f641b0cde568e9.tar.gz chromium_src-96997a53442ca17ccadb816838f641b0cde568e9.tar.bz2 |
GTK: Fix corrupted tab edges when theme changes.
The tab renderer caches composited images, but this means that pieces of the
old theme hang around when we switch themes. Drop the cache when we hear
a BROWSER_THEME_CHANGED notification.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/601095
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39255 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/gtk/tabs/tab_renderer_gtk.cc | 17 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/tab_renderer_gtk.h | 11 |
2 files changed, 27 insertions, 1 deletions
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc index 7de4808..c37b4f1 100644 --- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc @@ -262,6 +262,9 @@ TabRendererGtk::TabRendererGtk(ThemeProvider* theme_provider) hover_animation_.reset(new SlideAnimation(this)); hover_animation_->SetSlideDuration(kHoverDurationMs); + + registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, + NotificationService::AllSources()); } TabRendererGtk::~TabRendererGtk() { @@ -530,6 +533,20 @@ void TabRendererGtk::SetBounds(const gfx::Rect& bounds) { gtk_widget_set_size_request(tab_.get(), bounds.width(), bounds.height()); } +void TabRendererGtk::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); + + // Clear our cache when we receive a theme change notification because it + // contains cached bitmaps based off the previous theme. + for (BitmapCache::iterator it = cached_bitmaps_.begin(); + it != cached_bitmaps_.end(); ++it) { + delete it->second.bitmap; + } + cached_bitmaps_.clear(); +} + //////////////////////////////////////////////////////////////////////////////// // TabRendererGtk, protected: diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.h b/chrome/browser/gtk/tabs/tab_renderer_gtk.h index 0c50f12..440a0d7 100644 --- a/chrome/browser/gtk/tabs/tab_renderer_gtk.h +++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.h @@ -30,7 +30,8 @@ class TabContents; class ThemeProvider; class ThrobAnimation; -class TabRendererGtk : public AnimationDelegate { +class TabRendererGtk : public AnimationDelegate, + public NotificationObserver { public: // Possible animation states. enum AnimationState { @@ -146,6 +147,11 @@ class TabRendererGtk : public AnimationDelegate { // Sets the bounds of the tab. virtual void SetBounds(const gfx::Rect& bounds); + // Provide NotificationObserver implementation. + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + // Advance the loading animation to the next frame, or hide the animation if // the tab isn't loading. Returns |true| if the icon area needs to be // repainted. @@ -407,6 +413,9 @@ class TabRendererGtk : public AnimationDelegate { // The current color of the close button. SkColor close_button_color_; + // Used to listen for theme change notifications. + NotificationRegistrar registrar_; + DISALLOW_COPY_AND_ASSIGN(TabRendererGtk); }; |