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

Unified Diff: Source/core/html/forms/TextFieldInputType.cpp

Issue 258063005: Blink does not respect input.selectionStart and input.selectionEnd for some cases (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 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
Index: Source/core/html/forms/TextFieldInputType.cpp
diff --git a/Source/core/html/forms/TextFieldInputType.cpp b/Source/core/html/forms/TextFieldInputType.cpp
index beb8cd5bfc56b9c21268ca2fe4378d2270542a3b..132c896d28f9f891528d9013e5209af6fd558930 100644
--- a/Source/core/html/forms/TextFieldInputType.cpp
+++ b/Source/core/html/forms/TextFieldInputType.cpp
@@ -160,10 +160,14 @@ void TextFieldInputType::setValue(const String& sanitizedValue, bool valueChange
input->updateView();
unsigned max = visibleValue().length();
- if (input->focused())
- input->setSelectionRange(max, max);
- else
- input->cacheSelectionInResponseToSetValue(max);
+ if (input->focused()) {
+ if (input->selectionStart() != input->selectionEnd())
+ input->setSelectionRange(input->selectionStart(), input->selectionEnd());
+ else
+ input->setSelectionRange(max, max);
+ } else {
+ input->setSelectionRange(input->selectionStart(), input->selectionEnd());
yosin_UTC9 2014/07/03 01:58:36 Why do we need to set same value to input field se
harpreet.sk 2014/07/04 13:50:27 In case if input field is focused and selection is
+ }
if (!valueChanged)
return;

Powered by Google App Engine
This is Rietveld 408576698