Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/BackspaceStateMachine.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/BackspaceStateMachine.cpp b/third_party/WebKit/Source/core/editing/BackspaceStateMachine.cpp |
| index 701c07d0a03426b47cd8239bb53b97ed55bf0a9d..7c38fba9194c50789a03dbcd9a6abbc8670e874a 100644 |
| --- a/third_party/WebKit/Source/core/editing/BackspaceStateMachine.cpp |
| +++ b/third_party/WebKit/Source/core/editing/BackspaceStateMachine.cpp |
| @@ -8,24 +8,14 @@ |
| namespace blink { |
| -int BackspaceStateMachine::finalizeAndGetCodeUnitCountToBeDeleted() |
| -{ |
| - if (m_trailSurrogate != 0) { |
| - // Unpaired trail surrogate. Removing broken surrogate. |
| - ++m_codeUnitsToBeDeleted; |
| - m_trailSurrogate = 0; |
| - } |
| - return m_codeUnitsToBeDeleted; |
| -} |
| - |
| -bool BackspaceStateMachine::updateState(UChar codeUnit) |
| +BackspaceStateMachine::State 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 State::Finished; |
| } |
| codePoint = U16_GET_SUPPLEMENTARY(codeUnit, m_trailSurrogate); |
| m_trailSurrogate = 0; |
| @@ -33,21 +23,47 @@ bool BackspaceStateMachine::updateState(UChar codeUnit) |
| if (m_trailSurrogate != 0) { |
| // Unpaired trail surrogate. Aborting with deleting broken |
| // surrogate. |
| - return true; |
| + return State::Finished; |
| } |
| m_trailSurrogate = codeUnit; |
| - return false; // Needs surrogate lead. |
| + return State::NeedMoreCodeUnit; |
| } else { |
| if (m_trailSurrogate != 0) { |
| // Unpaired trail surrogate. Aborting with deleting broken |
| // surrogate. |
| - return true; |
| + return State::Finished; |
| } |
| } |
| // TODO(nona): Handle emoji sequences. |
| m_codeUnitsToBeDeleted = U16_LENGTH(codePoint); |
| - return true; |
| + return State::Finished; |
| +} |
| + |
| +BackspaceStateMachine::State BackspaceStateMachine::notifyEndOfPrecedingText() |
| +{ |
| + if (m_trailSurrogate != 0) { |
| + // Unpaired trail surrogate. Removing broken surrogate. |
| + ++m_codeUnitsToBeDeleted; |
| + m_trailSurrogate = 0; |
| + } |
| + return State::Finished; |
| +} |
| + |
| +BackspaceStateMachine::State BackspaceStateMachine::feedFollowingCodeUnit(UChar codeUnit) |
| +{ |
| + NOTREACHED(); |
| + return State::Unknown; |
|
yosin_UTC9
2016/03/30 07:43:06
|Invalid| is better for here? Because state machin
Seigo Nonaka
2016/03/30 08:13:09
Done.
|
| +} |
| + |
| +int BackspaceStateMachine::finalizeAndGetBoundaryOffset() |
| +{ |
| + if (m_trailSurrogate != 0) { |
| + // Unpaired trail surrogate. Removing broken surrogate. |
| + ++m_codeUnitsToBeDeleted; |
| + m_trailSurrogate = 0; |
| + } |
| + return -m_codeUnitsToBeDeleted; |
| } |
| void BackspaceStateMachine::reset() |