| Index: third_party/WebKit/Source/core/editing/state_machines/BackspaceStateMachine.cpp
|
| diff --git a/third_party/WebKit/Source/core/editing/BackspaceStateMachine.cpp b/third_party/WebKit/Source/core/editing/state_machines/BackspaceStateMachine.cpp
|
| similarity index 54%
|
| rename from third_party/WebKit/Source/core/editing/BackspaceStateMachine.cpp
|
| rename to third_party/WebKit/Source/core/editing/state_machines/BackspaceStateMachine.cpp
|
| index 701c07d0a03426b47cd8239bb53b97ed55bf0a9d..0f14512d1740f548818efeed50d36422a1f89abb 100644
|
| --- a/third_party/WebKit/Source/core/editing/BackspaceStateMachine.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/state_machines/BackspaceStateMachine.cpp
|
| @@ -2,30 +2,26 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "core/editing/BackspaceStateMachine.h"
|
| +#include "core/editing/state_machines/BackspaceStateMachine.h"
|
|
|
| #include "wtf/text/Unicode.h"
|
|
|
| namespace blink {
|
|
|
| -int BackspaceStateMachine::finalizeAndGetCodeUnitCountToBeDeleted()
|
| -{
|
| - if (m_trailSurrogate != 0) {
|
| - // Unpaired trail surrogate. Removing broken surrogate.
|
| - ++m_codeUnitsToBeDeleted;
|
| - m_trailSurrogate = 0;
|
| - }
|
| - return m_codeUnitsToBeDeleted;
|
| -}
|
| +namespace {
|
| +const TextSegmentationMachineState kInvalid = TextSegmentationMachineState::Invalid;
|
| +const TextSegmentationMachineState kNeedMoreCodeUnit = TextSegmentationMachineState::NeedMoreCodeUnit;
|
| +const TextSegmentationMachineState kFinished = TextSegmentationMachineState::Finished;
|
| +} // namespace
|
|
|
| -bool BackspaceStateMachine::updateState(UChar codeUnit)
|
| +TextSegmentationMachineState BackspaceStateMachine::feedPrecedingCodeUnit(UChar codeUnit)
|
| {
|
| uint32_t codePoint = codeUnit;
|
| if (U16_IS_LEAD(codeUnit)) {
|
| if (m_trailSurrogate == 0) {
|
| // Unpaired lead surrogate. Aborting with deleting broken surrogate.
|
| ++m_codeUnitsToBeDeleted;
|
| - return true;
|
| + return kFinished;
|
| }
|
| codePoint = U16_GET_SUPPLEMENTARY(codeUnit, m_trailSurrogate);
|
| m_trailSurrogate = 0;
|
| @@ -33,21 +29,47 @@ bool BackspaceStateMachine::updateState(UChar codeUnit)
|
| if (m_trailSurrogate != 0) {
|
| // Unpaired trail surrogate. Aborting with deleting broken
|
| // surrogate.
|
| - return true;
|
| + return kFinished;
|
| }
|
| m_trailSurrogate = codeUnit;
|
| - return false; // Needs surrogate lead.
|
| + return kNeedMoreCodeUnit;
|
| } else {
|
| if (m_trailSurrogate != 0) {
|
| // Unpaired trail surrogate. Aborting with deleting broken
|
| // surrogate.
|
| - return true;
|
| + return kFinished;
|
| }
|
| }
|
|
|
| // TODO(nona): Handle emoji sequences.
|
| m_codeUnitsToBeDeleted = U16_LENGTH(codePoint);
|
| - return true;
|
| + return kFinished;
|
| +}
|
| +
|
| +TextSegmentationMachineState BackspaceStateMachine::tellEndOfPrecedingText()
|
| +{
|
| + if (m_trailSurrogate != 0) {
|
| + // Unpaired trail surrogate. Removing broken surrogate.
|
| + ++m_codeUnitsToBeDeleted;
|
| + m_trailSurrogate = 0;
|
| + }
|
| + return kFinished;
|
| +}
|
| +
|
| +TextSegmentationMachineState BackspaceStateMachine::feedFollowingCodeUnit(UChar codeUnit)
|
| +{
|
| + NOTREACHED();
|
| + return kInvalid;
|
| +}
|
| +
|
| +int BackspaceStateMachine::finalizeAndGetBoundaryOffset()
|
| +{
|
| + if (m_trailSurrogate != 0) {
|
| + // Unpaired trail surrogate. Removing broken surrogate.
|
| + ++m_codeUnitsToBeDeleted;
|
| + m_trailSurrogate = 0;
|
| + }
|
| + return -m_codeUnitsToBeDeleted;
|
| }
|
|
|
| void BackspaceStateMachine::reset()
|
|
|