diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-01 08:27:32 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-01 08:27:32 +0000 |
commit | f8f606ef03a8afd7564c7f5a1bf82b54e6a6b392 (patch) | |
tree | bebb9be6f4b3a4a090917db063177fb5fb58f1dc /app | |
parent | 2cf57c8de64c62ec4f9c18ebf30b30961b208c3e (diff) | |
download | chromium_src-f8f606ef03a8afd7564c7f5a1bf82b54e6a6b392.zip chromium_src-f8f606ef03a8afd7564c7f5a1bf82b54e6a6b392.tar.gz chromium_src-f8f606ef03a8afd7564c7f5a1bf82b54e6a6b392.tar.bz2 |
linux: use ICU direction for determining text direction in renderer
We use the GTK text direction in the browser process, but that
is not available in the renderer.
BUG=36624
TEST=Arabic error pages are properly RTL
Review URL: http://codereview.chromium.org/660176
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40260 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app')
-rw-r--r-- | app/l10n_util.cc | 26 | ||||
-rw-r--r-- | app/l10n_util.h | 4 |
2 files changed, 17 insertions, 13 deletions
diff --git a/app/l10n_util.cc b/app/l10n_util.cc index 8d418d2..727fe25 100644 --- a/app/l10n_util.cc +++ b/app/l10n_util.cc @@ -434,8 +434,8 @@ void SplitAndNormalizeLanguageList(const std::string& env_language, namespace l10n_util { -// Represents the locale-specific text direction. -static TextDirection g_text_direction = UNKNOWN_DIRECTION; +// Represents the locale-specific ICU text direction. +static TextDirection g_icu_text_direction = UNKNOWN_DIRECTION; std::string GetApplicationLocale(const std::wstring& pref_locale) { #if !defined(OS_MACOSX) @@ -809,21 +809,21 @@ string16 ToUpper(const string16& string) { return result; } -// Returns the text direction for the default ICU locale. It is assumed -// that SetICUDefaultLocale has been called to set the default locale to -// the UI locale of Chrome. +TextDirection GetICUTextDirection() { + if (g_icu_text_direction == UNKNOWN_DIRECTION) { + const icu::Locale& locale = icu::Locale::getDefault(); + g_icu_text_direction = GetTextDirectionForLocale(locale.getName()); + } + return g_icu_text_direction; +} + TextDirection GetTextDirection() { - if (g_text_direction == UNKNOWN_DIRECTION) { #if defined(TOOLKIT_GTK) - GtkTextDirection gtk_dir = gtk_widget_get_default_direction(); - g_text_direction = - (gtk_dir == GTK_TEXT_DIR_LTR) ? LEFT_TO_RIGHT : RIGHT_TO_LEFT; + GtkTextDirection gtk_dir = gtk_widget_get_default_direction(); + return (gtk_dir == GTK_TEXT_DIR_LTR) ? LEFT_TO_RIGHT : RIGHT_TO_LEFT; #else - const icu::Locale& locale = icu::Locale::getDefault(); - g_text_direction = GetTextDirectionForLocale(locale.getName()); + return GetICUTextDirection(); #endif - } - return g_text_direction; } TextDirection GetTextDirectionForLocale(const char* locale_name) { diff --git a/app/l10n_util.h b/app/l10n_util.h index 66b9d23..b87442c 100644 --- a/app/l10n_util.h +++ b/app/l10n_util.h @@ -194,6 +194,10 @@ enum TextDirection { // * LEFT_TO_RIGHT: Left-To-Right (e.g. English, Chinese, etc.); // * RIGHT_TO_LEFT: Right-To-Left (e.g. Arabic, Hebrew, etc.), and; // * UNKNOWN_DIRECTION: unknown (or error). +TextDirection GetICUTextDirection(); + +// Get the application text direction. (This is just the ICU direction, +// except on GTK.) TextDirection GetTextDirection(); // Returns the text direction for |locale_name|. |