OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ForwardCodePointStateMachine_h |
| 6 #define ForwardCodePointStateMachine_h |
| 7 |
| 8 #include "core/CoreExport.h" |
| 9 #include "core/editing/state_machines/TextSegmentationMachineState.h" |
| 10 #include "wtf/Allocator.h" |
| 11 #include "wtf/Noncopyable.h" |
| 12 #include "wtf/text/Unicode.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 class CORE_EXPORT ForwardCodePointStateMachine { |
| 17 STACK_ALLOCATED(); |
| 18 WTF_MAKE_NONCOPYABLE(ForwardCodePointStateMachine); |
| 19 |
| 20 public: |
| 21 ForwardCodePointStateMachine(); |
| 22 ~ForwardCodePointStateMachine() = default; |
| 23 |
| 24 // Prepares by feeding preceding text. |
| 25 TextSegmentationMachineState feedPrecedingCodeUnit(UChar codeUnit); |
| 26 |
| 27 // Finds boundary offset by feeding following text. |
| 28 TextSegmentationMachineState feedFollowingCodeUnit(UChar codeUnit); |
| 29 |
| 30 // Returns true if we are at code point boundary. |
| 31 bool atCodePointBoundary(); |
| 32 |
| 33 // Returns the next boundary offset. |
| 34 int getBoundaryOffset(); |
| 35 |
| 36 // Resets the internal state to the initial state. |
| 37 void reset(); |
| 38 |
| 39 private: |
| 40 enum class ForwardCodePointState; |
| 41 |
| 42 // The number of code units to be deleted. |
| 43 // Nothing to delete if there is an invalid surrogate pair. |
| 44 int m_codeUnitsToBeDeleted = 0; |
| 45 |
| 46 // The internal state. |
| 47 ForwardCodePointState m_state; |
| 48 }; |
| 49 |
| 50 } // namespace blink |
| 51 |
| 52 #endif |
OLD | NEW |