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 #ifndef NGBidiParagraph_h | 5 #ifndef NGBidiParagraph_h |
6 #define NGBidiParagraph_h | 6 #define NGBidiParagraph_h |
7 | 7 |
8 #include "platform/text/TextDirection.h" | |
8 #include "platform/wtf/Allocator.h" | 9 #include "platform/wtf/Allocator.h" |
9 #include "platform/wtf/Forward.h" | 10 #include "platform/wtf/Forward.h" |
10 #include "platform/wtf/Vector.h" | 11 #include "platform/wtf/Vector.h" |
11 | 12 |
12 #include <unicode/ubidi.h> | 13 #include <unicode/ubidi.h> |
13 | 14 |
14 namespace blink { | 15 namespace blink { |
15 | 16 |
16 class ComputedStyle; | 17 class ComputedStyle; |
17 | 18 |
(...skipping 10 matching lines...) Expand all Loading... | |
28 public: | 29 public: |
29 NGBidiParagraph() {} | 30 NGBidiParagraph() {} |
30 ~NGBidiParagraph(); | 31 ~NGBidiParagraph(); |
31 | 32 |
32 // Splits the given paragraph to bidi runs and resolves the bidi embedding | 33 // Splits the given paragraph to bidi runs and resolves the bidi embedding |
33 // level of each run. | 34 // level of each run. |
34 // Returns false on failure. Nothing other than the destructor should be | 35 // Returns false on failure. Nothing other than the destructor should be |
35 // called. | 36 // called. |
36 bool SetParagraph(const String&, const ComputedStyle&); | 37 bool SetParagraph(const String&, const ComputedStyle&); |
37 | 38 |
38 // Returns whether the paragraph is LTR, RTL, or MIXED. | 39 // @return the entire text is undirectional and LTR. |
39 UBiDiDirection Direction() const { return ubidi_getDirection(ubidi_); } | 40 bool IsAllLtr() const { return ubidi_getDirection(ubidi_) == UBIDI_LTR; } |
eae
2017/06/20 17:54:41
Instead of IsAllLtr() could we make this more expl
| |
41 | |
42 // The base direction (a.k.a. paragraph direction) of this block. | |
43 TextDirection BaseDirection() const { return base_direction_; } | |
40 | 44 |
41 // Returns the end offset of a logical run that starts from the |start| | 45 // Returns the end offset of a logical run that starts from the |start| |
42 // offset. | 46 // offset. |
43 unsigned GetLogicalRun(unsigned start, UBiDiLevel*) const; | 47 unsigned GetLogicalRun(unsigned start, UBiDiLevel*) const; |
44 | 48 |
45 // Create a list of indices in the visual order. | 49 // Create a list of indices in the visual order. |
46 // A wrapper for ICU |ubidi_reorderVisual()|. | 50 // A wrapper for ICU |ubidi_reorderVisual()|. |
47 static void IndicesInVisualOrder( | 51 static void IndicesInVisualOrder( |
48 const Vector<UBiDiLevel, 32>& levels, | 52 const Vector<UBiDiLevel, 32>& levels, |
49 Vector<int32_t, 32>* indices_in_visual_order_out); | 53 Vector<int32_t, 32>* indices_in_visual_order_out); |
50 | 54 |
51 private: | 55 private: |
52 UBiDi* ubidi_ = nullptr; | 56 UBiDi* ubidi_ = nullptr; |
57 TextDirection base_direction_ = TextDirection::kLtr; | |
53 }; | 58 }; |
54 | 59 |
55 } // namespace blink | 60 } // namespace blink |
56 | 61 |
57 #endif // NGBidiParagraph_h | 62 #endif // NGBidiParagraph_h |
OLD | NEW |