nsCOMPtr<nsIViewManager> vm; shell->GetViewManager(getter_AddRefs(vm));
nsIViewManager* vm = shell->GetViewManager();
HTMLContentSink::StartLayout(){  if (mLayoutStarted) {    return;  }  mLayoutStarted = PR_TRUE;  mLastNotificationTime = PR_Now();  // If it's a frameset document then disable scrolling.  // Else, reset scrolling to default settings for this shell.  // This must happen before the initial reflow, when we create the root frame  nsresult rv;  nsCOMPtr<nsIScrollable> scrollableContainer = do_QueryInterface(mDocShell);  if (scrollableContainer) {    if (mFrameset) {      scrollableContainer->        SetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_Y,                                       NS_STYLE_OVERFLOW_HIDDEN);      scrollableContainer->        SetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_X,                                       NS_STYLE_OVERFLOW_HIDDEN);    } else {      scrollableContainer->ResetScrollbarPreferences();    }  }  PRInt32 i, ns = mDocument->GetNumberOfShells();  for (i = 0; i < ns; i++) {    nsCOMPtr<nsIPresShell> shell;    mDocument->GetShellAt(i, getter_AddRefs(shell));    if (shell) {      // Make sure we don't call InitialReflow() for a shell that has      // already called it. This can happen when the layout frame for      // an iframe is constructed *between* the Embed() call for the      // docshell in the iframe, and the content sink's call to OpenBody().      // (Bug 153815)      PRBool didInitialReflow = PR_FALSE;      shell->GetDidInitialReflow(&didInitialReflow);      if (didInitialReflow) {        // XXX: The assumption here is that if something already        // called InitialReflow() on this shell, it also did some of        // the setup below, so we do nothing and just move on to the        // next shell in the list.        continue;      }      // Make shell an observer for next time      shell->BeginObservingDocument();      // Resize-reflow this time      nsCOMPtr<nsIPresContext> cx;      shell->GetPresContext(getter_AddRefs(cx));      nsRect r;      cx->GetVisibleArea(r);      shell->InitialReflow(r.width, r.height);      // Now trigger a refresh      nsCOMPtr<nsIViewManager> vm;      shell->GetViewManager(getter_AddRefs(vm));      if (vm) {        RefreshIfEnabled(vm);      }    }  }  // If the document we are loading has a reference or it is a  // frameset document, disable the scroll bars on the views.  if (mDocumentURI) {    nsCAutoString ref;    // Since all URI's that pass through here aren't URL's we can't    // rely on the nsIURI implementation for providing a way for    // finding the 'ref' part of the URI, we'll haveto revert to    // string routines for finding the data past '#'    rv = mDocumentURI->GetSpec(ref);    nsReadingIterator<char> start, end;    ref.BeginReading(start);    ref.EndReading(end);    if (FindCharInReadable('#', start, end)) {      ++start; // Skip over the '#'      mRef = Substring(start, end);    }  }  if (!mRef.IsEmpty() || mFrameset) {    // XXX support more than one presentation-shell here    // Get initial scroll preference and save it away; disable the    // scroll bars.    ns = mDocument->GetNumberOfShells();    for (i = 0; i < ns; i++) {      nsCOMPtr<nsIPresShell> shell;      mDocument->GetShellAt(i, getter_AddRefs(shell));      if (shell) {        nsCOMPtr<nsIViewManager> vm;        shell->GetViewManager(getter_AddRefs(vm));        if (vm) {          nsIView* rootView = nsnull;          vm->GetRootView(rootView);          if (rootView) {            nsCOMPtr<nsIScrollableView> sview(do_QueryInterface(rootView));            if (sview) {              sview->SetScrollPreference(nsScrollPreference_kNeverScroll);            }          }        }      }    }  }}