Bug 1386905 part 1 - Have HTMLInputElement::SetDefaultValueAsValue notify when necessary. r?ehsan
MozReview-Commit-ID: 3ojxWuU9u12
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -1410,17 +1410,17 @@ HTMLInputElement::AfterSetAttr(int32_t a
}
// If @value is changed and BF_VALUE_CHANGED is false, @value is the value
// of the element so, if the value of the element is different than @value,
// we have to re-set it. This is only the case when GetValueMode() returns
// VALUE_MODE_VALUE.
if (aName == nsGkAtoms::value &&
!mValueChanged && GetValueMode() == VALUE_MODE_VALUE) {
- SetDefaultValueAsValue();
+ SetDefaultValueAsValue(aNotify);
}
//
// Checked must be set no matter what type of control it is, since
// mChecked must reflect the new value
if (aName == nsGkAtoms::checked && !mCheckedChanged) {
// Delay setting checked if we are creating this element (wait
// until everything is set)
@@ -6244,28 +6244,30 @@ HTMLInputElement::UpdateApzAwareFlag()
#if !defined(ANDROID) && !defined(XP_MACOSX)
if ((mType == NS_FORM_INPUT_NUMBER) || (mType == NS_FORM_INPUT_RANGE)) {
SetMayBeApzAware();
}
#endif
}
nsresult
-HTMLInputElement::SetDefaultValueAsValue()
+HTMLInputElement::SetDefaultValueAsValue(bool aNotify)
{
NS_ASSERTION(GetValueMode() == VALUE_MODE_VALUE,
"GetValueMode() should return VALUE_MODE_VALUE!");
// The element has a content attribute value different from it's value when
// it's in the value mode value.
nsAutoString resetVal;
GetDefaultValue(resetVal);
// SetValueInternal is going to sanitize the value.
- return SetValueInternal(resetVal, nsTextEditorState::eSetValue_Internal);
+ uint32_t flags = aNotify ? nsTextEditorState::eSetValue_Notify
+ : nsTextEditorState::eSetValue_Internal;
+ return SetValueInternal(resetVal, flags);
}
void
HTMLInputElement::SetDirectionFromValue(bool aNotify)
{
if (IsSingleLineTextControl(true)) {
nsAutoString value;
GetValue(value, CallerType::System);
@@ -6278,17 +6280,17 @@ HTMLInputElement::Reset()
{
// We should be able to reset all dirty flags regardless of the type.
SetCheckedChanged(false);
SetValueChanged(false);
mLastValueChangeWasInteractive = false;
switch (GetValueMode()) {
case VALUE_MODE_VALUE:
- return SetDefaultValueAsValue();
+ return SetDefaultValueAsValue(false);
case VALUE_MODE_DEFAULT_ON:
DoSetChecked(DefaultChecked(), true, false);
return NS_OK;
case VALUE_MODE_FILENAME:
ClearFiles(false);
return NS_OK;
case VALUE_MODE_DEFAULT:
default:
--- a/dom/html/HTMLInputElement.h
+++ b/dom/html/HTMLInputElement.h
@@ -1188,17 +1188,17 @@ protected:
*/
bool PlaceholderApplies() const;
/**
* Set the current default value to the value of the input element.
* @note You should not call this method if GetValueMode() doesn't return
* VALUE_MODE_VALUE.
*/
- nsresult SetDefaultValueAsValue();
+ nsresult SetDefaultValueAsValue(bool aNotify);
void SetDirectionFromValue(bool aNotify);
/**
* Return if an element should have a specific validity UI
* (with :-moz-ui-invalid and :-moz-ui-valid pseudo-classes).
*
* @return Whether the element should have a validity UI.