summaryrefslogtreecommitdiffstats
path: root/base/i18n
diff options
context:
space:
mode:
authorszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-16 22:34:14 +0000
committerszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-16 22:34:14 +0000
commitdfb88abf7d2927d4adb134de2b8fb01a0c897fd0 (patch)
treea3ad3e689be2d4de7072897393bcc9fd502c4b5b /base/i18n
parent36a18e4205e3fed5dcceb5c261ed959686f87f95 (diff)
downloadchromium_src-dfb88abf7d2927d4adb134de2b8fb01a0c897fd0.zip
chromium_src-dfb88abf7d2927d4adb134de2b8fb01a0c897fd0.tar.gz
chromium_src-dfb88abf7d2927d4adb134de2b8fb01a0c897fd0.tar.bz2
Revert of https://codereview.chromium.org/107513011/
Reason for revert: Test fails on main waterfall. TBR=jshin@chromium.org,msw@chromium.org,pkasting@chromium.org,skanuj@chromium.org NOTREECHECKS=true NOTRY=true BUG=327833 Review URL: https://codereview.chromium.org/103053014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241050 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/i18n')
-rw-r--r--base/i18n/rtl.cc15
-rw-r--r--base/i18n/rtl.h4
-rw-r--r--base/i18n/rtl_unittest.cc64
3 files changed, 1 insertions, 82 deletions
diff --git a/base/i18n/rtl.cc b/base/i18n/rtl.cc
index 851b036..d9818e8 100644
--- a/base/i18n/rtl.cc
+++ b/base/i18n/rtl.cc
@@ -163,21 +163,6 @@ TextDirection GetFirstStrongCharacterDirection(const string16& text) {
return LEFT_TO_RIGHT;
}
-TextDirection GetLastStrongCharacterDirection(const string16& text) {
- const UChar* string = text.c_str();
- size_t position = text.length();
- while (position > 0) {
- UChar32 character;
- size_t prev_position = position;
- U16_PREV(string, 0, prev_position, character);
- TextDirection direction = GetCharacterDirection(character);
- if (direction != UNKNOWN_DIRECTION)
- return direction;
- position = prev_position;
- }
- return LEFT_TO_RIGHT;
-}
-
TextDirection GetStringDirection(const string16& text) {
const UChar* string = text.c_str();
size_t length = text.length();
diff --git a/base/i18n/rtl.h b/base/i18n/rtl.h
index aa5f681..c80d2f8 100644
--- a/base/i18n/rtl.h
+++ b/base/i18n/rtl.h
@@ -64,7 +64,7 @@ BASE_I18N_EXPORT bool ICUIsRTL();
BASE_I18N_EXPORT TextDirection GetTextDirectionForLocale(
const char* locale_name);
-// Given the string in |text|, returns the directionality of the first or last
+// Given the string in |text|, returns the directionality of the first
// character with strong directionality in the string. If no character in the
// text has strong directionality, LEFT_TO_RIGHT is returned. The Bidi
// character types L, LRE, LRO, R, AL, RLE, and RLO are considered as strong
@@ -72,8 +72,6 @@ BASE_I18N_EXPORT TextDirection GetTextDirectionForLocale(
// for more information.
BASE_I18N_EXPORT TextDirection GetFirstStrongCharacterDirection(
const string16& text);
-BASE_I18N_EXPORT TextDirection GetLastStrongCharacterDirection(
- const string16& text);
// Given the string in |text|, returns LEFT_TO_RIGHT or RIGHT_TO_LEFT if all the
// strong directionality characters in the string are of the same
diff --git a/base/i18n/rtl_unittest.cc b/base/i18n/rtl_unittest.cc
index 8faaccf..58772b0 100644
--- a/base/i18n/rtl_unittest.cc
+++ b/base/i18n/rtl_unittest.cc
@@ -46,8 +46,6 @@ TEST_F(RTLTest, GetFirstStrongCharacterDirection) {
} cases[] = {
// Test pure LTR string.
{ L"foo bar", LEFT_TO_RIGHT },
- // Test pure RTL string.
- { L"\x05d0\x05d1\x05d2 \x05d3\x0d4\x05d5", RIGHT_TO_LEFT},
// Test bidi string in which the first character with strong directionality
// is a character with type L.
{ L"foo \x05d0 bar", LEFT_TO_RIGHT },
@@ -109,68 +107,6 @@ TEST_F(RTLTest, GetFirstStrongCharacterDirection) {
GetFirstStrongCharacterDirection(WideToUTF16(cases[i].text)));
}
-
-// Note that the cases with LRE, LRO, RLE and RLO are invalid for
-// GetLastStrongCharacterDirection because they should be followed by PDF
-// character.
-TEST_F(RTLTest, GetLastStrongCharacterDirection) {
- struct {
- const wchar_t* text;
- TextDirection direction;
- } cases[] = {
- // Test pure LTR string.
- { L"foo bar", LEFT_TO_RIGHT },
- // Test pure RTL string.
- { L"\x05d0\x05d1\x05d2 \x05d3\x0d4\x05d5", RIGHT_TO_LEFT},
- // Test bidi string in which the last character with strong directionality
- // is a character with type L.
- { L"foo \x05d0 bar", LEFT_TO_RIGHT },
- // Test bidi string in which the last character with strong directionality
- // is a character with type R.
- { L"\x05d0 foo bar \x05d3", RIGHT_TO_LEFT },
- // Test bidi string which ends with a character with weak directionality
- // and in which the last character with strong directionality is a
- // character with type L.
- { L"!foo \x05d0 bar!", LEFT_TO_RIGHT },
- // Test bidi string which ends with a character with weak directionality
- // and in which the last character with strong directionality is a
- // character with type R.
- { L",\x05d0 foo bar \x05d1,", RIGHT_TO_LEFT },
- // Test bidi string in which the last character with strong directionality
- // is a character with type AL.
- { L"\x0622 foo \x05d0 bar \x0622", RIGHT_TO_LEFT },
- // Test a string without strong directionality characters.
- { L",!.{}", LEFT_TO_RIGHT },
- // Test empty string.
- { L"", LEFT_TO_RIGHT },
- // Test characters in non-BMP (e.g. Phoenician letters. Please refer to
- // http://demo.icu-project.org/icu-bin/ubrowse?scr=151&b=10910 for more
- // information).
- {
-#if defined(WCHAR_T_IS_UTF32)
- L"abc 123" L" ! \x10910 !",
-#elif defined(WCHAR_T_IS_UTF16)
- L"abc 123" L" ! \xd802\xdd10 !",
-#else
-#error wchar_t should be either UTF-16 or UTF-32
-#endif
- RIGHT_TO_LEFT },
- {
-#if defined(WCHAR_T_IS_UTF32)
- L"abc 123" L" ! \x10401 !",
-#elif defined(WCHAR_T_IS_UTF16)
- L"abc 123" L" ! \xd801\xdc01 !",
-#else
-#error wchar_t should be either UTF-16 or UTF-32
-#endif
- LEFT_TO_RIGHT },
- };
-
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i)
- EXPECT_EQ(cases[i].direction,
- GetLastStrongCharacterDirection(WideToUTF16(cases[i].text)));
-}
-
TEST_F(RTLTest, GetStringDirection) {
struct {
const wchar_t* text;