diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-15 18:50:37 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-15 18:50:37 +0000 |
commit | 4bda39710e4b3b88563b0d25b48fb8118df4d745 (patch) | |
tree | eab74da15865d61bf6c74382b2f624df30c910c7 | |
parent | c82aec11bac4bb3506aa2da55d831a482b303196 (diff) | |
download | chromium_src-4bda39710e4b3b88563b0d25b48fb8118df4d745.zip chromium_src-4bda39710e4b3b88563b0d25b48fb8118df4d745.tar.gz chromium_src-4bda39710e4b3b88563b0d25b48fb8118df4d745.tar.bz2 |
glue/webpreferences: use string16 for font names
And fix the users.
BUG=23581
Review URL: http://codereview.chromium.org/5774005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69284 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/tab_contents/render_view_host_delegate_helper.cc | 10 | ||||
-rw-r--r-- | chrome/browser/tab_contents/web_contents_unittest.cc | 8 | ||||
-rw-r--r-- | webkit/glue/webpreferences.cc | 22 | ||||
-rw-r--r-- | webkit/glue/webpreferences.h | 14 | ||||
-rw-r--r-- | webkit/tools/test_shell/layout_test_controller.cc | 18 | ||||
-rw-r--r-- | webkit/tools/test_shell/layout_test_controller.h | 3 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.cc | 16 |
7 files changed, 47 insertions, 44 deletions
diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc index 408e490..5bde090 100644 --- a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc +++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc @@ -197,19 +197,19 @@ WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs( WebPreferences web_prefs; web_prefs.fixed_font_family = - UTF8ToWide(prefs->GetString(prefs::kWebKitFixedFontFamily)); + UTF8ToUTF16(prefs->GetString(prefs::kWebKitFixedFontFamily)); web_prefs.serif_font_family = - UTF8ToWide(prefs->GetString(prefs::kWebKitSerifFontFamily)); + UTF8ToUTF16(prefs->GetString(prefs::kWebKitSerifFontFamily)); web_prefs.sans_serif_font_family = - UTF8ToWide(prefs->GetString(prefs::kWebKitSansSerifFontFamily)); + UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily)); if (prefs->GetBoolean(prefs::kWebKitStandardFontIsSerif)) web_prefs.standard_font_family = web_prefs.serif_font_family; else web_prefs.standard_font_family = web_prefs.sans_serif_font_family; web_prefs.cursive_font_family = - UTF8ToWide(prefs->GetString(prefs::kWebKitCursiveFontFamily)); + UTF8ToUTF16(prefs->GetString(prefs::kWebKitCursiveFontFamily)); web_prefs.fantasy_font_family = - UTF8ToWide(prefs->GetString(prefs::kWebKitFantasyFontFamily)); + UTF8ToUTF16(prefs->GetString(prefs::kWebKitFantasyFontFamily)); web_prefs.default_font_size = prefs->GetInteger(prefs::kWebKitDefaultFontSize); diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc index 67d93a3..a494dd5 100644 --- a/chrome/browser/tab_contents/web_contents_unittest.cc +++ b/chrome/browser/tab_contents/web_contents_unittest.cc @@ -765,13 +765,13 @@ TEST_F(TabContentsTest, WebKitPrefs) { // These should still be the default values. #if defined(OS_MACOSX) - const wchar_t kDefaultFont[] = L"Times"; + const char kDefaultFont[] = "Times"; #elif defined(OS_CHROMEOS) - const wchar_t kDefaultFont[] = L"Tinos"; + const char kDefaultFont[] = "Tinos"; #else - const wchar_t kDefaultFont[] = L"Times New Roman"; + const char kDefaultFont[] = "Times New Roman"; #endif - EXPECT_EQ(kDefaultFont, webkit_prefs.standard_font_family); + EXPECT_EQ(ASCIIToUTF16(kDefaultFont), webkit_prefs.standard_font_family); EXPECT_TRUE(webkit_prefs.javascript_enabled); } diff --git a/webkit/glue/webpreferences.cc b/webkit/glue/webpreferences.cc index c6c32e7..abe5903 100644 --- a/webkit/glue/webpreferences.cc +++ b/webkit/glue/webpreferences.cc @@ -21,11 +21,11 @@ using WebKit::WebURL; using WebKit::WebView; WebPreferences::WebPreferences() - : standard_font_family(L"Times New Roman"), - fixed_font_family(L"Courier New"), - serif_font_family(L"Times New Roman"), - sans_serif_font_family(L"Arial"), - cursive_font_family(L"Script"), + : standard_font_family(ASCIIToUTF16("Times New Roman")), + fixed_font_family(ASCIIToUTF16("Courier New")), + serif_font_family(ASCIIToUTF16("Times New Roman")), + sans_serif_font_family(ASCIIToUTF16("Arial")), + cursive_font_family(ASCIIToUTF16("Script")), fantasy_font_family(), // Not sure what to use on Windows. default_font_size(16), default_fixed_font_size(13), @@ -73,12 +73,12 @@ WebPreferences::~WebPreferences() { void WebPreferences::Apply(WebView* web_view) const { WebSettings* settings = web_view->settings(); - settings->setStandardFontFamily(WideToUTF16Hack(standard_font_family)); - settings->setFixedFontFamily(WideToUTF16Hack(fixed_font_family)); - settings->setSerifFontFamily(WideToUTF16Hack(serif_font_family)); - settings->setSansSerifFontFamily(WideToUTF16Hack(sans_serif_font_family)); - settings->setCursiveFontFamily(WideToUTF16Hack(cursive_font_family)); - settings->setFantasyFontFamily(WideToUTF16Hack(fantasy_font_family)); + settings->setStandardFontFamily(standard_font_family); + settings->setFixedFontFamily(fixed_font_family); + settings->setSerifFontFamily(serif_font_family); + settings->setSansSerifFontFamily(sans_serif_font_family); + settings->setCursiveFontFamily(cursive_font_family); + settings->setFantasyFontFamily(fantasy_font_family); settings->setDefaultFontSize(default_font_size); settings->setDefaultFixedFontSize(default_fixed_font_size); settings->setMinimumFontSize(minimum_font_size); diff --git a/webkit/glue/webpreferences.h b/webkit/glue/webpreferences.h index 6cb8044..8ee4ce8 100644 --- a/webkit/glue/webpreferences.h +++ b/webkit/glue/webpreferences.h @@ -13,6 +13,8 @@ #include <string> #include <vector> + +#include "base/string16.h" #include "googleurl/src/gurl.h" namespace WebKit { @@ -20,12 +22,12 @@ class WebView; } struct WebPreferences { - std::wstring standard_font_family; - std::wstring fixed_font_family; - std::wstring serif_font_family; - std::wstring sans_serif_font_family; - std::wstring cursive_font_family; - std::wstring fantasy_font_family; + string16 standard_font_family; + string16 fixed_font_family; + string16 serif_font_family; + string16 sans_serif_font_family; + string16 cursive_font_family; + string16 fantasy_font_family; int default_font_size; int default_fixed_font_size; int minimum_font_size; diff --git a/webkit/tools/test_shell/layout_test_controller.cc b/webkit/tools/test_shell/layout_test_controller.cc index 3ddfaab..9b0a938 100644 --- a/webkit/tools/test_shell/layout_test_controller.cc +++ b/webkit/tools/test_shell/layout_test_controller.cc @@ -1181,12 +1181,12 @@ int32 LayoutTestController::CppVariantToInt32(const CppVariant& value) { return 0; } -std::wstring LayoutTestController::CppVariantToWstring( +string16 LayoutTestController::CppVariantToString16( const CppVariant& value) { if (value.isString()) - return UTF8ToWide(value.ToString()); + return UTF8ToUTF16(value.ToString()); LogErrorToConsole("Invalid value for preference. Expected string value."); - return std::wstring(); + return string16(); } void LayoutTestController::overridePreference( @@ -1196,17 +1196,17 @@ void LayoutTestController::overridePreference( CppVariant value = args[1]; WebPreferences* preferences = shell_->GetWebPreferences(); if (key == "WebKitStandardFont") - preferences->standard_font_family = CppVariantToWstring(value); + preferences->standard_font_family = CppVariantToString16(value); else if (key == "WebKitFixedFont") - preferences->fixed_font_family = CppVariantToWstring(value); + preferences->fixed_font_family = CppVariantToString16(value); else if (key == "WebKitSerifFont") - preferences->serif_font_family = CppVariantToWstring(value); + preferences->serif_font_family = CppVariantToString16(value); else if (key == "WebKitSansSerifFont") - preferences->sans_serif_font_family = CppVariantToWstring(value); + preferences->sans_serif_font_family = CppVariantToString16(value); else if (key == "WebKitCursiveFont") - preferences->cursive_font_family = CppVariantToWstring(value); + preferences->cursive_font_family = CppVariantToString16(value); else if (key == "WebKitFantasyFont") - preferences->fantasy_font_family = CppVariantToWstring(value); + preferences->fantasy_font_family = CppVariantToString16(value); else if (key == "WebKitDefaultFontSize") preferences->default_font_size = CppVariantToInt32(value); else if (key == "WebKitDefaultFixedFontSize") diff --git a/webkit/tools/test_shell/layout_test_controller.h b/webkit/tools/test_shell/layout_test_controller.h index 9138cc4..1b92fe1 100644 --- a/webkit/tools/test_shell/layout_test_controller.h +++ b/webkit/tools/test_shell/layout_test_controller.h @@ -17,6 +17,7 @@ #include <queue> #include "base/timer.h" +#include "base/string16.h" #include "webkit/glue/cpp_bound_class.h" class TestShell; @@ -396,7 +397,7 @@ class LayoutTestController : public CppBoundClass { // Support for overridePreference. bool CppVariantToBool(const CppVariant&); int32 CppVariantToInt32(const CppVariant&); - std::wstring CppVariantToWstring(const CppVariant&); + string16 CppVariantToString16(const CppVariant&); void LogErrorToConsole(const std::string& text); diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index 96d5415..d6dd067 100644 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -468,13 +468,13 @@ void TestShell::ResetWebPreferences() { *web_prefs_ = WebPreferences(); #if defined(OS_MACOSX) - web_prefs_->serif_font_family = L"Times"; - web_prefs_->cursive_font_family = L"Apple Chancery"; - web_prefs_->fantasy_font_family = L"Papyrus"; + web_prefs_->serif_font_family = ASCIIToUTF16("Times"); + web_prefs_->cursive_font_family = ASCIIToUTF16("Apple Chancery"); + web_prefs_->fantasy_font_family = ASCIIToUTF16("Papyrus"); #else // NOTE: case matters here, this must be 'times new roman', else // some layout tests fail. - web_prefs_->serif_font_family = L"times new roman"; + web_prefs_->serif_font_family = ASCIIToUTF16("times new roman"); // These two fonts are picked from the intersection of // Win XP font list and Vista font list : @@ -486,12 +486,12 @@ void TestShell::ResetWebPreferences() { // They (especially Impact for fantasy) are not typical cursive // and fantasy fonts, but it should not matter for layout tests // as long as they're available. - web_prefs_->cursive_font_family = L"Comic Sans MS"; - web_prefs_->fantasy_font_family = L"Impact"; + web_prefs_->cursive_font_family = ASCIIToUTF16("Comic Sans MS"); + web_prefs_->fantasy_font_family = ASCIIToUTF16("Impact"); #endif web_prefs_->standard_font_family = web_prefs_->serif_font_family; - web_prefs_->fixed_font_family = L"Courier"; - web_prefs_->sans_serif_font_family = L"Helvetica"; + web_prefs_->fixed_font_family = ASCIIToUTF16("Courier"); + web_prefs_->sans_serif_font_family = ASCIIToUTF16("Helvetica"); web_prefs_->default_encoding = "ISO-8859-1"; web_prefs_->default_font_size = 16; |