OLD | NEW |
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 #ifndef BASE_I18N_BIDI_LINE_ITERATOR_H_ | 5 #ifndef BASE_I18N_BIDI_LINE_ITERATOR_H_ |
6 #define BASE_I18N_BIDI_LINE_ITERATOR_H_ | 6 #define BASE_I18N_BIDI_LINE_ITERATOR_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/i18n/base_i18n_export.h" | 9 #include "base/i18n/base_i18n_export.h" |
| 10 #include "base/i18n/rtl.h" |
10 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
11 #include "third_party/icu/source/common/unicode/ubidi.h" | 12 #include "third_party/icu/source/common/unicode/ubidi.h" |
12 | 13 |
13 namespace base { | 14 namespace base { |
14 namespace i18n { | 15 namespace i18n { |
15 | 16 |
16 // A simple wrapper class for the bidirectional iterator of ICU. | 17 // A simple wrapper class for the bidirectional iterator of ICU. |
17 // This class uses the bidirectional iterator of ICU to split a line of | 18 // This class uses the bidirectional iterator of ICU to split a line of |
18 // bidirectional texts into visual runs in its display order. | 19 // bidirectional texts into visual runs in its display order. |
19 class BASE_I18N_EXPORT BiDiLineIterator { | 20 class BASE_I18N_EXPORT BiDiLineIterator { |
20 public: | 21 public: |
21 BiDiLineIterator(); | 22 BiDiLineIterator(); |
22 ~BiDiLineIterator(); | 23 ~BiDiLineIterator(); |
23 | 24 |
24 // Initializes the bidirectional iterator with the specified text. Returns | 25 // Initializes the bidirectional iterator with the specified text. Returns |
25 // whether initialization succeeded. | 26 // whether initialization succeeded. |
26 bool Open(const string16& text, bool right_to_left); | 27 bool Open(const string16& text, TextDirection direction); |
27 | 28 |
28 // Returns the number of visual runs in the text, or zero on error. | 29 // Returns the number of visual runs in the text, or zero on error. |
29 int CountRuns(); | 30 int CountRuns(); |
30 | 31 |
31 // Gets the logical offset, length, and direction of the specified visual run. | 32 // Gets the logical offset, length, and direction of the specified visual run. |
32 UBiDiDirection GetVisualRun(int index, int* start, int* length); | 33 UBiDiDirection GetVisualRun(int index, int* start, int* length); |
33 | 34 |
34 // Given a start position, figure out where the run ends (and the BiDiLevel). | 35 // Given a start position, figure out where the run ends (and the BiDiLevel). |
35 void GetLogicalRun(int start, int* end, UBiDiLevel* level); | 36 void GetLogicalRun(int start, int* end, UBiDiLevel* level); |
36 | 37 |
37 private: | 38 private: |
38 UBiDi* bidi_; | 39 UBiDi* bidi_; |
39 | 40 |
40 DISALLOW_COPY_AND_ASSIGN(BiDiLineIterator); | 41 DISALLOW_COPY_AND_ASSIGN(BiDiLineIterator); |
41 }; | 42 }; |
42 | 43 |
43 } // namespace i18n | 44 } // namespace i18n |
44 } // namespace base | 45 } // namespace base |
45 | 46 |
46 #endif // BASE_I18N_BIDI_LINE_ITERATOR_H_ | 47 #endif // BASE_I18N_BIDI_LINE_ITERATOR_H_ |
OLD | NEW |