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..aa706171b20828b075602111bed5c0106761c731 100644 |
| --- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp |
| +++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp |
| @@ -55,6 +55,7 @@ |
| #include "wtf/Assertions.h" |
| #include "wtf/StdLibExtras.h" |
| #include "wtf/text/StringBuilder.h" |
| +#include "wtf/text/Unicode.h" |
| namespace blink { |
| @@ -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()); |
|
tkent
2016/03/29 04:58:10
Should it be CHECK, not DHCECK? String::operator[
Seigo Nonaka
2016/03/29 06:12:06
Make sense to me. Changed to DCHECK.
Thank you.
|
| + if (U16_IS_TRAIL(text[--current])) |
| + --current; |
| + if (current < 0) |
| + current = 0; |
| + return current; |
| } |
| int uncheckedNextOffset(const Node* node, int current) |