Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1098)

Side by Side Diff: third_party/WebKit/Source/core/editing/state_machines/BackwardCodePointStateMachine.h

Issue 2706713002: Introduce BackwardCodePointStateMachine to traverse chars in code points (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 BackwardCodePointStateMachine_h
6 #define BackwardCodePointStateMachine_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 BackwardCodePointStateMachine {
17 STACK_ALLOCATED();
18 WTF_MAKE_NONCOPYABLE(BackwardCodePointStateMachine);
19
20 public:
21 BackwardCodePointStateMachine();
22 ~BackwardCodePointStateMachine() = 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 BackwardCodePointState;
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 BackwardCodePointState m_state;
48 };
49
50 } // namespace blink
51
52 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698