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(ubidi_, text.characters16(), text.length(), | 22 ubidi_setPara( |
23 block_style->unicodeBidi() == Plaintext | 23 ubidi_, text.characters16(), text.length(), |
24 ? UBIDI_DEFAULT_LTR | 24 block_style->unicodeBidi() == Plaintext |
25 : (block_style->direction() == RTL ? UBIDI_RTL : UBIDI_LTR), | 25 ? UBIDI_DEFAULT_LTR |
26 nullptr, &error); | 26 : (block_style->direction() == TextDirection::Rtl ? UBIDI_RTL |
| 27 : UBIDI_LTR), |
| 28 nullptr, &error); |
27 if (U_FAILURE(error)) { | 29 if (U_FAILURE(error)) { |
28 NOTREACHED(); | 30 NOTREACHED(); |
29 ubidi_close(ubidi_); | 31 ubidi_close(ubidi_); |
30 ubidi_ = nullptr; | 32 ubidi_ = nullptr; |
31 return false; | 33 return false; |
32 } | 34 } |
33 return true; | 35 return true; |
34 } | 36 } |
35 | 37 |
36 unsigned NGBidiParagraph::GetLogicalRun(unsigned start, | 38 unsigned NGBidiParagraph::GetLogicalRun(unsigned start, |
(...skipping 16 matching lines...) Expand all Loading... |
53 levels.append(item.BidiLevel()); | 55 levels.append(item.BidiLevel()); |
54 | 56 |
55 // Check the size before passing the raw pointers to ICU. | 57 // Check the size before passing the raw pointers to ICU. |
56 CHECK_EQ(items.Size(), levels.size()); | 58 CHECK_EQ(items.Size(), levels.size()); |
57 CHECK_EQ(items.Size(), item_indicies_in_visual_order_out->size()); | 59 CHECK_EQ(items.Size(), item_indicies_in_visual_order_out->size()); |
58 ubidi_reorderVisual(levels.data(), items.Size(), | 60 ubidi_reorderVisual(levels.data(), items.Size(), |
59 item_indicies_in_visual_order_out->data()); | 61 item_indicies_in_visual_order_out->data()); |
60 } | 62 } |
61 | 63 |
62 } // namespace blink | 64 } // namespace blink |
OLD | NEW |