Partial fix for 18604. r=pav

git-svn-id: svn://10.0.0.236/trunk@57814 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
hyatt%netscape.com 2000-01-14 09:57:31 +00:00
parent 7716a345d5
commit f9a7976334
2 changed files with 70 additions and 14 deletions

View File

@ -496,17 +496,30 @@ nsHTMLInputElement::SetAutocomplete(const nsString& aAutocomplete)
NS_IMETHODIMP
nsHTMLInputElement::GetChecked(PRBool* aValue)
{
nsString value("0");
nsIFormControlFrame* formControlFrame = nsnull;
if (NS_OK == nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame)) {
if (nsnull != formControlFrame) {
nsString value("0");
if (NS_SUCCEEDED(nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame))) {
if (nsnull != formControlFrame) {
formControlFrame->GetProperty(nsHTMLAtoms::checked, value);
if (value == "1")
*aValue = PR_TRUE;
else
*aValue = PR_FALSE;
}
}
else {
// Retrieve the presentation state instead.
nsCOMPtr<nsIPresState> presState;
nsGenericHTMLElement::GetPrimaryPresState(this, nsIStatefulFrame::eCheckboxType, getter_AddRefs(presState));
// Obtain the value property from the presentation state.
if (presState) {
nsAutoString value;
presState->GetStateProperty("checked", value);
}
}
if (value == "1")
*aValue = PR_TRUE;
else
*aValue = PR_FALSE;
return NS_OK;
}
@ -526,6 +539,21 @@ nsHTMLInputElement::SetChecked(PRBool aValue)
}
NS_IF_RELEASE(presContext);
}
else {
// Retrieve the presentation state instead.
nsCOMPtr<nsIPresState> presState;
nsGenericHTMLElement::GetPrimaryPresState(this, nsIStatefulFrame::eCheckboxType, getter_AddRefs(presState));
// Obtain the value property from the presentation state.
if (presState) {
nsAutoString value;
if (PR_TRUE == aValue)
value = "1";
else value = "0";
presState->SetStateProperty("checked", value);
}
}
return NS_OK;
}

View File

@ -496,17 +496,30 @@ nsHTMLInputElement::SetAutocomplete(const nsString& aAutocomplete)
NS_IMETHODIMP
nsHTMLInputElement::GetChecked(PRBool* aValue)
{
nsString value("0");
nsIFormControlFrame* formControlFrame = nsnull;
if (NS_OK == nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame)) {
if (nsnull != formControlFrame) {
nsString value("0");
if (NS_SUCCEEDED(nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame))) {
if (nsnull != formControlFrame) {
formControlFrame->GetProperty(nsHTMLAtoms::checked, value);
if (value == "1")
*aValue = PR_TRUE;
else
*aValue = PR_FALSE;
}
}
else {
// Retrieve the presentation state instead.
nsCOMPtr<nsIPresState> presState;
nsGenericHTMLElement::GetPrimaryPresState(this, nsIStatefulFrame::eCheckboxType, getter_AddRefs(presState));
// Obtain the value property from the presentation state.
if (presState) {
nsAutoString value;
presState->GetStateProperty("checked", value);
}
}
if (value == "1")
*aValue = PR_TRUE;
else
*aValue = PR_FALSE;
return NS_OK;
}
@ -526,6 +539,21 @@ nsHTMLInputElement::SetChecked(PRBool aValue)
}
NS_IF_RELEASE(presContext);
}
else {
// Retrieve the presentation state instead.
nsCOMPtr<nsIPresState> presState;
nsGenericHTMLElement::GetPrimaryPresState(this, nsIStatefulFrame::eCheckboxType, getter_AddRefs(presState));
// Obtain the value property from the presentation state.
if (presState) {
nsAutoString value;
if (PR_TRUE == aValue)
value = "1";
else value = "0";
presState->SetStateProperty("checked", value);
}
}
return NS_OK;
}