nsISupports* frameState = nsnull; rv = aState->GetState(ID, &frameState, type); if (NS_SUCCEEDED(rv) && nsnull != frameState) { rv = statefulFrame->RestoreState(aPresContext, frameState);
nsCOMPtr<nsIPresState> frameState; rv = aState->GetState(ID, getter_AddRefs(frameState), type); if (NS_SUCCEEDED(rv) && frameState) {  rv = statefulFrame->RestoreState(aPresContext, frameState);   aState->RemoveState(ID, type);
RestoreFrameStateFor(nsIPresContext* aPresContext, nsIFrame* aFrame, nsILayoutHistoryState* aState){  nsresult rv = NS_OK;  NS_PRECONDITION(nsnull != aFrame && nsnull != aState, "null parameters passed in");  // See if the frame is stateful.  // Frames are not ref-counted so no addref/release is required on statefulFrame.  nsIStatefulFrame* statefulFrame = nsnull;  aFrame->QueryInterface(nsIStatefulFrame::GetIID(), (void**) &statefulFrame);  if (nsnull != statefulFrame) {    // If so, get the content ID, state type and the frame state and    // ask the frame object to restore its state.        nsCOMPtr<nsIContent> content;        rv = aFrame->GetContent(getter_AddRefs(content));       if (NS_SUCCEEDED(rv)) {      PRUint32 ID;      rv = content->GetContentID(&ID);      if (NS_SUCCEEDED(rv) && ID) { // Must have ID (don't do anonymous content)        nsIStatefulFrame::StateType type = nsIStatefulFrame::eNoType;        rv = statefulFrame->GetStateType(aPresContext, &type);        if (NS_SUCCEEDED(rv)) {          nsISupports* frameState = nsnull;          rv = aState->GetState(ID, &frameState, type);                    if (NS_SUCCEEDED(rv) && nsnull != frameState) {            rv = statefulFrame->RestoreState(aPresContext, frameState);            }        }      }    }  }    return rv;}