summaryrefslogtreecommitdiffstats
path: root/app/bidi_line_iterator.h
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-25 20:38:53 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-25 20:38:53 +0000
commit8891d14891423a0bf861fb6cb8a88cc2b0b11d8e (patch)
tree286765dee398d8ef885c8895a06834063b53cdee /app/bidi_line_iterator.h
parentcb34b251707323165c85b7079467e9a03c65af8e (diff)
downloadchromium_src-8891d14891423a0bf861fb6cb8a88cc2b0b11d8e.zip
chromium_src-8891d14891423a0bf861fb6cb8a88cc2b0b11d8e.tar.gz
chromium_src-8891d14891423a0bf861fb6cb8a88cc2b0b11d8e.tar.bz2
remove ICU includes from l10n_util.h
95% of users of l10n_util use it for some functions; the other 5% want some complicated templates that pull in a ton of ICU headers as well. Before this change, the average includer of l10n_util.h pulled in an additional 80 subheaders because of it. Additionally, #including ICU headers from a header makes the includee depend on having the ICU include path in the -I header. Review URL: http://codereview.chromium.org/515059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37032 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/bidi_line_iterator.h')
-rw-r--r--app/bidi_line_iterator.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/app/bidi_line_iterator.h b/app/bidi_line_iterator.h
new file mode 100644
index 0000000..5f2f7e0
--- /dev/null
+++ b/app/bidi_line_iterator.h
@@ -0,0 +1,41 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef APP_BIDI_LINE_ITERATOR_H_
+#define APP_BIDI_LINE_ITERATOR_H_
+
+#include <string>
+
+#include "unicode/ubidi.h"
+
+#include "base/basictypes.h"
+
+// A simple wrapper class for the bidirectional iterator of ICU.
+// This class uses the bidirectional iterator of ICU to split a line of
+// bidirectional texts into visual runs in its display order.
+class BiDiLineIterator {
+ public:
+ BiDiLineIterator() : bidi_(NULL) { }
+ ~BiDiLineIterator();
+
+ // Initializes the bidirectional iterator with the specified text. Returns
+ // whether initialization succeeded.
+ UBool Open(const std::wstring& text, bool right_to_left, bool url);
+
+ // Returns the number of visual runs in the text, or zero on error.
+ int CountRuns();
+
+ // Gets the logical offset, length, and direction of the specified visual run.
+ UBiDiDirection GetVisualRun(int index, int* start, int* length);
+
+ // Given a start position, figure out where the run ends (and the BiDiLevel).
+ void GetLogicalRun(int start, int* end, UBiDiLevel* level);
+
+ private:
+ UBiDi* bidi_;
+
+ DISALLOW_COPY_AND_ASSIGN(BiDiLineIterator);
+};
+
+#endif // APP_BIDI_LINE_ITERATOR_H_