| 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 unidirectional. |
| 39 UBiDiDirection Direction() const { return ubidi_getDirection(ubidi_); } | 40 bool IsUnidirectional() const { |
| 41 return ubidi_getDirection(ubidi_) != UBIDI_MIXED; |
| 42 } |
| 43 |
| 44 // The base direction (a.k.a. paragraph direction) of this block. |
| 45 TextDirection BaseDirection() const { return base_direction_; } |
| 40 | 46 |
| 41 // Returns the end offset of a logical run that starts from the |start| | 47 // Returns the end offset of a logical run that starts from the |start| |
| 42 // offset. | 48 // offset. |
| 43 unsigned GetLogicalRun(unsigned start, UBiDiLevel*) const; | 49 unsigned GetLogicalRun(unsigned start, UBiDiLevel*) const; |
| 44 | 50 |
| 45 // Create a list of indices in the visual order. | 51 // Create a list of indices in the visual order. |
| 46 // A wrapper for ICU |ubidi_reorderVisual()|. | 52 // A wrapper for ICU |ubidi_reorderVisual()|. |
| 47 static void IndicesInVisualOrder( | 53 static void IndicesInVisualOrder( |
| 48 const Vector<UBiDiLevel, 32>& levels, | 54 const Vector<UBiDiLevel, 32>& levels, |
| 49 Vector<int32_t, 32>* indices_in_visual_order_out); | 55 Vector<int32_t, 32>* indices_in_visual_order_out); |
| 50 | 56 |
| 51 private: | 57 private: |
| 52 UBiDi* ubidi_ = nullptr; | 58 UBiDi* ubidi_ = nullptr; |
| 59 TextDirection base_direction_ = TextDirection::kLtr; |
| 53 }; | 60 }; |
| 54 | 61 |
| 55 } // namespace blink | 62 } // namespace blink |
| 56 | 63 |
| 57 #endif // NGBidiParagraph_h | 64 #endif // NGBidiParagraph_h |
| OLD | NEW |