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