*aState = mHistoryState; NS_IF_ADDREF(mHistoryState);
nsIFrame* rootFrame = nsnull; rv = GetRootFrame(&rootFrame); if (NS_FAILED(rv) || nsnull == rootFrame) return rv;  rv = mFrameManager->CaptureFrameState(mPresContext, rootFrame, mHistoryState);
PresShell::GetHistoryState(nsILayoutHistoryState** aState){  nsresult rv = NS_OK;  NS_PRECONDITION(nsnull != aState, "null state pointer");  if (!mHistoryState) {    // Create the document state object    rv = NS_NewLayoutHistoryState(aState); // This addrefs      if (NS_FAILED(rv)) {       *aState = nsnull;      return rv;    }    // Capture frame state for the entire frame hierarchy    nsIFrame* rootFrame = nsnull;    rv = GetRootFrame(&rootFrame);    if (NS_FAILED(rv) || nsnull == rootFrame) return rv;    rv = mFrameManager->CaptureFrameState(mPresContext, rootFrame, *aState);    mHistoryState = *aState;    return NS_OK;  }    *aState = mHistoryState;  NS_IF_ADDREF(mHistoryState);   return rv;}