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

Side by Side Diff: base/i18n/rtl.cc

Issue 103053014: Revert of Implement eliding/truncating at end in RenderText (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/i18n/rtl.h ('k') | base/i18n/rtl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/i18n/rtl.h" 5 #include "base/i18n/rtl.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 UChar32 character; 155 UChar32 character;
156 size_t next_position = position; 156 size_t next_position = position;
157 U16_NEXT(string, next_position, length, character); 157 U16_NEXT(string, next_position, length, character);
158 TextDirection direction = GetCharacterDirection(character); 158 TextDirection direction = GetCharacterDirection(character);
159 if (direction != UNKNOWN_DIRECTION) 159 if (direction != UNKNOWN_DIRECTION)
160 return direction; 160 return direction;
161 position = next_position; 161 position = next_position;
162 } 162 }
163 return LEFT_TO_RIGHT; 163 return LEFT_TO_RIGHT;
164 } 164 }
165
166 TextDirection GetLastStrongCharacterDirection(const string16& text) {
167 const UChar* string = text.c_str();
168 size_t position = text.length();
169 while (position > 0) {
170 UChar32 character;
171 size_t prev_position = position;
172 U16_PREV(string, 0, prev_position, character);
173 TextDirection direction = GetCharacterDirection(character);
174 if (direction != UNKNOWN_DIRECTION)
175 return direction;
176 position = prev_position;
177 }
178 return LEFT_TO_RIGHT;
179 }
180 165
181 TextDirection GetStringDirection(const string16& text) { 166 TextDirection GetStringDirection(const string16& text) {
182 const UChar* string = text.c_str(); 167 const UChar* string = text.c_str();
183 size_t length = text.length(); 168 size_t length = text.length();
184 size_t position = 0; 169 size_t position = 0;
185 170
186 TextDirection result(UNKNOWN_DIRECTION); 171 TextDirection result(UNKNOWN_DIRECTION);
187 while (position < length) { 172 while (position < length) {
188 UChar32 character; 173 UChar32 character;
189 size_t next_position = position; 174 size_t next_position = position;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 begin == kRightToLeftOverride) 374 begin == kRightToLeftOverride)
390 ++begin_index; 375 ++begin_index;
391 size_t end_index = text.length() - 1; 376 size_t end_index = text.length() - 1;
392 if (text[end_index] == kPopDirectionalFormatting) 377 if (text[end_index] == kPopDirectionalFormatting)
393 --end_index; 378 --end_index;
394 return text.substr(begin_index, end_index - begin_index + 1); 379 return text.substr(begin_index, end_index - begin_index + 1);
395 } 380 }
396 381
397 } // namespace i18n 382 } // namespace i18n
398 } // namespace base 383 } // namespace base
OLDNEW
« no previous file with comments | « base/i18n/rtl.h ('k') | base/i18n/rtl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698