mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 596785 - Do not update form validity for submit controls when we remove/add an element because of a type change. r=smaug a=blocking
This commit is contained in:
parent
68417f7637
commit
1d7af1e144
9
content/html/content/crashtests/596785-1.html
Normal file
9
content/html/content/crashtests/596785-1.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="reftest-wait">
|
||||
<body onload="document.getElementById('i').type = 'image';
|
||||
document.documentElement.className = '';">
|
||||
<form>
|
||||
<input id='i' required>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
9
content/html/content/crashtests/596785-2.html
Normal file
9
content/html/content/crashtests/596785-2.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="reftest-wait">
|
||||
<body onload="document.getElementById('i').type = 'text';
|
||||
document.documentElement.className = '';">
|
||||
<form>
|
||||
<input id='i' type='image' required>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
@ -18,3 +18,5 @@ load 570566-1.html
|
||||
load 571428-1.html
|
||||
load 580507-1.xhtml
|
||||
load 590387.html
|
||||
load 596785-1.html
|
||||
load 596785-2.html
|
||||
|
@ -2370,7 +2370,7 @@ nsGenericHTMLFormElement::ClearForm(PRBool aRemoveFromForm,
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::name, nameVal);
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::id, idVal);
|
||||
|
||||
mForm->RemoveElement(this, aNotify);
|
||||
mForm->RemoveElement(this, true, aNotify);
|
||||
|
||||
if (!nameVal.IsEmpty()) {
|
||||
mForm->RemoveElementFromTable(this, nameVal);
|
||||
@ -2569,7 +2569,7 @@ nsGenericHTMLFormElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
mForm->RemoveElementFromTable(this, tmp);
|
||||
}
|
||||
|
||||
mForm->RemoveElement(this, aNotify);
|
||||
mForm->RemoveElement(this, false, aNotify);
|
||||
|
||||
// Removing the element from the form can make it not be the default
|
||||
// control anymore. Go ahead and notify on that change, though we might
|
||||
@ -2627,7 +2627,7 @@ nsGenericHTMLFormElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
mForm->AddElementToTable(this, tmp);
|
||||
}
|
||||
|
||||
mForm->AddElement(this, aNotify);
|
||||
mForm->AddElement(this, false, aNotify);
|
||||
|
||||
// Adding the element to the form can make it be the default control .
|
||||
// Go ahead and notify on that change.
|
||||
@ -2940,7 +2940,7 @@ nsGenericHTMLFormElement::UpdateFormOwner(bool aBindToTree,
|
||||
SetFlags(ADDED_TO_FORM);
|
||||
|
||||
// Notify only if we just found this mForm.
|
||||
mForm->AddElement(this, !hadForm);
|
||||
mForm->AddElement(this, true, !hadForm);
|
||||
|
||||
if (!nameVal.IsEmpty()) {
|
||||
mForm->AddElementToTable(this, nameVal);
|
||||
|
@ -1076,7 +1076,7 @@ AssertDocumentOrder(const nsTArray<nsGenericHTMLFormElement*>& aControls,
|
||||
|
||||
nsresult
|
||||
nsHTMLFormElement::AddElement(nsGenericHTMLFormElement* aChild,
|
||||
PRBool aNotify)
|
||||
bool aUpdateValidity, PRBool aNotify)
|
||||
{
|
||||
NS_ASSERTION(aChild->GetParent(), "Form control should have a parent");
|
||||
|
||||
@ -1208,11 +1208,13 @@ nsHTMLFormElement::AddElement(nsGenericHTMLFormElement* aChild,
|
||||
|
||||
// If the element is subject to constraint validaton and is invalid, we need
|
||||
// to update our internal counter.
|
||||
nsCOMPtr<nsIConstraintValidation> cvElmt =
|
||||
do_QueryInterface(static_cast<nsGenericHTMLElement*>(aChild));
|
||||
if (cvElmt &&
|
||||
cvElmt->IsCandidateForConstraintValidation() && !cvElmt->IsValid()) {
|
||||
UpdateValidity(PR_FALSE);
|
||||
if (aUpdateValidity) {
|
||||
nsCOMPtr<nsIConstraintValidation> cvElmt =
|
||||
do_QueryInterface(static_cast<nsGenericHTMLElement*>(aChild));
|
||||
if (cvElmt &&
|
||||
cvElmt->IsCandidateForConstraintValidation() && !cvElmt->IsValid()) {
|
||||
UpdateValidity(PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -1228,7 +1230,8 @@ nsHTMLFormElement::AddElementToTable(nsGenericHTMLFormElement* aChild,
|
||||
|
||||
nsresult
|
||||
nsHTMLFormElement::RemoveElement(nsGenericHTMLFormElement* aChild,
|
||||
PRBool aNotify)
|
||||
bool aUpdateValidity,
|
||||
PRBool aNotify)
|
||||
{
|
||||
//
|
||||
// Remove it from the radio group if it's a radio button
|
||||
@ -1284,11 +1287,13 @@ nsHTMLFormElement::RemoveElement(nsGenericHTMLFormElement* aChild,
|
||||
|
||||
// If the element was subject to constraint validaton and is invalid, we need
|
||||
// to update our internal counter.
|
||||
nsCOMPtr<nsIConstraintValidation> cvElmt =
|
||||
do_QueryInterface(static_cast<nsGenericHTMLElement*>(aChild));
|
||||
if (cvElmt &&
|
||||
cvElmt->IsCandidateForConstraintValidation() && !cvElmt->IsValid()) {
|
||||
UpdateValidity(PR_TRUE);
|
||||
if (aUpdateValidity) {
|
||||
nsCOMPtr<nsIConstraintValidation> cvElmt =
|
||||
do_QueryInterface(static_cast<nsGenericHTMLElement*>(aChild));
|
||||
if (cvElmt &&
|
||||
cvElmt->IsCandidateForConstraintValidation() && !cvElmt->IsValid()) {
|
||||
UpdateValidity(PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -188,10 +188,12 @@ public:
|
||||
* Remove an element from this form's list of elements
|
||||
*
|
||||
* @param aElement the element to remove
|
||||
* @param aUpdateValidity If true, updates the form validity.
|
||||
* @param aNotify If true, send nsIDocumentObserver notifications as needed.
|
||||
* @return NS_OK if the element was successfully removed.
|
||||
*/
|
||||
nsresult RemoveElement(nsGenericHTMLFormElement* aElement, PRBool aNotify);
|
||||
nsresult RemoveElement(nsGenericHTMLFormElement* aElement,
|
||||
bool aUpdateValidity, PRBool aNotify);
|
||||
|
||||
/**
|
||||
* Remove an element from the lookup table maintained by the form.
|
||||
@ -210,10 +212,12 @@ public:
|
||||
* Add an element to end of this form's list of elements
|
||||
*
|
||||
* @param aElement the element to add
|
||||
* @param aUpdateValidity If true, the form validity will be updated.
|
||||
* @param aNotify If true, send nsIDocumentObserver notifications as needed.
|
||||
* @return NS_OK if the element was successfully added
|
||||
*/
|
||||
nsresult AddElement(nsGenericHTMLFormElement* aElement, PRBool aNotify);
|
||||
nsresult AddElement(nsGenericHTMLFormElement* aElement, bool aUpdateValidity,
|
||||
PRBool aNotify);
|
||||
|
||||
/**
|
||||
* Add an element to the lookup table maintained by the form.
|
||||
|
Loading…
Reference in New Issue
Block a user