if (NS_SUCCEEDED(rv)) { PRInt32 type = NS_HISTORY_STATE_TYPE_NONE;
if (NS_SUCCEEDED(rv) && ID) { StateType type = eNoType;
FrameManager::CaptureFrameState(nsIFrame* aFrame, nsILayoutHistoryState* aState){  nsresult rv = NS_OK;  NS_PRECONDITION(nsnull != aFrame && nsnull != aState, "null parameters passed in");  // See if the frame is stateful.  nsCOMPtr<nsIStatefulFrame> statefulFrame = do_QueryInterface(aFrame);  if (nsnull != statefulFrame) {    // If so, get the content ID, state type and the state and    // add an association between (ID, type) and (state) to the    // history state storage object, aState.    nsCOMPtr<nsIContent> content;        rv = aFrame->GetContent(getter_AddRefs(content));       if (NS_SUCCEEDED(rv)) {      PRUint32 ID;      rv = content->GetContentID(&ID);      if (NS_SUCCEEDED(rv)) {        PRInt32 type = NS_HISTORY_STATE_TYPE_NONE;                rv = statefulFrame->GetStateType(&type);        if (NS_SUCCEEDED(rv)) {          nsISupports* frameState;          rv = statefulFrame->SaveState(&frameState);          if (NS_SUCCEEDED(rv)) {            rv = aState->AddState(ID, frameState, type);          }        }      }    }  }  // XXX We are only going through the principal child list right now.  // Need to talk to Troy to find out about other kinds of  // child lists and whether they will contain stateful frames.  // (psl) YES, you need to iterate ALL child lists  // Capture frame state for the first child   nsIFrame* child = nsnull;  rv = aFrame->FirstChild(nsnull, &child);  if (NS_SUCCEEDED(rv) && nsnull != child) {    rv = CaptureFrameState(child, aState);  }  // Capture frame state for the next sibling  nsIFrame* sibling = nsnull;  rv = aFrame->GetNextSibling(&sibling);  if (NS_SUCCEEDED(rv) && nsnull != sibling) {    rv = CaptureFrameState(sibling, aState);      }  return rv;}