mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1556364 - Part 4: Support updating valid/invalid state on form-associated custom elements; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D130128
This commit is contained in:
parent
24c777bdf0
commit
87d6eccbbd
@ -167,6 +167,7 @@ void ElementInternals::SetValidity(
|
||||
SetValidityState(VALIDITY_STATE_STEP_MISMATCH, aFlags.mStepMismatch);
|
||||
SetValidityState(VALIDITY_STATE_BAD_INPUT, aFlags.mBadInput);
|
||||
SetValidityState(VALIDITY_STATE_CUSTOM_ERROR, aFlags.mCustomError);
|
||||
mTarget->UpdateState(true);
|
||||
|
||||
/**
|
||||
* 5. Set element's validation message to the empty string if message is not
|
||||
|
@ -198,6 +198,20 @@ nsresult HTMLElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
||||
aNameSpaceID, aName, aValue, aOldValue, aMaybeScriptedPrincipal, aNotify);
|
||||
}
|
||||
|
||||
EventStates HTMLElement::IntrinsicState() const {
|
||||
EventStates state = nsGenericHTMLFormElement::IntrinsicState();
|
||||
if (ElementInternals* internals = GetElementInternals()) {
|
||||
if (internals->IsCandidateForConstraintValidation()) {
|
||||
if (internals->IsValid()) {
|
||||
state |= NS_EVENT_STATE_VALID | NS_EVENT_STATE_MOZ_UI_VALID;
|
||||
} else {
|
||||
state |= NS_EVENT_STATE_INVALID | NS_EVENT_STATE_MOZ_UI_INVALID;
|
||||
}
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
void HTMLElement::SetFormInternal(HTMLFormElement* aForm, bool aBindToTree) {
|
||||
ElementInternals* internals = GetElementInternals();
|
||||
MOZ_ASSERT(internals);
|
||||
|
@ -55,6 +55,7 @@ class HTMLElement final : public nsGenericHTMLFormElement {
|
||||
const nsAttrValue* aValue, const nsAttrValue* aOldValue,
|
||||
nsIPrincipal* aMaybeScriptedPrincipal,
|
||||
bool aNotify) override;
|
||||
EventStates IntrinsicState() const override;
|
||||
|
||||
// nsGenericHTMLFormElement
|
||||
void SetFormInternal(HTMLFormElement* aForm, bool aBindToTree) override;
|
||||
|
@ -10,7 +10,3 @@
|
||||
|
||||
["anchor" argument of setValidity()]
|
||||
expected: FAIL
|
||||
|
||||
[Custom control affects :valid :invalid for FORM and FIELDSET]
|
||||
expected: FAIL
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user