diff --git a/content/html/content/src/nsHTMLInputElement.cpp b/content/html/content/src/nsHTMLInputElement.cpp
index 7329b85b200b..995988163344 100644
--- a/content/html/content/src/nsHTMLInputElement.cpp
+++ b/content/html/content/src/nsHTMLInputElement.cpp
@@ -340,7 +340,7 @@ nsHTMLInputElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
if (GET_BOOLBIT(mBitField, BF_CHECKED_CHANGED)) {
// We no longer have our original checked state. Set our
// checked state on the clone.
- it->DoSetChecked(GetChecked(), PR_FALSE);
+ it->DoSetChecked(GetChecked(), PR_FALSE, PR_TRUE);
}
break;
case NS_FORM_INPUT_IMAGE:
@@ -428,7 +428,7 @@ nsHTMLInputElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
} else {
PRBool defaultChecked;
GetDefaultChecked(&defaultChecked);
- DoSetChecked(defaultChecked);
+ DoSetChecked(defaultChecked, PR_TRUE, PR_TRUE);
SetCheckedChanged(PR_FALSE);
}
}
@@ -1024,20 +1024,21 @@ nsHTMLInputElement::GetCheckedChanged()
NS_IMETHODIMP
nsHTMLInputElement::SetChecked(PRBool aChecked)
{
- return DoSetChecked(aChecked);
+ return DoSetChecked(aChecked, PR_TRUE, PR_TRUE);
}
nsresult
-nsHTMLInputElement::DoSetChecked(PRBool aChecked, PRBool aNotify)
+nsHTMLInputElement::DoSetChecked(PRBool aChecked, PRBool aNotify,
+ PRBool aSetValueChanged)
{
nsresult rv = NS_OK;
- //
// If the user or JS attempts to set checked, whether it actually changes the
// value or not, we say the value was changed so that defaultValue don't
// affect it no more.
- //
- DoSetCheckedChanged(PR_TRUE, aNotify);
+ if (aSetValueChanged) {
+ DoSetCheckedChanged(PR_TRUE, aNotify);
+ }
//
// Don't do anything if we're not changing whether it's checked (it would
@@ -1493,7 +1494,7 @@ nsHTMLInputElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
}
GetChecked(&originalCheckedValue);
- DoSetChecked(!originalCheckedValue);
+ DoSetChecked(!originalCheckedValue, PR_TRUE, PR_TRUE);
SET_BOOLBIT(mBitField, BF_CHECKED_IS_TOGGLED, PR_TRUE);
}
break;
@@ -1513,7 +1514,7 @@ nsHTMLInputElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
originalCheckedValue = GetChecked();
if (!originalCheckedValue) {
- DoSetChecked(PR_TRUE);
+ DoSetChecked(PR_TRUE, PR_TRUE, PR_TRUE);
SET_BOOLBIT(mBitField, BF_CHECKED_IS_TOGGLED, PR_TRUE);
}
}
@@ -1674,13 +1675,13 @@ nsHTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
// If this one is no longer a radio button we must reset it back to
// false to cancel the action. See how the web of hack grows?
if (mType != NS_FORM_INPUT_RADIO) {
- DoSetChecked(PR_FALSE);
+ DoSetChecked(PR_FALSE, PR_TRUE, PR_TRUE);
}
} else if (oldType == NS_FORM_INPUT_CHECKBOX) {
PRBool originalIndeterminateValue =
!!(aVisitor.mItemFlags & NS_ORIGINAL_INDETERMINATE_VALUE);
SetIndeterminateInternal(originalIndeterminateValue, PR_FALSE);
- DoSetChecked(originalCheckedValue);
+ DoSetChecked(originalCheckedValue, PR_TRUE, PR_TRUE);
}
} else {
FireOnChange();
@@ -2380,7 +2381,7 @@ nsHTMLInputElement::SetDefaultValueAsValue()
{
PRBool resetVal;
GetDefaultChecked(&resetVal);
- return DoSetChecked(resetVal);
+ return DoSetChecked(resetVal, PR_TRUE, PR_FALSE);
}
case NS_FORM_INPUT_SEARCH:
case NS_FORM_INPUT_PASSWORD:
@@ -2664,7 +2665,7 @@ nsHTMLInputElement::DoneCreatingElement()
GET_BOOLBIT(mBitField, BF_SHOULD_INIT_CHECKED)) {
PRBool resetVal;
GetDefaultChecked(&resetVal);
- DoSetChecked(resetVal, PR_FALSE);
+ DoSetChecked(resetVal, PR_FALSE, PR_TRUE);
DoSetCheckedChanged(PR_FALSE, PR_FALSE);
}
@@ -2719,7 +2720,7 @@ nsHTMLInputElement::RestoreState(nsPresState* aState)
{
if (inputState->IsCheckedSet()) {
restoredCheckedState = PR_TRUE;
- DoSetChecked(inputState->GetChecked());
+ DoSetChecked(inputState->GetChecked(), PR_TRUE, PR_TRUE);
}
break;
}
diff --git a/content/html/content/src/nsHTMLInputElement.h b/content/html/content/src/nsHTMLInputElement.h
index 64c2699bfd25..94b1ed90f0dd 100644
--- a/content/html/content/src/nsHTMLInputElement.h
+++ b/content/html/content/src/nsHTMLInputElement.h
@@ -280,7 +280,7 @@ protected:
* Do all the work that |SetChecked| does (radio button handling, etc.), but
* take an |aNotify| parameter.
*/
- nsresult DoSetChecked(PRBool aValue, PRBool aNotify = PR_TRUE);
+ nsresult DoSetChecked(PRBool aValue, PRBool aNotify, PRBool aSetValueChanged);
/**
* Do all the work that |SetCheckedChanged| does (radio button handling,