summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/resource_bundle.h3
-rw-r--r--app/theme_provider.h3
-rw-r--r--chrome/browser/browser_theme_provider.h6
-rw-r--r--chrome/browser/browser_theme_provider_gtk.cc22
-rw-r--r--chrome/browser/gtk/custom_button.cc17
5 files changed, 38 insertions, 13 deletions
diff --git a/app/resource_bundle.h b/app/resource_bundle.h
index c718b9a..8d0b29a 100644
--- a/app/resource_bundle.h
+++ b/app/resource_bundle.h
@@ -124,8 +124,7 @@ class ResourceBundle {
// is missing.
GdkPixbuf* GetPixbufNamed(int resource_id);
- // As above, but flips it in RTL locales. Note that this will add the flipped
- // pixbuf to the same cache used by GetPixbufNamed().
+ // As above, but flips it in RTL locales.
GdkPixbuf* GetRTLEnabledPixbufNamed(int resource_id);
private:
diff --git a/app/theme_provider.h b/app/theme_provider.h
index b004f3b..5dddd99 100644
--- a/app/theme_provider.h
+++ b/app/theme_provider.h
@@ -64,6 +64,9 @@ class ThemeProvider {
// pointer to a shared empty placeholder bitmap so it will be visible what
// is missing.
virtual GdkPixbuf* GetPixbufNamed(int id) = 0;
+
+ // As above, but flips it in RTL locales.
+ virtual GdkPixbuf* GetRTLEnabledPixbufNamed(int id) = 0;
#elif defined(OS_MACOSX)
// Gets the NSImage with the specified |id|.
//
diff --git a/chrome/browser/browser_theme_provider.h b/chrome/browser/browser_theme_provider.h
index f91b494..6d7bb70 100644
--- a/chrome/browser/browser_theme_provider.h
+++ b/chrome/browser/browser_theme_provider.h
@@ -137,6 +137,7 @@ class BrowserThemeProvider : public base::RefCounted<BrowserThemeProvider>,
virtual bool HasCustomImage(int id);
#if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)
virtual GdkPixbuf* GetPixbufNamed(int id);
+ virtual GdkPixbuf* GetRTLEnabledPixbufNamed(int id);
#elif defined(OS_MACOSX)
virtual NSImage* GetNSImageNamed(int id);
virtual NSColor* GetNSColorTint(int id);
@@ -252,6 +253,11 @@ class BrowserThemeProvider : public base::RefCounted<BrowserThemeProvider>,
// from ClearCaches().
void FreePlatformCaches();
+#if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)
+ // Loads an image and flips it horizontally if |rtl_enabled| is true.
+ GdkPixbuf* GetPixbufImpl(int id, bool rtl_enabled);
+#endif
+
// Cached images. We cache all retrieved and generated bitmaps and keep
// track of the pointers. We own these and will delete them when we're done
// using them.
diff --git a/chrome/browser/browser_theme_provider_gtk.cc b/chrome/browser/browser_theme_provider_gtk.cc
index 9605344..2787dce 100644
--- a/chrome/browser/browser_theme_provider_gtk.cc
+++ b/chrome/browser/browser_theme_provider_gtk.cc
@@ -4,14 +4,25 @@
#include "chrome/browser/browser_theme_provider.h"
+#include "app/l10n_util.h"
#include "base/gfx/gtk_util.h"
#include "base/logging.h"
GdkPixbuf* BrowserThemeProvider::GetPixbufNamed(int id) {
+ return GetPixbufImpl(id, false);
+}
+
+GdkPixbuf* BrowserThemeProvider::GetRTLEnabledPixbufNamed(int id) {
+ return GetPixbufImpl(id, true);
+}
+
+GdkPixbuf* BrowserThemeProvider::GetPixbufImpl(int id, bool rtl_enabled) {
DCHECK(CalledOnValidThread());
+ // Use the negative |resource_id| for the key for BIDI-aware images.
+ int key = rtl_enabled ? -id : id;
// Check to see if we already have the pixbuf in the cache.
- GdkPixbufMap::const_iterator found = gdk_pixbufs_.find(id);
+ GdkPixbufMap::const_iterator found = gdk_pixbufs_.find(key);
if (found != gdk_pixbufs_.end())
return found->second;
@@ -20,7 +31,14 @@ GdkPixbuf* BrowserThemeProvider::GetPixbufNamed(int id) {
// We loaded successfully. Cache the pixbuf.
if (pixbuf) {
- gdk_pixbufs_[id] = pixbuf;
+ if ((l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) &&
+ rtl_enabled) {
+ GdkPixbuf* original_pixbuf = pixbuf;
+ pixbuf = gdk_pixbuf_flip(pixbuf, TRUE);
+ g_object_unref(original_pixbuf);
+ }
+
+ gdk_pixbufs_[key] = pixbuf;
return pixbuf;
}
diff --git a/chrome/browser/gtk/custom_button.cc b/chrome/browser/gtk/custom_button.cc
index d2e092f..b49c422 100644
--- a/chrome/browser/gtk/custom_button.cc
+++ b/chrome/browser/gtk/custom_button.cc
@@ -80,16 +80,15 @@ void CustomDrawButtonBase::Observe(NotificationType type,
DCHECK(theme_provider_);
DCHECK(NotificationType::BROWSER_THEME_CHANGED == type);
- // TODO(tc): Add GetRTLEnabledPixbufNamed to ThemeProviderGtk.
- pixbufs_[GTK_STATE_NORMAL] =
- normal_id_ ? theme_provider_->GetPixbufNamed(normal_id_) : NULL;
- pixbufs_[GTK_STATE_ACTIVE] =
- active_id_ ? theme_provider_->GetPixbufNamed(active_id_) : NULL;
- pixbufs_[GTK_STATE_PRELIGHT] =
- highlight_id_ ? theme_provider_->GetPixbufNamed(highlight_id_) : NULL;
+ pixbufs_[GTK_STATE_NORMAL] = normal_id_ ?
+ theme_provider_->GetRTLEnabledPixbufNamed(normal_id_) : NULL;
+ pixbufs_[GTK_STATE_ACTIVE] = active_id_ ?
+ theme_provider_->GetRTLEnabledPixbufNamed(active_id_) : NULL;
+ pixbufs_[GTK_STATE_PRELIGHT] = highlight_id_ ?
+ theme_provider_->GetRTLEnabledPixbufNamed(highlight_id_) : NULL;
pixbufs_[GTK_STATE_SELECTED] = NULL;
- pixbufs_[GTK_STATE_INSENSITIVE] =
- depressed_id_ ? theme_provider_->GetPixbufNamed(depressed_id_) : NULL;
+ pixbufs_[GTK_STATE_INSENSITIVE] = depressed_id_ ?
+ theme_provider_->GetRTLEnabledPixbufNamed(depressed_id_) : NULL;
}
CustomDrawButton::CustomDrawButton(int normal_id, int active_id,