Bug 589977 - Removing aNotify in nsGenericHTMLFormElement::ClearForm. r=sicking a=blocking-final

This commit is contained in:
Mounir Lamouri 2010-11-11 13:36:42 +01:00
parent f94b370201
commit 2ddbae3c2a
6 changed files with 21 additions and 28 deletions

View File

@ -278,8 +278,7 @@ nsNodeUtils::LastRelease(nsINode* aNode)
aNode->HasFlag(ADDED_TO_FORM)) {
// Tell the form (if any) this node is going away. Don't
// notify, since we're being destroyed in any case.
static_cast<nsGenericHTMLFormElement*>(aNode)->ClearForm(PR_TRUE,
PR_FALSE);
static_cast<nsGenericHTMLFormElement*>(aNode)->ClearForm(PR_TRUE);
}
}
aNode->UnsetFlags(NODE_HAS_PROPERTIES);

View File

@ -137,9 +137,8 @@ public:
*
* @param aRemoveFromForm set false if you do not want this element removed
* from the form. (Used by nsFormControlList::Clear())
* @param aNotify If true, send nsIDocumentObserver notifications as needed.
*/
virtual void ClearForm(PRBool aRemoveFromForm, PRBool aNotify) = 0;
virtual void ClearForm(PRBool aRemoveFromForm) = 0;
/**
* Get the type of this control as an int (see NS_FORM_* above)

View File

@ -2384,8 +2384,7 @@ nsGenericHTMLFormElement::SetForm(nsIDOMHTMLFormElement* aForm)
}
void
nsGenericHTMLFormElement::ClearForm(PRBool aRemoveFromForm,
PRBool aNotify)
nsGenericHTMLFormElement::ClearForm(PRBool aRemoveFromForm)
{
NS_ASSERTION((mForm != nsnull) == HasFlag(ADDED_TO_FORM),
"Form control should have had flag set correctly");
@ -2399,7 +2398,7 @@ nsGenericHTMLFormElement::ClearForm(PRBool aRemoveFromForm,
GetAttr(kNameSpaceID_None, nsGkAtoms::name, nameVal);
GetAttr(kNameSpaceID_None, nsGkAtoms::id, idVal);
mForm->RemoveElement(this, true, aNotify);
mForm->RemoveElement(this, true);
if (!nameVal.IsEmpty()) {
mForm->RemoveElementFromTable(this, nameVal);
@ -2514,12 +2513,12 @@ nsGenericHTMLFormElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
// Might need to unset mForm
if (aNullParent) {
// No more parent means no more form
ClearForm(PR_TRUE, PR_TRUE);
ClearForm(PR_TRUE);
} else {
// Recheck whether we should still have an mForm.
if (HasAttr(kNameSpaceID_None, nsGkAtoms::form) ||
!FindAncestorForm(mForm)) {
ClearForm(PR_TRUE, PR_TRUE);
ClearForm(PR_TRUE);
} else {
UnsetFlags(MAYBE_ORPHAN_FORM_ELEMENT);
}
@ -2571,7 +2570,7 @@ nsGenericHTMLFormElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
mForm->RemoveElementFromTable(this, tmp);
}
mForm->RemoveElement(this, false, aNotify);
mForm->RemoveElement(this, false);
// 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
@ -2893,8 +2892,7 @@ nsGenericHTMLFormElement::UpdateFormOwner(bool aBindToTree,
bool hadForm = mForm;
if (!aBindToTree) {
// TODO: we should get ride of this aNotify parameter, bug 589977.
ClearForm(PR_TRUE, PR_TRUE);
ClearForm(PR_TRUE);
}
if (!mForm) {

View File

@ -834,7 +834,7 @@ public:
// nsIFormControl
virtual mozilla::dom::Element* GetFormElement();
virtual void SetForm(nsIDOMHTMLFormElement* aForm);
virtual void ClearForm(PRBool aRemoveFromForm, PRBool aNotify);
virtual void ClearForm(PRBool aRemoveFromForm);
nsresult GetForm(nsIDOMHTMLFormElement** aForm);

View File

@ -493,7 +493,7 @@ CollectOrphans(nsINode* aRemovalRoot, nsTArray<nsGenericHTMLFormElement*> aArray
if (node->HasFlag(MAYBE_ORPHAN_FORM_ELEMENT)) {
node->UnsetFlags(MAYBE_ORPHAN_FORM_ELEMENT);
if (!nsContentUtils::ContentIsDescendantOf(node, aRemovalRoot)) {
node->ClearForm(PR_TRUE, PR_TRUE);
node->ClearForm(PR_TRUE);
// When submit controls have no more form, they need to be updated.
if (node->IsSubmitControl()) {
@ -1235,8 +1235,7 @@ nsHTMLFormElement::AddElementToTable(nsGenericHTMLFormElement* aChild,
nsresult
nsHTMLFormElement::RemoveElement(nsGenericHTMLFormElement* aChild,
bool aUpdateValidity,
PRBool aNotify)
bool aUpdateValidity)
{
//
// Remove it from the radio group if it's a radio button
@ -1282,7 +1281,7 @@ nsHTMLFormElement::RemoveElement(nsGenericHTMLFormElement* aChild,
// Need to reset mDefaultSubmitElement. Do this asynchronously so
// that we're not doing it while the DOM is in flux.
mDefaultSubmitElement = nsnull;
nsContentUtils::AddScriptRunner(new RemoveElementRunnable(this, aNotify));
nsContentUtils::AddScriptRunner(new RemoveElementRunnable(this));
// Note that we don't need to notify on the old default submit (which is
// being removed) because it's either being removed from the DOM or
@ -1305,7 +1304,7 @@ nsHTMLFormElement::RemoveElement(nsGenericHTMLFormElement* aChild,
}
void
nsHTMLFormElement::HandleDefaultSubmitRemoval(PRBool aNotify)
nsHTMLFormElement::HandleDefaultSubmitRemoval()
{
if (mDefaultSubmitElement) {
// Already got reset somehow; nothing else to do here
@ -1331,7 +1330,7 @@ nsHTMLFormElement::HandleDefaultSubmitRemoval(PRBool aNotify)
"What happened here?");
// Notify about change if needed.
if (aNotify && mDefaultSubmitElement) {
if (mDefaultSubmitElement) {
nsIDocument* document = GetCurrentDoc();
if (document) {
MOZ_AUTO_DOC_UPDATE(document, UPDATE_CONTENT_STATE, PR_TRUE);
@ -2093,12 +2092,12 @@ nsFormControlList::Clear()
// Null out childrens' pointer to me. No refcounting here
PRInt32 i;
for (i = mElements.Length()-1; i >= 0; i--) {
mElements[i]->ClearForm(PR_FALSE, PR_TRUE);
mElements[i]->ClearForm(PR_FALSE);
}
mElements.Clear();
for (i = mNotInElements.Length()-1; i >= 0; i--) {
mNotInElements[i]->ClearForm(PR_FALSE, PR_TRUE);
mNotInElements[i]->ClearForm(PR_FALSE);
}
mNotInElements.Clear();

View File

@ -189,11 +189,10 @@ public:
*
* @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,
bool aUpdateValidity, PRBool aNotify);
bool aUpdateValidity);
/**
* Remove an element from the lookup table maintained by the form.
@ -303,18 +302,17 @@ protected:
class RemoveElementRunnable : public nsRunnable {
public:
RemoveElementRunnable(nsHTMLFormElement* aForm, PRBool aNotify):
mForm(aForm), mNotify(aNotify)
RemoveElementRunnable(nsHTMLFormElement* aForm)
: mForm(aForm)
{}
NS_IMETHOD Run() {
mForm->HandleDefaultSubmitRemoval(mNotify);
mForm->HandleDefaultSubmitRemoval();
return NS_OK;
}
private:
nsRefPtr<nsHTMLFormElement> mForm;
PRBool mNotify;
};
nsresult DoSubmitOrReset(nsEvent* aEvent,
@ -322,7 +320,7 @@ protected:
nsresult DoReset();
// Async callback to handle removal of our default submit
void HandleDefaultSubmitRemoval(PRBool aNotify);
void HandleDefaultSubmitRemoval();
//
// Submit Helpers