зеркало из https://github.com/mozilla/pjs.git
Set checkbox checked state if we didn't restore it (instead of if we didn't
restore anything at all). Bug 259486, r+sr=jst
This commit is contained in:
Родитель
e9b6da637b
Коммит
f24cc01791
|
@ -135,8 +135,10 @@ public:
|
|||
* control will grab its state from there.
|
||||
*
|
||||
* @param aState the pres state to use to restore the control
|
||||
* @return PR_TRUE if the form control was a checkbox and its
|
||||
* checked state was restored, PR_FALSE otherwise.
|
||||
*/
|
||||
NS_IMETHOD RestoreState(nsIPresState* aState) = 0;
|
||||
virtual PRBool RestoreState(nsIPresState* aState) = 0;
|
||||
|
||||
virtual PRBool AllowDrop() = 0;
|
||||
};
|
||||
|
|
|
@ -2354,9 +2354,8 @@ nsGenericHTMLElement::RestoreFormControlState(nsIHTMLContent* aContent,
|
|||
// Get the pres state for this key
|
||||
rv = history->GetState(key, getter_AddRefs(state));
|
||||
if (state) {
|
||||
rv = aControl->RestoreState(state);
|
||||
history->RemoveState(key);
|
||||
return NS_SUCCEEDED(rv);
|
||||
return aControl->RestoreState(state);
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
|
|
|
@ -617,8 +617,8 @@ public:
|
|||
*
|
||||
* @param aContent an nsIHTMLContent* pointing to the form control
|
||||
* @param aControl an nsIFormControl* pointing to the form control
|
||||
* @return whether or not the RestoreState() was called and exited
|
||||
* successfully.
|
||||
* @return PR_FALSE if RestoreState() was not called, the return
|
||||
* value of RestoreState() otherwise.
|
||||
*/
|
||||
static PRBool RestoreFormControlState(nsIHTMLContent* aContent,
|
||||
nsIFormControl* aControl);
|
||||
|
@ -872,9 +872,9 @@ public:
|
|||
{
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD RestoreState(nsIPresState* aState)
|
||||
virtual PRBool RestoreState(nsIPresState* aState)
|
||||
{
|
||||
return NS_OK;
|
||||
return PR_FALSE;
|
||||
}
|
||||
virtual PRBool AllowDrop()
|
||||
{
|
||||
|
|
|
@ -170,7 +170,7 @@ public:
|
|||
NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission,
|
||||
nsIContent* aSubmitElement);
|
||||
NS_IMETHOD SaveState();
|
||||
NS_IMETHOD RestoreState(nsIPresState* aState);
|
||||
virtual PRBool RestoreState(nsIPresState* aState);
|
||||
virtual PRBool AllowDrop();
|
||||
|
||||
// nsIContent
|
||||
|
@ -2433,14 +2433,14 @@ nsHTMLInputElement::DoneCreatingElement()
|
|||
//
|
||||
// Restore state for checkbox, radio, text and file
|
||||
//
|
||||
PRBool restored = PR_FALSE;
|
||||
PRBool restoredCheckedState = PR_FALSE;
|
||||
switch (mType) {
|
||||
case NS_FORM_INPUT_CHECKBOX:
|
||||
case NS_FORM_INPUT_RADIO:
|
||||
case NS_FORM_INPUT_TEXT:
|
||||
case NS_FORM_INPUT_FILE:
|
||||
case NS_FORM_INPUT_HIDDEN:
|
||||
restored = RestoreFormControlState(this, this);
|
||||
restoredCheckedState = RestoreFormControlState(this, this);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2448,7 +2448,8 @@ nsHTMLInputElement::DoneCreatingElement()
|
|||
// If restore does not occur, we initialize .checked using the CHECKED
|
||||
// property.
|
||||
//
|
||||
if (!restored && GET_BOOLBIT(mBitField, BF_SHOULD_INIT_CHECKED)) {
|
||||
if (!restoredCheckedState &&
|
||||
GET_BOOLBIT(mBitField, BF_SHOULD_INIT_CHECKED)) {
|
||||
PRBool resetVal;
|
||||
GetDefaultChecked(&resetVal);
|
||||
DoSetChecked(resetVal, PR_FALSE);
|
||||
|
@ -2465,18 +2466,22 @@ nsHTMLInputElement::DoneCreatingElement()
|
|||
AddedToRadioGroup(PR_FALSE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PRBool
|
||||
nsHTMLInputElement::RestoreState(nsIPresState* aState)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRBool restoredCheckedState = PR_FALSE;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
switch (mType) {
|
||||
case NS_FORM_INPUT_CHECKBOX:
|
||||
case NS_FORM_INPUT_RADIO:
|
||||
{
|
||||
nsAutoString checked;
|
||||
rv = aState->GetStateProperty(NS_LITERAL_STRING("checked"), checked);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "checked restore failed!");
|
||||
if (rv == NS_STATE_PROPERTY_EXISTS) {
|
||||
restoredCheckedState = PR_TRUE;
|
||||
DoSetChecked(checked.EqualsLiteral("t"), PR_FALSE);
|
||||
}
|
||||
break;
|
||||
|
@ -2497,17 +2502,13 @@ nsHTMLInputElement::RestoreState(nsIPresState* aState)
|
|||
}
|
||||
|
||||
nsAutoString disabled;
|
||||
nsresult rv2 = aState->GetStateProperty(NS_LITERAL_STRING("disabled"), disabled);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv2), "disabled restore failed!");
|
||||
if (rv2 == NS_STATE_PROPERTY_EXISTS) {
|
||||
rv = aState->GetStateProperty(NS_LITERAL_STRING("disabled"), disabled);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "disabled restore failed!");
|
||||
if (rv == NS_STATE_PROPERTY_EXISTS) {
|
||||
SetDisabled(disabled.EqualsLiteral("t"));
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv|rv2)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return restoredCheckedState;
|
||||
}
|
||||
|
||||
PRBool
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission,
|
||||
nsIContent* aSubmitElement);
|
||||
NS_IMETHOD SaveState();
|
||||
NS_IMETHOD RestoreState(nsIPresState* aState);
|
||||
virtual PRBool RestoreState(nsIPresState* aState);
|
||||
|
||||
virtual void DoneAddingChildren();
|
||||
virtual PRBool IsDoneAddingChildren();
|
||||
|
@ -181,10 +181,10 @@ nsHTMLObjectElement::SaveState()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PRBool
|
||||
nsHTMLObjectElement::RestoreState(nsIPresState* aState)
|
||||
{
|
||||
return NS_OK;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Code, code)
|
||||
|
|
|
@ -238,7 +238,7 @@ public:
|
|||
NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission,
|
||||
nsIContent* aSubmitElement);
|
||||
NS_IMETHOD SaveState();
|
||||
NS_IMETHOD RestoreState(nsIPresState* aState);
|
||||
virtual PRBool RestoreState(nsIPresState* aState);
|
||||
|
||||
// nsISelectElement
|
||||
NS_DECL_NSISELECTELEMENT
|
||||
|
@ -1834,7 +1834,7 @@ nsHTMLSelectElement::SaveState()
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PRBool
|
||||
nsHTMLSelectElement::RestoreState(nsIPresState* aState)
|
||||
{
|
||||
// Get the presentation state object to retrieve our stuff out of.
|
||||
|
@ -1852,7 +1852,7 @@ nsHTMLSelectElement::RestoreState(nsIPresState* aState)
|
|||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -80,7 +80,7 @@ public:
|
|||
NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission,
|
||||
nsIContent* aSubmitElement);
|
||||
NS_IMETHOD SaveState();
|
||||
NS_IMETHOD RestoreState(nsIPresState* aState);
|
||||
virtual PRBool RestoreState(nsIPresState* aState);
|
||||
|
||||
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
|
@ -151,10 +151,10 @@ nsHTMLObjectElement::SaveState()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PRBool
|
||||
nsHTMLObjectElement::RestoreState(nsIPresState* aState)
|
||||
{
|
||||
return NS_OK;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Code, code)
|
||||
|
|
|
@ -105,7 +105,7 @@ public:
|
|||
NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission,
|
||||
nsIContent* aSubmitElement);
|
||||
NS_IMETHOD SaveState();
|
||||
NS_IMETHOD RestoreState(nsIPresState* aState);
|
||||
virtual PRBool RestoreState(nsIPresState* aState);
|
||||
|
||||
// nsITextControlElemet
|
||||
NS_IMETHOD TakeTextFrameValue(const nsAString& aValue);
|
||||
|
@ -837,15 +837,16 @@ nsHTMLTextAreaElement::SaveState()
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PRBool
|
||||
nsHTMLTextAreaElement::RestoreState(nsIPresState* aState)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsAutoString value;
|
||||
rv = aState->GetStateProperty(NS_LITERAL_STRING("value"), value);
|
||||
#ifdef DEBUG
|
||||
nsresult rv =
|
||||
#endif
|
||||
aState->GetStateProperty(NS_LITERAL_STRING("value"), value);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "value restore failed!");
|
||||
SetValue(value);
|
||||
|
||||
return rv;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче