summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-10 21:40:32 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-10 21:40:32 +0000
commit93623c5d8fd1847dc31b67ed15779a3267a78d97 (patch)
treee311599b977576d6b94ab47829ccfffcbaaf9fad /chrome/common
parent9fb89471331ec0b7fad12ffafa505aa6b8425fa5 (diff)
downloadchromium_src-93623c5d8fd1847dc31b67ed15779a3267a78d97.zip
chromium_src-93623c5d8fd1847dc31b67ed15779a3267a78d97.tar.gz
chromium_src-93623c5d8fd1847dc31b67ed15779a3267a78d97.tar.bz2
re-apply r34183
--------------- linux: theme scrollbars from GTK theme Pick the color of the slider's thumbpart and rail from the GTK theme. We cannot match the exact visual appearance of the GTK theme, as rendering engines can make arbitrary changes to the actual visual appearance. But by sampling a representative set of pixels, we ensure that we will at least match the general color scheme. BUG=10949 patch by <markus [at] chromium> original review: http://codereview.chromium.org/400027/show Review URL: http://codereview.chromium.org/479006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34285 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/gtk_util.cc22
-rw-r--r--chrome/common/gtk_util.h3
-rw-r--r--chrome/common/platform_util.h3
-rw-r--r--chrome/common/platform_util_linux.cc12
-rw-r--r--chrome/common/platform_util_mac.mm4
-rw-r--r--chrome/common/platform_util_win.cc4
-rw-r--r--chrome/common/render_messages.h12
-rw-r--r--chrome/common/renderer_preferences.h9
8 files changed, 45 insertions, 24 deletions
diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc
index c9fce55..9154b92 100644
--- a/chrome/common/gtk_util.cc
+++ b/chrome/common/gtk_util.cc
@@ -13,6 +13,7 @@
#include "app/resource_bundle.h"
#include "base/linux_util.h"
#include "base/logging.h"
+#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/common/renderer_preferences.h"
#include "grit/theme_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -434,7 +435,8 @@ GtkWidget* IndentWidget(GtkWidget* content) {
return content_alignment;
}
-void InitRendererPrefsFromGtkSettings(RendererPreferences* prefs) {
+void InitRendererPrefsFromGtkSettings(RendererPreferences* prefs,
+ bool use_gtk_theme) {
DCHECK(prefs);
gint antialias = 0;
@@ -491,6 +493,24 @@ void InitRendererPrefsFromGtkSettings(RendererPreferences* prefs) {
prefs->focus_ring_color =
SkColorSetRGB(color.red / 257, color.green / 257, color.blue / 257);
+ GdkColor thumb_active_color, thumb_inactive_color, track_color;
+ GtkThemeProvider::GetScrollbarColors(&thumb_active_color,
+ &thumb_inactive_color,
+ &track_color,
+ use_gtk_theme);
+ prefs->thumb_active_color =
+ SkColorSetRGB(thumb_active_color.red / 257,
+ thumb_active_color.green / 257,
+ thumb_active_color.blue / 257);
+ prefs->thumb_inactive_color =
+ SkColorSetRGB(thumb_inactive_color.red / 257,
+ thumb_inactive_color.green / 257,
+ thumb_inactive_color.blue / 257);
+ prefs->track_color =
+ SkColorSetRGB(track_color.red / 257,
+ track_color.green / 257,
+ track_color.blue / 257);
+
if (hint_style)
g_free(hint_style);
if (rgba_style)
diff --git a/chrome/common/gtk_util.h b/chrome/common/gtk_util.h
index 7484f48..b46db0a 100644
--- a/chrome/common/gtk_util.h
+++ b/chrome/common/gtk_util.h
@@ -158,7 +158,8 @@ GtkWidget* IndentWidget(GtkWidget* content);
// Initialize the font settings in |prefs| (used when creating new renderers)
// based on GtkSettings (which itself comes from XSETTINGS).
-void InitRendererPrefsFromGtkSettings(RendererPreferences* prefs);
+void InitRendererPrefsFromGtkSettings(RendererPreferences* prefs,
+ bool use_gtk_theme);
// Get the current location of the mouse cursor relative to the screen.
gfx::Point ScreenPoint(GtkWidget* widget);
diff --git a/chrome/common/platform_util.h b/chrome/common/platform_util.h
index fbe1ba6..0a042f2 100644
--- a/chrome/common/platform_util.h
+++ b/chrome/common/platform_util.h
@@ -7,7 +7,6 @@
#include "app/gfx/native_widget_types.h"
#include "base/string16.h"
-#include "chrome/common/renderer_preferences.h"
class FilePath;
class GURL;
@@ -45,8 +44,6 @@ void SimpleErrorBox(gfx::NativeWindow parent,
const string16& title,
const string16& message);
-RendererPreferences GetInitedRendererPreferences();
-
}
#endif // CHROME_COMMON_PLATFORM_UTIL_H_
diff --git a/chrome/common/platform_util_linux.cc b/chrome/common/platform_util_linux.cc
index 021d6a1..b7853c5 100644
--- a/chrome/common/platform_util_linux.cc
+++ b/chrome/common/platform_util_linux.cc
@@ -8,8 +8,8 @@
#include "base/file_util.h"
#include "base/process_util.h"
-#include "base/singleton.h"
#include "base/string_util.h"
+#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/common/gtk_util.h"
#include "chrome/common/process_watcher.h"
#include "googleurl/src/gurl.h"
@@ -88,14 +88,4 @@ void SimpleErrorBox(gfx::NativeWindow parent,
gtk_widget_show_all(dialog);
}
-RendererPreferences GetInitedRendererPreferences() {
- RendererPreferences* prefs = Singleton<RendererPreferences>::get();
- static bool inited = false;
- if (!inited) {
- gtk_util::InitRendererPrefsFromGtkSettings(prefs);
- inited = true;
- }
- return *prefs;
-}
-
} // namespace platform_util
diff --git a/chrome/common/platform_util_mac.mm b/chrome/common/platform_util_mac.mm
index db474a2..2c9883a 100644
--- a/chrome/common/platform_util_mac.mm
+++ b/chrome/common/platform_util_mac.mm
@@ -84,8 +84,4 @@ void SimpleErrorBox(gfx::NativeWindow parent,
[alert runModal];
}
-RendererPreferences GetInitedRendererPreferences() {
- return RendererPreferences();
-}
-
} // namespace platform_util
diff --git a/chrome/common/platform_util_win.cc b/chrome/common/platform_util_win.cc
index 6ddd47c..1b1b666 100644
--- a/chrome/common/platform_util_win.cc
+++ b/chrome/common/platform_util_win.cc
@@ -157,8 +157,4 @@ void SimpleErrorBox(gfx::NativeWindow parent,
win_util::MessageBox(parent, message, title, MB_OK | MB_SETFOREGROUND);
}
-RendererPreferences GetInitedRendererPreferences() {
- return RendererPreferences();
-}
-
} // namespace platform_util
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index fa714cc..ce25321 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -1559,6 +1559,9 @@ struct ParamTraits<RendererPreferences> {
WriteParam(m, static_cast<int>(p.hinting));
WriteParam(m, static_cast<int>(p.subpixel_rendering));
WriteParam(m, p.focus_ring_color);
+ WriteParam(m, p.thumb_active_color);
+ WriteParam(m, p.thumb_inactive_color);
+ WriteParam(m, p.track_color);
WriteParam(m, p.browser_handles_top_level_requests);
}
static bool Read(const Message* m, void** iter, param_type* p) {
@@ -1584,6 +1587,15 @@ struct ParamTraits<RendererPreferences> {
return false;
p->focus_ring_color = focus_ring_color;
+ int thumb_active_color, thumb_inactive_color, track_color;
+ if (!ReadParam(m, iter, &thumb_active_color) ||
+ !ReadParam(m, iter, &thumb_inactive_color) ||
+ !ReadParam(m, iter, &track_color))
+ return false;
+ p->thumb_active_color = thumb_active_color;
+ p->thumb_inactive_color = thumb_inactive_color;
+ p->track_color = track_color;
+
if (!ReadParam(m, iter, &p->browser_handles_top_level_requests))
return false;
diff --git a/chrome/common/renderer_preferences.h b/chrome/common/renderer_preferences.h
index b08548e..a982d57 100644
--- a/chrome/common/renderer_preferences.h
+++ b/chrome/common/renderer_preferences.h
@@ -51,6 +51,12 @@ struct RendererPreferences {
// The color of the focus ring. Currently only used on Linux.
SkColor focus_ring_color;
+ // The color of different parts of the scrollbar. Currently only used on
+ // Linux.
+ SkColor thumb_active_color;
+ SkColor thumb_inactive_color;
+ SkColor track_color;
+
// Browser wants a look at all top level requests
bool browser_handles_top_level_requests;
@@ -61,6 +67,9 @@ struct RendererPreferences {
subpixel_rendering(
RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT),
focus_ring_color(0),
+ thumb_active_color(0),
+ thumb_inactive_color(0),
+ track_color(0),
browser_handles_top_level_requests(false) {
}
};