Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2873)

Unified Diff: base/i18n/rtl.cc

Issue 112063003: Implement eliding/truncating at end in RenderText (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/i18n/rtl.cc
diff --git a/base/i18n/rtl.cc b/base/i18n/rtl.cc
index d9818e800e2559307efa181432fb039337ce24e5..851b03642defb3ce43742b1a74405e8f05362cd5 100644
--- a/base/i18n/rtl.cc
+++ b/base/i18n/rtl.cc
@@ -163,6 +163,21 @@ 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();

Powered by Google App Engine
This is Rietveld 408576698