OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "OrientationIterator.h" | 5 #include "OrientationIterator.h" |
6 | 6 |
7 #include "platform/wtf/PtrUtil.h" | 7 #include "platform/wtf/PtrUtil.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
11 OrientationIterator::OrientationIterator(const UChar* buffer, | 11 OrientationIterator::OrientationIterator(const UChar* buffer, |
12 unsigned buffer_size, | 12 unsigned buffer_size, |
13 FontOrientation run_orientation) | 13 FontOrientation run_orientation) |
14 : utf16_iterator_(WTF::MakeUnique<UTF16TextIterator>(buffer, buffer_size)), | 14 : utf16_iterator_(WTF::MakeUnique<UTF16TextIterator>(buffer, buffer_size)), |
15 buffer_size_(buffer_size), | 15 buffer_size_(buffer_size), |
16 at_end_(buffer_size == 0) { | 16 at_end_(buffer_size == 0) { |
17 // There's not much point in segmenting by isUprightInVertical if the text | 17 // There's not much point in segmenting by isUprightInVertical if the text |
18 // orientation is not "mixed". | 18 // orientation is not "mixed". |
19 ASSERT(run_orientation == FontOrientation::kVerticalMixed); | 19 DCHECK_EQ(run_orientation, FontOrientation::kVerticalMixed); |
20 } | 20 } |
21 | 21 |
22 bool OrientationIterator::Consume(unsigned* orientation_limit, | 22 bool OrientationIterator::Consume(unsigned* orientation_limit, |
23 RenderOrientation* render_orientation) { | 23 RenderOrientation* render_orientation) { |
24 if (at_end_) | 24 if (at_end_) |
25 return false; | 25 return false; |
26 | 26 |
27 RenderOrientation current_render_orientation = kOrientationInvalid; | 27 RenderOrientation current_render_orientation = kOrientationInvalid; |
28 UChar32 next_u_char32; | 28 UChar32 next_u_char32; |
29 while (utf16_iterator_->Consume(next_u_char32)) { | 29 while (utf16_iterator_->Consume(next_u_char32)) { |
(...skipping 14 matching lines...) Expand all Loading... |
44 } | 44 } |
45 utf16_iterator_->Advance(); | 45 utf16_iterator_->Advance(); |
46 } | 46 } |
47 *orientation_limit = buffer_size_; | 47 *orientation_limit = buffer_size_; |
48 *render_orientation = current_render_orientation; | 48 *render_orientation = current_render_orientation; |
49 at_end_ = true; | 49 at_end_ = true; |
50 return true; | 50 return true; |
51 } | 51 } |
52 | 52 |
53 } // namespace blink | 53 } // namespace blink |
OLD | NEW |