Fix bug 572896 and bug 572897 bustage on embedding/test/test_bug293834.html; r=Smaug

This commit is contained in:
Mounir Lamouri 2010-07-22 20:27:33 +02:00
Родитель 67dac4b3bc
Коммит 71f63ae56e
2 изменённых файлов: 16 добавлений и 15 удалений

Просмотреть файл

@ -340,7 +340,7 @@ nsHTMLInputElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
if (GET_BOOLBIT(mBitField, BF_CHECKED_CHANGED)) { if (GET_BOOLBIT(mBitField, BF_CHECKED_CHANGED)) {
// We no longer have our original checked state. Set our // We no longer have our original checked state. Set our
// checked state on the clone. // checked state on the clone.
it->DoSetChecked(GetChecked(), PR_FALSE); it->DoSetChecked(GetChecked(), PR_FALSE, PR_TRUE);
} }
break; break;
case NS_FORM_INPUT_IMAGE: case NS_FORM_INPUT_IMAGE:
@ -428,7 +428,7 @@ nsHTMLInputElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
} else { } else {
PRBool defaultChecked; PRBool defaultChecked;
GetDefaultChecked(&defaultChecked); GetDefaultChecked(&defaultChecked);
DoSetChecked(defaultChecked); DoSetChecked(defaultChecked, PR_TRUE, PR_TRUE);
SetCheckedChanged(PR_FALSE); SetCheckedChanged(PR_FALSE);
} }
} }
@ -1024,20 +1024,21 @@ nsHTMLInputElement::GetCheckedChanged()
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLInputElement::SetChecked(PRBool aChecked) nsHTMLInputElement::SetChecked(PRBool aChecked)
{ {
return DoSetChecked(aChecked); return DoSetChecked(aChecked, PR_TRUE, PR_TRUE);
} }
nsresult nsresult
nsHTMLInputElement::DoSetChecked(PRBool aChecked, PRBool aNotify) nsHTMLInputElement::DoSetChecked(PRBool aChecked, PRBool aNotify,
PRBool aSetValueChanged)
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
//
// If the user or JS attempts to set checked, whether it actually changes the // 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 // value or not, we say the value was changed so that defaultValue don't
// affect it no more. // affect it no more.
// if (aSetValueChanged) {
DoSetCheckedChanged(PR_TRUE, aNotify); DoSetCheckedChanged(PR_TRUE, aNotify);
}
// //
// Don't do anything if we're not changing whether it's checked (it would // 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); GetChecked(&originalCheckedValue);
DoSetChecked(!originalCheckedValue); DoSetChecked(!originalCheckedValue, PR_TRUE, PR_TRUE);
SET_BOOLBIT(mBitField, BF_CHECKED_IS_TOGGLED, PR_TRUE); SET_BOOLBIT(mBitField, BF_CHECKED_IS_TOGGLED, PR_TRUE);
} }
break; break;
@ -1513,7 +1514,7 @@ nsHTMLInputElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
originalCheckedValue = GetChecked(); originalCheckedValue = GetChecked();
if (!originalCheckedValue) { if (!originalCheckedValue) {
DoSetChecked(PR_TRUE); DoSetChecked(PR_TRUE, PR_TRUE, PR_TRUE);
SET_BOOLBIT(mBitField, BF_CHECKED_IS_TOGGLED, 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 // 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? // false to cancel the action. See how the web of hack grows?
if (mType != NS_FORM_INPUT_RADIO) { if (mType != NS_FORM_INPUT_RADIO) {
DoSetChecked(PR_FALSE); DoSetChecked(PR_FALSE, PR_TRUE, PR_TRUE);
} }
} else if (oldType == NS_FORM_INPUT_CHECKBOX) { } else if (oldType == NS_FORM_INPUT_CHECKBOX) {
PRBool originalIndeterminateValue = PRBool originalIndeterminateValue =
!!(aVisitor.mItemFlags & NS_ORIGINAL_INDETERMINATE_VALUE); !!(aVisitor.mItemFlags & NS_ORIGINAL_INDETERMINATE_VALUE);
SetIndeterminateInternal(originalIndeterminateValue, PR_FALSE); SetIndeterminateInternal(originalIndeterminateValue, PR_FALSE);
DoSetChecked(originalCheckedValue); DoSetChecked(originalCheckedValue, PR_TRUE, PR_TRUE);
} }
} else { } else {
FireOnChange(); FireOnChange();
@ -2380,7 +2381,7 @@ nsHTMLInputElement::SetDefaultValueAsValue()
{ {
PRBool resetVal; PRBool resetVal;
GetDefaultChecked(&resetVal); GetDefaultChecked(&resetVal);
return DoSetChecked(resetVal); return DoSetChecked(resetVal, PR_TRUE, PR_FALSE);
} }
case NS_FORM_INPUT_SEARCH: case NS_FORM_INPUT_SEARCH:
case NS_FORM_INPUT_PASSWORD: case NS_FORM_INPUT_PASSWORD:
@ -2664,7 +2665,7 @@ nsHTMLInputElement::DoneCreatingElement()
GET_BOOLBIT(mBitField, BF_SHOULD_INIT_CHECKED)) { GET_BOOLBIT(mBitField, BF_SHOULD_INIT_CHECKED)) {
PRBool resetVal; PRBool resetVal;
GetDefaultChecked(&resetVal); GetDefaultChecked(&resetVal);
DoSetChecked(resetVal, PR_FALSE); DoSetChecked(resetVal, PR_FALSE, PR_TRUE);
DoSetCheckedChanged(PR_FALSE, PR_FALSE); DoSetCheckedChanged(PR_FALSE, PR_FALSE);
} }
@ -2719,7 +2720,7 @@ nsHTMLInputElement::RestoreState(nsPresState* aState)
{ {
if (inputState->IsCheckedSet()) { if (inputState->IsCheckedSet()) {
restoredCheckedState = PR_TRUE; restoredCheckedState = PR_TRUE;
DoSetChecked(inputState->GetChecked()); DoSetChecked(inputState->GetChecked(), PR_TRUE, PR_TRUE);
} }
break; break;
} }

Просмотреть файл

@ -280,7 +280,7 @@ protected:
* Do all the work that |SetChecked| does (radio button handling, etc.), but * Do all the work that |SetChecked| does (radio button handling, etc.), but
* take an |aNotify| parameter. * 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, * Do all the work that |SetCheckedChanged| does (radio button handling,