OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/layout/ng/ng_bidi_paragraph.h" | 5 #include "core/layout/ng/ng_bidi_paragraph.h" |
6 | 6 |
7 #include "core/layout/ng/ng_inline_node.h" | 7 #include "core/layout/ng/ng_inline_node.h" |
8 #include "core/style/ComputedStyle.h" | 8 #include "core/style/ComputedStyle.h" |
9 #include "platform/text/ICUError.h" | 9 #include "platform/text/ICUError.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 NGBidiParagraph::~NGBidiParagraph() { | 13 NGBidiParagraph::~NGBidiParagraph() { |
14 ubidi_close(ubidi_); | 14 ubidi_close(ubidi_); |
15 } | 15 } |
16 | 16 |
17 bool NGBidiParagraph::SetParagraph(const String& text, | 17 bool NGBidiParagraph::SetParagraph(const String& text, |
18 const ComputedStyle* block_style) { | 18 const ComputedStyle* block_style) { |
19 DCHECK(!ubidi_); | 19 DCHECK(!ubidi_); |
20 ubidi_ = ubidi_open(); | 20 ubidi_ = ubidi_open(); |
21 ICUError error; | 21 ICUError error; |
22 ubidi_setPara( | 22 ubidi_setPara( |
23 ubidi_, text.characters16(), text.length(), | 23 ubidi_, text.characters16(), text.length(), |
24 block_style->unicodeBidi() == Plaintext | 24 block_style->unicodeBidi() == Plaintext |
25 ? UBIDI_DEFAULT_LTR | 25 ? UBIDI_DEFAULT_LTR |
26 : (block_style->direction() == TextDirection::Rtl ? UBIDI_RTL | 26 : (block_style->direction() == TextDirection::kRtl ? UBIDI_RTL |
27 : UBIDI_LTR), | 27 : UBIDI_LTR), |
28 nullptr, &error); | 28 nullptr, &error); |
29 if (U_FAILURE(error)) { | 29 if (U_FAILURE(error)) { |
30 NOTREACHED(); | 30 NOTREACHED(); |
31 ubidi_close(ubidi_); | 31 ubidi_close(ubidi_); |
32 ubidi_ = nullptr; | 32 ubidi_ = nullptr; |
33 return false; | 33 return false; |
34 } | 34 } |
35 return true; | 35 return true; |
36 } | 36 } |
37 | 37 |
38 unsigned NGBidiParagraph::GetLogicalRun(unsigned start, | 38 unsigned NGBidiParagraph::GetLogicalRun(unsigned start, |
39 UBiDiLevel* level) const { | 39 UBiDiLevel* level) const { |
40 int32_t end; | 40 int32_t end; |
41 ubidi_getLogicalRun(ubidi_, start, &end, level); | 41 ubidi_getLogicalRun(ubidi_, start, &end, level); |
42 return end; | 42 return end; |
43 } | 43 } |
44 | 44 |
45 void NGBidiParagraph::IndiciesInVisualOrder( | 45 void NGBidiParagraph::IndiciesInVisualOrder( |
46 const Vector<UBiDiLevel, 32>& levels, | 46 const Vector<UBiDiLevel, 32>& levels, |
47 Vector<int32_t, 32>* indicies_in_visual_order_out) { | 47 Vector<int32_t, 32>* indicies_in_visual_order_out) { |
48 // Check the size before passing the raw pointers to ICU. | 48 // Check the size before passing the raw pointers to ICU. |
49 CHECK_EQ(levels.size(), indicies_in_visual_order_out->size()); | 49 CHECK_EQ(levels.size(), indicies_in_visual_order_out->size()); |
50 ubidi_reorderVisual(levels.data(), levels.size(), | 50 ubidi_reorderVisual(levels.data(), levels.size(), |
51 indicies_in_visual_order_out->data()); | 51 indicies_in_visual_order_out->data()); |
52 } | 52 } |
53 | 53 |
54 } // namespace blink | 54 } // namespace blink |
OLD | NEW |