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

Unified Diff: components/test_runner/text_input_controller.cc

Issue 2020973002: Reland: Fix setComposingText with empty text when newCursorPosition != 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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
« no previous file with comments | « no previous file | content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/test_runner/text_input_controller.cc
diff --git a/components/test_runner/text_input_controller.cc b/components/test_runner/text_input_controller.cc
index 64d2a75656f3862abd36021d2a06f29d8ba7e269..6d5fd2392378d1ca006dc66a4b7d34651d2cd864 100644
--- a/components/test_runner/text_input_controller.cc
+++ b/components/test_runner/text_input_controller.cc
@@ -257,14 +257,18 @@ void TextInputController::SetComposition(const std::string& text) {
key_down.setKeyIdentifierFromWindowsKeyCode();
view()->handleInputEvent(key_down);
+ // The value returned by std::string::length() may not correspond to the
+ // actual number of encoded characters in sequences of multi-byte or
+ // variable-length characters.
+ blink::WebString newText = blink::WebString::fromUTF8(text);
+ size_t textLength = base::string16(newText).length();
tkent 2016/07/04 00:51:49 Doesn't newText.length() work?
yabinh 2016/07/04 01:03:22 No, it doesn't. For "عالم", its length is 4. But n
tkent 2016/07/04 01:08:16 It shouldn't happen. It implies WebString has a s
+
std::vector<blink::WebCompositionUnderline> underlines;
- underlines.push_back(blink::WebCompositionUnderline(0, text.length(),
- SK_ColorBLACK, false,
- SK_ColorTRANSPARENT));
+ underlines.push_back(blink::WebCompositionUnderline(
+ 0, textLength, SK_ColorBLACK, false, SK_ColorTRANSPARENT));
view()->setComposition(
- blink::WebString::fromUTF8(text),
- blink::WebVector<blink::WebCompositionUnderline>(underlines),
- text.length(), text.length());
+ newText, blink::WebVector<blink::WebCompositionUnderline>(underlines),
+ textLength, textLength);
}
blink::WebView* TextInputController::view() {
« no previous file with comments | « no previous file | content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698