Chromium Code Reviews| 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..43648cbcf2ba3994b7679df882eb2710ae4a4f5d 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" |
| @@ -549,7 +550,20 @@ int uncheckedPreviousOffset(const Node* n, int current) |
| static int uncheckedPreviousOffsetForBackwardDeletion(const Node* n, int current) |
|
yosin_UTC9
2016/03/25 04:37:23
Please avoid to use one letter variable name.
Seigo Nonaka
2016/03/25 06:59:06
Done.
|
| { |
| - return n->layoutObject() ? n->layoutObject()->previousOffsetForBackwardDeletion(current) : current - 1; |
| + if (current <= 1) |
| + return 0; |
| + if (!n->isTextNode()) |
| + return current - 1; |
| + |
| + const String& text = toText(n)->data(); |
| + CHECK(static_cast<unsigned>(current - 1) < text.length()); |
| + BackspaceStateMachine machine; |
| + for (int i = current - 1; i >= 0; --i) { |
| + if (machine.ComputeNextState(text[i])) { |
|
yosin_UTC9
2016/03/25 04:37:23
nit: no need to have braces for single line statem
Seigo Nonaka
2016/03/25 06:59:06
Done.
|
| + break; |
| + } |
| + } |
| + return current - machine.FinalizeAndGetCodeUnitCountToBeDeleted(); |
| } |
| int uncheckedNextOffset(const Node* n, int current) |