| Index: third_party/WebKit/Source/core/editing/EditingUtilities.cpp
|
| diff --git a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
|
| index fed03353f55ed4fa03b8f0b67ffc02d2b62934ef..ed9fffdebb792350ced2828ad2dc618055353b78 100644
|
| --- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
|
| @@ -32,6 +32,7 @@
|
| #include "core/dom/Range.h"
|
| #include "core/dom/Text.h"
|
| #include "core/dom/shadow/ShadowRoot.h"
|
| +#include "core/editing/BackspaceStateMachine.h"
|
| #include "core/editing/EditingStrategy.h"
|
| #include "core/editing/Editor.h"
|
| #include "core/editing/PlainTextRange.h"
|
| @@ -547,9 +548,21 @@ int uncheckedPreviousOffset(const Node* n, int current)
|
| return n->layoutObject() ? n->layoutObject()->previousOffset(current) : current - 1;
|
| }
|
|
|
| -static int uncheckedPreviousOffsetForBackwardDeletion(const Node* n, int current)
|
| +static int uncheckedPreviousOffsetForBackwardDeletion(const Node* node, int current)
|
| {
|
| - return n->layoutObject() ? n->layoutObject()->previousOffsetForBackwardDeletion(current) : current - 1;
|
| + if (current <= 1)
|
| + return 0;
|
| + if (!node->isTextNode())
|
| + return current - 1;
|
| +
|
| + const String& text = toText(node)->data();
|
| + CHECK(static_cast<unsigned>(current - 1) < text.length());
|
| + BackspaceStateMachine machine;
|
| + for (int i = current - 1; i >= 0; --i) {
|
| + if (machine.updateState(text[i]))
|
| + break;
|
| + }
|
| + return current - machine.finalizeAndGetCodeUnitCountToBeDeleted();
|
| }
|
|
|
| int uncheckedNextOffset(const Node* n, int current)
|
|
|