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 a5748f859505025388e33c7a977601d7afb6f13f..5d68a43fc3030207458db69c7934cbf5a7828392 100644 |
| --- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp |
| +++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp |
| @@ -52,6 +52,7 @@ |
| #include "core/html/HTMLUListElement.h" |
| #include "core/layout/LayoutObject.h" |
| #include "core/layout/LayoutTableCell.h" |
| +#include "third_party/icu/source/common/unicode/utf16.h" |
|
tkent
2016/03/29 00:00:48
I think wtf/unicode/Unicode.h provides U16_IS_TRAI
Seigo Nonaka
2016/03/29 04:38:47
Done.
|
| #include "wtf/Assertions.h" |
| #include "wtf/StdLibExtras.h" |
| #include "wtf/text/StringBuilder.h" |
| @@ -556,9 +557,21 @@ int uncheckedPreviousOffset(const Node* node, int current) |
| return result == TextBreakDone ? current - 1 : result; |
| } |
| -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; |
| + DCHECK_GE(current, 0); |
| + 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()); |
| + if (U16_IS_TRAIL(text[--current])) |
| + --current; |
| + if (current < 0) |
| + current = 0; |
| + return current; |
| } |
| int uncheckedNextOffset(const Node* node, int current) |