зеркало из https://github.com/mozilla/gecko-dev.git
Get rid of ghost elements in a form's |elements| array. Bug 98487,
r=jkeiser, sr=jst
This commit is contained in:
Родитель
2acc607fe2
Коммит
720d779db1
|
@ -4095,6 +4095,20 @@ nsGenericHTMLContainerFormElement::SetDocument(nsIDocument* aDocument,
|
|||
|
||||
if (aDocument && mParent && !mForm) {
|
||||
rv = FindAndSetForm(this);
|
||||
} else if (!aDocument && mForm) {
|
||||
// We got removed from document. We have a parent form. Check
|
||||
// that the form is still in the document, and if so remove
|
||||
// ourselves from the form. This keeps ghosts from appearing in
|
||||
// the form's |elements| array
|
||||
nsCOMPtr<nsIContent> formContent(do_QueryInterface(mForm, &rv));
|
||||
if (formContent) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
rv = formContent->GetDocument(*getter_AddRefs(doc));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (doc) {
|
||||
SetForm(nsnull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
@ -4335,6 +4349,20 @@ nsGenericHTMLLeafFormElement::SetDocument(nsIDocument* aDocument,
|
|||
|
||||
if (aDocument && mParent && !mForm) {
|
||||
rv = FindAndSetForm(this);
|
||||
} else if (!aDocument && mForm) {
|
||||
// We got removed from document. We have a parent form. Check
|
||||
// that the form is still in the document, and if so remove
|
||||
// ourselves from the form. This keeps ghosts from appearing in
|
||||
// the form's |elements| array
|
||||
nsCOMPtr<nsIContent> formContent(do_QueryInterface(mForm, &rv));
|
||||
if (formContent) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
rv = formContent->GetDocument(*getter_AddRefs(doc));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (doc) {
|
||||
SetForm(nsnull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче