Index: Source/core/html/HTMLTextAreaElement.cpp |
diff --git a/Source/core/html/HTMLTextAreaElement.cpp b/Source/core/html/HTMLTextAreaElement.cpp |
index f0ba03afd35d1ce1f43aa75fcfee22ee89c688bd..631ab4e063ac4e0d0f2925df0afd9791b76842a1 100644 |
--- a/Source/core/html/HTMLTextAreaElement.cpp |
+++ b/Source/core/html/HTMLTextAreaElement.cpp |
@@ -336,9 +336,16 @@ String HTMLTextAreaElement::value() const |
void HTMLTextAreaElement::setValue(const String& value, TextFieldEventBehavior eventBehavior) |
{ |
RefPtrWillBeRawPtr<HTMLTextAreaElement> protector(this); |
- setValueCommon(value, eventBehavior); |
+ bool isUpdated = setValueCommon(value, eventBehavior); |
m_isDirty = true; |
setNeedsValidityCheck(); |
+ |
+ if (isUpdated) { |
+ // Set the caret to the end of the text value. |
+ unsigned endOfString = m_value.length(); |
+ setSelectionRange(endOfString, endOfString); |
+ } |
+ |
if (document().focusedElement() == this) |
document().frameHost()->chrome().client().didUpdateTextOfFocusedElementByNonUserInput(); |
} |
@@ -350,7 +357,7 @@ void HTMLTextAreaElement::setNonDirtyValue(const String& value) |
setNeedsValidityCheck(); |
} |
-void HTMLTextAreaElement::setValueCommon(const String& newValue, TextFieldEventBehavior eventBehavior) |
+bool HTMLTextAreaElement::setValueCommon(const String& newValue, TextFieldEventBehavior eventBehavior) |
{ |
// Code elsewhere normalizes line endings added by the user via the keyboard or pasting. |
// We normalize line endings coming from JavaScript here. |
@@ -361,7 +368,7 @@ void HTMLTextAreaElement::setValueCommon(const String& newValue, TextFieldEventB |
// Return early because we don't want to move the caret or trigger other side effects |
// when the value isn't changing. This matches Firefox behavior, at least. |
if (normalizedValue == value()) |
- return; |
+ return false; |
m_value = normalizedValue; |
setInnerEditorValue(m_value); |
@@ -371,12 +378,6 @@ void HTMLTextAreaElement::setValueCommon(const String& newValue, TextFieldEventB |
setNeedsStyleRecalc(SubtreeStyleChange); |
m_suggestedValue = String(); |
- // Set the caret to the end of the text value. |
- if (document().focusedElement() == this) { |
- unsigned endOfString = m_value.length(); |
- setSelectionRange(endOfString, endOfString); |
- } |
- |
notifyFormStateChanged(); |
if (eventBehavior == DispatchNoEvent) { |
setTextAsOfLastFormControlChangeEvent(normalizedValue); |
@@ -385,6 +386,7 @@ void HTMLTextAreaElement::setValueCommon(const String& newValue, TextFieldEventB |
dispatchFormControlInputEvent(); |
dispatchFormControlChangeEvent(); |
} |
+ return true; |
} |
void HTMLTextAreaElement::setInnerEditorValue(const String& value) |