Move save/restore form control state to content (bug 108309). r=rods@netscape.com, sr=jst@netscape.com, a=asa@mozilla.org

This commit is contained in:
jkeiser@netscape.com
2002-03-31 10:14:01 +00:00
parent 11eab3b865
commit e4395c199e
56 changed files with 558 additions and 763 deletions
-47
View File
@@ -466,8 +466,6 @@ nsGfxButtonControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
if (aIID.Equals(NS_GET_IID(nsIAnonymousContentCreator))) {
*aInstancePtr = NS_STATIC_CAST(nsIAnonymousContentCreator*, this);
} else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = NS_STATIC_CAST(nsIStatefulFrame*, this);
}
else {
return nsHTMLButtonControlFrame::QueryInterface(aIID, aInstancePtr);
@@ -651,48 +649,3 @@ nsGfxButtonControlFrame::HandleEvent(nsIPresContext* aPresContext,
return NS_OK;
}
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsGfxButtonControlFrame::SaveState(nsIPresContext* aPresContext, nsIPresState** aState)
{
NS_ENSURE_ARG_POINTER(aState);
// Get the value string
nsAutoString stateString;
nsresult res = GetProperty(nsHTMLAtoms::value, stateString);
NS_ENSURE_SUCCESS(res, res);
// Compare to default value, and only save if needed (Bug 62713)
NS_ENSURE_TRUE(mContent->IsContentOfType(nsIContent::eHTML_FORM_CONTROL),
NS_ERROR_UNEXPECTED);
nsAutoString defaultStateString;
if (!mDefaultValueWasChanged) {
mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, defaultStateString);
}
if (mDefaultValueWasChanged || !stateString.Equals(defaultStateString)) {
// Construct a pres state and store value in it.
res = NS_NewPresState(aState);
NS_ENSURE_SUCCESS(res, res);
res = (*aState)->SetStateProperty(NS_LITERAL_STRING("value"), stateString);
}
return res;
}
NS_IMETHODIMP
nsGfxButtonControlFrame::RestoreState(nsIPresContext* aPresContext, nsIPresState* aState)
{
NS_ENSURE_ARG_POINTER(aState);
// Set the value to the stored state.
nsAutoString stateString;
nsresult res = aState->GetStateProperty(NS_LITERAL_STRING("value"), stateString);
NS_ENSURE_SUCCESS(res, res);
return SetProperty(aPresContext, nsHTMLAtoms::value, stateString);
}