summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorfalken@chromium.org <falken@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-18 07:20:32 +0000
committerfalken@chromium.org <falken@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-18 07:20:32 +0000
commit966d1e1627da47dc782a3d7ca8204de233b6edd6 (patch)
tree49477476b24226b10881e6b0cc35e26197b77c74 /ppapi
parent1c6189ff4780f3a0968eb93370de7f477bf44b50 (diff)
downloadchromium_src-966d1e1627da47dc782a3d7ca8204de233b6edd6.zip
chromium_src-966d1e1627da47dc782a3d7ca8204de233b6edd6.tar.gz
chromium_src-966d1e1627da47dc782a3d7ca8204de233b6edd6.tar.bz2
Migrate WebKit "global script" font prefs.
The effect is to migrate a pref like webkit.webprefs.global.standard_font_family to webkit.webprefs.fonts.standard.Zyyy This has two motivations: 1) Undo the migration of font prefs to the "global" (as opposed to per-tab) namespace, as planned here: <http://codereview.chromium.org/9838050>. There are still more prefs to move out of "global" after this patch. 2) Move the "global script" (as opposed to per-script) font prefs into the per-script font maps, under the script code "Zyyy" (the ISO 15924 code for the "Common" script). This is consistent with WebKit-side settings and should simplify the code overall as we no longer have to special case the global script vs the per-script fonts. TBR=gene for chrome/browser/printing BUG=123812 TEST=browser_tests --gtest_filter=PrefsTab* and ExtensionApiTest.Font* Review URL: https://chromiumcodereview.appspot.com/10107014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137835 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/proxy/ppapi_messages.h8
-rw-r--r--ppapi/shared_impl/ppapi_preferences.cc10
-rw-r--r--ppapi/shared_impl/ppapi_preferences.h10
-rw-r--r--ppapi/shared_impl/private/ppb_browser_font_trusted_shared.cc30
-rw-r--r--ppapi/shared_impl/private/ppb_font_shared.cc30
5 files changed, 61 insertions, 27 deletions
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index 493352d6..b96f13d 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -123,10 +123,10 @@ IPC_STRUCT_TRAITS_BEGIN(ppapi::ViewData)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(ppapi::Preferences)
- IPC_STRUCT_TRAITS_MEMBER(standard_font_family)
- IPC_STRUCT_TRAITS_MEMBER(fixed_font_family)
- IPC_STRUCT_TRAITS_MEMBER(serif_font_family)
- IPC_STRUCT_TRAITS_MEMBER(sans_serif_font_family)
+ IPC_STRUCT_TRAITS_MEMBER(standard_font_family_map)
+ IPC_STRUCT_TRAITS_MEMBER(fixed_font_family_map)
+ IPC_STRUCT_TRAITS_MEMBER(serif_font_family_map)
+ IPC_STRUCT_TRAITS_MEMBER(sans_serif_font_family_map)
IPC_STRUCT_TRAITS_MEMBER(default_font_size)
IPC_STRUCT_TRAITS_MEMBER(default_fixed_font_size)
IPC_STRUCT_TRAITS_END()
diff --git a/ppapi/shared_impl/ppapi_preferences.cc b/ppapi/shared_impl/ppapi_preferences.cc
index 8622640..14c89f0 100644
--- a/ppapi/shared_impl/ppapi_preferences.cc
+++ b/ppapi/shared_impl/ppapi_preferences.cc
@@ -4,8 +4,6 @@
#include "ppapi/shared_impl/ppapi_preferences.h"
-#include "webkit/glue/webpreferences.h"
-
namespace ppapi {
Preferences::Preferences()
@@ -15,10 +13,10 @@ Preferences::Preferences()
}
Preferences::Preferences(const webkit_glue::WebPreferences& prefs)
- : standard_font_family(prefs.standard_font_family),
- fixed_font_family(prefs.fixed_font_family),
- serif_font_family(prefs.serif_font_family),
- sans_serif_font_family(prefs.sans_serif_font_family),
+ : standard_font_family_map(prefs.standard_font_family_map),
+ fixed_font_family_map(prefs.fixed_font_family_map),
+ serif_font_family_map(prefs.serif_font_family_map),
+ sans_serif_font_family_map(prefs.sans_serif_font_family_map),
default_font_size(prefs.default_font_size),
default_fixed_font_size(prefs.default_fixed_font_size),
// Pepper 3D support keys off of WebGL which is what the GPU blacklist
diff --git a/ppapi/shared_impl/ppapi_preferences.h b/ppapi/shared_impl/ppapi_preferences.h
index 66b2051..008811f 100644
--- a/ppapi/shared_impl/ppapi_preferences.h
+++ b/ppapi/shared_impl/ppapi_preferences.h
@@ -5,8 +5,8 @@
#ifndef PPAPI_SHARED_IMPL_PPAPI_PREFERENCES_H_
#define PPAPI_SHARED_IMPL_PPAPI_PREFERENCES_H_
-#include "base/string16.h"
#include "ppapi/shared_impl/ppapi_shared_export.h"
+#include "webkit/glue/webpreferences.h"
namespace webkit_glue {
struct WebPreferences;
@@ -20,10 +20,10 @@ struct PPAPI_SHARED_EXPORT Preferences {
explicit Preferences(const webkit_glue::WebPreferences& prefs);
~Preferences();
- string16 standard_font_family;
- string16 fixed_font_family;
- string16 serif_font_family;
- string16 sans_serif_font_family;
+ webkit_glue::WebPreferences::ScriptFontFamilyMap standard_font_family_map;
+ webkit_glue::WebPreferences::ScriptFontFamilyMap fixed_font_family_map;
+ webkit_glue::WebPreferences::ScriptFontFamilyMap serif_font_family_map;
+ webkit_glue::WebPreferences::ScriptFontFamilyMap sans_serif_font_family_map;
int default_font_size;
int default_fixed_font_size;
diff --git a/ppapi/shared_impl/private/ppb_browser_font_trusted_shared.cc b/ppapi/shared_impl/private/ppb_browser_font_trusted_shared.cc
index 0d73691..e5414b3 100644
--- a/ppapi/shared_impl/private/ppb_browser_font_trusted_shared.cc
+++ b/ppapi/shared_impl/private/ppb_browser_font_trusted_shared.cc
@@ -37,6 +37,20 @@ namespace ppapi {
namespace {
+// Same as WebPreferences::kCommonScript. I'd use that directly here, but get an
+// undefined reference linker error.
+const char kCommonScript[] = "Zyyy";
+
+string16 GetFontFromMap(
+ const webkit_glue::WebPreferences::ScriptFontFamilyMap& map,
+ const std::string& script) {
+ webkit_glue::WebPreferences::ScriptFontFamilyMap::const_iterator it =
+ map.find(script);
+ if (it != map.end())
+ return it->second;
+ return string16();
+}
+
bool PPTextRunToWebTextRun(const PP_BrowserFont_Trusted_TextRun& text,
WebTextRun* run) {
StringVar* text_string = StringVar::FromPPVar(text.text);
@@ -88,17 +102,21 @@ WebFontDescription PPFontDescToWebFontDesc(
// Resolve the generic family.
switch (font.family) {
case PP_BROWSERFONT_TRUSTED_FAMILY_SERIF:
- resolved_family = prefs.serif_font_family;
+ resolved_family = GetFontFromMap(prefs.serif_font_family_map,
+ kCommonScript);
break;
case PP_BROWSERFONT_TRUSTED_FAMILY_SANSSERIF:
- resolved_family = prefs.sans_serif_font_family;
+ resolved_family = GetFontFromMap(prefs.sans_serif_font_family_map,
+ kCommonScript);
break;
case PP_BROWSERFONT_TRUSTED_FAMILY_MONOSPACE:
- resolved_family = prefs.fixed_font_family;
+ resolved_family = GetFontFromMap(prefs.fixed_font_family_map,
+ kCommonScript);
break;
case PP_BROWSERFONT_TRUSTED_FAMILY_DEFAULT:
default:
- resolved_family = prefs.standard_font_family;
+ resolved_family = GetFontFromMap(prefs.standard_font_family_map,
+ kCommonScript);
break;
}
} else {
@@ -115,7 +133,8 @@ WebFontDescription PPFontDescToWebFontDesc(
// level to detect if the requested font is fixed width, so we only apply
// the alternate font size to the default fixed font family.
if (StringToLowerASCII(resolved_family) ==
- StringToLowerASCII(prefs.fixed_font_family))
+ StringToLowerASCII(GetFontFromMap(prefs.fixed_font_family_map,
+ kCommonScript)))
result.size = static_cast<float>(prefs.default_fixed_font_size);
else
result.size = static_cast<float>(prefs.default_font_size);
@@ -314,4 +333,3 @@ void PPB_BrowserFont_Trusted_Shared::DrawTextToCanvas(
}
} // namespace ppapi
-
diff --git a/ppapi/shared_impl/private/ppb_font_shared.cc b/ppapi/shared_impl/private/ppb_font_shared.cc
index 36c9ed2..e71aaf5 100644
--- a/ppapi/shared_impl/private/ppb_font_shared.cc
+++ b/ppapi/shared_impl/private/ppb_font_shared.cc
@@ -40,6 +40,20 @@ namespace ppapi {
namespace {
+// Same as WebPreferences::kCommonScript. I'd use that directly here, but get an
+// undefined reference linker error.
+const char kCommonScript[] = "Zyyy";
+
+string16 GetFontFromMap(
+ const webkit_glue::WebPreferences::ScriptFontFamilyMap& map,
+ const std::string& script) {
+ webkit_glue::WebPreferences::ScriptFontFamilyMap::const_iterator it =
+ map.find(script);
+ if (it != map.end())
+ return it->second;
+ return string16();
+}
+
// Converts the given PP_TextRun to a TextRun, returning true on success.
// False means the input was invalid.
bool PPTextRunToTextRun(const PP_TextRun_Dev* run,
@@ -92,17 +106,21 @@ WebFontDescription PPFontDescToWebFontDesc(const PP_FontDescription_Dev& font,
// Resolve the generic family.
switch (font.family) {
case PP_FONTFAMILY_SERIF:
- resolved_family = prefs.serif_font_family;
+ resolved_family = GetFontFromMap(prefs.serif_font_family_map,
+ kCommonScript);
break;
case PP_FONTFAMILY_SANSSERIF:
- resolved_family = prefs.sans_serif_font_family;
+ resolved_family = GetFontFromMap(prefs.sans_serif_font_family_map,
+ kCommonScript);
break;
case PP_FONTFAMILY_MONOSPACE:
- resolved_family = prefs.fixed_font_family;
+ resolved_family = GetFontFromMap(prefs.fixed_font_family_map,
+ kCommonScript);
break;
case PP_FONTFAMILY_DEFAULT:
default:
- resolved_family = prefs.standard_font_family;
+ resolved_family = GetFontFromMap(prefs.standard_font_family_map,
+ kCommonScript);
break;
}
} else {
@@ -119,7 +137,8 @@ WebFontDescription PPFontDescToWebFontDesc(const PP_FontDescription_Dev& font,
// level to detect if the requested font is fixed width, so we only apply
// the alternate font size to the default fixed font family.
if (StringToLowerASCII(resolved_family) ==
- StringToLowerASCII(prefs.fixed_font_family))
+ StringToLowerASCII(GetFontFromMap(prefs.fixed_font_family_map,
+ kCommonScript)))
result.size = static_cast<float>(prefs.default_fixed_font_size);
else
result.size = static_cast<float>(prefs.default_font_size);
@@ -401,4 +420,3 @@ int32_t PPB_Font_Shared::PixelOffsetForCharacter(const PP_TextRun_Dev* text,
}
} // namespace ppapi
-