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

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

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 months 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
« no previous file with comments | « base/i18n/bidi_line_iterator.h ('k') | base/i18n/case_conversion_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/bidi_line_iterator.h" 5 #include "base/i18n/bidi_line_iterator.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace base { 9 namespace base {
10 namespace i18n { 10 namespace i18n {
11 11
12 BiDiLineIterator::BiDiLineIterator() : bidi_(NULL) { 12 BiDiLineIterator::BiDiLineIterator() : bidi_(NULL) {
13 } 13 }
14 14
15 BiDiLineIterator::~BiDiLineIterator() { 15 BiDiLineIterator::~BiDiLineIterator() {
16 if (bidi_) { 16 if (bidi_) {
17 ubidi_close(bidi_); 17 ubidi_close(bidi_);
18 bidi_ = NULL; 18 bidi_ = NULL;
19 } 19 }
20 } 20 }
21 21
22 bool BiDiLineIterator::Open(const string16& text, 22 bool BiDiLineIterator::Open(const string16& text, bool right_to_left) {
23 bool right_to_left,
24 bool url) {
25 DCHECK(!bidi_); 23 DCHECK(!bidi_);
26 UErrorCode error = U_ZERO_ERROR; 24 UErrorCode error = U_ZERO_ERROR;
27 bidi_ = ubidi_openSized(static_cast<int>(text.length()), 0, &error); 25 bidi_ = ubidi_openSized(static_cast<int>(text.length()), 0, &error);
28 if (U_FAILURE(error)) 26 if (U_FAILURE(error))
29 return false; 27 return false;
30 if (right_to_left && url)
31 ubidi_setReorderingMode(bidi_, UBIDI_REORDER_RUNS_ONLY);
32 ubidi_setPara(bidi_, text.data(), static_cast<int>(text.length()), 28 ubidi_setPara(bidi_, text.data(), static_cast<int>(text.length()),
33 right_to_left ? UBIDI_DEFAULT_RTL : UBIDI_DEFAULT_LTR, 29 right_to_left ? UBIDI_DEFAULT_RTL : UBIDI_DEFAULT_LTR,
34 NULL, &error); 30 NULL, &error);
35 return (U_SUCCESS(error) == TRUE); 31 return (U_SUCCESS(error) == TRUE);
36 } 32 }
37 33
38 int BiDiLineIterator::CountRuns() { 34 int BiDiLineIterator::CountRuns() {
39 DCHECK(bidi_ != NULL); 35 DCHECK(bidi_ != NULL);
40 UErrorCode error = U_ZERO_ERROR; 36 UErrorCode error = U_ZERO_ERROR;
41 const int runs = ubidi_countRuns(bidi_, &error); 37 const int runs = ubidi_countRuns(bidi_, &error);
42 return U_SUCCESS(error) ? runs : 0; 38 return U_SUCCESS(error) ? runs : 0;
43 } 39 }
44 40
45 UBiDiDirection BiDiLineIterator::GetVisualRun(int index, 41 UBiDiDirection BiDiLineIterator::GetVisualRun(int index,
46 int* start, 42 int* start,
47 int* length) { 43 int* length) {
48 DCHECK(bidi_ != NULL); 44 DCHECK(bidi_ != NULL);
49 return ubidi_getVisualRun(bidi_, index, start, length); 45 return ubidi_getVisualRun(bidi_, index, start, length);
50 } 46 }
51 47
52 void BiDiLineIterator::GetLogicalRun(int start, 48 void BiDiLineIterator::GetLogicalRun(int start,
53 int* end, 49 int* end,
54 UBiDiLevel* level) { 50 UBiDiLevel* level) {
55 DCHECK(bidi_ != NULL); 51 DCHECK(bidi_ != NULL);
56 ubidi_getLogicalRun(bidi_, start, end, level); 52 ubidi_getLogicalRun(bidi_, start, end, level);
57 } 53 }
58 54
59 } // namespace i18n 55 } // namespace i18n
60 } // namespace base 56 } // namespace base
OLDNEW
« no previous file with comments | « base/i18n/bidi_line_iterator.h ('k') | base/i18n/case_conversion_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698