| OLD | NEW |
| 1 // Copyright (c) 2010 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 "app/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 #include "base/string16.h" | |
| 9 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 10 | 9 |
| 10 namespace base { |
| 11 namespace i18n { |
| 12 |
| 13 BiDiLineIterator::BiDiLineIterator() : bidi_(NULL) { |
| 14 } |
| 15 |
| 11 BiDiLineIterator::~BiDiLineIterator() { | 16 BiDiLineIterator::~BiDiLineIterator() { |
| 12 if (bidi_) { | 17 if (bidi_) { |
| 13 ubidi_close(bidi_); | 18 ubidi_close(bidi_); |
| 14 bidi_ = NULL; | 19 bidi_ = NULL; |
| 15 } | 20 } |
| 16 } | 21 } |
| 17 | 22 |
| 18 UBool BiDiLineIterator::Open(const string16& text, | 23 bool BiDiLineIterator::Open(const string16& text, |
| 19 bool right_to_left, | 24 bool right_to_left, |
| 20 bool url) { | 25 bool url) { |
| 21 DCHECK(bidi_ == NULL); | 26 DCHECK(bidi_ == NULL); |
| 22 UErrorCode error = U_ZERO_ERROR; | 27 UErrorCode error = U_ZERO_ERROR; |
| 23 bidi_ = ubidi_openSized(static_cast<int>(text.length()), 0, &error); | 28 bidi_ = ubidi_openSized(static_cast<int>(text.length()), 0, &error); |
| 24 if (U_FAILURE(error)) | 29 if (U_FAILURE(error)) |
| 25 return false; | 30 return false; |
| 26 if (right_to_left && url) | 31 if (right_to_left && url) |
| 27 ubidi_setReorderingMode(bidi_, UBIDI_REORDER_RUNS_ONLY); | 32 ubidi_setReorderingMode(bidi_, UBIDI_REORDER_RUNS_ONLY); |
| 28 ubidi_setPara(bidi_, text.data(), static_cast<int>(text.length()), | 33 ubidi_setPara(bidi_, text.data(), static_cast<int>(text.length()), |
| 29 right_to_left ? UBIDI_DEFAULT_RTL : UBIDI_DEFAULT_LTR, | 34 right_to_left ? UBIDI_DEFAULT_RTL : UBIDI_DEFAULT_LTR, |
| 30 NULL, &error); | 35 NULL, &error); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 44 DCHECK(bidi_ != NULL); | 49 DCHECK(bidi_ != NULL); |
| 45 return ubidi_getVisualRun(bidi_, index, start, length); | 50 return ubidi_getVisualRun(bidi_, index, start, length); |
| 46 } | 51 } |
| 47 | 52 |
| 48 void BiDiLineIterator::GetLogicalRun(int start, | 53 void BiDiLineIterator::GetLogicalRun(int start, |
| 49 int* end, | 54 int* end, |
| 50 UBiDiLevel* level) { | 55 UBiDiLevel* level) { |
| 51 DCHECK(bidi_ != NULL); | 56 DCHECK(bidi_ != NULL); |
| 52 ubidi_getLogicalRun(bidi_, start, end, level); | 57 ubidi_getLogicalRun(bidi_, start, end, level); |
| 53 } | 58 } |
| 59 |
| 60 } // namespace i18n |
| 61 } // namespace base |
| OLD | NEW |