summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-06 22:17:26 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-06 22:17:26 +0000
commit05c453db1e7a357eb2cc1b6ac67ff32a5256bb19 (patch)
tree34a4f7e5e7062b378cab8a9c399ef4f6f5a403c5 /chrome
parentd6f7d56a9f137a08fc65a06aa6fab3e1038f13c6 (diff)
downloadchromium_src-05c453db1e7a357eb2cc1b6ac67ff32a5256bb19.zip
chromium_src-05c453db1e7a357eb2cc1b6ac67ff32a5256bb19.tar.gz
chromium_src-05c453db1e7a357eb2cc1b6ac67ff32a5256bb19.tar.bz2
Linux: Pass font settings through to interstitial renderers.
BUG=18483 TESTED=restarted and visited a page with a broken SSL cert a few times while changing font settings via gnome-appearance-properties Review URL: http://codereview.chromium.org/164094 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22679 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/tab_contents/interstitial_page.cc7
-rw-r--r--chrome/browser/tab_contents/interstitial_page.h7
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_gtk.cc47
-rw-r--r--chrome/common/gtk_util.cc56
-rw-r--r--chrome/common/gtk_util.h6
5 files changed, 77 insertions, 46 deletions
diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc
index c8863d9..4a6439f 100644
--- a/chrome/browser/tab_contents/interstitial_page.cc
+++ b/chrome/browser/tab_contents/interstitial_page.cc
@@ -17,6 +17,9 @@
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_contents_view.h"
#include "chrome/common/bindings_policy.h"
+#if defined(TOOLKIT_GTK)
+#include "chrome/common/gtk_util.h"
+#endif
#include "chrome/common/notification_service.h"
#include "grit/browser_resources.h"
#include "net/base/escape.h"
@@ -130,6 +133,10 @@ InterstitialPage::InterstitialPage(TabContents* tab,
// a page) when we have a pending entry (in the process of loading a new top
// frame).
DCHECK(new_navigation || !tab->controller().pending_entry());
+
+#if defined(TOOLKIT_GTK)
+ gtk_util::InitRendererPrefsFromGtkSettings(&renderer_preferences_);
+#endif
}
InterstitialPage::~InterstitialPage() {
diff --git a/chrome/browser/tab_contents/interstitial_page.h b/chrome/browser/tab_contents/interstitial_page.h
index 05b2031..c2d7db9 100644
--- a/chrome/browser/tab_contents/interstitial_page.h
+++ b/chrome/browser/tab_contents/interstitial_page.h
@@ -12,6 +12,7 @@
#include "base/scoped_ptr.h"
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
#include "chrome/common/notification_registrar.h"
+#include "chrome/common/renderer_preferences.h"
#include "googleurl/src/gurl.h"
class MessageLoop;
@@ -102,6 +103,9 @@ class InterstitialPage : public NotificationObserver,
const std::wstring& title);
virtual void DomOperationResponse(const std::string& json_string,
int automation_id);
+ virtual RendererPreferences GetRendererPrefs() const {
+ return renderer_preferences_;
+ }
// Invoked when the page sent a command through DOMAutomation.
virtual void CommandReceived(const std::string& command) {}
@@ -200,6 +204,9 @@ class InterstitialPage : public NotificationObserver,
typedef std::map<TabContents*,InterstitialPage*> InterstitialPageMap;
static InterstitialPageMap* tab_to_interstitial_page_;
+ // Settings passed to the renderer.
+ RendererPreferences renderer_preferences_;
+
DISALLOW_COPY_AND_ASSIGN(InterstitialPage);
};
diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/tab_contents/tab_contents_view_gtk.cc
index 0c3a072..fca9efa 100644
--- a/chrome/browser/tab_contents/tab_contents_view_gtk.cc
+++ b/chrome/browser/tab_contents/tab_contents_view_gtk.cc
@@ -559,52 +559,7 @@ gfx::NativeWindow TabContentsViewGtk::GetTopLevelNativeWindow() const {
}
void TabContentsViewGtk::InitRendererPrefs(RendererPreferences* prefs) {
- GtkSettings* gtk_settings = gtk_settings_get_default();
-
- gint antialias = 0;
- gint hinting = 0;
- gchar* hint_style = NULL;
- gchar* rgba_style = NULL;
- g_object_get(gtk_settings,
- "gtk-xft-antialias", &antialias,
- "gtk-xft-hinting", &hinting,
- "gtk-xft-hintstyle", &hint_style,
- "gtk-xft-rgba", &rgba_style,
- NULL);
-
- // g_object_get() doesn't tell us whether the properties were present or not,
- // but if they aren't (because gnome-settings-daemon isn't running), we'll get
- // NULL values for the strings.
- if (hint_style && rgba_style) {
- prefs->should_antialias_text = antialias;
-
- if (hinting == 0 || strcmp(hint_style, "hintnone") == 0) {
- prefs->hinting = RENDERER_PREFERENCES_HINTING_NONE;
- } else if (strcmp(hint_style, "hintslight") == 0) {
- prefs->hinting = RENDERER_PREFERENCES_HINTING_SLIGHT;
- } else if (strcmp(hint_style, "hintmedium") == 0) {
- prefs->hinting = RENDERER_PREFERENCES_HINTING_MEDIUM;
- } else if (strcmp(hint_style, "hintfull") == 0) {
- prefs->hinting = RENDERER_PREFERENCES_HINTING_FULL;
- }
-
- if (strcmp(rgba_style, "none") == 0) {
- prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE;
- } else if (strcmp(rgba_style, "rgb") == 0) {
- prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB;
- } else if (strcmp(rgba_style, "bgr") == 0) {
- prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR;
- } else if (strcmp(rgba_style, "vrgb") == 0) {
- prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB;
- } else if (strcmp(rgba_style, "vbgr") == 0) {
- prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR;
- }
- }
-
- if (hint_style)
- g_free(hint_style);
- if (rgba_style)
- g_free(rgba_style);
+ gtk_util::InitRendererPrefsFromGtkSettings(prefs);
}
void TabContentsViewGtk::GetContainerBounds(gfx::Rect* out) const {
diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc
index 6e0d733..08658a7 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/common/renderer_preferences.h"
#include "grit/theme_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -432,4 +433,59 @@ GtkWidget* IndentWidget(GtkWidget* content) {
return content_alignment;
}
+void InitRendererPrefsFromGtkSettings(RendererPreferences* prefs) {
+ DCHECK(prefs);
+
+ gint antialias = 0;
+ gint hinting = 0;
+ gchar* hint_style = NULL;
+ gchar* rgba_style = NULL;
+ g_object_get(gtk_settings_get_default(),
+ "gtk-xft-antialias", &antialias,
+ "gtk-xft-hinting", &hinting,
+ "gtk-xft-hintstyle", &hint_style,
+ "gtk-xft-rgba", &rgba_style,
+ NULL);
+
+ // Set some reasonable defaults.
+ prefs->should_antialias_text = true;
+ prefs->hinting = RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT;
+ prefs->subpixel_rendering =
+ RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT;
+
+ // g_object_get() doesn't tell us whether the properties were present or not,
+ // but if they aren't (because gnome-settings-daemon isn't running), we'll get
+ // NULL values for the strings.
+ if (hint_style && rgba_style) {
+ prefs->should_antialias_text = antialias;
+
+ if (hinting == 0 || strcmp(hint_style, "hintnone") == 0) {
+ prefs->hinting = RENDERER_PREFERENCES_HINTING_NONE;
+ } else if (strcmp(hint_style, "hintslight") == 0) {
+ prefs->hinting = RENDERER_PREFERENCES_HINTING_SLIGHT;
+ } else if (strcmp(hint_style, "hintmedium") == 0) {
+ prefs->hinting = RENDERER_PREFERENCES_HINTING_MEDIUM;
+ } else if (strcmp(hint_style, "hintfull") == 0) {
+ prefs->hinting = RENDERER_PREFERENCES_HINTING_FULL;
+ }
+
+ if (strcmp(rgba_style, "none") == 0) {
+ prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE;
+ } else if (strcmp(rgba_style, "rgb") == 0) {
+ prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB;
+ } else if (strcmp(rgba_style, "bgr") == 0) {
+ prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR;
+ } else if (strcmp(rgba_style, "vrgb") == 0) {
+ prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB;
+ } else if (strcmp(rgba_style, "vbgr") == 0) {
+ prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR;
+ }
+ }
+
+ if (hint_style)
+ g_free(hint_style);
+ if (rgba_style)
+ g_free(rgba_style);
+}
+
} // namespace gtk_util
diff --git a/chrome/common/gtk_util.h b/chrome/common/gtk_util.h
index c5ef51e..786c5a3 100644
--- a/chrome/common/gtk_util.h
+++ b/chrome/common/gtk_util.h
@@ -16,6 +16,8 @@
typedef struct _GtkWidget GtkWidget;
+struct RendererPreferences; // from common/renderer_preferences.h
+
namespace event_utils {
// Translates event flags into what kind of disposition they represent.
@@ -144,6 +146,10 @@ void SetLabelColor(GtkWidget* label, const GdkColor* color);
// Adds the given widget to an alignment identing it by |kGroupIndent|.
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);
+
} // namespace gtk_util
#endif // CHROME_COMMON_GTK_UTIL_H_