Bug 613019 - Track whether the last input/textarea change was done interactively, and enable the commented-out maxLength tracking code. r=mrbkap

This commit is contained in:
Thomas Wisniewski
2016-08-06 11:59:08 -04:00
parent 15c69b47bd
commit 59fe578703
8 changed files with 88 additions and 18 deletions

View File

@@ -1145,6 +1145,7 @@ HTMLInputElement::HTMLInputElement(already_AddRefed<mozilla::dom::NodeInfo>& aNo
, mAutocompleteAttrState(nsContentUtils::eAutocompleteAttrState_Unknown)
, mDisabledChanged(false)
, mValueChanged(false)
, mLastValueChangeWasInteractive(false)
, mCheckedChanged(false)
, mChecked(false)
, mHandlingSelectEvent(false)
@@ -1326,6 +1327,7 @@ HTMLInputElement::Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) co
break;
}
it->mLastValueChangeWasInteractive = mLastValueChangeWasInteractive;
it.forget(aResult);
return NS_OK;
}
@@ -3071,7 +3073,8 @@ HTMLInputElement::SetValueInternal(const nsAString& aValue, uint32_t aFlags)
}
}
if (!mParserCreating) {
OnValueChanged(true);
OnValueChanged(/* aNotify = */ true,
/* aWasInteractiveUserChange = */ false);
}
// else DoneCreatingElement calls us again once mParserCreating is false
}
@@ -6065,6 +6068,7 @@ 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:
@@ -6917,9 +6921,10 @@ HTMLInputElement::SetCustomValidity(const nsAString& aError)
bool
HTMLInputElement::IsTooLong()
{
if (!MaxLengthApplies() ||
!HasAttr(kNameSpaceID_None, nsGkAtoms::maxlength) ||
!mValueChanged) {
if (!mValueChanged ||
!mLastValueChangeWasInteractive ||
!MaxLengthApplies() ||
!HasAttr(kNameSpaceID_None, nsGkAtoms::maxlength)) {
return false;
}
@@ -7192,10 +7197,7 @@ HTMLInputElement::HasBadInput() const
void
HTMLInputElement::UpdateTooLongValidityState()
{
// TODO: this code will be re-enabled with bug 613016 and bug 613019.
#if 0
SetValidityState(VALIDITY_STATE_TOO_LONG, IsTooLong());
#endif
}
void
@@ -7735,8 +7737,10 @@ HTMLInputElement::InitializeKeyboardEventListeners()
}
NS_IMETHODIMP_(void)
HTMLInputElement::OnValueChanged(bool aNotify)
HTMLInputElement::OnValueChanged(bool aNotify, bool aWasInteractiveUserChange)
{
mLastValueChangeWasInteractive = aWasInteractiveUserChange;
UpdateAllValidityStates(aNotify);
if (HasDirAuto()) {