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

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: Addressing the expected behavior and changes asked for LayoutTests Created 6 years, 7 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 5bbc66fa83073a96345c481aebfbae2559450e4e..8bda4617582415e17b815de8249afc2521f9ab89 100644
--- a/Source/core/html/forms/TextFieldInputType.cpp
+++ b/Source/core/html/forms/TextFieldInputType.cpp
@@ -159,11 +159,17 @@ void TextFieldInputType::setValue(const String& sanitizedValue, bool valueChange
if (valueChanged)
input->updateView();
- unsigned max = visibleValue().length();
- if (input->focused())
+ int max = visibleValue().length();
+ if (input->focused()) {
input->setSelectionRange(max, max);
- else
- input->cacheSelectionInResponseToSetValue(max);
+ } else {
+ if (max < input->selectionStart())
tkent 2014/05/19 00:00:34 This |if| statement should be input->setSelect
harpreet.sk 2014/05/19 11:16:52 Done.
+ input->setSelectionRange(max, max);
+ else if (max >= input->selectionStart() && max < input->selectionEnd())
+ input->setSelectionRange(input->selectionStart(), max);
+ else
+ input->setSelectionRange(input->selectionStart(), input->selectionEnd());
+ }
if (!valueChanged)
return;

Powered by Google App Engine
This is Rietveld 408576698