mView->GetWidget(*getter_AddRefs(mWindow));
view->GetWidget(*getter_AddRefs(mWindow));
DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,                               const nsRect& aBounds){  nsresult rv;  mViewManager = do_CreateInstance(kViewManagerCID, &rv);  if (NS_FAILED(rv))    return rv;  nsCOMPtr<nsIDeviceContext> dx;  mPresContext->GetDeviceContext(getter_AddRefs(dx));   nsRect tbounds = aBounds;  float p2t;  mPresContext->GetPixelsToTwips(&p2t);  tbounds *= p2t;   // Initialize the view manager with an offset. This allows the viewmanager   // to manage a coordinate space offset from (0,0)  rv = mViewManager->Init(dx);  if (NS_FAILED(rv))    return rv;  rv = mViewManager->SetWindowOffset(tbounds.x, tbounds.y);  if (NS_FAILED(rv))    return rv;   // Reset the bounds offset so the root view is set to 0,0. The offset is   // specified in nsIViewManager::Init above.    // Besides, layout will reset the root view to (0,0) during reflow,    // so changing it to 0,0 eliminates placing   // the root view in the wrong place initially.  tbounds.x = 0;  tbounds.y = 0;  // Create a child window of the parent that is our "root view/window"  // Create a view  rv = CallCreateInstance(kViewCID, &mView);  if (NS_FAILED(rv))    return rv;  // if aParentWidget has a view, we'll hook our view manager up to its view tree  void* clientData;  nsIView* containerView = nsnull;  if (NS_SUCCEEDED(aParentWidget->GetClientData(clientData))) {    nsISupports* data = (nsISupports*)clientData;        if (nsnull != data) {      data->QueryInterface(NS_GET_IID(nsIView), (void **)&containerView);    }  }  if (nsnull != containerView) {    // see if the containerView has already been hooked into a foreign view manager hierarchy    // if it has, then we have to hook into the hierarchy too otherwise bad things will happen.    nsCOMPtr<nsIViewManager> containerVM;    containerView->GetViewManager(*getter_AddRefs(containerVM));    nsCOMPtr<nsIViewManager> checkVM;    nsIView* pView = containerView;    do {      pView->GetParent(pView);    } while (pView != nsnull             && NS_SUCCEEDED(pView->GetViewManager(*getter_AddRefs(checkVM))) && checkVM == containerVM);    if (nsnull == pView) {      // OK, so the container is not already hooked up into a foreign view manager hierarchy.      // That means we can choose not to hook ourselves up.      //      // If the parent container is a chrome shell, or a frameset, then we won't hook into its view      // tree. This will improve performance a little bit (especially given scrolling/painting perf bugs)      // but is really just for peace of mind. This check can be removed if we want to support fancy       // chrome effects like transparent controls floating over content, transparent Web browsers, and      // things like that, and the perf bugs are fixed.      nsCOMPtr<nsIDocShellTreeItem> container(do_QueryInterface(mContainer));      nsCOMPtr<nsIDocShellTreeItem> parentContainer;      PRInt32 itemType;      if (nsnull == container          || NS_FAILED(container->GetParent(getter_AddRefs(parentContainer)))          || nsnull == parentContainer          || NS_FAILED(parentContainer->GetItemType(&itemType))          || itemType != nsIDocShellTreeItem::typeContent) {        containerView = nsnull;      } else {        nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(parentContainer));        if (nsnull == webShell || IsWebShellAFrameSet(webShell)) {          containerView = nsnull;        }      }    }  }  rv = mView->Init(mViewManager, tbounds, containerView);  if (NS_FAILED(rv))    return rv;  rv = mView->CreateWidget(kWidgetCID, nsnull,                           aParentWidget->GetNativeData(NS_NATIVE_WIDGET),                           PR_TRUE, PR_FALSE);  if (rv != NS_OK)    return rv;  // Setup hierarchical relationship in view manager  mViewManager->SetRootView(mView);  mView->GetWidget(*getter_AddRefs(mWindow));  // This SetFocus is necessary so the Arrow Key and Page Key events  // go to the scrolled view as soon as the Window is created instead of going to  // the browser window (this enables keyboard scrolling of the document)  // mWindow->SetFocus();  return rv;}