Bug 55988: Hidden and button inputs save state when the content attribute named 'value' changes, r=jst@netscape.com, sr=vidur@netscape.com

This commit is contained in:
pollmann%netscape.com 2001-03-14 07:36:01 +00:00
parent bbb16c850a
commit e002ee6306
4 changed files with 20 additions and 8 deletions

View File

@ -41,6 +41,7 @@ nsGfxButtonControlFrame::nsGfxButtonControlFrame()
mRenderer.SetNameSpace(kNameSpaceID_None);
mSuggestedWidth = kSuggestedNotSet;
mSuggestedHeight = kSuggestedNotSet;
mDefaultValueWasChanged = PR_FALSE;
}
PRBool
@ -523,6 +524,7 @@ nsGfxButtonControlFrame::AttributeChanged(nsIPresContext* aPresContext,
} else {
rv = NS_ERROR_UNEXPECTED;
}
mDefaultValueWasChanged = PR_TRUE;
// defer to HTMLButtonControlFrame
} else {
@ -692,12 +694,14 @@ nsGfxButtonControlFrame::SaveState(nsIPresContext* aPresContext, nsIPresState**
// Compare to default value, and only save if needed (Bug 62713)
nsAutoString defaultStateString;
nsCOMPtr<nsIHTMLContent> formControl(do_QueryInterface(mContent));
if (formControl) {
formControl->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, defaultStateString);
if (!mDefaultValueWasChanged) {
nsCOMPtr<nsIHTMLContent> formControl(do_QueryInterface(mContent));
if (formControl) {
formControl->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, defaultStateString);
}
}
if (! stateString.Equals(defaultStateString)) {
if (mDefaultValueWasChanged || !stateString.Equals(defaultStateString)) {
// Construct a pres state and store value in it.
res = NS_NewPresState(aState);

View File

@ -107,6 +107,8 @@ private:
nscoord mSuggestedWidth;
nscoord mSuggestedHeight;
nsCOMPtr<nsITextContent> mTextContent;
PRBool mDefaultValueWasChanged;
};

View File

@ -41,6 +41,7 @@ nsGfxButtonControlFrame::nsGfxButtonControlFrame()
mRenderer.SetNameSpace(kNameSpaceID_None);
mSuggestedWidth = kSuggestedNotSet;
mSuggestedHeight = kSuggestedNotSet;
mDefaultValueWasChanged = PR_FALSE;
}
PRBool
@ -523,6 +524,7 @@ nsGfxButtonControlFrame::AttributeChanged(nsIPresContext* aPresContext,
} else {
rv = NS_ERROR_UNEXPECTED;
}
mDefaultValueWasChanged = PR_TRUE;
// defer to HTMLButtonControlFrame
} else {
@ -692,12 +694,14 @@ nsGfxButtonControlFrame::SaveState(nsIPresContext* aPresContext, nsIPresState**
// Compare to default value, and only save if needed (Bug 62713)
nsAutoString defaultStateString;
nsCOMPtr<nsIHTMLContent> formControl(do_QueryInterface(mContent));
if (formControl) {
formControl->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, defaultStateString);
if (!mDefaultValueWasChanged) {
nsCOMPtr<nsIHTMLContent> formControl(do_QueryInterface(mContent));
if (formControl) {
formControl->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, defaultStateString);
}
}
if (! stateString.Equals(defaultStateString)) {
if (mDefaultValueWasChanged || !stateString.Equals(defaultStateString)) {
// Construct a pres state and store value in it.
res = NS_NewPresState(aState);

View File

@ -107,6 +107,8 @@ private:
nscoord mSuggestedWidth;
nscoord mSuggestedHeight;
nsCOMPtr<nsITextContent> mTextContent;
PRBool mDefaultValueWasChanged;
};