| 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 #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, |
| 23 bool right_to_left, | 23 bool right_to_left, |
| 24 bool url) { | 24 bool url) { |
| 25 DCHECK(bidi_ == NULL); | 25 DCHECK(!bidi_); |
| 26 UErrorCode error = U_ZERO_ERROR; | 26 UErrorCode error = U_ZERO_ERROR; |
| 27 bidi_ = ubidi_openSized(static_cast<int>(text.length()), 0, &error); | 27 bidi_ = ubidi_openSized(static_cast<int>(text.length()), 0, &error); |
| 28 if (U_FAILURE(error)) | 28 if (U_FAILURE(error)) |
| 29 return false; | 29 return false; |
| 30 if (right_to_left && url) | 30 if (right_to_left && url) |
| 31 ubidi_setReorderingMode(bidi_, UBIDI_REORDER_RUNS_ONLY); | 31 ubidi_setReorderingMode(bidi_, UBIDI_REORDER_RUNS_ONLY); |
| 32 ubidi_setPara(bidi_, text.data(), static_cast<int>(text.length()), | 32 ubidi_setPara(bidi_, text.data(), static_cast<int>(text.length()), |
| 33 right_to_left ? UBIDI_DEFAULT_RTL : UBIDI_DEFAULT_LTR, | 33 right_to_left ? UBIDI_DEFAULT_RTL : UBIDI_DEFAULT_LTR, |
| 34 NULL, &error); | 34 NULL, &error); |
| 35 return U_SUCCESS(error) ? true : false; | 35 return U_SUCCESS(error) ? true : false; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 51 | 51 |
| 52 void BiDiLineIterator::GetLogicalRun(int start, | 52 void BiDiLineIterator::GetLogicalRun(int start, |
| 53 int* end, | 53 int* end, |
| 54 UBiDiLevel* level) { | 54 UBiDiLevel* level) { |
| 55 DCHECK(bidi_ != NULL); | 55 DCHECK(bidi_ != NULL); |
| 56 ubidi_getLogicalRun(bidi_, start, end, level); | 56 ubidi_getLogicalRun(bidi_, start, end, level); |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // namespace i18n | 59 } // namespace i18n |
| 60 } // namespace base | 60 } // namespace base |
| OLD | NEW |