summaryrefslogtreecommitdiffstats
path: root/base/i18n
diff options
context:
space:
mode:
authorjshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-28 17:45:40 +0000
committerjshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-28 17:45:40 +0000
commitdc8e44a27106d13d8605ccfa2ca0dd8ef3959bef (patch)
tree289b0251635b593b06953bd7cc9c71f85da87216 /base/i18n
parentb67b086a73fee8d840f8a8b532259c9eeeee9bfd (diff)
downloadchromium_src-dc8e44a27106d13d8605ccfa2ca0dd8ef3959bef.zip
chromium_src-dc8e44a27106d13d8605ccfa2ca0dd8ef3959bef.tar.gz
chromium_src-dc8e44a27106d13d8605ccfa2ca0dd8ef3959bef.tar.bz2
Make 'dangerous download warning' visible in Japanese UI on Windows.
Use line break iterator to get the splitting of 'dangerous download warning' in Chinese/Japanese/Thai to 2 lines to work correctly. In break_iterator.cc, make WORD_SPACE an alias to WORD_LINE and change the explanation about what it does. No code change is made there. More i18n-oriented tests will be added in the follow-up CL to break_iterator_unittest.cc BUG=3638 TEST=manual: launch Chrome on Windows in Japanese/Thai/Chinese (--lang=ja , th, zh-CN, or zh-TW) and follow the instruction at http://crbug.com/76652 (comment 0). Review URL: http://codereview.chromium.org/6713119 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79584 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/i18n')
-rw-r--r--base/i18n/break_iterator.cc6
-rw-r--r--base/i18n/break_iterator.h31
2 files changed, 25 insertions, 12 deletions
diff --git a/base/i18n/break_iterator.cc b/base/i18n/break_iterator.cc
index e1b5e29..edc8950 100644
--- a/base/i18n/break_iterator.cc
+++ b/base/i18n/break_iterator.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -33,7 +33,7 @@ bool BreakIterator::Init() {
case BREAK_WORD:
break_type = UBRK_WORD;
break;
- case BREAK_SPACE:
+ case BREAK_LINE:
case BREAK_NEWLINE:
break_type = UBRK_LINE;
break;
@@ -59,7 +59,7 @@ bool BreakIterator::Advance() {
prev_ = pos_;
switch (break_type_) {
case BREAK_WORD:
- case BREAK_SPACE:
+ case BREAK_LINE:
pos = ubrk_next(static_cast<UBreakIterator*>(iter_));
if (pos == UBRK_DONE) {
pos_ = npos;
diff --git a/base/i18n/break_iterator.h b/base/i18n/break_iterator.h
index 9de7ac7..f64a1e1 100644
--- a/base/i18n/break_iterator.h
+++ b/base/i18n/break_iterator.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -12,19 +12,28 @@
// The BreakIterator class iterates through the words, word breaks, and
// line breaks in a UTF-16 string.
//
-// It provides several modes, BREAK_WORD, BREAK_SPACE, and BREAK_NEWLINE,
+// It provides several modes, BREAK_WORD, BREAK_LINE, and BREAK_NEWLINE,
// which modify how characters are aggregated into the returned string.
//
// Under BREAK_WORD mode, once a word is encountered any non-word
// characters are not included in the returned string (e.g. in the
// UTF-16 equivalent of the string " foo bar! ", the word breaks are at
// the periods in ". .foo. .bar.!. .").
+// Note that Chinese/Japanese/Thai do not use spaces between words so that
+// boundaries can fall in the middle of a continuous run of non-space /
+// non-punctuation characters.
//
-// Under BREAK_SPACE mode, once a word is encountered, any non-word
-// characters are included in the returned string, breaking only when a
-// space-equivalent character is encountered (e.g. in the
-// UTF16-equivalent of the string " foo bar! ", the word breaks are at
-// the periods in ". .foo .bar! .").
+// Under BREAK_LINE mode, once a line breaking opportunity is encountered,
+// any non-word characters are included in the returned string, breaking
+// only when a space-equivalent character or a line breaking opportunity
+// is encountered (e.g. in the UTF16-equivalent of the string " foo bar! ",
+// the breaks are at the periods in ". .foo .bar! .").
+//
+// Note that lines can be broken at any character/syllable/grapheme cluster
+// boundary in Chinese/Japanese/Korean and at word boundaries in Thai
+// (Thai does not use spaces between words). Therefore, this is NOT the same
+// as breaking only at space-equivalent characters where its former
+// name (BREAK_SPACE) implied.
//
// Under BREAK_NEWLINE mode, all characters are included in the returned
// string, breking only when a newline-equivalent character is encountered
@@ -48,7 +57,11 @@ class BreakIterator {
public:
enum BreakType {
BREAK_WORD,
- BREAK_SPACE,
+ BREAK_LINE,
+ // TODO(jshin): Remove this after reviewing call sites.
+ // If call sites really need break only on space-like characters
+ // implement it separately.
+ BREAK_SPACE = BREAK_LINE,
BREAK_NEWLINE,
};
@@ -75,7 +88,7 @@ class BreakIterator {
// Under BREAK_WORD mode, returns true if the break we just hit is the
// end of a word. (Otherwise, the break iterator just skipped over e.g.
- // whitespace or punctuation.) Under BREAK_SPACE and BREAK_NEWLINE modes,
+ // whitespace or punctuation.) Under BREAK_LINE and BREAK_NEWLINE modes,
// this distinction doesn't apply and it always retuns false.
bool IsWord() const;