viewManager->Composite();
aPresContext->GetViewManager()->Composite();
nsTypedSelection::ScrollPointIntoClipView(nsIPresContext *aPresContext, nsIView *aView, nsPoint& aPoint, PRBool *aDidScroll){  nsresult result;  if (!aPresContext || !aView || !aDidScroll)    return NS_ERROR_NULL_POINTER;  *aDidScroll = PR_FALSE;  //  // Get aView's scrollable view.  //  nsIScrollableView *scrollableView = 0;  result = GetClosestScrollableView(aView, &scrollableView);  if (NS_FAILED(result))    return result;  if (!scrollableView)    return NS_OK; // Nothing to do!  //  // Get the clip view.  //  const nsIView *cView = 0;  result = scrollableView->GetClipView(&cView);  if (NS_FAILED(result))    return result;  //  // Get the view that is being scrolled.  //  nsIView *scrolledView = 0;  result = scrollableView->GetScrolledView(scrolledView);  if (!cView)    return NS_ERROR_FAILURE;    //  // Now walk up aView's hierarchy, this time keeping track of  // the view offsets until you hit the scrolledView.  //  nsPoint viewOffset(0,0);  result = GetViewAncestorOffset(aView, scrolledView, &viewOffset.x, &viewOffset.y);  if (NS_FAILED(result))    return result;  //  // See if aPoint is outside the clip view's boundaries.  // If it is, scroll the view till it is inside the visible area!  //  nsRect bounds;  result = cView->GetBounds(bounds);  if (NS_FAILED(result))    return result;  result = scrollableView->GetScrollPosition(bounds.x,bounds.y);  if (NS_FAILED(result))    return result;  //  // Calculate the amount we would have to scroll in  // the vertical and horizontal directions to get the point  // within the clip area.  //  nscoord dx = 0, dy = 0;  nsPoint ePoint = aPoint;  ePoint.x += viewOffset.x;  ePoint.y += viewOffset.y;    nscoord x1 = bounds.x;  nscoord x2 = bounds.x + bounds.width;  nscoord y1 = bounds.y;  nscoord y2 = bounds.y + bounds.height;  if (ePoint.x < x1)    dx = ePoint.x - x1;  else if (ePoint.x > x2)    dx = ePoint.x - x2;        if (ePoint.y < y1)    dy = ePoint.y - y1;  else if (ePoint.y > y2)    dy = ePoint.y - y2;  //  // Now clip the scroll amounts so that we don't scroll  // beyond the ends of the document.  //  nscoord scrollX = 0, scrollY = 0;  nscoord docWidth = 0, docHeight = 0;  result = scrollableView->GetScrollPosition(scrollX, scrollY);  if (NS_SUCCEEDED(result))    result = scrollableView->GetContainerSize(&docWidth, &docHeight);  if (NS_SUCCEEDED(result))  {    if (dx < 0 && scrollX == 0)      dx = 0;    else if (dx > 0)    {      x1 = scrollX + dx + bounds.width;      if (x1 > docWidth)        dx -= x1 - docWidth;    }    if (dy < 0 && scrollY == 0)      dy = 0;    else if (dy > 0)    {      y1 = scrollY + dy + bounds.height;      if (y1 > docHeight)        dy -= y1 - docHeight;    }    //    // Now scroll the view if neccessary.    //    if (dx != 0 || dy != 0)    {      // Get the PresShell      nsCOMPtr<nsIPresShell> presShell;      result = aPresContext->GetShell(getter_AddRefs(presShell));      NS_ENSURE_TRUE(presShell,result);      // Get the ViewManager      nsCOMPtr<nsIViewManager> viewManager;      result = presShell->GetViewManager(getter_AddRefs(viewManager));      NS_ENSURE_TRUE(viewManager,result);      // Make sure latest bits are available before we scroll them.            viewManager->Composite();      // Now scroll the view!      result = scrollableView->ScrollTo(scrollX + dx, scrollY + dy, NS_VMREFRESH_NO_SYNC);      if (NS_FAILED(result))        return result;      nsPoint newPos;      result = scrollableView->GetScrollPosition(newPos.x, newPos.y);      if (NS_FAILED(result))        return result;      *aDidScroll = (bounds.x != newPos.x || bounds.y != newPos.y);    }  }  return result;}