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

Unified Diff: third_party/WebKit/Source/core/html/HTMLTextAreaElement.cpp

Issue 2735633006: INPUT/TEXTAREA elements: Dispatch 'select' event only if text selection is changed. (Closed)
Patch Set: Remove throttling 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/html/HTMLTextAreaElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLTextAreaElement.cpp b/third_party/WebKit/Source/core/html/HTMLTextAreaElement.cpp
index 14546b547b875c7a7505eece485454917b82db7d..72ed028b4cbeeedb8b11a70ee2b477c549fddd10 100644
--- a/third_party/WebKit/Source/core/html/HTMLTextAreaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLTextAreaElement.cpp
@@ -377,18 +377,22 @@ String HTMLTextAreaElement::value() const {
}
void HTMLTextAreaElement::setValue(const String& value,
- TextFieldEventBehavior eventBehavior) {
- setValueCommon(value, eventBehavior);
+ TextFieldEventBehavior eventBehavior,
+ TextControlSetValueSelection selection) {
+ setValueCommon(value, eventBehavior, selection);
m_isDirty = true;
}
void HTMLTextAreaElement::setNonDirtyValue(const String& value) {
- setValueCommon(value, DispatchNoEvent);
+ setValueCommon(value, DispatchNoEvent,
+ TextControlSetValueSelection::kSetSelectionToEnd);
m_isDirty = false;
}
-void HTMLTextAreaElement::setValueCommon(const String& newValue,
- TextFieldEventBehavior eventBehavior) {
+void HTMLTextAreaElement::setValueCommon(
+ const String& newValue,
+ TextFieldEventBehavior eventBehavior,
+ TextControlSetValueSelection selection) {
// Code elsewhere normalizes line endings added by the user via the keyboard
// or pasting. We normalize line endings coming from JavaScript here.
String normalizedValue = newValue.isNull() ? "" : newValue;
@@ -411,7 +415,8 @@ void HTMLTextAreaElement::setValueCommon(const String& newValue,
StyleChangeReason::ControlValue));
m_suggestedValue = String();
setNeedsValidityCheck();
- if (isFinishedParsingChildren()) {
+ if (isFinishedParsingChildren() &&
+ selection == TextControlSetValueSelection::kSetSelectionToEnd) {
// Set the caret to the end of the text value except for initialize.
unsigned endOfString = m_value.length();
setSelectionRange(endOfString, endOfString);
@@ -632,7 +637,8 @@ void HTMLTextAreaElement::copyNonAttributePropertiesFromElement(
const Element& source) {
const HTMLTextAreaElement& sourceElement =
static_cast<const HTMLTextAreaElement&>(source);
- setValueCommon(sourceElement.value(), DispatchNoEvent);
+ setValueCommon(sourceElement.value(), DispatchNoEvent,
+ TextControlSetValueSelection::kSetSelectionToEnd);
m_isDirty = sourceElement.m_isDirty;
TextControlElement::copyNonAttributePropertiesFromElement(source);
}
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLTextAreaElement.h ('k') | third_party/WebKit/Source/core/html/TextControlElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698