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

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

Issue 1839753005: Move state machines to state_machines subdir (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Introduce notifyEndOfPrecedingText. Created 4 years, 8 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
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 BackspaceStateMachine_h 5 #ifndef BackspaceStateMachine_h
6 #define BackspaceStateMachine_h 6 #define BackspaceStateMachine_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "wtf/Allocator.h" 9 #include "wtf/Allocator.h"
10 #include "wtf/Noncopyable.h" 10 #include "wtf/Noncopyable.h"
11 #include "wtf/text/Unicode.h" 11 #include "wtf/text/Unicode.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 class CORE_EXPORT BackspaceStateMachine { 15 class CORE_EXPORT BackspaceStateMachine {
16 STACK_ALLOCATED(); 16 STACK_ALLOCATED();
17 WTF_MAKE_NONCOPYABLE(BackspaceStateMachine); 17 WTF_MAKE_NONCOPYABLE(BackspaceStateMachine);
18 public: 18 public:
19 enum class State {
20 Unknown, // Indicates the state machine is in unknown state.
21 NeedMoreCodeUnit, // Indicates the state machine needs more code units t o transit the state.
22 NeedFollowingCodeUnit, // Indicates the state machine needs following co de units to transit the state.
23 Finished, // Indicates the state machine found a boundary.
24 };
19 BackspaceStateMachine() = default; 25 BackspaceStateMachine() = default;
20 26
21 // Returns true when the state machine has stopped. 27 // Prepares by feeding preceding text.
22 bool updateState(UChar codeUnit); 28 // This method must not be called after feedFollowingCodeUnit().
29 State feedPrecedingCodeUnit(UChar codeUnit);
23 30
24 // Finalize the state machine and returns the code unit count to be deleted. 31 // Notify the end of preceding text to the state machine.
25 // If the state machine hasn't finished, this method finishes the state 32 State notifyEndOfPrecedingText();
yosin_UTC9 2016/03/30 07:43:07 How about |tellEndOfPrecedingText()|. It seems |no
Seigo Nonaka 2016/03/30 08:13:09 Done.
26 // machine first. 33
27 int finalizeAndGetCodeUnitCountToBeDeleted(); 34 // Find boundary offset by feeding following text.
35 // This method must be called after feedPrecedingCodeUnit() returns NeedsFol lowingCodeUnit.
36 State feedFollowingCodeUnit(UChar codeUnit);
37
38 // Returns the next boundary offset. This method finalizes the state machine if it is not finished.
39 int finalizeAndGetBoundaryOffset();
28 40
29 // Resets the internal state to the initial state. 41 // Resets the internal state to the initial state.
30 void reset(); 42 void reset();
31 43
32 private: 44 private:
33 int m_codeUnitsToBeDeleted = 0; 45 int m_codeUnitsToBeDeleted = 0;
34 46
35 // Used for composing supplementary code point with surrogate pairs. 47 // Used for composing supplementary code point with surrogate pairs.
36 UChar m_trailSurrogate = 0; 48 UChar m_trailSurrogate = 0;
37 }; 49 };
38 50
39 } // namespace blink 51 } // namespace blink
40 52
41 #endif 53 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698