Bug 1340477 - Support feature detection for autocomplete attribute. r=smaug

This commit is contained in:
johndai1984
2017-05-09 22:57:00 -04:00
parent dfdd816a4d
commit 51e081877c
9 changed files with 278 additions and 112 deletions

View File

@@ -1139,6 +1139,7 @@ HTMLInputElement::HTMLInputElement(already_AddRefed<mozilla::dom::NodeInfo>& aNo
FromParser aFromParser, FromClone aFromClone)
: nsGenericHTMLFormElementWithState(aNodeInfo, kInputDefaultType->value)
, mAutocompleteAttrState(nsContentUtils::eAutocompleteAttrState_Unknown)
, mAutocompleteInfoState(nsContentUtils::eAutocompleteAttrState_Unknown)
, mDisabledChanged(false)
, mValueChanged(false)
, mLastValueChangeWasInteractive(false)
@@ -1515,8 +1516,9 @@ HTMLInputElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
}
}
} else if (aName == nsGkAtoms::autocomplete) {
// Clear the cached @autocomplete attribute state.
// Clear the cached @autocomplete attribute and autocompleteInfo state.
mAutocompleteAttrState = nsContentUtils::eAutocompleteAttrState_Unknown;
mAutocompleteInfoState = nsContentUtils::eAutocompleteAttrState_Unknown;
}
}
@@ -1595,7 +1597,7 @@ HTMLInputElement::GetAutocomplete(nsAString& aValue)
return NS_OK;
}
aValue.Truncate(0);
aValue.Truncate();
const nsAttrValue* attributeVal = GetParsedAttr(nsGkAtoms::autocomplete);
mAutocompleteAttrState =
@@ -1619,9 +1621,10 @@ HTMLInputElement::GetAutocompleteInfo(Nullable<AutocompleteInfo>& aInfo)
}
const nsAttrValue* attributeVal = GetParsedAttr(nsGkAtoms::autocomplete);
mAutocompleteAttrState =
mAutocompleteInfoState =
nsContentUtils::SerializeAutocompleteAttribute(attributeVal, aInfo.SetValue(),
mAutocompleteAttrState);
mAutocompleteInfoState,
true);
}
int32_t