summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-04 17:12:04 +0000
committerflackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-04 17:12:04 +0000
commitf6f8283f35f39c9d565aa75f8e347eb90ac89bec (patch)
treed51063b60cb8ff2522e39627a795bf1dc905ae09
parentf50ebe52e0f92fa62d5ce9859ccedc583f79f640 (diff)
downloadchromium_src-f6f8283f35f39c9d565aa75f8e347eb90ac89bec.zip
chromium_src-f6f8283f35f39c9d565aa75f8e347eb90ac89bec.tar.gz
chromium_src-f6f8283f35f39c9d565aa75f8e347eb90ac89bec.tar.bz2
Split default font settings into webkit and browser settings having separate flags to enable subpixel positioning.
Allows separately specifying subpixel positioning for webkit and browser UI. Adds a flag in about:flags to enable subpixel positioning in web pages. BUG=145020 TEST=Run chrome with Webkit text subpixel positioning flag enabled and navigate to http://jsfiddle.net/ALd5F/21/, span widths should be non-integer values. Review URL: https://chromiumcodereview.appspot.com/10916055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154767 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd6
-rw-r--r--chrome/browser/about_flags.cc7
-rw-r--r--chrome/browser/renderer_preferences_util.cc2
-rw-r--r--content/browser/renderer_host/render_sandbox_host_linux.cc2
-rw-r--r--ui/base/ui_base_switches.cc12
-rw-r--r--ui/base/ui_base_switches.h3
-rw-r--r--ui/gfx/font_render_params_android.cc5
-rw-r--r--ui/gfx/font_render_params_linux.cc33
-rw-r--r--ui/gfx/font_render_params_linux.h3
9 files changed, 57 insertions, 16 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index ab32b02..4f430da 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -6056,6 +6056,12 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_FLAGS_DISABLE_ACCELERATED_VIDEO_DECODE_DESCRIPTION" desc="Description for the flag to disable accelerated video decode where available.">
Disables hardware-accelerated video decode where available.
</message>
+ <message name="IDS_FLAGS_ENABLE_WEBKIT_TEXT_SUBPIXEL_POSITIONING_NAME" desc="Name of the flag to enable subpixel text positioning on web pages.">
+ Enable webpage text sub-pixel positioning.
+ </message>
+ <message name="IDS_FLAGS_ENABLE_WEBKIT_TEXT_SUBPIXEL_POSITIONING_DESCRIPTION" desc="Description for the flag to set when subpixel text positioning is enabled on web pages.">
+ Allows text glyphs on web pages to have X positions which aren't snapped to the pixel grid.
+ </message>
<!-- Crashes -->
<message name="IDS_CRASHES_TITLE" desc="Title for the chrome://crashes page.">
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 00e35b1..6661e87 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -702,6 +702,13 @@ const Experiment kExperiments[] = {
MULTI_VALUE_TYPE(kTouchOptimizedUIChoices)
},
{
+ "enable-webkit-text-subpixel-positioning",
+ IDS_FLAGS_ENABLE_WEBKIT_TEXT_SUBPIXEL_POSITIONING_NAME,
+ IDS_FLAGS_ENABLE_WEBKIT_TEXT_SUBPIXEL_POSITIONING_DESCRIPTION,
+ kOsCrOS,
+ SINGLE_VALUE_TYPE(switches::kEnableWebkitTextSubpixelPositioning)
+ },
+ {
"enable-touch-events",
IDS_ENABLE_TOUCH_EVENTS_NAME,
IDS_ENABLE_TOUCH_EVENTS_DESCRIPTION,
diff --git a/chrome/browser/renderer_preferences_util.cc b/chrome/browser/renderer_preferences_util.cc
index bb29ee2..f782b43 100644
--- a/chrome/browser/renderer_preferences_util.cc
+++ b/chrome/browser/renderer_preferences_util.cc
@@ -106,7 +106,7 @@ void UpdateFromSystemSettings(
#endif
#if defined(OS_LINUX) || defined(OS_ANDROID)
- const gfx::FontRenderParams& params = gfx::GetDefaultFontRenderParams();
+ const gfx::FontRenderParams& params = gfx::GetDefaultWebKitFontRenderParams();
prefs->should_antialias_text = params.antialiasing;
prefs->use_subpixel_positioning = params.subpixel_positioning;
prefs->hinting = GetRendererPreferencesHintingEnum(params.hinting);
diff --git a/content/browser/renderer_host/render_sandbox_host_linux.cc b/content/browser/renderer_host/render_sandbox_host_linux.cc
index 1ef8e71..0249836 100644
--- a/content/browser/renderer_host/render_sandbox_host_linux.cc
+++ b/content/browser/renderer_host/render_sandbox_host_linux.cc
@@ -76,7 +76,7 @@ class SandboxIPCProcess {
// positioning, so just pass false here to avoid the issue.
false
#else
- gfx::GetDefaultFontRenderParams().subpixel_positioning
+ gfx::GetDefaultWebKitFontRenderParams().subpixel_positioning
#endif
);
}
diff --git a/ui/base/ui_base_switches.cc b/ui/base/ui_base_switches.cc
index 50d9709..545189e 100644
--- a/ui/base/ui_base_switches.cc
+++ b/ui/base/ui_base_switches.cc
@@ -14,9 +14,10 @@ const char kEnableBezelTouch[] = "enable-bezel-touch";
const char kDisableScalingInImageSkiaOperations[] =
"disable-scaling-in-image-skia-operations";
-// Let text glyphs have X-positions that aren't snapped to the pixel grid.
-const char kEnableTextSubpixelPositioning[] =
- "enable-text-subpixel-positioning";
+// Let text glyphs have X-positions that aren't snapped to the pixel grid in
+// the browser UI.
+const char kEnableBrowserTextSubpixelPositioning[] =
+ "enable-browser-text-subpixel-positioning";
// Enable touch screen calibration.
const char kEnableTouchCalibration[] = "enable-touch-calibration";
@@ -27,6 +28,11 @@ const char kEnableTouchEvents[] = "enable-touch-events";
// Enables the Views textfield on Windows.
const char kEnableViewsTextfield[] = "enable-views-textfield";
+// Enable text glyphs to have X-positions that aren't snapped to the pixel grid
+// in webkit renderers.
+const char kEnableWebkitTextSubpixelPositioning[] =
+ "enable-webkit-text-subpixel-positioning";
+
// Overrides the device scale factor for the browser UI and the
// contents.
const char kForceDeviceScaleFactor[] = "force-device-scale-factor";
diff --git a/ui/base/ui_base_switches.h b/ui/base/ui_base_switches.h
index 2613fe8..0f522ce 100644
--- a/ui/base/ui_base_switches.h
+++ b/ui/base/ui_base_switches.h
@@ -14,10 +14,11 @@ namespace switches {
UI_EXPORT extern const char kEnableBezelTouch[];
UI_EXPORT extern const char kDisableScalingInImageSkiaOperations[];
-UI_EXPORT extern const char kEnableTextSubpixelPositioning[];
+UI_EXPORT extern const char kEnableBrowserTextSubpixelPositioning[];
UI_EXPORT extern const char kEnableTouchCalibration[];
UI_EXPORT extern const char kEnableTouchEvents[];
UI_EXPORT extern const char kEnableViewsTextfield[];
+UI_EXPORT extern const char kEnableWebkitTextSubpixelPositioning[];
UI_EXPORT extern const char kForceDeviceScaleFactor[];
UI_EXPORT extern const char kHighlightMissing2xResources[];
UI_EXPORT extern const char kLang[];
diff --git a/ui/gfx/font_render_params_android.cc b/ui/gfx/font_render_params_android.cc
index e3547e1..3dfd668 100644
--- a/ui/gfx/font_render_params_android.cc
+++ b/ui/gfx/font_render_params_android.cc
@@ -29,7 +29,12 @@ const FontRenderParams& GetDefaultFontRenderParams() {
static FontRenderParams default_params;
if (!loaded_defaults)
LoadDefaults(&default_params);
+ loaded_defaults = true;
return default_params;
}
+const FontRenderParams& GetDefaultWebKitFontRenderParams() {
+ return GetDefaultFontRenderParams();
+}
+
} // namespace gfx
diff --git a/ui/gfx/font_render_params_linux.cc b/ui/gfx/font_render_params_linux.cc
index ddefc95..2b32c7b 100644
--- a/ui/gfx/font_render_params_linux.cc
+++ b/ui/gfx/font_render_params_linux.cc
@@ -18,8 +18,9 @@ namespace gfx {
namespace {
-// Initializes |params| with the system's default settings.
-void LoadDefaults(FontRenderParams* params) {
+// Initializes |params| with the system's default settings. |renderer| is true
+// when setting WebKit renderer defaults.
+void LoadDefaults(FontRenderParams* params, bool renderer) {
#if defined(TOOLKIT_GTK)
params->antialiasing = true;
params->subpixel_positioning = false;
@@ -105,15 +106,17 @@ void LoadDefaults(FontRenderParams* params) {
params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_NONE;
}
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableTextSubpixelPositioning)) {
- // To enable subpixel positioning, we need to disable hinting.
- params->subpixel_positioning = true;
+ params->subpixel_positioning =
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ renderer ?
+ switches::kEnableWebkitTextSubpixelPositioning :
+ switches::kEnableBrowserTextSubpixelPositioning);
+
+ // To enable subpixel positioning, we need to disable hinting.
+ if (params->subpixel_positioning)
params->hinting = FontRenderParams::HINTING_NONE;
- } else {
- params->subpixel_positioning = false;
+ else
params->hinting = FontRenderParams::HINTING_SLIGHT;
- }
#endif
}
@@ -123,7 +126,17 @@ const FontRenderParams& GetDefaultFontRenderParams() {
static bool loaded_defaults = false;
static FontRenderParams default_params;
if (!loaded_defaults)
- LoadDefaults(&default_params);
+ LoadDefaults(&default_params, /* renderer */ false);
+ loaded_defaults = true;
+ return default_params;
+}
+
+const FontRenderParams& GetDefaultWebKitFontRenderParams() {
+ static bool loaded_defaults = false;
+ static FontRenderParams default_params;
+ if (!loaded_defaults)
+ LoadDefaults(&default_params, /* renderer */ true);
+ loaded_defaults = true;
return default_params;
}
diff --git a/ui/gfx/font_render_params_linux.h b/ui/gfx/font_render_params_linux.h
index 7a9339a..de15d01 100644
--- a/ui/gfx/font_render_params_linux.h
+++ b/ui/gfx/font_render_params_linux.h
@@ -56,6 +56,9 @@ struct UI_EXPORT FontRenderParams {
// Returns the system's default parameters for font rendering.
UI_EXPORT const FontRenderParams& GetDefaultFontRenderParams();
+// Returns the system's default parameters for WebKit font rendering.
+UI_EXPORT const FontRenderParams& GetDefaultWebKitFontRenderParams();
+
} // namespace gfx
#endif // UI_GFX_FONT_RENDER_PARAMS_LINUX_H_