Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Unified Diff: third_party/WebKit/Source/core/editing/commands/InsertIncrementalTextCommand.cpp

Issue 2782823002: Make InsertIncrementalTextCommand to handle surrogate pair (Closed)
Patch Set: 2017-03-29T16:13:30 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/commands/InsertIncrementalTextCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/InsertIncrementalTextCommand.cpp b/third_party/WebKit/Source/core/editing/commands/InsertIncrementalTextCommand.cpp
index 5d01df334bae6e8115465cbcbf88449539a4fcf4..d0dd77ed19d88503e4b70e480b6f60f395ea602d 100644
--- a/third_party/WebKit/Source/core/editing/commands/InsertIncrementalTextCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/InsertIncrementalTextCommand.cpp
@@ -12,6 +12,7 @@
#include "core/editing/PlainTextRange.h"
#include "core/editing/VisibleUnits.h"
#include "core/editing/iterators/CharacterIterator.h"
+#include "core/editing/state_machines/ForwardCodePointStateMachine.h"
#include "core/html/HTMLSpanElement.h"
namespace blink {
@@ -20,9 +21,15 @@ namespace {
size_t computeCommonPrefixLength(const String& str1, const String& str2) {
const size_t maxCommonPrefixLength = std::min(str1.length(), str2.length());
+ ForwardCodePointStateMachine codePointStateMachine;
+ int result = 0;
for (size_t index = 0; index < maxCommonPrefixLength; ++index) {
if (str1[index] != str2[index])
- return index;
+ return result;
+ codePointStateMachine.feedFollowingCodeUnit(str1[index]);
+ if (!codePointStateMachine.atCodePointBoundary())
+ continue;
+ result = index;
}
return maxCommonPrefixLength;
}

Powered by Google App Engine
This is Rietveld 408576698