diff options
author | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-13 01:47:37 +0000 |
---|---|---|
committer | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-13 01:47:37 +0000 |
commit | f9a768d7504e2eb159bfce3cff516bf7f2508fd2 (patch) | |
tree | 3d3af4c9ba65bbaa9e7b8c84e62c3d5c435038cf /base/i18n/rtl.cc | |
parent | 6313bb0014b49cbf7bd341d2b6da067ba1fa4d5c (diff) | |
download | chromium_src-f9a768d7504e2eb159bfce3cff516bf7f2508fd2.zip chromium_src-f9a768d7504e2eb159bfce3cff516bf7f2508fd2.tar.gz chromium_src-f9a768d7504e2eb159bfce3cff516bf7f2508fd2.tar.bz2 |
Check string and UI direction in GetDisplayStringInLTRDirectionality, etc.
Continue always wrapping the string in RTL UI.
(in case it's appended to an RTL string later, etc.)
Additionally wrap strings with RTL first strong characters in LTR UI.
(previously, text inherited UI base direction, now it uses the first strong char)
Add, expand upon, and cleanup unit tests.
BUG=144541
TEST=Download shelf (and other UI) file paths are shown as LTR (without stray rendered glyphs or other regressions).
Review URL: https://chromiumcodereview.appspot.com/10910128
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156459 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/i18n/rtl.cc')
-rw-r--r-- | base/i18n/rtl.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/base/i18n/rtl.cc b/base/i18n/rtl.cc index 29a2a88..cbbb63f 100644 --- a/base/i18n/rtl.cc +++ b/base/i18n/rtl.cc @@ -319,11 +319,14 @@ void WrapPathWithLTRFormatting(const FilePath& path, } string16 GetDisplayStringInLTRDirectionality(const string16& text) { - if (!IsRTL()) - return text; - string16 text_mutable(text); - WrapStringWithLTRFormatting(&text_mutable); - return text_mutable; + // Always wrap the string in RTL UI (it may be appended to RTL string). + // Also wrap strings with an RTL first strong character direction in LTR UI. + if (IsRTL() || GetFirstStrongCharacterDirection(text) == RIGHT_TO_LEFT) { + string16 text_mutable(text); + WrapStringWithLTRFormatting(&text_mutable); + return text_mutable; + } + return text; } string16 StripWrappingBidiControlCharacters(const string16& text) { |