Bug 1850238 - Make BROKEN state non-intrinsic. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D187108
This commit is contained in:
Emilio Cobos Álvarez
2023-08-31 07:46:24 +00:00
parent a14c4a020b
commit 01b6773528
22 changed files with 80 additions and 184 deletions

View File

@@ -4528,17 +4528,26 @@ void HTMLInputElement::HandleTypeChange(FormControlType aNewType,
// We're no longer an image input. Cancel our image requests, if we have
// any.
CancelImageRequests(aNotify);
} else if (aNotify) {
RemoveStates(ElementState::BROKEN, aNotify);
} else {
// We just got switched to be an image input; we should see whether we
// have an image to load;
nsAutoString src;
if (GetAttr(nsGkAtoms::src, src)) {
// Mark channel as urgent-start before load image if the image load is
// initiated by a user interaction.
mUseUrgentStartForChannel = UserActivation::IsHandlingUserInput();
bool hasSrc = false;
if (aNotify) {
nsAutoString src;
if ((hasSrc = GetAttr(nsGkAtoms::src, src))) {
// Mark channel as urgent-start before load image if the image load is
// initiated by a user interaction.
mUseUrgentStartForChannel = UserActivation::IsHandlingUserInput();
LoadImage(src, false, aNotify, eImageLoadType_Normal,
mSrcTriggeringPrincipal);
LoadImage(src, false, aNotify, eImageLoadType_Normal,
mSrcTriggeringPrincipal);
}
} else {
hasSrc = HasAttr(nsGkAtoms::src);
}
if (!hasSrc) {
AddStates(ElementState::BROKEN, aNotify);
}
}
// We should update our mapped attribute mapping function.
@@ -6059,17 +6068,6 @@ void HTMLInputElement::DestroyContent() {
TextControlElement::DestroyContent();
}
ElementState HTMLInputElement::IntrinsicState() const {
// If you add states here, and they're type-dependent, you need to add them to
// HandleTypeChange.
ElementState state =
nsGenericHTMLFormControlElementWithState::IntrinsicState();
if (mType == FormControlType::InputImage) {
state |= nsImageLoadingContent::ImageState();
}
return state;
}
void HTMLInputElement::UpdateValidityElementStates(bool aNotify) {
AutoStateChangeNotifier notifier(*this, aNotify);
RemoveStatesSilently(ElementState::VALIDITY_STATES);