summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-08 18:50:56 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-08 18:50:56 +0000
commit362646053314c8bb9b078799cd0c9aa1f3d973f3 (patch)
tree37c0c39375fea2c6abbd5bf548687055fea36211
parentb56ccebe2ee52aaaac8f6ec68edc024235e7d478 (diff)
downloadchromium_src-362646053314c8bb9b078799cd0c9aa1f3d973f3.zip
chromium_src-362646053314c8bb9b078799cd0c9aa1f3d973f3.tar.gz
chromium_src-362646053314c8bb9b078799cd0c9aa1f3d973f3.tar.bz2
linux: Pass subpixel positioning setting to WebKit.
This makes us configure renderers appropriately based on --enable-text-subpixel-positioning. It also updates SandboxIPCProcess to pass the flag through so the results returned by its calls to WebFontInfo::renderStyleForStrike() will reflect the setting. BUG=125066 TEST=manual: both regular and web fonts within the renderer use subpixel positioning when --enable-text-subpixel-positioning is set Review URL: https://chromiumcodereview.appspot.com/10540038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141246 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/renderer_preferences_util.cc9
-rw-r--r--content/browser/renderer_host/render_sandbox_host_linux.cc10
-rw-r--r--content/common/child_process_sandbox_support_impl_linux.cc9
-rw-r--r--content/common/view_messages.h1
-rw-r--r--content/public/common/renderer_preferences.cc1
-rw-r--r--content/public/common/renderer_preferences.h4
-rw-r--r--content/renderer/render_view_linux.cc21
7 files changed, 42 insertions, 13 deletions
diff --git a/chrome/browser/renderer_preferences_util.cc b/chrome/browser/renderer_preferences_util.cc
index 96cbbc4..7c66eb2 100644
--- a/chrome/browser/renderer_preferences_util.cc
+++ b/chrome/browser/renderer_preferences_util.cc
@@ -12,6 +12,9 @@
#if defined(TOOLKIT_GTK)
#include "chrome/browser/ui/gtk/gtk_theme_service.h"
#include "chrome/browser/ui/gtk/gtk_util.h"
+#elif defined(USE_ASH)
+#include "base/command_line.h"
+#include "ui/base/ui_base_switches.h"
#endif
namespace renderer_preferences_util {
@@ -36,6 +39,12 @@ void UpdateFromSystemSettings(
prefs->inactive_selection_fg_color =
theme_service->get_inactive_selection_fg_color();
#elif defined(USE_ASH)
+ // TODO(derat): This code and GetCairoFontOptions() from ui/gfx/pango_util.cc
+ // should get their settings from the same place.
+ prefs->use_subpixel_positioning =
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableTextSubpixelPositioning);
+
// This color is 0x544d90fe modulated with 0xffffff.
prefs->active_selection_bg_color = SkColorSetRGB(0xCB, 0xE4, 0xFA);
prefs->active_selection_fg_color = SK_ColorBLACK;
diff --git a/content/browser/renderer_host/render_sandbox_host_linux.cc b/content/browser/renderer_host/render_sandbox_host_linux.cc
index 8681ddd..3685a89 100644
--- a/content/browser/renderer_host/render_sandbox_host_linux.cc
+++ b/content/browser/renderer_host/render_sandbox_host_linux.cc
@@ -34,6 +34,7 @@
#include "third_party/npapi/bindings/npapi_extensions.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontInfo.h"
+#include "ui/base/ui_base_switches.h"
using WebKit::WebCString;
using WebKit::WebFontInfo;
@@ -62,6 +63,12 @@ class SandboxIPCProcess {
sandbox_cmd_.push_back(sandbox_cmd);
sandbox_cmd_.push_back(base::kFindInodeSwitch);
}
+
+ // FontConfig doesn't provide a standard property to control subpixel
+ // positioning, so we pass a UI flag through to WebKit.
+ WebFontInfo::setSubpixelPositioning(
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableTextSubpixelPositioning));
}
~SandboxIPCProcess();
@@ -300,7 +307,8 @@ class SandboxIPCProcess {
reply.WriteInt(style.useHinting);
reply.WriteInt(style.hintStyle);
reply.WriteInt(style.useAntiAlias);
- reply.WriteInt(style.useSubpixel);
+ reply.WriteInt(style.useSubpixelRendering);
+ reply.WriteInt(style.useSubpixelPositioning);
SendRendererReply(fds, reply, -1);
}
diff --git a/content/common/child_process_sandbox_support_impl_linux.cc b/content/common/child_process_sandbox_support_impl_linux.cc
index 5a07986..9294e7b 100644
--- a/content/common/child_process_sandbox_support_impl_linux.cc
+++ b/content/common/child_process_sandbox_support_impl_linux.cc
@@ -65,19 +65,22 @@ void GetRenderStyleForStrike(const char* family, int sizeAndStyle,
Pickle reply(reinterpret_cast<char*>(buf), n);
PickleIterator pickle_iter(reply);
- int useBitmaps, useAutoHint, useHinting, hintStyle, useAntiAlias, useSubpixel;
+ int useBitmaps, useAutoHint, useHinting, hintStyle, useAntiAlias;
+ int useSubpixelRendering, useSubpixelPositioning;
if (reply.ReadInt(&pickle_iter, &useBitmaps) &&
reply.ReadInt(&pickle_iter, &useAutoHint) &&
reply.ReadInt(&pickle_iter, &useHinting) &&
reply.ReadInt(&pickle_iter, &hintStyle) &&
reply.ReadInt(&pickle_iter, &useAntiAlias) &&
- reply.ReadInt(&pickle_iter, &useSubpixel)) {
+ reply.ReadInt(&pickle_iter, &useSubpixelRendering) &&
+ reply.ReadInt(&pickle_iter, &useSubpixelPositioning)) {
out->useBitmaps = useBitmaps;
out->useAutoHint = useAutoHint;
out->useHinting = useHinting;
out->hintStyle = hintStyle;
out->useAntiAlias = useAntiAlias;
- out->useSubpixel = useSubpixel;
+ out->useSubpixelRendering = useSubpixelRendering;
+ out->useSubpixelPositioning = useSubpixelPositioning;
}
}
diff --git a/content/common/view_messages.h b/content/common/view_messages.h
index 09c6cf3..0d43b11 100644
--- a/content/common/view_messages.h
+++ b/content/common/view_messages.h
@@ -296,6 +296,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::RendererPreferences)
IPC_STRUCT_TRAITS_MEMBER(should_antialias_text)
IPC_STRUCT_TRAITS_MEMBER(hinting)
IPC_STRUCT_TRAITS_MEMBER(subpixel_rendering)
+ IPC_STRUCT_TRAITS_MEMBER(use_subpixel_positioning)
IPC_STRUCT_TRAITS_MEMBER(focus_ring_color)
IPC_STRUCT_TRAITS_MEMBER(thumb_active_color)
IPC_STRUCT_TRAITS_MEMBER(thumb_inactive_color)
diff --git a/content/public/common/renderer_preferences.cc b/content/public/common/renderer_preferences.cc
index 8d6dc3c..ddb4c11 100644
--- a/content/public/common/renderer_preferences.cc
+++ b/content/public/common/renderer_preferences.cc
@@ -12,6 +12,7 @@ RendererPreferences::RendererPreferences()
hinting(RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT),
subpixel_rendering(
RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT),
+ use_subpixel_positioning(false),
focus_ring_color(0),
thumb_active_color(0),
thumb_inactive_color(0),
diff --git a/content/public/common/renderer_preferences.h b/content/public/common/renderer_preferences.h
index b745d09..ac7e58c 100644
--- a/content/public/common/renderer_preferences.h
+++ b/content/public/common/renderer_preferences.h
@@ -54,6 +54,10 @@ struct CONTENT_EXPORT RendererPreferences {
// Currently only used by Linux.
RendererPreferencesSubpixelRenderingEnum subpixel_rendering;
+ // Whether subpixel positioning should be used, permitting fractional X
+ // positions for glyphs. Currently only used by Linux.
+ bool use_subpixel_positioning;
+
// The color of the focus ring. Currently only used on Linux.
SkColor focus_ring_color;
diff --git a/content/renderer/render_view_linux.cc b/content/renderer/render_view_linux.cc
index e48ba8c..ca35529 100644
--- a/content/renderer/render_view_linux.cc
+++ b/content/renderer/render_view_linux.cc
@@ -1,12 +1,14 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/renderer/render_view_impl.h"
#include "content/public/common/renderer_preferences.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontInfo.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontRendering.h"
+using WebKit::WebFontInfo;
using WebKit::WebFontRendering;
static SkPaint::Hinting RendererPreferencesToSkiaHinting(
@@ -86,7 +88,7 @@ static bool RendererPreferencesToAntiAliasFlag(
return prefs.should_antialias_text;
}
-static bool RendererPreferencesToSubpixelGlyphsFlag(
+static bool RendererPreferencesToSubpixelRenderingFlag(
const content::RendererPreferences& prefs) {
if (prefs.subpixel_rendering !=
content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT &&
@@ -94,18 +96,19 @@ static bool RendererPreferencesToSubpixelGlyphsFlag(
content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE) {
return true;
}
-
return false;
}
void RenderViewImpl::UpdateFontRenderingFromRendererPrefs() {
const content::RendererPreferences& prefs = renderer_preferences_;
WebFontRendering::setHinting(RendererPreferencesToSkiaHinting(prefs));
- WebFontRendering::setLCDOrder(RendererPreferencesToSkiaLCDOrder(
- prefs.subpixel_rendering));
- WebFontRendering::setLCDOrientation(RendererPreferencesToSkiaLCDOrientation(
- prefs.subpixel_rendering));
+ WebFontRendering::setLCDOrder(
+ RendererPreferencesToSkiaLCDOrder(prefs.subpixel_rendering));
+ WebFontRendering::setLCDOrientation(
+ RendererPreferencesToSkiaLCDOrientation(prefs.subpixel_rendering));
WebFontRendering::setAntiAlias(RendererPreferencesToAntiAliasFlag(prefs));
- WebFontRendering::setSubpixelGlyphs(RendererPreferencesToSubpixelGlyphsFlag(
- prefs));
+ WebFontRendering::setSubpixelRendering(
+ RendererPreferencesToSubpixelRenderingFlag(prefs));
+ WebFontRendering::setSubpixelPositioning(prefs.use_subpixel_positioning);
+ WebFontInfo::setSubpixelPositioning(prefs.use_subpixel_positioning);
}