Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
nsViewManager Class Reference

#include <nsViewManager.h>

Inheritance diagram for nsViewManager:
Inheritance graph
[legend]
Collaboration diagram for nsViewManager:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsViewManager ()
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS NS_IMETHOD 
Init (nsIDeviceContext *aContext)
 Initialize the ViewManager Note: this instance does not hold a reference to the viewobserver because it holds a reference to this instance.
 NS_IMETHOD_ (nsIView *) CreateView(const nsRect &aBounds
 Create an ordinary view.
 NS_IMETHOD_ (nsIScrollableView *) CreateScrollableView(const nsRect &aBounds
 Create an scrollable view.
NS_IMETHOD GetRootView (nsIView *&aView)
 Get the root of the view tree.
NS_IMETHOD SetRootView (nsIView *aView)
 Set the root of the view tree.
NS_IMETHOD GetWindowDimensions (nscoord *width, nscoord *height)
 Get the dimensions of the root window.
NS_IMETHOD SetWindowDimensions (nscoord width, nscoord height)
 Set the dimensions of the root window.
NS_IMETHOD Composite (void)
 Called to force a redrawing of any dirty areas.
NS_IMETHOD UpdateView (nsIView *aView, PRUint32 aUpdateFlags)
 Called to inform the view manager that the entire area of a view is dirty and needs to be redrawn.
NS_IMETHOD UpdateView (nsIView *aView, const nsRect &aRect, PRUint32 aUpdateFlags)
 Called to inform the view manager that some portion of a view is dirty and needs to be redrawn.
NS_IMETHOD UpdateAllViews (PRUint32 aUpdateFlags)
 Called to inform the view manager that it should redraw all views.
NS_IMETHOD DispatchEvent (nsGUIEvent *aEvent, nsEventStatus *aStatus)
 Called to dispatch an event to the appropriate view.
NS_IMETHOD GrabMouseEvents (nsIView *aView, PRBool &aResult)
 Used to grab/capture all mouse events for a specific view, irrespective of the cursor position at which the event occurred.
NS_IMETHOD GrabKeyEvents (nsIView *aView, PRBool &aresult)
 Used to grab/capture all keyboard events for a specific view, irrespective of the cursor position at which the event occurred.
NS_IMETHOD GetMouseEventGrabber (nsIView *&aView)
 Get the current view, if any, that's capturing mouse events.
NS_IMETHOD GetKeyEventGrabber (nsIView *&aView)
 Get the current view, if any, that's capturing keyboard events.
NS_IMETHOD InsertChild (nsIView *parent, nsIView *child, nsIView *sibling, PRBool above)
 Given a parent view, insert another view as its child.
NS_IMETHOD InsertChild (nsIView *parent, nsIView *child, PRInt32 zindex)
NS_IMETHOD InsertZPlaceholder (nsIView *parent, nsIView *child, nsIView *sibling, PRBool above)
 Given a parent view, insert a placeholder for a view that logically belongs to this parent but has to be moved somewhere else for geometry reasons ("fixed" positioning).
NS_IMETHOD RemoveChild (nsIView *parent)
 Remove a specific child view from its parent.
NS_IMETHOD MoveViewBy (nsIView *aView, nscoord aX, nscoord aY)
NS_IMETHOD MoveViewTo (nsIView *aView, nscoord aX, nscoord aY)
 Move a view to the specified position, provided in parent coordinates.
NS_IMETHOD ResizeView (nsIView *aView, const nsRect &aRect, PRBool aRepaintExposedAreaOnly=PR_FALSE)
 Resize a view.
NS_IMETHOD SetViewChildClipRegion (nsIView *aView, const nsRegion *aRegion)
 Set the region to which a view's descendants are clipped.
NS_IMETHOD SetViewBitBltEnabled (nsIView *aView, PRBool aEnable)
 Set whether the view can be bitblitted during scrolling.
NS_IMETHOD SetViewCheckChildEvents (nsIView *aView, PRBool aEnable)
 Set whether the view's children should be searched during event processing.
NS_IMETHOD SetViewFloating (nsIView *aView, PRBool aFloating)
 Set whether the view "floats" above all other views, which tells the compositor not to consider higher views in the view hierarchy that would geometrically intersect with this view.
NS_IMETHOD SetViewVisibility (nsIView *aView, nsViewVisibility aVisible)
 Set the visibility of a view.
NS_IMETHOD SetViewZIndex (nsIView *aView, PRBool aAuto, PRInt32 aZIndex, PRBool aTopMost=PR_FALSE)
 Set the z-index of a view.
NS_IMETHOD SetViewContentTransparency (nsIView *aView, PRBool aTransparent)
 Used set the transparency status of the content in a view.
NS_IMETHOD SetViewOpacity (nsIView *aView, float aOpacity)
 Note: This didn't exist in 4.0.
NS_IMETHOD SetViewObserver (nsIViewObserver *aObserver)
 Set the view observer associated with this manager.
NS_IMETHOD GetViewObserver (nsIViewObserver *&aObserver)
 Get the view observer associated with this manager.
NS_IMETHOD GetDeviceContext (nsIDeviceContext *&aContext)
 Get the device context associated with this manager.
NS_IMETHOD DisableRefresh (void)
 prevent the view manager from refreshing.
NS_IMETHOD EnableRefresh (PRUint32 aUpdateFlags)
 allow the view manager to refresh.
NS_IMETHOD BeginUpdateViewBatch (void)
 prevents the view manager from refreshing.
NS_IMETHOD EndUpdateViewBatch (PRUint32 aUpdateFlags)
 allow the view manager to refresh any damaged areas accumulated after the BeginUpdateViewBatch() call.
NS_IMETHOD SetRootScrollableView (nsIScrollableView *aScrollable)
 set the view that is is considered to be the root scrollable view for the document.
NS_IMETHOD GetRootScrollableView (nsIScrollableView **aScrollable)
 get the view that is is considered to be the root scrollable view for the document.
NS_IMETHOD Display (nsIView *aView, nscoord aX, nscoord aY, const nsRect &aClipRect)
 Display the specified view.
NS_IMETHOD RenderOffscreen (nsIView *aView, nsRect aRect, PRBool aUntrusted, PRBool aIgnoreViewportScrolling, nscolor aBackgroundColor, nsIRenderingContext **aRenderedContext)
 Dump the specified view into a new offscreen rendering context.
NS_IMETHOD AddCompositeListener (nsICompositeListener *aListener)
 Add a listener to the view manager's composite listener list.
NS_IMETHOD RemoveCompositeListener (nsICompositeListener *aListener)
 Remove a listener from the view manager's composite listener list.
NS_IMETHOD GetWidget (nsIWidget **aWidget)
 Retrieve the widget at the root of the view manager.
nsIWidgetGetWidget ()
NS_IMETHOD ForceUpdate ()
 Force update of view manager widget Callers should use UpdateView(view, NS_VMREFRESH_IMMEDIATE) in most cases instead.
NS_IMETHOD AllowDoubleBuffering (PRBool aDoubleBuffer)
 Control double buffering of the display.
NS_IMETHOD IsPainting (PRBool &aIsPainting)
 Indicate whether the viewmanager is currently painting.
NS_IMETHOD SetDefaultBackgroundColor (nscolor aColor)
 Set the default background color that the view manager should use to paint otherwise unowned areas.
NS_IMETHOD GetDefaultBackgroundColor (nscolor *aColor)
 Retrieve the default background color.
NS_IMETHOD GetLastUserEventTime (PRUint32 &aTime)
 Retrieve the time of the last user event.
void ProcessInvalidateEvent ()
NS_IMETHOD GetRectVisibility (nsIView *aView, const nsRect &aRect, PRUint16 aMinTwips, nsRectVisibility *aRectVisibility)
 Determine if a rectangle specified in the view's coordinate system is completely, or partially visible.
NS_IMETHOD SynthesizeMouseMove (PRBool aFromScroll)
 Dispatch a mouse move event based on the most recent mouse position.
void ProcessSynthMouseMoveEvent (PRBool aFromScroll)
void InvalidateHierarchy ()
nsViewGetRootView () const
nsViewGetMouseEventGrabber () const
nsViewGetKeyEventGrabber () const
nsViewManagerRootViewManager () const
PRBool IsRootVM () const
nsEventStatus HandleEvent (nsView *aView, nsGUIEvent *aEvent, PRBool aCaptured)
void WillBitBlit (nsView *aView, nsPoint aScrollAmount)
 Called to inform the view manager that a view is about to bit-blit.
void UpdateViewAfterScroll (nsView *aView)
 Called to inform the view manager that a view has scrolled.
PRBool CanScrollWithBitBlt (nsView *aView)
nsresult CreateRegion (nsIRegion **result)
PRBool IsRefreshEnabled ()
nsIViewObserverGetViewObserver ()
void PostPendingUpdate ()

Static Public Member Functions

static PRInt32 GetViewManagerCount ()
static const nsVoidArrayGetViewManagerArray ()
static nsPoint ComputeViewOffset (const nsView *aView)

Public Attributes

const nsIViewaParent
const nsIView nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow)

Static Public Attributes

static PRUint32 gLastUserEventTime = 0

Protected Member Functions

virtual ~nsViewManager ()

Private Member Functions

void FlushPendingInvalidates ()
void ProcessPendingUpdates (nsView *aView, PRBool aDoInvalidate)
void ReparentChildWidgets (nsIView *aView, nsIWidget *aNewWidget)
void ReparentWidgets (nsIView *aView, nsIView *aParent)
already_AddRefed
< nsIRenderingContext
CreateRenderingContext (nsView &aView)
void UpdateWidgetArea (nsView *aWidgetView, const nsRegion &aDamagedRegion, nsView *aIgnoreWidgetView)
void UpdateViews (nsView *aView, PRUint32 aUpdateFlags)
void Refresh (nsView *aView, nsIRenderingContext *aContext, nsIRegion *region, PRUint32 aUpdateFlags)
 aRegion is given in device coordinates!!
void DefaultRefresh (nsView *aView, const nsRect *aRect)
 Refresh aView (which must be non-null) with our default background color.
PRBool BuildRenderingDisplayList (nsIView *aRootView, const nsRegion &aRegion, nsVoidArray *aDisplayList, PLArenaPool &aPool, PRBool aIgnoreCoveringWidgets, PRBool aIgnoreOutsideClipping, nsIView *aSuppressScrolling)
void RenderViews (nsView *aRootView, nsIRenderingContext &aRC, const nsRegion &aRegion, nsIDrawingSurface *aRCSurface, const nsVoidArray &aDisplayList)
void RenderDisplayListElement (DisplayListElement2 *element, nsIRenderingContext *aRC)
void PaintView (nsView *aView, nsIRenderingContext &aRC, nscoord x, nscoord y, const nsRect &aDamageRect)
void InvalidateRectDifference (nsView *aView, const nsRect &aRect, const nsRect &aCutOut, PRUint32 aUpdateFlags)
void InvalidateHorizontalBandDifference (nsView *aView, const nsRect &aRect, const nsRect &aCutOut, PRUint32 aUpdateFlags, nscoord aY1, nscoord aY2, PRBool aInCutOut)
BlendingBuffersCreateBlendingBuffers (nsIRenderingContext *aRC, PRBool aBorrowContext, nsIDrawingSurface *aBorrowSurface, PRBool aNeedAlpha, const nsRect &aArea)
void ReparentViews (DisplayZTreeNode *aNode, nsHashtable &)
void BuildDisplayList (nsView *aView, const nsRect &aRect, PRBool aEventProcessing, PRBool aCaptured, nsIView *aSuppressScrolling, nsVoidArray *aDisplayList, PLArenaPool &aPool)
void BuildEventTargetList (nsVoidArray &aTargets, nsView *aView, nsGUIEvent *aEvent, PRBool aCaptured, PLArenaPool &aPool)
PRBool CreateDisplayList (nsView *aView, DisplayZTreeNode *&aResult, nscoord aOriginX, nscoord aOriginY, nsView *aRealView, const nsRect *aDamageRect, nsView *aTopView, nscoord aX, nscoord aY, PRBool aPaintFloats, PRBool aEventProcessing, nsIView *aSuppressClip, nsHashtable &, PLArenaPool &aPool)
 XXX this needs major simplification and cleanup.
PRBool AddToDisplayList (nsView *aView, DisplayZTreeNode *&aParent, nsRect &aClipRect, nsRect &aDirtyRect, PRUint32 aFlags, nscoord aAbsX, nscoord aAbsY, PRBool aAssumeIntersection, PLArenaPool &aPool, nsIView *aStopClippingAtView)
void OptimizeDisplayList (const nsVoidArray *aDisplayList, const nsRegion &aDirtyRegion, nsRect &aFinalTransparentRect, nsRegion &aOpaqueRgn, PRBool aTreatUniformAsOpaque)
 Walk the display list, looking for opaque views, and remove any views that are behind them and totally occluded.
void AddCoveringWidgetsToOpaqueRegion (nsRegion &aRgn, nsIDeviceContext *aContext, nsView *aRootView)
PRBool DoesViewHaveNativeWidget (nsView *aView)
void PauseTimer (void)
void RestartTimer (void)
void OptimizeDisplayListClipping (const nsVoidArray *aDisplayList, PRBool aHaveClip, nsRect &aClipRect, PRInt32 &aIndex, PRBool &aAnyRendered)
nsRect OptimizeTranslucentRegions (const nsVoidArray &aDisplayList, PRInt32 *aIndex, nsRegion *aOpaqueRegion)
void ShowDisplayList (const nsVoidArray *aDisplayList)
PRBool IsViewInserted (nsView *aView)
void UpdateWidgetsForView (nsView *aView)
 Function to recursively call Update() on all widgets belonging to a view or its kids.
void ViewToWidget (nsView *aView, nsView *aWidgetView, nsRect &aRect) const
 Transforms a rectangle from specified view's coordinate system to the first parent that has an attached widget.
nsresult GetAbsoluteRect (nsView *aView, const nsRect &aRect, nsRect &aAbsRect)
 Transforms a rectangle from specified view's coordinate system to an absolute coordinate rectangle which can be compared against the rectangle returned by GetVisibleRect to determine visibility.
nsresult GetVisibleRect (nsRect &aVisibleRect)
 Determine the visible rect.
void GetMaxWidgetBounds (nsRect &aMaxWidgetBounds) const
 Determine the maximum and width and height of all of the view manager's widgets.
void DoSetWindowDimensions (nscoord aWidth, nscoord aHeight)
void IncrementUpdateCount ()
void DecrementUpdateCount ()
PRInt32 UpdateCount () const
void ClearUpdateCount ()
PRBool IsPainting () const
void SetPainting (PRBool aPainting)
void PostInvalidateEvent ()

Static Private Member Functions

static nsViewGetWidgetView (nsView *aView)
 Returns the nearest parent view with an attached widget.

Private Attributes

nsIDeviceContextmContext
float mTwipsToPixels
float mPixelsToTwips
nsIViewObservermObserver
nsViewmKeyGrabber
nsIScrollableViewmRootScrollable
nscolor mDefaultBackgroundColor
nsPoint mMouseLocation
nsSize mDelayedResize
nsCOMPtr< nsIBlendermBlender
nsISupportsArraymCompositeListeners
nsCOMPtr< nsIFactorymRegionFactory
nsViewmRootView
nsViewManagermRootViewManager
nsCOMPtr< nsIEventQueueServicemEventQueueService
nsCOMPtr< nsIEventQueuemSynthMouseMoveEventQueue
PRPackedBool mAllowDoubleBuffering
nsViewmMouseGrabber
PRInt32 mUpdateCnt
PRInt32 mUpdateBatchCnt
PRUint32 mUpdateBatchFlags
PRInt32 mScrollCnt
nsCOMPtr< nsIEventQueuemInvalidateEventQueue
PRPackedBool mRefreshEnabled
PRPackedBool mPainting
PRPackedBool mRecursiveRefreshPending
PRPackedBool mHasPendingUpdates
PRPackedBool mInScroll

Static Private Attributes

static PRInt32 mVMCount = 0
static nsIRenderingContextgCleanupContext = nsnull
static nsVoidArraygViewManagers = nsnull

Detailed Description

Definition at line 148 of file nsViewManager.h.


Constructor & Destructor Documentation

Definition at line 453 of file nsViewManager.cpp.

  : mMouseLocation(NSCOORD_NONE, NSCOORD_NONE)
  , mDelayedResize(NSCOORD_NONE, NSCOORD_NONE)
  , mRootViewManager(this)
{
  if (gViewManagers == nsnull) {
    NS_ASSERTION(mVMCount == 0, "View Manager count is incorrect");
    // Create an array to hold a list of view managers
    gViewManagers = new nsVoidArray;
  }
 
  if (gCleanupContext == nsnull) {
    /* XXX: This should use a device to create a matching |nsIRenderingContext| object */
    CallCreateInstance(kRenderingContextCID, &gCleanupContext);
    NS_ASSERTION(gCleanupContext,
                 "Wasn't able to create a graphics context for cleanup");
  }

  gViewManagers->AppendElement(this);

  mVMCount++;
  // NOTE:  we use a zeroing operator new, so all data members are
  // assumed to be cleared here.
  mDefaultBackgroundColor = NS_RGBA(0, 0, 0, 0);
  mAllowDoubleBuffering = PR_TRUE; 
  mHasPendingUpdates = PR_FALSE;
  mRecursiveRefreshPending = PR_FALSE;
  mUpdateBatchFlags = 0;
}

Here is the call graph for this function:

nsViewManager::~nsViewManager ( ) [protected, virtual]

Definition at line 483 of file nsViewManager.cpp.

{
  if (mRootView) {
    // Destroy any remaining views
    mRootView->Destroy();
    mRootView = nsnull;
  }

  // Make sure to RevokeEvents for all viewmanagers, since some events
  // are posted by a non-root viewmanager.
  nsCOMPtr<nsIEventQueue> eventQueue;
  mEventQueueService->GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
                                           getter_AddRefs(eventQueue));
  NS_ASSERTION(eventQueue, "Event queue is null"); 
  eventQueue->RevokeEvents(this);
  
  if (!IsRootVM()) {
    // We have a strong ref to mRootViewManager
    NS_RELEASE(mRootViewManager);
  }
  
  mInvalidateEventQueue = nsnull;  
  mSynthMouseMoveEventQueue = nsnull;  

  mRootScrollable = nsnull;

  NS_ASSERTION((mVMCount > 0), "underflow of viewmanagers");
  --mVMCount;

#ifdef DEBUG
  PRBool removed =
#endif
    gViewManagers->RemoveElement(this);
  NS_ASSERTION(removed, "Viewmanager instance not was not in the global list of viewmanagers");

  if (0 == mVMCount) {
    // There aren't any more view managers so
    // release the global array of view managers
   
    NS_ASSERTION(gViewManagers != nsnull, "About to delete null gViewManagers");
    delete gViewManagers;
    gViewManagers = nsnull;

    // Cleanup all of the offscreen drawing surfaces if the last view manager
    // has been destroyed and there is something to cleanup

    // Note: A global rendering context is needed because it is not possible 
    // to create a nsIRenderingContext during the shutdown of XPCOM. The last
    // viewmanager is typically destroyed during XPCOM shutdown.

    if (gCleanupContext) {

      gCleanupContext->DestroyCachedBackbuffer();
    } else {
      NS_ASSERTION(PR_FALSE, "Cleanup of drawing surfaces + offscreen buffer failed");
    }

    NS_IF_RELEASE(gCleanupContext);
  }

  mObserver = nsnull;
  mContext = nsnull;

  if (nsnull != mCompositeListeners) {
    mCompositeListeners->Clear();
    NS_RELEASE(mCompositeListeners);
  }
}

Here is the call graph for this function:


Member Function Documentation

Add a listener to the view manager's composite listener list.

Parameters:
aListener- new listener
Returns:
error status

Implements nsIViewManager.

Definition at line 3631 of file nsViewManager.cpp.

Here is the call graph for this function:

void nsViewManager::AddCoveringWidgetsToOpaqueRegion ( nsRegion &  aRgn,
nsIDeviceContext aContext,
nsView aRootView 
) [private]

Definition at line 1224 of file nsViewManager.cpp.

                                                                        {
  NS_PRECONDITION(aRootView, "Must have root view");
  
  // We accumulate the bounds of widgets obscuring aRootView's widget into opaqueRgn.
  // In OptimizeDisplayList, display list elements which lie behind obscuring native
  // widgets are dropped.
  // This shouldn't really be necessary, since the GFX/Widget toolkit should remove these
  // covering widgets from the clip region passed into the paint command. But right now
  // they only give us a paint rect and not a region, so we can't access that information.
  // It's important to identifying areas that are covered by native widgets to avoid
  // painting their views many times as we process invalidates from the root widget all the
  // way down to the nested widgets.
  // 
  // NB: we must NOT add widgets that correspond to floating views!
  // We may be required to paint behind them
  aRgn.SetEmpty();

  nsIWidget* widget = aRootView->GetNearestWidget(nsnull);
  if (!widget) {
    return;
  }

  for (nsIWidget* childWidget = widget->GetFirstChild();
       childWidget;
       childWidget = childWidget->GetNextSibling()) {
    PRBool widgetVisible;
    childWidget->IsVisible(widgetVisible);
    if (widgetVisible) {
      nsView* view = nsView::GetViewFor(childWidget);
      if (view && view->GetVisibility() == nsViewVisibility_kShow
          && !view->GetFloating()) {
        nsRect bounds = view->GetBounds();
        if (bounds.width > 0 && bounds.height > 0) {
          nsView* viewParent = view->GetParent();
            
          while (viewParent && viewParent != aRootView) {
            viewParent->ConvertToParentCoords(&bounds.x, &bounds.y);
            viewParent = viewParent->GetParent();
          }
            
          // maybe we couldn't get the view into the coordinate
          // system of aRootView (maybe it's not a descendant
          // view of aRootView?); if so, don't use it
          if (viewParent) {
            aRgn.Or(aRgn, bounds);
          }
        }
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsViewManager::AddToDisplayList ( nsView aView,
DisplayZTreeNode *&  aParent,
nsRect aClipRect,
nsRect aDirtyRect,
PRUint32  aFlags,
nscoord  aAbsX,
nscoord  aAbsY,
PRBool  aAssumeIntersection,
PLArenaPool aPool,
nsIView aStopClippingAtView 
) [private]

Definition at line 3925 of file nsViewManager.cpp.

{
  nsRect clipRect = aView->GetClippedRect(aStopClippingAtView);
  PRBool clipped = clipRect != aView->GetDimensions();

  // get clipRect into the coordinate system of aView's parent. aAbsX and
  // aAbsY give an offset to the origin of aView's parent.
  clipRect.MoveBy(aView->GetPosition());
  clipRect.x += aAbsX;
  clipRect.y += aAbsY;

  if (!clipped) {
    // XXX this code can't be right. If we're only clipped by one pixel,
    // then that's no reason to use a whole different rectangle.
    NS_ASSERTION(clipRect == aClipRect, "gah!!!");
    clipRect = aClipRect;
  }

  PRBool overlap = clipRect.IntersectRect(clipRect, aDirtyRect);
  if (!overlap && !aAssumeIntersection) {
    return PR_FALSE;
  }

  DisplayListElement2* element;
  ARENA_ALLOCATE(element, &aPool, DisplayListElement2);
  if (element == nsnull) {
    return PR_TRUE;
  }
  DisplayZTreeNode* node;
  ARENA_ALLOCATE(node, &aPool, DisplayZTreeNode);
  if (nsnull == node) {
    return PR_TRUE;
  }

  EnsureZTreeNodeCreated(aView, aParent, aPool);

  node->mDisplayElement = element;
  node->mView = nsnull;
  node->mZChild = nsnull;
  node->mZSibling = aParent->mZChild;
  aParent->mZChild = node;

  element->mView = aView;
  element->mBounds = clipRect;
  element->mAbsX = aClipRect.x;
  element->mAbsY = aClipRect.y;
  element->mFlags = aFlags;
  if (clipped) { 
    element->mFlags |= VIEW_CLIPPED;
  }
  
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Control double buffering of the display.

If double buffering is enabled the viewmanager is allowed to render to an offscreen drawing surface before copying to the display in order to prevent flicker. If it is disabled all rendering will appear directly on the the display. The display is double buffered by default.

Parameters:
aDoubleBufferPR_TRUE to enable double buffering PR_FALSE to disable double buffering

Implements nsIViewManager.

Definition at line 4371 of file nsViewManager.cpp.

{
  mAllowDoubleBuffering = aDoubleBuffer;
  return NS_OK;
}

prevents the view manager from refreshing.

allows UpdateView() to notify widgets of damaged regions that should be repainted when the batch is ended.

Returns:
error status

Implements nsIViewManager.

Definition at line 3455 of file nsViewManager.cpp.

{
  if (!IsRootVM()) {
    return RootViewManager()->BeginUpdateViewBatch();
  }
  
  nsresult result = NS_OK;
  
  if (mUpdateBatchCnt == 0) {
    mUpdateBatchFlags = 0;
    result = DisableRefresh();
  }

  if (NS_SUCCEEDED(result))
    ++mUpdateBatchCnt;

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewManager::BuildDisplayList ( nsView aView,
const nsRect aRect,
PRBool  aEventProcessing,
PRBool  aCaptured,
nsIView aSuppressScrolling,
nsVoidArray aDisplayList,
PLArenaPool aPool 
) [private]

Definition at line 2400 of file nsViewManager.cpp.

{
  // compute this view's origin
  nsPoint origin = ComputeViewOffset(aView);
    
  nsView *displayRoot = aView;
  if (!aCaptured) {
    for (;;) {
      nsView *displayParent = displayRoot->GetParent();

      if (nsnull == displayParent) {
        break;
      }

      if (displayRoot->GetFloating() && !displayParent->GetFloating()) {
        break;
      }
      displayRoot = displayParent;
    }
  }
    
  DisplayZTreeNode *zTree;

  nsPoint displayRootOrigin = ComputeViewOffset(displayRoot);
  displayRoot->ConvertFromParentCoords(&displayRootOrigin.x, &displayRootOrigin.y);
    
  // Determine, for each view, whether it is or contains a ZPlaceholderView
  ComputePlaceholderContainment(displayRoot);

  // Create the Z-ordered view tree
  PRBool paintFloats;
  if (aEventProcessing) {
    paintFloats = PR_TRUE;
  } else {
    paintFloats = displayRoot->GetFloating();
  }

  {
    nsHashtable       PlaceholderHash;

    CreateDisplayList(displayRoot, zTree, origin.x, origin.y,
                      aView, &aRect, displayRoot,
                      displayRootOrigin.x, displayRootOrigin.y,
                      paintFloats, aEventProcessing,
                      aSuppressScrolling ? aSuppressScrolling->GetFirstChild() : nsnull,
                      PlaceholderHash, aPool);

    // Reparent any views that need reparenting in the Z-order tree
    if(zTree) {
      ReparentViews(zTree, PlaceholderHash);
    }
  }
    
  if (nsnull != zTree) {
    // Apply proper Z-order handling
    nsAutoVoidArray mergeTmp;

    SortByZOrder(zTree, *aDisplayList, mergeTmp, PR_TRUE, aPool);
  }

  if (aSuppressScrolling) {
    // Don't render viewport scrollbars
    for (PRInt32 i = 0; i < aDisplayList->Count(); i++) {
      DisplayListElement2* element = NS_STATIC_CAST(DisplayListElement2*,
                                                    aDisplayList->ElementAt(i));
      if ((element->mFlags & VIEW_RENDERED)
          && IsViewportScrollApparatus(element->mView, aSuppressScrolling)) {
        element->mFlags &= ~VIEW_RENDERED;
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewManager::BuildEventTargetList ( nsVoidArray aTargets,
nsView aView,
nsGUIEvent aEvent,
PRBool  aCaptured,
PLArenaPool aPool 
) [private]

Definition at line 2476 of file nsViewManager.cpp.

{
  NS_ASSERTION(!IsPainting(),
               "View manager cannot handle events during a paint");
  if (IsPainting()) {
    return;
  }

  nsRect eventRect(aEvent->point.x, aEvent->point.y, 1, 1);
  nsAutoVoidArray displayList;
  BuildDisplayList(aView, eventRect, PR_TRUE, aCaptured, nsnull, &displayList, aPool);

#ifdef DEBUG_roc
  if (getenv("MOZ_SHOW_DISPLAY_LIST")) ShowDisplayList(&displayList);
#endif

  // The display list is in order from back to front. We return the target list in order from
  // front to back.
  for (PRInt32 i = displayList.Count() - 1; i >= 0; --i) {
    DisplayListElement2* element = NS_STATIC_CAST(DisplayListElement2*, displayList.ElementAt(i));
    if (element->mFlags & VIEW_RENDERED) {
      aTargets.AppendElement(element);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsViewManager::BuildRenderingDisplayList ( nsIView aRootView,
const nsRegion &  aRegion,
nsVoidArray aDisplayList,
PLArenaPool aPool,
PRBool  aIgnoreCoveringWidgets,
PRBool  aIgnoreOutsideClipping,
nsIView aSuppressScrolling 
) [private]

Definition at line 1277 of file nsViewManager.cpp.

{
  BuildDisplayList(NS_STATIC_CAST(nsView*, aRootView),
                   aRegion.GetBounds(), PR_FALSE, aIgnoreOutsideClipping,
                   aSuppressScrolling,
                   aDisplayList, aPool);

  nsRegion opaqueRgn;
  if (!aIgnoreCoveringWidgets) {
    AddCoveringWidgetsToOpaqueRegion(opaqueRgn, mContext,
                                     NS_STATIC_CAST(nsView*, aRootView));
  }

  nsRect finalTransparentRect;
  OptimizeDisplayList(aDisplayList, aRegion, finalTransparentRect, opaqueRgn, PR_FALSE);

#ifdef DEBUG_roc
  if (!finalTransparentRect.IsEmpty()) {
    printf("XXX: Using final transparent rect, x=%d, y=%d, width=%d, height=%d\n",
           finalTransparentRect.x, finalTransparentRect.y, finalTransparentRect.width, finalTransparentRect.height);
  }
#endif

  return !finalTransparentRect.IsEmpty();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3045 of file nsViewManager.cpp.

{
  NS_ASSERTION(!IsPainting(),
               "View manager shouldn't be scrolling during a paint");
  if (IsPainting()) {
    return PR_FALSE; // do the safe thing
  }

  nsRect r = aView->GetClippedRect();
  // Only check the area that intersects the view's non clipped rectangle
  if (r.IsEmpty()) {
    return PR_TRUE; // nothing to scroll
  }

  nsAutoVoidArray displayList;
  PLArenaPool displayArena;
  PL_INIT_ARENA_POOL(&displayArena, "displayArena", 1024);
  BuildDisplayList(aView, r, PR_FALSE, PR_FALSE, nsnull, &displayList, displayArena);

  PRInt32 i;
  for (i = 0; i < displayList.Count(); i++) {
    DisplayListElement2* element = NS_STATIC_CAST(DisplayListElement2*, displayList.ElementAt(i));
    if ((element->mFlags & VIEW_RENDERED) != 0) {
      if (IsAncestorOf(aView, element->mView)) {
        element->mFlags |= (VIEW_ISSCROLLED | VIEW_TRANSPARENT);
      }
    }
  }

  nsRect finalTransparentRect;

  // We DON'T use AddCoveringWidgetsToOpaqueRegion here. Our child widgets are going to be moved
  // as if they were scrolled, so we need to examine the display list elements that might be covered by
  // child widgets.

  // However, we do want to ignore areas that are covered by widgets which have not moved.
  // Unfortunately figuring out that area is not easy, because we don't yet trust the native
  // widget layer to tell us the correct z-order of native widgets.
  // We still have to handle at least one case well:
  // widgets for fixed-position elements when we are scrolling the root scrollable (or something inside
  // the root scrollable) are on top.
  nsRegion opaqueRegion;
  if (mRootScrollable != nsnull) {
    if (IsAncestorOf(NS_STATIC_CAST(const nsScrollPortView*, mRootScrollable), aView)) {
      // add areas of fixed views to the opaque area.
      // This is a bit of a hack. We should not be doing special case processing for fixed views.
      nsView* fixedView = mRootView->GetFirstChild();
      while (fixedView != nsnull) {
        if (fixedView->GetZParent() != nsnull && fixedView->GetZIndex() >= 0) {
          opaqueRegion.Or(opaqueRegion, fixedView->GetBounds());
        }
        fixedView = fixedView->GetNextSibling();
      }

      // get the region into the coordinates of aView
      nscoord deltaX = 0, deltaY = 0;
      for (nsView* v = aView; v; v = v->GetParent()) {
        v->ConvertToParentCoords(&deltaX, &deltaY);
      }
      opaqueRegion.MoveBy(-deltaX, -deltaY);
    }
  }

  // We DO need to use OptimizeDisplayList here to eliminate views
  // that are covered by views we know are opaque. Typically aView's
  // scrolled view is opaque and we want to eliminate views behind it,
  // such as aView itself, that aren't being moved and would otherwise
  // cause us to decide not to blit.  Note that if for some view,
  // view->HasUniformBackground(), that's also sufficient to ignore
  // views behind 'view'; we've been promised that they produce only a
  // uniform background, which is still blittable. So we can treat
  // 'view' as opaque.

  // (Note that it's possible for aView's parent to actually be in
  // front of aView (if aView has a negative z-index) but if so, this
  // code still does the right thing. Yay for the display list based
  // approach!)

  OptimizeDisplayList(&displayList, nsRegion(r), finalTransparentRect, opaqueRegion, PR_TRUE);

  PRBool anyUnscrolledViews = PR_FALSE;
  PRBool anyUnblittableViews = PR_FALSE;

  for (i = 0; i < displayList.Count(); i++) {
    DisplayListElement2* element = NS_STATIC_CAST(DisplayListElement2*, displayList.ElementAt(i));
    if ((element->mFlags & VIEW_RENDERED) != 0) {
      if ((element->mFlags & VIEW_ISSCROLLED) == 0 && element->mView != aView) {
        anyUnscrolledViews = PR_TRUE;
      } else if ((element->mView->GetViewFlags() & NS_VIEW_FLAG_DONT_BITBLT) != 0) {
        anyUnblittableViews = PR_TRUE;
      }
    }
  }

  PL_FreeArenaPool(&displayArena);
  PL_FinishArenaPool(&displayArena);

  return !anyUnscrolledViews && !anyUnblittableViews;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewManager::ClearUpdateCount ( ) [inline, private]

Definition at line 441 of file nsViewManager.h.

                          {
    NS_ASSERTION(IsRootVM(),
                 "DecrementUpdateCount called on non-root viewmanager");
    mUpdateCnt = 0;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Called to force a redrawing of any dirty areas.

Implements nsIViewManager.

Definition at line 1623 of file nsViewManager.cpp.

{
  if (!IsRootVM()) {
    return RootViewManager()->Composite();
  }
  
  if (UpdateCount() > 0)
    {
      ForceUpdate();
      ClearUpdateCount();
    }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4185 of file nsViewManager.cpp.

{
  NS_PRECONDITION(aView, "Null view in ComputeViewOffset?");
  
  nsPoint origin(0, 0);
#ifdef DEBUG
  const nsView* rootView;
  const nsView* origView = aView;
#endif

  while (aView) {
#ifdef DEBUG
    rootView = aView;
#endif
    origin += aView->GetPosition();
    aView = aView->GetParent();
  }
  NS_ASSERTION(rootView ==
               origView->GetViewManager()->RootViewManager()->GetRootView(),
               "Unexpected root view");
  return origin;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BlendingBuffers * nsViewManager::CreateBlendingBuffers ( nsIRenderingContext aRC,
PRBool  aBorrowContext,
nsIDrawingSurface aBorrowSurface,
PRBool  aNeedAlpha,
const nsRect aArea 
) [private]

Definition at line 1521 of file nsViewManager.cpp.

{
  nsresult rv;

  // create a blender, if none exists already.
  if (!mBlender) {
    mBlender = do_CreateInstance(kBlenderCID, &rv);
    if (NS_FAILED(rv))
      return nsnull;
    rv = mBlender->Init(mContext);
    if (NS_FAILED(rv)) {
      mBlender = nsnull;
      return nsnull;
    }
  }

  BlendingBuffers* buffers = new BlendingBuffers(aRC);
  if (!buffers)
    return nsnull;

  buffers->mOffset = nsPoint(aRect.x, aRect.y);

  nsRect offscreenBounds(0, 0, aRect.width, aRect.height);
  offscreenBounds.ScaleRoundOut(mTwipsToPixels);

  if (aBorrowContext) {
    buffers->mBlackCX = aRC;
    buffers->mBlack = aBorrowSurface;
  } else {
    rv = aRC->CreateDrawingSurface(offscreenBounds, NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS, buffers->mBlack);
    if (NS_FAILED(rv)) {
      delete buffers;
      return nsnull;
    }
    buffers->mOwnBlackSurface = PR_TRUE;
    
    rv = NewOffscreenContext(mContext, buffers->mBlack, aRect, getter_AddRefs(buffers->mBlackCX));
    if (NS_FAILED(rv)) {
      delete buffers;
      return nsnull;
    }
  }

  if (aNeedAlpha) {
    rv = aRC->CreateDrawingSurface(offscreenBounds, NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS, buffers->mWhite);
    if (NS_FAILED(rv)) {
      delete buffers;
      return nsnull;
    }
    
    rv = NewOffscreenContext(mContext, buffers->mWhite, aRect, getter_AddRefs(buffers->mWhiteCX));
    if (NS_FAILED(rv)) {
      delete buffers;
      return nsnull;
    }
    
    // Note that we only need to fill mBlackCX with black when some pixels are going
    // to be transparent.
    buffers->mBlackCX->SetColor(NS_RGB(0, 0, 0));
    buffers->mBlackCX->FillRect(aRect);
    buffers->mWhiteCX->SetColor(NS_RGB(255, 255, 255));
    buffers->mWhiteCX->FillRect(aRect);
  }

  return buffers;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsViewManager::CreateDisplayList ( nsView aView,
DisplayZTreeNode *&  aResult,
nscoord  aOriginX,
nscoord  aOriginY,
nsView aRealView,
const nsRect aDamageRect,
nsView aTopView,
nscoord  aX,
nscoord  aY,
PRBool  aPaintFloats,
PRBool  aEventProcessing,
nsIView aSuppressClip,
nsHashtable &  aMapPlaceholderViewToZTreeNode,
PLArenaPool aPool 
) [private]

XXX this needs major simplification and cleanup.

Parameters:
aViewthe view are visiting to create display list element(s) for
aResultinsert display list elements under here
aOriginX/aOriginYthe offset from the origin of aTopView to the origin of the view that is being painted (aRealView)
aRealViewthe view that is being painted
aDamageRectthe rect that needs to be painted, relative to the origin of aRealView
aTopViewthe displayRoot, the root of the collection of views to be painted
aX/aYthe offset from aTopView to the origin of the parent of aView
aPaintFloatsPR_TRUE if we should paint floating views, PR_FALSE if we should avoid descending into any floating views
aEventProcessingPR_TRUE if we intend to do event processing with this display list
aSuppressClipif non-null, any clipping from this view and its ancestors should not be applied
aPoolthe arena to allocate the aResults elements from

Definition at line 3703 of file nsViewManager.cpp.

{
  PRBool retval = PR_FALSE;

  aResult = nsnull;

  NS_ASSERTION((aView != nsnull), "no view");

  if (nsViewVisibility_kHide == aView->GetVisibility()) {
    // bail out if the view is marked invisible; all children are invisible
    return retval;
  }

  nsRect bounds = aView->GetBounds();
  nsPoint pos = aView->GetPosition();

  // -> to global coordinates (relative to aTopView)
  bounds.x += aX;
  bounds.y += aY;
  pos.MoveBy(aX, aY);

  // does this view clip all its children?
  PRBool isClipView =
    (aView->GetClipChildrenToBounds(PR_FALSE)
     && !(aView->GetViewFlags() & NS_VIEW_FLAG_CONTAINS_PLACEHOLDER))
    || aView->GetClipChildrenToBounds(PR_TRUE);
  
  if (isClipView && aSuppressClip && IsAncestorOf(aView, aSuppressClip)) {
    isClipView = PR_FALSE;
  }
  PRBool overlap;
  nsRect irect;

  nsIView* clipUpTo = aSuppressClip ? aSuppressClip : aTopView;
    
  // -> to refresh-frame coordinates (relative to aRealView)
  bounds.x -= aOriginX;
  bounds.y -= aOriginY;
  if (aDamageRect) {
    overlap = irect.IntersectRect(bounds, *aDamageRect);
    if (isClipView) {
      aDamageRect = &irect;
    }
    if (aEventProcessing && aTopView == aView) {
      // Always deliver an event somewhere, at least to the top-level target.
      // There may be mouse capturing going on.
      overlap = PR_TRUE;
    }
  }
  else
    overlap = PR_TRUE;

  // -> to global coordinates (relative to aTopView)
  bounds.x += aOriginX;
  bounds.y += aOriginY;

  // if there's no overlap between the dirty area and the bounds of
  // the view, we should be able to ignore the view and all its
  // children. Unfortunately there is the possibility of reparenting:
  // some other view in the tree might want to be reparented to one of
  // our children, and that view might lie outside our
  // bounds. Typically we need to go ahead and add this view and its
  // children to the ZTree in case someone wants to reparent into it.
  //
  // We can avoid this in two cases: if we clip our children to our
  // bounds, then even if a view is reparented under us, none of its
  // visible area can lie outside our bounds, so it can't intersect
  // the dirty area.  Also, if we don't contain any placeholder views,
  // then there is no way for anyone to reparent below us.
  if (!overlap && !(aView->GetViewFlags() & NS_VIEW_FLAG_CONTAINS_PLACEHOLDER)) {
    return PR_FALSE;
  }

  // Don't paint floating views unless the root view being painted is a floating view.
  // This is important because we may be asked to paint
  // a window that's behind a transient float; in this case we must paint the real window
  // contents, not the float contents (bug 63496)
  if (!aPaintFloats && aView->GetFloating()) {
    return PR_FALSE;
  }

  PRBool anyChildren = aView->GetFirstChild() != nsnull;

  if (aEventProcessing
      && (aView->GetViewFlags() & NS_VIEW_FLAG_DONT_CHECK_CHILDREN) != 0) {
    anyChildren = PR_FALSE;
  }

  PRBool hasFilter = aView->GetOpacity() != 1.0f;
  if (hasFilter) {
    // -> to refresh-frame coordinates (relative to aRealView)
    bounds.x -= aOriginX;
    bounds.y -= aOriginY;
    
    // Add POP first because the z-tree is in reverse order
    retval = AddToDisplayList(aView, aResult, bounds, bounds,
                              POP_FILTER, aX - aOriginX, aY - aOriginY, PR_TRUE, aPool,
                              clipUpTo);
    if (retval)
      return retval;
    
    // -> to global coordinates (relative to aTopView)
    bounds.x += aOriginX;
    bounds.y += aOriginY;
  }

  if (anyChildren) {
    if (isClipView) {
      // -> to refresh-frame coordinates (relative to aRealView)
      bounds.x -= aOriginX;
      bounds.y -= aOriginY;

      // Add POP first because the z-tree is in reverse order
      retval = AddToDisplayList(aView, aResult, bounds, bounds,
                                POP_CLIP, aX - aOriginX, aY - aOriginY, PR_TRUE, aPool,
                                clipUpTo);

      if (retval)
        return retval;

      // -> to global coordinates (relative to aTopView)
      bounds.x += aOriginX;
      bounds.y += aOriginY;
    }

    // Put in all the children before we add this view itself.
    // This preserves document order.
    nsView *childView = nsnull;
    for (childView = aView->GetFirstChild(); nsnull != childView;
         childView = childView->GetNextSibling()) {
      DisplayZTreeNode* createdNode;
      retval = CreateDisplayList(childView, createdNode,
                                 aOriginX, aOriginY, aRealView, aDamageRect, aTopView,
                                 pos.x, pos.y, aPaintFloats, aEventProcessing,
                                 aSuppressClip,
                                 aMapPlaceholderViewToZTreeNode, aPool);
      if (createdNode != nsnull) {
        EnsureZTreeNodeCreated(aView, aResult, aPool);
        createdNode->mZSibling = aResult->mZChild;
        aResult->mZChild = createdNode;
      }

      if (retval)
        break;
    }
  }

  if (!retval) {
    if (overlap) {
      // -> to refresh-frame coordinates (relative to aRealView)
      bounds.x -= aOriginX;
      bounds.y -= aOriginY;

      if (aEventProcessing || aView->GetOpacity() > 0.0f) {
        PRUint32 flags = VIEW_RENDERED;
        if (aView->IsTransparent())
          flags |= VIEW_TRANSPARENT;
        retval = AddToDisplayList(aView, aResult, bounds, irect, flags,
                                  aX - aOriginX, aY - aOriginY,
                                  aEventProcessing && aTopView == aView, aPool,
                                  clipUpTo);
        // We're forcing AddToDisplayList to pick up the view only
        // during event processing, and only when aView is back at the
        // root of the tree of acceptable views (note that when event
        // capturing is in effect, aTopView is the capturing view)
      }

      // -> to global coordinates (relative to aTopView)
      bounds.x += aOriginX;
      bounds.y += aOriginY;
    } else {
      if (aView->IsZPlaceholderView()) {
        EnsureZTreeNodeCreated(aView, aResult, aPool);
        nsVoidKey key(aView);
        aMapPlaceholderViewToZTreeNode.Put(&key, aResult);
      }
    }
  }

  if (anyChildren && isClipView) {
    // -> to refresh-frame coordinates (relative to aRealView)
    bounds.x -= aOriginX;
    bounds.y -= aOriginY;

    if (AddToDisplayList(aView, aResult, bounds, bounds, PUSH_CLIP,
                         aX - aOriginX, aY - aOriginY, PR_TRUE, aPool,
                         clipUpTo)) {
      retval = PR_TRUE;
    }
    
    // -> to global coordinates (relative to aTopView)
    bounds.x += aOriginX;
    bounds.y += aOriginY;
  }

  if (hasFilter) {
    // -> to refresh-frame coordinates (relative to aRealView)
    bounds.x -= aOriginX;
    bounds.y -= aOriginY;
    
    retval = AddToDisplayList(aView, aResult, bounds, bounds,
                              PUSH_FILTER, aX - aOriginX, aY - aOriginY, PR_TRUE, aPool,
                              clipUpTo);
    if (retval)
      return retval;
    
    // -> to global coordinates (relative to aTopView)
    bounds.x += aOriginX;
    bounds.y += aOriginY;
  }

  return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 555 of file nsViewManager.cpp.

{
  nsresult rv;

  if (!mRegionFactory) {
    mRegionFactory = do_GetClassObject(kRegionCID, &rv);
    if (NS_FAILED(rv)) {
      *result = nsnull;
      return rv;
    }
  }

  nsIRegion* region = nsnull;
  rv = CallCreateInstance(mRegionFactory.get(), &region);
  if (NS_SUCCEEDED(rv)) {
    rv = region->Init();
    *result = region;
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3378 of file nsViewManager.cpp.

{
  nsView              *par = &aView;
  nsIWidget*          win;
  nsIRenderingContext *cx = nsnull;
  nscoord             ax = 0, ay = 0;

  do
    {
      win = par->GetWidget();
      if (win)
        break;

      //get absolute coordinates of view, but don't
      //add in view pos since the first thing you ever
      //need to do when painting a view is to translate
      //the rendering context by the views pos and other parts
      //of the code do this for us...

      if (par != &aView)
        {
          par->ConvertToParentCoords(&ax, &ay);
        }

      par = par->GetParent();
    }
  while (nsnull != par);

  if (nsnull != win)
    {
      mContext->CreateRenderingContext(par, cx);

      if (nsnull != cx)
        cx->Translate(ax, ay);
    }

  return cx;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 429 of file nsViewManager.h.

                              {
    NS_ASSERTION(IsRootVM(),
                 "DecrementUpdateCount called on non-root viewmanager");
    --mUpdateCnt;
  }

Here is the call graph for this function:

void nsViewManager::DefaultRefresh ( nsView aView,
const nsRect aRect 
) [private]

Refresh aView (which must be non-null) with our default background color.

Definition at line 985 of file nsViewManager.cpp.

{
  NS_PRECONDITION(aView, "Must have a view to work with!");
  nsIWidget* widget = aView->GetNearestWidget(nsnull);
  if (! widget)
    return;

  nsCOMPtr<nsIRenderingContext> context = CreateRenderingContext(*aView);

  if (! context)
    return;

  nscolor bgcolor = mDefaultBackgroundColor;

  if (NS_GET_A(mDefaultBackgroundColor) == 0) {
    NS_WARNING("nsViewManager: Asked to paint a default background, but no default background color is set!");
    return;
  }

  context->SetColor(bgcolor);
  context->FillRect(*aRect);
}

Here is the call graph for this function:

Here is the caller graph for this function:

prevent the view manager from refreshing.

Returns:
error status

Implements nsIViewManager.

Definition at line 3417 of file nsViewManager.cpp.

{
  if (!IsRootVM()) {
    return RootViewManager()->DisableRefresh();
  }
  
  if (mUpdateBatchCnt > 0)
    return NS_OK;

  mRefreshEnabled = PR_FALSE;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsViewManager::DispatchEvent ( nsGUIEvent aEvent,
nsEventStatus aStatus 
) [virtual]

Called to dispatch an event to the appropriate view.

Often called as a result of receiving a mouse or keyboard event from the widget event system.

Parameters:
eventevent to dispatch
Returns:
event handling status

Implements nsIViewManager.

Definition at line 1925 of file nsViewManager.cpp.

{
  *aStatus = nsEventStatus_eIgnore;

  switch(aEvent->message)
    {
    case NS_SIZE:
      {
        nsView* view = nsView::GetViewFor(aEvent->widget);

        if (nsnull != view)
          {
            nscoord width = ((nsSizeEvent*)aEvent)->windowSize->width;
            nscoord height = ((nsSizeEvent*)aEvent)->windowSize->height;
            width = ((nsSizeEvent*)aEvent)->mWinWidth;
            height = ((nsSizeEvent*)aEvent)->mWinHeight;

            // The root view may not be set if this is the resize associated with
            // window creation

            if (view == mRootView)
              {
                // Convert from pixels to twips
                float p2t;
                p2t = mContext->DevUnitsToAppUnits();

                //printf("resize: (pix) %d, %d\n", width, height);
                SetWindowDimensions(NSIntPixelsToTwips(width, p2t),
                                    NSIntPixelsToTwips(height, p2t));
                *aStatus = nsEventStatus_eConsumeNoDefault;
              }
          }

        break;
      }

    case NS_PAINT:
      {
        nsPaintEvent *event = NS_STATIC_CAST(nsPaintEvent*, aEvent);
        nsView *view = nsView::GetViewFor(aEvent->widget);

        if (!view || !mContext)
          break;

        *aStatus = nsEventStatus_eConsumeNoDefault;

        // The rect is in device units, and it's in the coordinate space of its
        // associated window.
        nsCOMPtr<nsIRegion> region = event->region;
        if (!region) {
          if (NS_FAILED(CreateRegion(getter_AddRefs(region))))
            break;

          const nsRect& damrect = *event->rect;
          region->SetTo(damrect.x, damrect.y, damrect.width, damrect.height);
        }
        
        if (region->IsEmpty())
          break;

        // Refresh the view
        if (IsRefreshEnabled()) {
          // If an ancestor widget was hidden and then shown, we could
          // have a delayed resize to handle.
          PRBool didResize = PR_FALSE;
          for (nsViewManager *vm = this; vm;
               vm = vm->mRootView->GetParent()
                      ? vm->mRootView->GetParent()->GetViewManager()
                      : nsnull) {
            if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) &&
                IsViewVisible(vm->mRootView)) {
              vm->DoSetWindowDimensions(vm->mDelayedResize.width,
                                        vm->mDelayedResize.height);
              vm->mDelayedResize.SizeTo(NSCOORD_NONE, NSCOORD_NONE);

              // Paint later.
              vm->UpdateView(vm->mRootView, NS_VMREFRESH_NO_SYNC);
              didResize = PR_TRUE;
            }
          }

          if (!didResize) {
            //NS_ASSERTION(IsViewVisible(view), "painting an invisible view");

            // Just notify our own view observer that we're about to paint
            // XXXbz do we need to notify other view observers for viewmanagers
            // in our tree?
            // Make sure to not send WillPaint notifications while scrolling
            nsViewManager* rootVM = RootViewManager();

            nsIWidget *widget = mRootView->GetWidget();
            PRBool translucentWindow = PR_FALSE;
            if (widget)
                widget->GetWindowTranslucency(translucentWindow);

            if (rootVM->mScrollCnt == 0 && !translucentWindow) {
              nsIViewObserver* observer = GetViewObserver();
              if (observer) {
                // Do an update view batch.  Make sure not to do it DEFERRED,
                // since that would effectively delay any invalidates that are
                // triggered by the WillPaint notification (they'd happen when
                // the invalide event fires, which is later than the reflow
                // event would fire and could end up being after some timer
                // events, leading to frame dropping in DHTML).  Note that the
                // observer may try to reenter this code from inside
                // WillPaint() by trying to do a synchronous paint, but since
                // refresh will be disabled it won't be able to do the paint.
                // We should really sort out the rules on our synch painting
                // api....
                BeginUpdateViewBatch();
                observer->WillPaint();
                EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC);

                // Get the view pointer again since the code above might have
                // destroyed it (bug 378273).
                view = nsView::GetViewFor(aEvent->widget);
              }
            }
            // Make sure to sync up any widget geometry changes we
            // have pending before we paint.
            if (rootVM->mHasPendingUpdates) {
              rootVM->ProcessPendingUpdates(mRootView, PR_FALSE);
            }
            
            if (view) {
              Refresh(view, event->renderingContext, region,
                      NS_VMREFRESH_DOUBLE_BUFFER);
            }
          }
        } else {
          // since we got an NS_PAINT event, we need to
          // draw something so we don't get blank areas.
          nsRect damRect;
          region->GetBoundingBox(&damRect.x, &damRect.y, &damRect.width, &damRect.height);
          float p2t;
          p2t = mContext->DevUnitsToAppUnits();
          damRect.ScaleRoundOut(p2t);
          DefaultRefresh(view, &damRect);
        
          // Clients like the editor can trigger multiple
          // reflows during what the user perceives as a single
          // edit operation, so it disables view manager
          // refreshing until the edit operation is complete
          // so that users don't see the intermediate steps.
          // 
          // Unfortunately some of these reflows can trigger
          // nsScrollPortView and nsScrollingView Scroll() calls
          // which in most cases force an immediate BitBlt and
          // synchronous paint to happen even if the view manager's
          // refresh is disabled. (Bug 97674)
          //
          // Calling UpdateView() here, is necessary to add
          // the exposed region specified in the synchronous paint
          // event to  the view's damaged region so that it gets
          // painted properly when refresh is enabled.
          //
          // Note that calling UpdateView() here was deemed
          // to have the least impact on performance, since the
          // other alternative was to make Scroll() post an
          // async paint event for the *entire* ScrollPort or
          // ScrollingView's viewable area. (See bug 97674 for this
          // alternate patch.)
          
          UpdateView(view, damRect, NS_VMREFRESH_NO_SYNC);
        }

        break;
      }

    case NS_CREATE:
    case NS_DESTROY:
    case NS_SETZLEVEL:
    case NS_MOVE:
      /* Don't pass these events through. Passing them through
         causes performance problems on pages with lots of views/frames 
         @see bug 112861 */
      *aStatus = nsEventStatus_eConsumeNoDefault;
      break;


    case NS_DISPLAYCHANGED:

      //Destroy the cached backbuffer to force a new backbuffer
      //be constructed with the appropriate display depth.
      //@see bugzilla bug 6061
      *aStatus = nsEventStatus_eConsumeDoDefault;
      if (gCleanupContext) {
        gCleanupContext->DestroyCachedBackbuffer();
      }
      break;

    case NS_SYSCOLORCHANGED:
      {
        // Hold a refcount to the observer. The continued existence of the observer will
        // delay deletion of this view hierarchy should the event want to cause its
        // destruction in, say, some JavaScript event handler.
        nsView *view = nsView::GetViewFor(aEvent->widget);
        nsCOMPtr<nsIViewObserver> obs = GetViewObserver();
        if (obs) {
          PRBool handled;
          obs->HandleEvent(view, aEvent, aStatus, PR_TRUE, handled);
        }
      }
      break; 

    default:
      {
        if ((NS_IS_MOUSE_EVENT(aEvent) &&
             // Ignore moves that we synthesize.
             NS_STATIC_CAST(nsMouseEvent*,aEvent)->reason ==
               nsMouseEvent::eReal &&
             // Ignore mouse exit and enter (we'll get moves if the user
             // is really moving the mouse) since we get them when we
             // create and destroy widgets.
             aEvent->message != NS_MOUSE_EXIT &&
             aEvent->message != NS_MOUSE_ENTER) ||
            NS_IS_KEY_EVENT(aEvent) ||
            NS_IS_IME_EVENT(aEvent)) {
          gLastUserEventTime = PR_IntervalToMicroseconds(PR_IntervalNow());
        }

        if (aEvent->message == NS_DEACTIVATE) {
          PRBool result;
          GrabMouseEvents(nsnull, result);
          mKeyGrabber = nsnull;
        }

        //Find the view whose coordinates system we're in.
        nsView* baseView = nsView::GetViewFor(aEvent->widget);
        nsView* view = baseView;
        PRBool capturedEvent = PR_FALSE;

        //Find the view to which we're initially going to send the event 
        //for hittesting.
        if (NS_IS_MOUSE_EVENT(aEvent) || NS_IS_DRAG_EVENT(aEvent)) {
          nsView* mouseGrabber = GetMouseEventGrabber();
          if (mouseGrabber) {
            view = mouseGrabber;
            capturedEvent = PR_TRUE;
          }
        }
        else if (NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_EVENT(aEvent)) {
          if (mKeyGrabber) {
            view = mKeyGrabber;
            capturedEvent = PR_TRUE;
          }
        }

        if (nsnull != view) {
          float t2p = mContext->AppUnitsToDevUnits();
          float p2t = mContext->DevUnitsToAppUnits();

          if ((aEvent->message == NS_MOUSE_MOVE &&
               NS_STATIC_CAST(nsMouseEvent*,aEvent)->reason ==
                 nsMouseEvent::eReal) ||
              aEvent->message == NS_MOUSE_ENTER) {
            nsPoint rootOffset(0, 0);
            for (nsView *v = baseView; v != mRootView; v = v->GetParent())
              v->ConvertToParentCoords(&rootOffset.x, &rootOffset.y);
            // aEvent->point is relative to the widget, i.e. the view top-left,
            // so we need to add the offset to the view origin
            rootOffset += baseView->GetDimensions().TopLeft();
            mMouseLocation.MoveTo(NSTwipsToIntPixels(rootOffset.x, t2p) +
                                    aEvent->point.x,
                                  NSTwipsToIntPixels(rootOffset.y, t2p) +
                                    aEvent->point.y);
#ifdef DEBUG_MOUSE_LOCATION
            if (aEvent->message == NS_MOUSE_ENTER)
              printf("[vm=%p]got mouse enter for %p\n",
                     this, aEvent->widget);
            printf("[vm=%p]setting mouse location to (%d,%d)\n",
                   this, mMouseLocation.x, mMouseLocation.y);
#endif
            if (aEvent->message == NS_MOUSE_ENTER)
              SynthesizeMouseMove(PR_FALSE);
          } else if (aEvent->message == NS_MOUSE_EXIT) {
            // Although we only care about the mouse moving into an area
            // for which this view manager doesn't receive mouse move
            // events, we don't check which view the mouse exit was for
            // since this seems to vary by platform.  Hopefully this
            // won't matter at all since we'll get the mouse move or
            // enter after the mouse exit when the mouse moves from one
            // of our widgets into another.
            mMouseLocation.MoveTo(NSCOORD_NONE, NSCOORD_NONE);
#ifdef DEBUG_MOUSE_LOCATION
            printf("[vm=%p]got mouse exit for %p\n",
                   this, aEvent->widget);
            printf("[vm=%p]clearing mouse location\n",
                   this);
#endif
          }

          //Calculate the proper offset for the view we're going to
          nsPoint offset(0, 0);

          if (view != baseView) {
            //Get offset from root of baseView
            nsView *parent;
            for (parent = baseView; parent; parent = parent->GetParent())
              parent->ConvertToParentCoords(&offset.x, &offset.y);

            //Subtract back offset from root of view
            for (parent = view; parent; parent = parent->GetParent())
              parent->ConvertFromParentCoords(&offset.x, &offset.y);
          }

          //Dispatch the event
          //Before we start mucking with coords, make sure we know our baseline
          aEvent->refPoint.x = aEvent->point.x;
          aEvent->refPoint.y = aEvent->point.y;

          nsRect baseViewDimensions;
          if (baseView != nsnull) {
            baseView->GetDimensions(baseViewDimensions);
          }

          nsPoint oldpt = aEvent->point;
          // Set the mouse cursor to the middle of the pixel, because
          // that's how we paint --- a frame paints a pixel if it covers
          // the center of the pixel
          aEvent->point.x = baseViewDimensions.x +
            NSFloatPixelsToTwips(float(aEvent->point.x) + 0.5f, p2t);
          aEvent->point.y = baseViewDimensions.y +
            NSFloatPixelsToTwips(float(aEvent->point.y) + 0.5f, p2t);

          aEvent->point.x += offset.x;
          aEvent->point.y += offset.y;

          *aStatus = HandleEvent(view, aEvent, capturedEvent);

          // From here on out, "this" could have been deleted!!!
          aEvent->point = oldpt;

          //
          // if the event is an nsTextEvent, we need to map the reply back into platform coordinates
          //
          if (aEvent->message==NS_TEXT_TEXT) {
            ((nsTextEvent*)aEvent)->theReply.mCursorPosition.x=NSTwipsToIntPixels(((nsTextEvent*)aEvent)->theReply.mCursorPosition.x, t2p);
            ((nsTextEvent*)aEvent)->theReply.mCursorPosition.y=NSTwipsToIntPixels(((nsTextEvent*)aEvent)->theReply.mCursorPosition.y, t2p);
            ((nsTextEvent*)aEvent)->theReply.mCursorPosition.width=NSTwipsToIntPixels(((nsTextEvent*)aEvent)->theReply.mCursorPosition.width, t2p);
            ((nsTextEvent*)aEvent)->theReply.mCursorPosition.height=NSTwipsToIntPixels(((nsTextEvent*)aEvent)->theReply.mCursorPosition.height, t2p);
          }
          if((aEvent->message==NS_COMPOSITION_START) ||
             (aEvent->message==NS_COMPOSITION_QUERY)) {
            ((nsCompositionEvent*)aEvent)->theReply.mCursorPosition.x=NSTwipsToIntPixels(((nsCompositionEvent*)aEvent)->theReply.mCursorPosition.x,t2p);
            ((nsCompositionEvent*)aEvent)->theReply.mCursorPosition.y=NSTwipsToIntPixels(((nsCompositionEvent*)aEvent)->theReply.mCursorPosition.y,t2p);
            ((nsCompositionEvent*)aEvent)->theReply.mCursorPosition.width=NSTwipsToIntPixels(((nsCompositionEvent*)aEvent)->theReply.mCursorPosition.width,t2p);
            ((nsCompositionEvent*)aEvent)->theReply.mCursorPosition.height=NSTwipsToIntPixels(((nsCompositionEvent*)aEvent)->theReply.mCursorPosition.height,t2p);
          }
          if(aEvent->message==NS_QUERYCARETRECT) {
            ((nsQueryCaretRectEvent*)aEvent)->theReply.mCaretRect.x=NSTwipsToIntPixels(((nsQueryCaretRectEvent*)aEvent)->theReply.mCaretRect.x,t2p);
            ((nsQueryCaretRectEvent*)aEvent)->theReply.mCaretRect.y=NSTwipsToIntPixels(((nsQueryCaretRectEvent*)aEvent)->theReply.mCaretRect.y,t2p);
            ((nsQueryCaretRectEvent*)aEvent)->theReply.mCaretRect.width=NSTwipsToIntPixels(((nsQueryCaretRectEvent*)aEvent)->theReply.mCaretRect.width,t2p);
            ((nsQueryCaretRectEvent*)aEvent)->theReply.mCaretRect.height=NSTwipsToIntPixels(((nsQueryCaretRectEvent*)aEvent)->theReply.mCaretRect.height,t2p);
          }
        }
    
        break;
      }
    }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsViewManager::Display ( nsIView aView,
nscoord  aX,
nscoord  aY,
const nsRect aClipRect 
) [virtual]

Display the specified view.

Used when printing.

Implements nsIViewManager.

Definition at line 3584 of file nsViewManager.cpp.

{
  nsView              *view = NS_STATIC_CAST(nsView*, aView);
  nsIRenderingContext *localcx = nsnull;

  if (! IsRefreshEnabled())
    return NS_OK;

  NS_ASSERTION(!IsPainting(), "recursive painting not permitted");

  SetPainting(PR_TRUE);

  mContext->CreateRenderingContext(localcx);

  //couldn't get rendering context. this is ok if at startup
  if (nsnull == localcx)
    {
      SetPainting(PR_FALSE);
      return NS_ERROR_FAILURE;
    }

  nsRect trect = view->GetBounds();
  view->ConvertFromParentCoords(&trect.x, &trect.y);

  localcx->Translate(aX, aY);

  localcx->SetClipRect(aClipRect, nsClipCombine_kReplace);

  // Paint the view. The clipping rect was set above set don't clip again.
  //aView->Paint(*localcx, trect, NS_VIEW_FLAG_CLIP_SET, result);
  nsAutoVoidArray displayList;
  PLArenaPool displayArena;
  PL_INIT_ARENA_POOL(&displayArena, "displayArena", 1024);
  BuildRenderingDisplayList(view, nsRegion(trect), &displayList, displayArena,
                            PR_FALSE, PR_FALSE, nsnull);
  RenderViews(view, *localcx, nsRegion(trect), PR_FALSE, displayList);
  PL_FreeArenaPool(&displayArena);
  PL_FinishArenaPool(&displayArena);

  NS_RELEASE(localcx);

  SetPainting(PR_FALSE);

  return NS_OK;

}

Here is the call graph for this function:

Definition at line 4208 of file nsViewManager.cpp.

{
  if (aView->HasWidget())
    return (nsnull != aView->GetWidget()->GetNativeData(NS_NATIVE_WIDGET));
  return PR_FALSE;
}

Here is the call graph for this function:

void nsViewManager::DoSetWindowDimensions ( nscoord  aWidth,
nscoord  aHeight 
) [inline, private]

Definition at line 409 of file nsViewManager.h.

  {
    nsRect oldDim;
    nsRect newDim(0, 0, aWidth, aHeight);
    mRootView->GetDimensions(oldDim);
    if (oldDim != newDim) {
      // Don't resize the widget. It is already being set elsewhere.
      mRootView->SetDimensions(newDim, PR_TRUE, PR_FALSE);
      if (mObserver)
        mObserver->ResizeReflow(mRootView, aWidth, aHeight);
    }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

allow the view manager to refresh.

this may cause a synchronous paint to occur inside the call.

Parameters:
aUpdateFlagssee bottom of nsIViewManager.h for description
Returns:
error status

Implements nsIViewManager.

Definition at line 3430 of file nsViewManager.cpp.

{
  if (!IsRootVM()) {
    return RootViewManager()->EnableRefresh(aUpdateFlags);
  }
  
  if (mUpdateBatchCnt > 0)
    return NS_OK;

  mRefreshEnabled = PR_TRUE;

  // nested batching can combine IMMEDIATE with DEFERRED. Favour
  // IMMEDIATE over DEFERRED and DEFERRED over NO_SYNC.
  if (aUpdateFlags & NS_VMREFRESH_IMMEDIATE) {
    FlushPendingInvalidates();
    Composite();
  } else if (aUpdateFlags & NS_VMREFRESH_DEFERRED) {
    PostInvalidateEvent();
  } else { // NO_SYNC
    FlushPendingInvalidates();
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

allow the view manager to refresh any damaged areas accumulated after the BeginUpdateViewBatch() call.

this may cause a synchronous paint to occur inside the call if aUpdateFlags NS_VMREFRESH_IMMEDIATE is set.

If this is not the outermost view batch command, then this does nothing except that the specified flags are remembered. When the outermost batch finally ends, we merge together all the flags for the inner batches in the following way: -- If any batch specified NS_VMREFRESH_IMMEDIATE, then we use that flag (i.e. there is a synchronous paint under the last EndUpdateViewBatch) -- Otherwise if any batch specified NS_VMREFERSH_DEFERRED, then we use that flag (i.e. invalidation is deferred until the processing of an Invalidate PLEvent) -- Otherwise all batches specified NS_VMREFRESH_NO_SYNC and we honor that; all widgets are invalidated normally and will be painted the next time the toolkit chooses to update them.

Parameters:
aUpdateFlagssee bottom of nsIViewManager.h for description
Returns:
error status

Implements nsIViewManager.

Definition at line 3474 of file nsViewManager.cpp.

{
  if (!IsRootVM()) {
    return RootViewManager()->EndUpdateViewBatch(aUpdateFlags);
  }
  
  nsresult result = NS_OK;

  --mUpdateBatchCnt;

  NS_ASSERTION(mUpdateBatchCnt >= 0, "Invalid batch count!");

  if (mUpdateBatchCnt < 0)
    {
      mUpdateBatchCnt = 0;
      return NS_ERROR_FAILURE;
    }

  mUpdateBatchFlags |= aUpdateFlags;
  if (mUpdateBatchCnt == 0) {
    result = EnableRefresh(mUpdateBatchFlags);
  }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4385 of file nsViewManager.cpp.

{
  NS_ASSERTION(IsRootVM(), "Must be root VM for this to be called!\n");
  NS_ASSERTION(mUpdateBatchCnt == 0, "Must not be in an update batch!");
  // XXXbz this is probably not quite OK yet, if callers can explicitly
  // DisableRefresh while we have an event posted.
  // NS_ASSERTION(mRefreshEnabled, "How did we get here?");

  // Let all the view observers of all viewmanagers in this tree know that
  // we're about to "paint" (this lets them get in their invalidates now so
  // we don't go through two invalidate-processing cycles).
  NS_ASSERTION(gViewManagers, "Better have a viewmanagers array!");

  // Make sure to not send WillPaint notifications while scrolling
  if (mScrollCnt == 0) {
    // Disable refresh while we notify our view observers, so that if they do
    // view update batches we don't reenter this code and so that we batch
    // all of them together.  We don't use
    // BeginUpdateViewBatch/EndUpdateViewBatch, since that would reenter this
    // exact code, but we want the effect of a single big update batch.
    PRBool refreshEnabled = mRefreshEnabled;
    mRefreshEnabled = PR_FALSE;
    ++mUpdateBatchCnt;
    
    PRInt32 index;
    for (index = 0; index < mVMCount; index++) {
      nsViewManager* vm = (nsViewManager*)gViewManagers->ElementAt(index);
      if (vm->RootViewManager() == this) {
        // One of our kids
        nsIViewObserver* observer = vm->GetViewObserver();
        if (observer) {
          observer->WillPaint();
          NS_ASSERTION(mUpdateBatchCnt == 1,
                       "Observer did not end view batch?");
        }
      }
    }
    
    --mUpdateBatchCnt;
    // Someone could have called EnableRefresh on us from inside WillPaint().
    // Only reset the old mRefreshEnabled value if the current value is false.
    if (!mRefreshEnabled) {
      mRefreshEnabled = refreshEnabled;
    }
  }
  
  if (mHasPendingUpdates) {
    ProcessPendingUpdates(mRootView, PR_TRUE);
    mHasPendingUpdates = PR_FALSE;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Force update of view manager widget Callers should use UpdateView(view, NS_VMREFRESH_IMMEDIATE) in most cases instead.

Returns:
error status

Implements nsIViewManager.

Definition at line 3656 of file nsViewManager.cpp.

{
  if (!IsRootVM()) {
    return RootViewManager()->ForceUpdate();
  }

  // Walk the view tree looking for widgets, and call Update() on each one
  UpdateWidgetsForView(mRootView);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsViewManager::GetAbsoluteRect ( nsView aView,
const nsRect aRect,
nsRect aAbsRect 
) [private]

Transforms a rectangle from specified view's coordinate system to an absolute coordinate rectangle which can be compared against the rectangle returned by GetVisibleRect to determine visibility.

Parameters:
aViewview that aRect coordinates are specified relative to
aRectrectangle in twips to convert to absolute coordinates
aAbsRectrectangle in absolute coorindates.
Returns:
NS_OK if successful otherwise, NS_ERROR_FAILURE

Definition at line 4269 of file nsViewManager.cpp.

{
  nsIScrollableView* scrollingView = nsnull;
  GetRootScrollableView(&scrollingView);
  if (nsnull == scrollingView) { 
    return NS_ERROR_FAILURE;
  }

  nsIView* scrolledIView = nsnull;
  scrollingView->GetScrolledView(scrolledIView);
  
  nsView* scrolledView = NS_STATIC_CAST(nsView*, scrolledIView);

  // Calculate the absolute coordinates of the aRect passed in.
  // aRects values are relative to aView
  aAbsRect = aRect;
  nsView *parentView = aView;
  while ((parentView != nsnull) && (parentView != scrolledView)) {
    parentView->ConvertToParentCoords(&aAbsRect.x, &aAbsRect.y);
    parentView = parentView->GetParent();
  }

  if (parentView != scrolledView) {
    return NS_ERROR_FAILURE;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Retrieve the default background color.

Parameters:
aColorthe default background color

Implements nsIViewManager.

Definition at line 4463 of file nsViewManager.cpp.

{
  *aColor = mDefaultBackgroundColor;
  return NS_OK;
}

Get the device context associated with this manager.

Returns:
device context

Implements nsIViewManager.

Definition at line 3336 of file nsViewManager.cpp.

{
  NS_IF_ADDREF(mContext);
  aContext = mContext;
  return NS_OK;
}

Here is the caller graph for this function:

Get the current view, if any, that's capturing keyboard events.

Returns:
view that is capturing keyboard events or nsnull

Implements nsIViewManager.

Definition at line 2632 of file nsViewManager.cpp.

{
  aView = mKeyGrabber;
  return NS_OK;
}

Definition at line 460 of file nsViewManager.h.

{ return mKeyGrabber; }

Retrieve the time of the last user event.

User events include mouse and keyboard events. The viewmanager saves the time of the last user event.

Parameters:
aTimeLast user event time in microseconds

Implements nsIViewManager.

Definition at line 4471 of file nsViewManager.cpp.

{
  aTime = gLastUserEventTime;
  return NS_OK;
}
void nsViewManager::GetMaxWidgetBounds ( nsRect aMaxWidgetBounds) const [private]

Determine the maximum and width and height of all of the view manager's widgets.

Parameters:
aMaxWidgetBoundsthe maximum width and height of all view managers widgets on exit.

Definition at line 3343 of file nsViewManager.cpp.

{
  // Go through the list of viewmanagers and get the maximum width and 
  // height of their widgets
  aMaxWidgetBounds.width = 0;
  aMaxWidgetBounds.height = 0;
  PRInt32 index = 0;
  for (index = 0; index < mVMCount; index++) {

    nsViewManager* vm = (nsViewManager*)gViewManagers->ElementAt(index);
    nsCOMPtr<nsIWidget> rootWidget;

    if(NS_SUCCEEDED(vm->GetWidget(getter_AddRefs(rootWidget))) && rootWidget)
      {
        nsRect widgetBounds;
        rootWidget->GetBounds(widgetBounds);
        aMaxWidgetBounds.width = PR_MAX(aMaxWidgetBounds.width, widgetBounds.width);
        aMaxWidgetBounds.height = PR_MAX(aMaxWidgetBounds.height, widgetBounds.height);
      }
  }

  //   printf("WIDGET BOUNDS %d %d\n", aMaxWidgetBounds.width, aMaxWidgetBounds.height);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Get the current view, if any, that's capturing mouse events.

Returns:
view that is capturing mouse events or nsnull

Implements nsIViewManager.

Definition at line 2626 of file nsViewManager.cpp.

{
  aView = GetMouseEventGrabber();
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 457 of file nsViewManager.h.

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsViewManager::GetRectVisibility ( nsIView aView,
const nsRect aRect,
PRUint16  aMinTwips,
nsRectVisibility aRectVisibility 
) [virtual]

Determine if a rectangle specified in the view's coordinate system is completely, or partially visible.

Parameters:
aViewview that aRect coordinates are specified relative to
aRectrectangle in twips to test for visibility
aMinTwipsis the min. pixel rows or cols at edge of screen needed for object to be counted visible
aRectVisibilityreturns eVisible if the rect is visible, otherwise it returns an enum indicating why not

Implements nsIViewManager.

Definition at line 4300 of file nsViewManager.cpp.

{
  nsView* view = NS_STATIC_CAST(nsView*, aView);

  // The parameter aMinTwips determines how many rows/cols of pixels must be visible on each side of the element,
  // in order to be counted as visible

  *aRectVisibility = nsRectVisibility_kZeroAreaRect;
  if (aRect.width == 0 || aRect.height == 0) {
    return NS_OK;
  }

  // is this view even visible?
  if (view->GetVisibility() == nsViewVisibility_kHide) {
    return NS_OK; 
  }

  // nsViewManager::InsertChild ensures that descendants of floating views
  // are also marked floating.
  if (view->GetFloating()) {
    *aRectVisibility = nsRectVisibility_kVisible;
    return NS_OK;
  }

  // Calculate the absolute coordinates for the visible rectangle   
  nsRect visibleRect;
  if (GetVisibleRect(visibleRect) == NS_ERROR_FAILURE) {
    *aRectVisibility = nsRectVisibility_kVisible;
    return NS_OK;
  }

  // Calculate the absolute coordinates of the aRect passed in.
  // aRects values are relative to aView
  nsRect absRect;
  if ((GetAbsoluteRect(view, aRect, absRect)) == NS_ERROR_FAILURE) {
    *aRectVisibility = nsRectVisibility_kVisible;
    return NS_OK;
  }
 
  /*
   * If aMinTwips > 0, ensure at least aMinTwips of space around object is visible
   * The object is not visible if:
   * ((objectTop     < windowTop    && objectBottom < windowTop) ||
   *  (objectBottom  > windowBottom && objectTop    > windowBottom) ||
   *  (objectLeft    < windowLeft   && objectRight  < windowLeft) ||
   *  (objectRight   > windowRight  && objectLeft   > windowRight))
   */

  if (absRect.y < visibleRect.y  && 
      absRect.y + absRect.height < visibleRect.y + aMinTwips)
    *aRectVisibility = nsRectVisibility_kAboveViewport;
  else if (absRect.y + absRect.height > visibleRect.y + visibleRect.height &&
           absRect.y > visibleRect.y + visibleRect.height - aMinTwips)
    *aRectVisibility = nsRectVisibility_kBelowViewport;
  else if (absRect.x < visibleRect.x && 
           absRect.x + absRect.width < visibleRect.x + aMinTwips)
    *aRectVisibility = nsRectVisibility_kLeftOfViewport;
  else if (absRect.x + absRect.width > visibleRect.x  + visibleRect.width &&
           absRect.x > visibleRect.x + visibleRect.width - aMinTwips)
    *aRectVisibility = nsRectVisibility_kRightOfViewport;
  else
    *aRectVisibility = nsRectVisibility_kVisible;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

get the view that is is considered to be the root scrollable view for the document.

Parameters:
aScrollableout parameter for root scrollable view
Returns:
error status

Implements nsIViewManager.

Definition at line 3514 of file nsViewManager.cpp.

{
  *aScrollable = mRootScrollable;
  return NS_OK;
}

Here is the caller graph for this function:

Get the root of the view tree.

Returns:
the root view

Implements nsIViewManager.

Definition at line 634 of file nsViewManager.cpp.

{
  aView = mRootView;
  return NS_OK;
}

Here is the caller graph for this function:

nsView* nsViewManager::GetRootView ( ) const [inline]

Definition at line 456 of file nsViewManager.h.

{ return mRootView; }

Here is the caller graph for this function:

Definition at line 3372 of file nsViewManager.cpp.

{
  return gViewManagers;
}

Definition at line 3367 of file nsViewManager.cpp.

{
  return mVMCount;
}

Get the view observer associated with this manager.

Parameters:
aObserver- out parameter for observer
Returns:
error status

Implements nsIViewManager.

Definition at line 3326 of file nsViewManager.cpp.

{
  if (nsnull != mObserver) {
    aObserver = mObserver;
    NS_ADDREF(mObserver);
    return NS_OK;
  } else
    return NS_ERROR_NO_INTERFACE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 493 of file nsViewManager.h.

{ return mObserver; }

Here is the caller graph for this function:

nsresult nsViewManager::GetVisibleRect ( nsRect aVisibleRect) [private]

Determine the visible rect.

Parameters:
aVisibleRectvisible rectangle in twips
Returns:
NS_OK if successful, otherwise NS_ERROR_FAILURE.

Definition at line 4247 of file nsViewManager.cpp.

{
  nsresult rv = NS_OK;

  // Get the viewport scroller
  nsIScrollableView* scrollingView;
  GetRootScrollableView(&scrollingView);

  if (scrollingView) {   
    // Determine the visible rect in the scrolled view's coordinate space.
    // The size of the visible area is the clip view size
    nsScrollPortView* clipView = NS_STATIC_CAST(nsScrollPortView*, scrollingView);
    clipView->GetDimensions(aVisibleRect);

    scrollingView->GetScrollPosition(aVisibleRect.x, aVisibleRect.y);
  } else {
    rv = NS_ERROR_FAILURE;
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Retrieve the widget at the root of the view manager.

This is the widget associated with the root view, if the root view exists and has a widget.

Implements nsIViewManager.

Definition at line 3649 of file nsViewManager.cpp.

{
  *aWidget = GetWidget();
  NS_IF_ADDREF(*aWidget);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 241 of file nsViewManager.h.

{ return mRootView ? mRootView->GetWidget() : nsnull; }

Here is the call graph for this function:

Here is the caller graph for this function:

nsView * nsViewManager::GetWidgetView ( nsView aView) [static, private]

Returns the nearest parent view with an attached widget.

Can be the same view as passed-in.

Definition at line 4216 of file nsViewManager.cpp.

{
  while (aView) {
    if (aView->HasWidget())
      return aView;
    aView = aView->GetParent();
  }
  return nsnull;
}

Here is the call graph for this function:

NS_IMETHODIMP nsViewManager::GetWindowDimensions ( nscoord aWidth,
nscoord aHeight 
) [virtual]

Get the dimensions of the root window.

The dimensions are in twips

Parameters:
aWidthout parameter for width of window in twips
aHeightout parameter for height of window in twips

Implements nsIViewManager.

Definition at line 668 of file nsViewManager.cpp.

{
  if (nsnull != mRootView) {
    if (mDelayedResize == nsSize(NSCOORD_NONE, NSCOORD_NONE)) {
      nsRect dim;
      mRootView->GetDimensions(dim);
      *aWidth = dim.width;
      *aHeight = dim.height;
    } else {
      *aWidth = mDelayedResize.width;
      *aHeight = mDelayedResize.height;
    }
  }
  else
    {
      *aWidth = 0;
      *aHeight = 0;
    }
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsViewManager::GrabKeyEvents ( nsIView aView,
PRBool aResult 
) [virtual]

Used to grab/capture all keyboard events for a specific view, irrespective of the cursor position at which the event occurred.

Parameters:
aViewview to capture keyboard events
Returns:
event handling status

Implements nsIViewManager.

Definition at line 2619 of file nsViewManager.cpp.

NS_IMETHODIMP nsViewManager::GrabMouseEvents ( nsIView aView,
PRBool aResult 
) [virtual]

Used to grab/capture all mouse events for a specific view, irrespective of the cursor position at which the event occurred.

Parameters:
aViewview to capture mouse events
Returns:
event handling status

Implements nsIViewManager.

Definition at line 2593 of file nsViewManager.cpp.

{
  if (!IsRootVM()) {
    return RootViewManager()->GrabMouseEvents(aView, aResult);
  }

  // Along with nsView::SetVisibility, we enforce that the mouse grabber
  // can never be a hidden view.
  if (aView && NS_STATIC_CAST(nsView*, aView)->GetVisibility()
               == nsViewVisibility_kHide) {
    aView = nsnull;
  }

#ifdef DEBUG_mjudge
  if (aView)
    {
      printf("capturing mouse events for view %x\n",aView);
    }
  printf("removing mouse capture from view %x\n",mMouseGrabber);
#endif

  mMouseGrabber = NS_STATIC_CAST(nsView*, aView);
  aResult = PR_TRUE;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsEventStatus nsViewManager::HandleEvent ( nsView aView,
nsGUIEvent aEvent,
PRBool  aCaptured 
)

Definition at line 2503 of file nsViewManager.cpp.

                                                                                            {
//printf(" %d %d %d %d (%d,%d) \n", this, event->widget, event->widgetSupports, 
//       event->message, event->point.x, event->point.y);

  // Hold a refcount to the observer. The continued existence of the observer will
  // delay deletion of this view hierarchy should the event want to cause its
  // destruction in, say, some JavaScript event handler.
  nsCOMPtr<nsIViewObserver> obs = GetViewObserver();

  // accessibility events and key events are dispatched directly to the focused view
  if (aEvent->eventStructType == NS_ACCESSIBLE_EVENT
      || aEvent->message == NS_CONTEXTMENU_KEY
      || NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_EVENT(aEvent) || NS_IS_FOCUS_EVENT(aEvent)) {
    nsEventStatus status = nsEventStatus_eIgnore;
    if (obs) {
       PRBool handled;
       obs->HandleEvent(aView, aEvent, &status, PR_TRUE, handled);
    }
    return status;
  }
    
  nsAutoVoidArray targetViews;
  nsCOMArray<nsIViewObserver> heldRefCountsToOtherVMs;

  // In fact, we only need to take this expensive path when the event is a mouse event ... riiiight?
  PLArenaPool displayArena;
  PL_INIT_ARENA_POOL(&displayArena, "displayArena", 1024);
  BuildEventTargetList(targetViews, aView, aEvent, aCaptured, displayArena);

  nsEventStatus status = nsEventStatus_eIgnore;

  // get a death grip on any view managers' view observers (other than this one)
  PRInt32 i;
  for (i = 0; i < targetViews.Count(); i++) {
    DisplayListElement2* element = NS_STATIC_CAST(DisplayListElement2*, targetViews.ElementAt(i));
    nsView* v = element->mView;
    nsViewManager* vVM = v->GetViewManager();
    if (vVM != this) {
      nsIViewObserver* vobs = vVM->GetViewObserver();
      if (vobs) {
        heldRefCountsToOtherVMs.AppendObject(vobs);
      }
    }
  }

  // Save aEvent->point because child code might change it
  nsPoint pt = aEvent->point;
  for (i = 0; i < targetViews.Count(); i++) {
    DisplayListElement2* element = NS_STATIC_CAST(DisplayListElement2*, targetViews.ElementAt(i));
    nsView* v = element->mView;

    if (nsnull != v->GetClientData()) {
      PRBool handled = PR_FALSE;
      nsRect r;
      v->GetDimensions(r);

      aEvent->point = pt - (nsPoint(element->mAbsX, element->mAbsY) - r.TopLeft());

      nsViewManager* vVM = v->GetViewManager();
      if (vVM == this) {
        if (nsnull != obs) {
          obs->HandleEvent(v, aEvent, &status, i == targetViews.Count() - 1, handled);
        }
      } else {
        // Hold a refcount to the observer. The continued existence of the observer will
        // delay deletion of this view hierarchy should the event want to cause its
        // destruction in, say, some JavaScript event handler.
        nsCOMPtr<nsIViewObserver> vobs = vVM->GetViewObserver();
        if (vobs) {
          vobs->HandleEvent(v, aEvent, &status, i == targetViews.Count() - 1, handled);
        }
      }

      if (handled) {
        break;
      }
      // if the child says "not handled" but did something which deleted the entire view hierarchy,
      // we'll crash in the next iteration. Oh well. The old code would have crashed too.
    }
  }
  // Need to restore the event point here because someone may use it later.
  // In particular Windows seems to need this.
  aEvent->point = pt;

  PL_FreeArenaPool(&displayArena);
  PL_FinishArenaPool(&displayArena);

  return status;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 423 of file nsViewManager.h.

                              {
    NS_ASSERTION(IsRootVM(),
                 "IncrementUpdateCount called on non-root viewmanager");
    ++mUpdateCnt;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Initialize the ViewManager Note: this instance does not hold a reference to the viewobserver because it holds a reference to this instance.

Returns:
The result of the initialization, NS_OK if no errors

Implements nsIViewManager.

Definition at line 578 of file nsViewManager.cpp.

Here is the call graph for this function:

NS_IMETHODIMP nsViewManager::InsertChild ( nsIView aParent,
nsIView aChild,
nsIView aSibling,
PRBool  aAfter 
) [virtual]

Given a parent view, insert another view as its child.

aSibling and aAbove control the "document order" for the insertion. If aSibling is null, the view is inserted at the end of the document order if aAfter is PR_TRUE, otherwise it is inserted at the beginning. If aSibling is non-null, then if aAfter is PR_TRUE, the view is inserted after the sibling in document order (appearing above the sibling unless overriden by z-order). If it is PR_FALSE, the view is inserted before the sibling. The view manager generates the appopriate dirty regions.

Parameters:
aParentparent view
aChildchild view
aSiblingsibling view
aAfterafter or before in the document order

Implements nsIViewManager.

Definition at line 2693 of file nsViewManager.cpp.

{
  nsView* parent = NS_STATIC_CAST(nsView*, aParent);
  nsView* child = NS_STATIC_CAST(nsView*, aChild);
  nsView* sibling = NS_STATIC_CAST(nsView*, aSibling);
  
  NS_PRECONDITION(nsnull != parent, "null ptr");
  NS_PRECONDITION(nsnull != child, "null ptr");
  NS_ASSERTION(sibling == nsnull || sibling->GetParent() == parent,
               "tried to insert view with invalid sibling");
  NS_ASSERTION(!IsViewInserted(child), "tried to insert an already-inserted view");

  if ((nsnull != parent) && (nsnull != child))
    {
      // if aAfter is set, we will insert the child after 'prev' (i.e. after 'kid' in document
      // order, otherwise after 'kid' (i.e. before 'kid' in document order).

#if 1
      if (nsnull == aSibling) {
        if (aAfter) {
          // insert at end of document order, i.e., before first view
          // this is the common case, by far
          parent->InsertChild(child, nsnull);
          ReparentWidgets(child, parent);
        } else {
          // insert at beginning of document order, i.e., after last view
          nsView *kid = parent->GetFirstChild();
          nsView *prev = nsnull;
          while (kid) {
            prev = kid;
            kid = kid->GetNextSibling();
          }
          // prev is last view or null if there are no children
          parent->InsertChild(child, prev);
          ReparentWidgets(child, parent);
        }
      } else {
        nsView *kid = parent->GetFirstChild();
        nsView *prev = nsnull;
        while (kid && sibling != kid) {
          //get the next sibling view
          prev = kid;
          kid = kid->GetNextSibling();
        }
        NS_ASSERTION(kid != nsnull,
                     "couldn't find sibling in child list");
        if (aAfter) {
          // insert after 'kid' in document order, i.e. before in view order
          parent->InsertChild(child, prev);
          ReparentWidgets(child, parent);
        } else {
          // insert before 'kid' in document order, i.e. after in view order
          parent->InsertChild(child, kid);
          ReparentWidgets(child, parent);
        }
      }
#else // don't keep consistent document order, but order things by z-index instead
      // essentially we're emulating the old InsertChild(parent, child, zindex)
      PRInt32 zIndex = child->GetZIndex();
      while (nsnull != kid)
        {
          PRInt32 idx = kid->GetZIndex();

          if (CompareZIndex(zIndex, child->IsTopMost(), child->GetZIndexIsAuto(),
                            idx, kid->IsTopMost(), kid->GetZIndexIsAuto()) >= 0)
            break;

          prev = kid;
          kid = kid->GetNextSibling();
        }

      parent->InsertChild(child, prev);
      ReparentWidgets(child, parent);
#endif

      // if the parent view is marked as "floating", make the newly added view float as well.
      if (parent->GetFloating())
        child->SetFloating(PR_TRUE);

      //and mark this area as dirty if the view is visible...

      if (nsViewVisibility_kHide != child->GetVisibility())
        UpdateView(child, NS_VMREFRESH_NO_SYNC);
    }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsViewManager::InsertChild ( nsIView parent,
nsIView child,
PRInt32  zindex 
)

Definition at line 2800 of file nsViewManager.cpp.

{
  // no-one really calls this with anything other than aZIndex == 0 on a fresh view
  // XXX this method should simply be eliminated and its callers redirected to the real method
  SetViewZIndex(aChild, PR_FALSE, aZIndex, PR_FALSE);
  return InsertChild(aParent, aChild, nsnull, PR_TRUE);
}

Here is the call graph for this function:

NS_IMETHODIMP nsViewManager::InsertZPlaceholder ( nsIView aParent,
nsIView aChild,
nsIView aSibling,
PRBool  aAfter 
) [virtual]

Given a parent view, insert a placeholder for a view that logically belongs to this parent but has to be moved somewhere else for geometry reasons ("fixed" positioning).

Parameters:
aParentparent view
aChildchild view
aSiblingsibling view
aAfterafter or before in the document order

Implements nsIViewManager.

Definition at line 2781 of file nsViewManager.cpp.

{
  nsView* parent = NS_STATIC_CAST(nsView*, aParent);
  nsView* child = NS_STATIC_CAST(nsView*, aChild);

  NS_PRECONDITION(nsnull != parent, "null ptr");
  NS_PRECONDITION(nsnull != child, "null ptr");

  nsZPlaceholderView* placeholder = new nsZPlaceholderView(this);
  // mark the placeholder as "shown" so that it will be included in a built display list
  placeholder->SetParent(parent);
  placeholder->SetReparentedView(child);
  placeholder->SetZIndex(child->GetZIndexIsAuto(), child->GetZIndex(), child->IsTopMost());
  child->SetZParent(placeholder);
  
  return InsertChild(parent, placeholder, aSibling, aAfter);
}

Here is the call graph for this function:

Definition at line 4589 of file nsViewManager.cpp.

{
  if (mRootView) {
    if (!IsRootVM()) {
      NS_RELEASE(mRootViewManager);
    }
    nsView *parent = mRootView->GetParent();
    if (parent) {
      mRootViewManager = parent->GetViewManager()->RootViewManager();
      NS_ADDREF(mRootViewManager);
      NS_ASSERTION(mRootViewManager != this,
                   "Root view had a parent, but it has the same view manager");
    } else {
      mRootViewManager = this;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewManager::InvalidateHorizontalBandDifference ( nsView aView,
const nsRect aRect,
const nsRect aCutOut,
PRUint32  aUpdateFlags,
nscoord  aY1,
nscoord  aY2,
PRBool  aInCutOut 
) [private]

Definition at line 2853 of file nsViewManager.cpp.

                                                                     {
  nscoord height = aY2 - aY1;
  if (aRect.x < aCutOut.x) {
    nsRect r(aRect.x, aY1, aCutOut.x - aRect.x, height);
    UpdateView(aView, r, aUpdateFlags);
  }
  if (!aInCutOut && aCutOut.x < aCutOut.XMost()) {
    nsRect r(aCutOut.x, aY1, aCutOut.width, height);
    UpdateView(aView, r, aUpdateFlags);
  }
  if (aCutOut.XMost() < aRect.XMost()) {
    nsRect r(aCutOut.XMost(), aY1, aRect.XMost() - aCutOut.XMost(), height);
    UpdateView(aView, r, aUpdateFlags);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewManager::InvalidateRectDifference ( nsView aView,
const nsRect aRect,
const nsRect aCutOut,
PRUint32  aUpdateFlags 
) [private]

Definition at line 2870 of file nsViewManager.cpp.

                         {
  if (aRect.y < aCutOut.y) {
    InvalidateHorizontalBandDifference(aView, aRect, aCutOut, aUpdateFlags, aRect.y, aCutOut.y, PR_FALSE);
  }
  if (aCutOut.y < aCutOut.YMost()) {
    InvalidateHorizontalBandDifference(aView, aRect, aCutOut, aUpdateFlags, aCutOut.y, aCutOut.YMost(), PR_TRUE);
  }
  if (aCutOut.YMost() < aRect.YMost()) {
    InvalidateHorizontalBandDifference(aView, aRect, aCutOut, aUpdateFlags, aCutOut.YMost(), aRect.YMost(), PR_FALSE);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsViewManager::IsPainting ( PRBool aIsPainting) [virtual]

Indicate whether the viewmanager is currently painting.

Parameters:
aPaintingPR_TRUE if the viewmanager is painting PR_FALSE otherwise

Implements nsIViewManager.

Definition at line 4378 of file nsViewManager.cpp.

{
  aIsPainting = IsPainting();
  return NS_OK;
}

Here is the call graph for this function:

PRBool nsViewManager::IsPainting ( ) const [inline, private]

Definition at line 447 of file nsViewManager.h.

                            {
    return RootViewManager()->mPainting;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 491 of file nsViewManager.h.

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsViewManager::IsRootVM ( ) const [inline]

Definition at line 462 of file nsViewManager.h.

{ return this == RootViewManager(); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3235 of file nsViewManager.cpp.

{
  if (mRootView == aView) {
    return PR_TRUE;
  } else if (aView->GetParent() == nsnull) {
    return PR_FALSE;
  } else {
    nsView* view = aView->GetParent()->GetFirstChild();
    while (view != nsnull) {
      if (view == aView) {
        return PR_TRUE;
      }        
      view = view->GetNextSibling();
    }
    return PR_FALSE;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2825 of file nsViewManager.cpp.

{
  nsView* view = NS_STATIC_CAST(nsView*, aView);

  nsPoint pt = view->GetPosition();
  MoveViewTo(view, aX + pt.x, aY + pt.y);
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsViewManager::MoveViewTo ( nsIView aView,
nscoord  aX,
nscoord  aY 
) [virtual]

Move a view to the specified position, provided in parent coordinates.

The new position is the (0, 0) origin for the view's coordinate system. The view's bounds may extend above or to the left of this point. The view manager generates the appropriate dirty regions.

Parameters:
aViewview to move
aXx value for new view position
aYy value for new view position

Implements nsIViewManager.

Definition at line 2834 of file nsViewManager.cpp.

{
  nsView* view = NS_STATIC_CAST(nsView*, aView);
  nsPoint oldPt = view->GetPosition();
  nsRect oldArea = view->GetBounds();
  view->SetPosition(aX, aY);

  // only do damage control if the view is visible

  if ((aX != oldPt.x) || (aY != oldPt.y)) {
    if (view->GetVisibility() != nsViewVisibility_kHide) {
      nsView* parentView = view->GetParent();
      UpdateView(parentView, oldArea, NS_VMREFRESH_NO_SYNC);
      UpdateView(parentView, view->GetBounds(), NS_VMREFRESH_NO_SYNC);
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Create an ordinary view.

Parameters:
aBoundsinitial bounds for view XXX We should eliminate this parameter; you can set the bounds after CreateView
aParentintended parent for view. this is not actually set in the nsIView through this method. it is only used by the initialization code to walk up the view tree, if necessary, to find resources. XXX We should eliminate this parameter!
aVisibilityFlaginitial visibility state of view XXX We should eliminate this parameter; you can set it after CreateView
Returns:
The new view

Reimplemented from nsIViewManager.

Create an scrollable view.

Parameters:
aBoundsinitial bounds for view XXX We should eliminate this parameter; you can set the bounds after CreateScrollableView
aParentintended parent for view. this is not actually set in the nsIView through this method. it is only used by the initialization code to walk up the view tree, if necessary, to find resources. XXX We should eliminate this parameter!
Returns:
The new view

Reimplemented from nsIViewManager.

void nsViewManager::OptimizeDisplayList ( const nsVoidArray aDisplayList,
const nsRegion &  aDamageRegion,
nsRect aFinalTransparentRect,
nsRegion &  aOpaqueRegion,
PRBool  aTreatUniformAsOpaque 
) [private]

Walk the display list, looking for opaque views, and remove any views that are behind them and totally occluded.

Parameters:
aFinalTransparentRectReceives a rectangle enclosing all pixels in the damage rectangle which will not be opaquely painted over by the display list. Usually this will be empty, but nothing really prevents someone from creating a set of views that are (for example) all transparent.

Definition at line 3994 of file nsViewManager.cpp.

{
  // Mark all views inside a PUSH_FILTER/POP_FILTER as being translucent.
  // If we don't do this, we'll incorrectly optimize by thinking views are
  // opaque when they really aren't.
  PRInt32 i;
  PRInt32 filterDepth = 0;
  for (i = 0; i < aDisplayList->Count(); ++i) {
    DisplayListElement2* element = NS_STATIC_CAST(DisplayListElement2*,
                                                  aDisplayList->ElementAt(i));
    if (element->mFlags & PUSH_FILTER) {
      ++filterDepth;
    }
    if (filterDepth > 0 && (element->mFlags & VIEW_RENDERED)) {
      element->mFlags |= VIEW_TRANSLUCENT;
    }
    if (element->mFlags & POP_FILTER) {
      --filterDepth;
    }
  }

  for (i = aDisplayList->Count() - 1; i >= 0; --i) {
    DisplayListElement2* element = NS_STATIC_CAST(DisplayListElement2*, aDisplayList->ElementAt(i));
    if (element->mFlags & VIEW_RENDERED) {
      nsRegion tmpRgn;
      tmpRgn.Sub(element->mBounds, aOpaqueRegion);
      tmpRgn.And(tmpRgn, aDamageRegion);

      if (tmpRgn.IsEmpty()) {
        element->mFlags &= ~VIEW_RENDERED;
      } else {
        element->mBounds = tmpRgn.GetBounds();

        PRBool tooComplex = aOpaqueRegion.GetNumRects() > MAX_OPAQUE_REGION_COMPLEXITY &&
          !element->mBounds.Contains(aOpaqueRegion.GetBounds());
        // See whether we should add this view's bounds to aOpaqueRegion
        if (!tooComplex &&
            // a view is opaque if it is neither transparent nor transluscent
            (!(element->mFlags & (VIEW_TRANSPARENT | VIEW_TRANSLUCENT))
            // also, treat it as opaque if it's drawn onto a uniform background
            // and we're doing scrolling analysis; if the background is uniform,
            // we don't care what's under it. But the background might be translucent
            // because of some enclosing opacity group, in which case we do care
            // what's under it. Unfortunately we don't know exactly where the
            // background comes from ... it may not even have a view ... but
            // the side condition on SetHasUniformBackground ensures that
            // if the background is translucent, then this view is also marked
            // translucent.
            || (element->mView->HasUniformBackground() && aTreatUniformAsOpaque
                && !(element->mFlags & VIEW_TRANSLUCENT)))) {
          aOpaqueRegion.Or(aOpaqueRegion, element->mBounds);
        }
      }
    }
  }

  nsRegion tmpRgn;
  tmpRgn.Sub(aDamageRegion, aOpaqueRegion);
  aFinalTransparentRect = tmpRgn.GetBounds();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewManager::OptimizeDisplayListClipping ( const nsVoidArray aDisplayList,
PRBool  aHaveClip,
nsRect aClipRect,
PRInt32 aIndex,
PRBool aAnyRendered 
) [private]

Definition at line 4058 of file nsViewManager.cpp.

{   
  aAnyRendered = PR_FALSE;

  while (aIndex < aDisplayList->Count()) {
    DisplayListElement2* element =
      NS_STATIC_CAST(DisplayListElement2*, aDisplayList->ElementAt(aIndex));
    aIndex++;

    if (element->mFlags & VIEW_RENDERED) {
      aAnyRendered = PR_TRUE;

      if (aHaveClip && (element->mFlags & VIEW_CLIPPED)) {
        nsRect newClip;
        newClip.IntersectRect(aClipRect, element->mBounds);
        // no need to clip if the clip rect doesn't change
        if (newClip == aClipRect) {
          element->mFlags &= ~VIEW_CLIPPED;
        }
      }
    }

    if (element->mFlags & PUSH_CLIP) {
      nsRect newClip;
      if (aHaveClip) {
        newClip.IntersectRect(aClipRect, element->mBounds);
      } else {
        newClip = element->mBounds;
      }

      PRBool anyRenderedViews = PR_FALSE;
      OptimizeDisplayListClipping(aDisplayList, PR_TRUE, newClip, aIndex, anyRenderedViews);
      DisplayListElement2* popElement =
        NS_STATIC_CAST(DisplayListElement2*, aDisplayList->ElementAt(aIndex - 1));
      NS_ASSERTION(popElement->mFlags & POP_CLIP, "Must end with POP!");

      if (anyRenderedViews) {
        aAnyRendered = PR_TRUE;
      }
      if (!anyRenderedViews || (aHaveClip && newClip == aClipRect)) {
        // no need to clip if nothing's going to be rendered
        // ... or if the clip rect didn't change
        element->mFlags &= ~PUSH_CLIP;
        popElement->mFlags &= ~POP_CLIP;
      }
    }

    if (element->mFlags & POP_CLIP) {
      return;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsRect nsViewManager::OptimizeTranslucentRegions ( const nsVoidArray aDisplayList,
PRInt32 aIndex,
nsRegion *  aOpaqueRegion 
) [private]

Definition at line 4119 of file nsViewManager.cpp.

{
  nsRect r;
  while (*aIndex < aDisplayList.Count()) {
    DisplayListElement2* element =
      NS_STATIC_CAST(DisplayListElement2*, aDisplayList.ElementAt(*aIndex));
    (*aIndex)++;

    if (element->mFlags & VIEW_RENDERED) {
      r.UnionRect(r, element->mBounds);
      // the bounds of a non-transparent element are added to the opaque
      // region
      if (!element->mView->IsTransparent() && aOpaqueRegion) {
        aOpaqueRegion->Or(*aOpaqueRegion, element->mBounds);
      }
    }

    if (element->mFlags & PUSH_FILTER) {
      // the region inside the PUSH/POP pair that's painted opaquely
      nsRegion opaqueRegion;
      // save the bounds of the area that's painted by elements between the PUSH/POP
      element->mBounds = OptimizeTranslucentRegions(aDisplayList, aIndex,
                                                    &opaqueRegion);
      DisplayListElement2* popElement =
        NS_STATIC_CAST(DisplayListElement2*, aDisplayList.ElementAt(*aIndex - 1));
      popElement->mBounds = element->mBounds;
      NS_ASSERTION(popElement->mFlags & POP_FILTER, "Must end with POP!");

      // don't bother with filters if nothing is visible inside the filter
      if (element->mBounds.IsEmpty()) {
        element->mFlags &= ~PUSH_FILTER;
        popElement->mFlags &= ~POP_FILTER;
      } else {
        nsRegion tmpRegion;
        tmpRegion.Sub(element->mBounds, opaqueRegion);
        if (!tmpRegion.IsEmpty()) {
          // remember whether this PUSH_FILTER/POP_FILTER contents are fully opaque or not
          element->mFlags |= VIEW_TRANSPARENT;
        }
      }

      // The filter doesn't paint opaquely, so don't add anything to aOpaqueRegion
      r.UnionRect(r, element->mBounds);
    }
    if (element->mFlags & POP_FILTER) {
      return r;
    }
  }

  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewManager::PaintView ( nsView aView,
nsIRenderingContext aRC,
nscoord  x,
nscoord  y,
const nsRect aDamageRect 
) [private]

Definition at line 1463 of file nsViewManager.cpp.

{
  aRC.PushState();
  aRC.Translate(x, y);
  PRBool unused;
  aView->Paint(aRC, aDamageRect, 0, unused);
  aRC.PopState();
}

Here is the call graph for this function:

Definition at line 428 of file nsViewManager.cpp.

{
  NS_ASSERTION(IsRootVM(), "Caller screwed up");
  
  nsCOMPtr<nsIEventQueue> eventQueue;
  mEventQueueService->GetSpecialEventQueue(
    nsIEventQueueService::UI_THREAD_EVENT_QUEUE, getter_AddRefs(eventQueue));
  NS_ASSERTION(nsnull != eventQueue, "Event queue is null");

  if (eventQueue != mInvalidateEventQueue) {
    nsInvalidateEvent* ev = new nsInvalidateEvent(this);
    eventQueue->PostEvent(ev);
    mInvalidateEventQueue = eventQueue;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 497 of file nsViewManager.h.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4438 of file nsViewManager.cpp.

{
  NS_ASSERTION(IsRootVM(),
               "Incorrectly targeted invalidate event");
  // If we're in the middle of an update batch, just repost the event,
  // to be processed when the batch ends.
  PRBool processEvent = (mUpdateBatchCnt == 0);
  if (processEvent) {
    FlushPendingInvalidates();
  }
  mInvalidateEventQueue = nsnull;
  if (!processEvent) {
    // We didn't actually process this event... post a new one
    PostInvalidateEvent();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewManager::ProcessPendingUpdates ( nsView aView,
PRBool  aDoInvalidate 
) [private]

Definition at line 1592 of file nsViewManager.cpp.

{
  NS_ASSERTION(IsRootVM(), "Updates will be missed");

  // Protect against a null-view.
  if (!aView) {
    return;
  }

  if (aView->HasWidget()) {
    aView->ResetWidgetBounds(PR_FALSE, PR_FALSE, PR_TRUE);
  }

  // process pending updates in child view.
  for (nsView* childView = aView->GetFirstChild(); childView;
       childView = childView->GetNextSibling()) {
    ProcessPendingUpdates(childView, aDoInvalidate);
  }

  if (aDoInvalidate && aView->HasNonEmptyDirtyRegion()) {
    // Push out updates after we've processed the children; ensures that
    // damage is applied based on the final widget geometry
    NS_ASSERTION(mRefreshEnabled, "Cannot process pending updates with refresh disabled");
    nsRegion* dirtyRegion = aView->GetDirtyRegion();
    if (dirtyRegion) {
      UpdateWidgetArea(aView, *dirtyRegion, nsnull);
      dirtyRegion->SetEmpty();
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4539 of file nsViewManager.cpp.

{
  // allow new event to be posted while handling this one only if the
  // source of the event is a scroll (to prevent infinite reflow loops)
  if (aFromScroll)
    mSynthMouseMoveEventQueue = nsnull;

  if (mMouseLocation == nsPoint(NSCOORD_NONE, NSCOORD_NONE) || !mRootView) {
    mSynthMouseMoveEventQueue = nsnull;
    return;
  }

  // Hold a ref to ourselves so DispatchEvent won't destroy us (since
  // we need to access members after we call DispatchEvent).
  nsCOMPtr<nsIViewManager> kungFuDeathGrip(this);
  
#ifdef DEBUG_MOUSE_LOCATION
  printf("[vm=%p]synthesizing mouse move to (%d,%d)\n",
         this, mMouseLocation.x, mMouseLocation.y);
#endif

  nsPoint pt = mMouseLocation;
  pt.x = NSToCoordRound(mMouseLocation.x*mPixelsToTwips);
  pt.y = NSToCoordRound(mMouseLocation.y*mPixelsToTwips);
  // This could be a bit slow (traverses entire view hierarchy)
  // but it's OK to do it once per synthetic mouse event
  nsView* view = FindFloatingViewContaining(mRootView, pt);
  nsPoint offset(0, 0);
  if (!view) {
    view = mRootView;
  } else {
    offset = view->GetOffsetTo(mRootView);
    offset.x = NSToIntRound(offset.x*mTwipsToPixels);
    offset.y = NSToIntRound(offset.y*mTwipsToPixels);
  }
  nsMouseEvent event(PR_TRUE, NS_MOUSE_MOVE, view->GetWidget(),
                     nsMouseEvent::eSynthesized);

  event.point = mMouseLocation - offset;
  event.time = PR_IntervalNow();
  // XXX set event.isShift, event.isControl, event.isAlt, event.isMeta ?

  nsEventStatus status;
  view->GetViewManager()->DispatchEvent(&event, &status);

  if (!aFromScroll)
    mSynthMouseMoveEventQueue = nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewManager::Refresh ( nsView aView,
nsIRenderingContext aContext,
nsIRegion region,
PRUint32  aUpdateFlags 
) [private]

aRegion is given in device coordinates!!

Definition at line 759 of file nsViewManager.cpp.

{
  NS_ASSERTION(aRegion != nsnull, "Null aRegion");

  if (! IsRefreshEnabled())
    return;

  nsRect viewRect;
  aView->GetDimensions(viewRect);

  // damageRegion is the damaged area, in twips, relative to the view origin
  nsRegion damageRegion;
  // convert pixels-relative-to-widget-origin to twips-relative-to-widget-origin
  ConvertNativeRegionToAppRegion(aRegion, &damageRegion, mContext);
  // move it from widget coordinates into view coordinates
  damageRegion.MoveBy(viewRect.x, viewRect.y);

  // Clip it to the view; shouldn't be necessary, but do it for sanity
  damageRegion.And(damageRegion, viewRect);
  if (damageRegion.IsEmpty()) {
#ifdef DEBUG_roc
    nsRect damageRect = damageRegion.GetBounds();
    printf("XXX Damage rectangle (%d,%d,%d,%d) does not intersect the widget's view (%d,%d,%d,%d)!\n",
           damageRect.x, damageRect.y, damageRect.width, damageRect.height,
           viewRect.x, viewRect.y, viewRect.width, viewRect.height);
#endif
    return;
  }

#ifdef NS_VM_PERF_METRICS
  MOZ_TIMER_DEBUGLOG(("Reset nsViewManager::Refresh(region), this=%p\n", this));
  MOZ_TIMER_RESET(mWatch);

  MOZ_TIMER_DEBUGLOG(("Start: nsViewManager::Refresh(region)\n"));
  MOZ_TIMER_START(mWatch);
#endif

  NS_ASSERTION(!IsPainting(), "recursive painting not permitted");
  if (IsPainting()) {
    RootViewManager()->mRecursiveRefreshPending = PR_TRUE;
    return;
  }  
  SetPainting(PR_TRUE);

  // force double buffering in general
  aUpdateFlags |= NS_VMREFRESH_DOUBLE_BUFFER;

  if (!DoDoubleBuffering())
    aUpdateFlags &= ~NS_VMREFRESH_DOUBLE_BUFFER;

  // check if the rendering context wants double-buffering or not
  if (aContext) {
    PRBool contextWantsBackBuffer = PR_TRUE;
    aContext->UseBackbuffer(&contextWantsBackBuffer);
    if (!contextWantsBackBuffer)
      aUpdateFlags &= ~NS_VMREFRESH_DOUBLE_BUFFER;
  }
  
  if (PR_FALSE == mAllowDoubleBuffering) {
    // Turn off double-buffering of the display
    aUpdateFlags &= ~NS_VMREFRESH_DOUBLE_BUFFER;
  }

  nsCOMPtr<nsIRenderingContext> localcx;
  nsIDrawingSurface*    ds = nsnull;

  if (nsnull == aContext)
    {
      localcx = CreateRenderingContext(*aView);

      //couldn't get rendering context. this is ok at init time atleast
      if (nsnull == localcx) {
        SetPainting(PR_FALSE);
        return;
      }
    } else {
      // plain assignment grabs another reference.
      localcx = aContext;
    }

  // notify the listeners.
  if (nsnull != mCompositeListeners) {
    PRUint32 listenerCount;
    if (NS_SUCCEEDED(mCompositeListeners->Count(&listenerCount))) {
      nsCOMPtr<nsICompositeListener> listener;
      for (PRUint32 i = 0; i < listenerCount; i++) {
        if (NS_SUCCEEDED(mCompositeListeners->QueryElementAt(i, NS_GET_IID(nsICompositeListener), getter_AddRefs(listener)))) {
          listener->WillRefreshRegion(this, aView, aContext, aRegion, aUpdateFlags);
        }
      }
    }
  }

  // damageRect is the clipped damage area bounds, in twips-relative-to-view-origin
  nsRect damageRect = damageRegion.GetBounds();
  // widgetDamageRectInPixels is the clipped damage area bounds,
  // in pixels-relative-to-widget-origin
  nsRect widgetDamageRectInPixels = damageRect;
  widgetDamageRectInPixels.MoveBy(-viewRect.x, -viewRect.y);
  float t2p;
  t2p = mContext->AppUnitsToDevUnits();
  widgetDamageRectInPixels.ScaleRoundOut(t2p);

  // On the Mac, we normally turn doublebuffering off because Quartz is
  // doublebuffering for us. But we need to turn it on anyway if we need
  // to use our blender, which requires access to the "current pixel values"
  // when it blends onto the canvas.
  nsAutoVoidArray displayList;
  PLArenaPool displayArena;
  PL_INIT_ARENA_POOL(&displayArena, "displayArena", 1024);
  PRBool anyTransparentPixels
    = BuildRenderingDisplayList(aView, damageRegion, &displayList, displayArena,
                                PR_FALSE, PR_FALSE, nsnull);
  PRBool needBlending = PR_FALSE;
  for (PRInt32 i = 0; i < displayList.Count(); i++) {
    DisplayListElement2* element = NS_STATIC_CAST(DisplayListElement2*, displayList.ElementAt(i));
    if (element->mFlags & PUSH_FILTER) {
      aUpdateFlags |= NS_VMREFRESH_DOUBLE_BUFFER;
      needBlending = PR_TRUE;
      break;
    }
  } 

  if (aUpdateFlags & NS_VMREFRESH_DOUBLE_BUFFER)
  {
    nsRect maxWidgetSize;
    GetMaxWidgetBounds(maxWidgetSize);

    nsRect r(0, 0, widgetDamageRectInPixels.width, widgetDamageRectInPixels.height);
    if (NS_FAILED(localcx->GetBackbuffer(r, maxWidgetSize, needBlending, ds))) {
      //Failed to get backbuffer so turn off double buffering
      aUpdateFlags &= ~NS_VMREFRESH_DOUBLE_BUFFER;
    }
  }

  // painting will be done in aView's coordinates
  PRBool usingDoubleBuffer = (aUpdateFlags & NS_VMREFRESH_DOUBLE_BUFFER) && ds;
  if (usingDoubleBuffer) {
    // Adjust translations because the backbuffer holds just the damaged area,
    // not the whole widget

    // RenderViews draws in view coordinates. We want (damageRect.x, damageRect.y)
    // to be translated to (0,0) in the backbuffer. So:
    localcx->Translate(-damageRect.x, -damageRect.y);
    // We're going to reset the clip region for the backbuffer. We can't
    // just use damageRegion because nsIRenderingContext::SetClipRegion doesn't
    // translate/scale the coordinates (grrrrrrrrrr)
    // So we have to translate the region before we use it. aRegion is in
    // pixels-relative-to-widget-origin, so:
    aRegion->Offset(-widgetDamageRectInPixels.x, -widgetDamageRectInPixels.y);
  } else {
    // RenderViews draws in view coordinates. We want (viewRect.x, viewRect.y)
    // to be translated to (0,0) in the widget. So:
    localcx->Translate(-viewRect.x, -viewRect.y);
  }

  // Note that nsIRenderingContext::SetClipRegion always works in pixel coordinates,
  // and nsIRenderingContext::SetClipRect always works in app coordinates. Stupid huh?
  // Also, SetClipRegion doesn't subject its argument to the current transform, but
  // SetClipRect does.
  localcx->SetClipRegion(*aRegion, nsClipCombine_kReplace);
  localcx->SetClipRect(damageRect, nsClipCombine_kIntersect);

  if (anyTransparentPixels) {
    // There are some bits here that aren't going to be completely painted unless we do it now.
    // XXX Which color should we use for these bits?
    localcx->SetColor(NS_RGB(128, 128, 128));
    localcx->FillRect(damageRegion.GetBounds());
  }
  RenderViews(aView, *localcx, damageRegion, ds, displayList);
  PL_FreeArenaPool(&displayArena);
  PL_FinishArenaPool(&displayArena);

  if (usingDoubleBuffer) {
    // Flush bits back to the screen

    // Restore aRegion to pixels-relative-to-widget-origin
    aRegion->Offset(widgetDamageRectInPixels.x, widgetDamageRectInPixels.y);
    // Restore translation to its previous state (so that (0,0) is the widget origin)
    localcx->Translate(damageRect.x, damageRect.y);
    // Make damageRect twips-relative-to-widget-origin
    damageRect.MoveBy(-viewRect.x, -viewRect.y);
    // Reset clip region to widget-relative
    localcx->SetClipRegion(*aRegion, nsClipCombine_kReplace);
    localcx->SetClipRect(damageRect, nsClipCombine_kIntersect);
    // neither source nor destination are transformed
    localcx->CopyOffScreenBits(ds, 0, 0, widgetDamageRectInPixels, NS_COPYBITS_USE_SOURCE_CLIP_REGION);
  } else {
    // undo earlier translation
    localcx->Translate(viewRect.x, viewRect.y);
  }

  SetPainting(PR_FALSE);

  // notify the listeners.
  if (nsnull != mCompositeListeners) {
    PRUint32 listenerCount;
    if (NS_SUCCEEDED(mCompositeListeners->Count(&listenerCount))) {
      nsCOMPtr<nsICompositeListener> listener;
      for (PRUint32 i = 0; i < listenerCount; i++) {
        if (NS_SUCCEEDED(mCompositeListeners->QueryElementAt(i, NS_GET_IID(nsICompositeListener), getter_AddRefs(listener)))) {
          listener->DidRefreshRegion(this, aView, aContext, aRegion, aUpdateFlags);
        }
      }
    }
  }

  if (RootViewManager()->mRecursiveRefreshPending) {
    // Unset this flag first, since if aUpdateFlags includes NS_VMREFRESH_IMMEDIATE
    // we'll reenter this code from the UpdateAllViews call.
    RootViewManager()->mRecursiveRefreshPending = PR_FALSE;
    UpdateAllViews(aUpdateFlags);
  }

  localcx->ReleaseBackbuffer();

#ifdef NS_VM_PERF_METRICS
  MOZ_TIMER_DEBUGLOG(("Stop: nsViewManager::Refresh(region), this=%p\n", this));
  MOZ_TIMER_STOP(mWatch);
  MOZ_TIMER_LOG(("vm2 Paint time (this=%p): ", this));
  MOZ_TIMER_PRINT(mWatch);
#endif

}

Here is the call graph for this function:

Here is the caller graph for this function:

Remove a specific child view from its parent.

This will NOT remove its placeholder if there is one. The view manager generates the appropriate dirty regions.

Parameters:
aParentparent view
aChildchild view

Implements nsIViewManager.

Definition at line 2808 of file nsViewManager.cpp.

{
  nsView* child = NS_STATIC_CAST(nsView*, aChild);

  NS_PRECONDITION(nsnull != child, "null ptr");

  nsView* parent = child->GetParent();

  if ((nsnull != parent) && (nsnull != child))
    {
      UpdateView(child, NS_VMREFRESH_NO_SYNC);
      parent->RemoveChild(child);
    }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Remove a listener from the view manager's composite listener list.

Parameters:
aListener- listener to remove
Returns:
error status

Implements nsIViewManager.

Definition at line 3641 of file nsViewManager.cpp.

{
  if (nsnull != mCompositeListeners) {
    return mCompositeListeners->RemoveElement(aListener);
  }
  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Definition at line 1439 of file nsViewManager.cpp.

                                                                       {
  if (!aRC)
    return;
  
  PRBool clipEmpty;
  nsRect r;
  nsView* view = element->mView;

  view->GetDimensions(r);

  aRC->PushState();

  nscoord x = element->mAbsX - r.x, y = element->mAbsY - r.y;
  aRC->Translate(x, y);

  nsRect drect(element->mBounds.x - x, element->mBounds.y - y,
               element->mBounds.width, element->mBounds.height);
  
  element->mView->Paint(*aRC, drect, 0, clipEmpty);
  
  aRC->PopState();
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsViewManager::RenderOffscreen ( nsIView aView,
nsRect  aRect,
PRBool  aUntrusted,
PRBool  aIgnoreViewportScrolling,
nscolor  aBackgroundColor,
nsIRenderingContext **  aRenderedContext 
) [virtual]

Dump the specified view into a new offscreen rendering context.

Parameters:
aRectis the region to capture into the offscreen buffer, in the view's coordinate system
aUntrustedset to PR_TRUE if the contents may be passed to malicious agents. E.g. we might choose not to paint the contents of sensitive widgets such as the file name in a file upload widget, and we might choose not to paint themes.
aIgnoreViewportScrollingignore clipping/scrolling/scrollbar painting due to scrolling in the viewport
aBackgroundColora background color to render onto
aRenderedContextgets set to a rendering context whose offscreen buffer can be locked to get the data. The buffer's size will be aRect's size. In all cases the caller must clean it up by calling cx->DestroyDrawingSurface(cx->GetDrawingSurface()).

Implements nsIViewManager.

Definition at line 3520 of file nsViewManager.cpp.

{
  nsView* view = NS_STATIC_CAST(nsView*, aView);

  *aRenderedContext = nsnull;

  NS_ASSERTION(!aUntrusted, "We don't support untrusted yet");
  if (aUntrusted)
    return NS_ERROR_NOT_IMPLEMENTED;

  nsCOMPtr<nsIRenderingContext> tmpContext
    = CreateRenderingContext(*view);
  if (!tmpContext)
    return NS_ERROR_FAILURE;

  nsRect bounds(nsPoint(0, 0), aRect.Size());
  bounds.ScaleRoundOut(mTwipsToPixels);
  
  nsIDrawingSurface* surface;
  nsresult rv
    = tmpContext->CreateDrawingSurface(bounds, NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS,
                                       surface);
  if (NS_FAILED(rv))
    return NS_ERROR_FAILURE;
  nsCOMPtr<nsIRenderingContext> localcx;
  rv = NewOffscreenContext(mContext, surface, aRect, getter_AddRefs(localcx));
  if (NS_FAILED(rv)) {
    tmpContext->DestroyDrawingSurface(surface);
    return NS_ERROR_FAILURE;
  }
  // clipping and translation is set by NewOffscreenContext

  localcx->SetColor(aBackgroundColor);
  localcx->FillRect(aRect);

  nsRect r = aRect;
  nsIView* suppressScrolling = nsnull;
  if (aIgnoreViewportScrolling && mRootScrollable) {
    // Suppress clipping/scrolling/scrollbar painting due to our
    // viewport scrollable view
    nscoord x, y;
    mRootScrollable->GetScrollPosition(x, y);
    localcx->Translate(x, y);
    r.MoveBy(-x, -y);
    suppressScrolling = mRootScrollable->View();
  }

  nsAutoVoidArray displayList;
  PLArenaPool displayArena;
  PL_INIT_ARENA_POOL(&displayArena, "displayArena", 1024);
  BuildRenderingDisplayList(view, nsRegion(r), &displayList, displayArena,
                            PR_TRUE, PR_TRUE, suppressScrolling);
  RenderViews(view, *localcx, nsRegion(aRect), surface, displayList);
  PL_FreeArenaPool(&displayArena);
  PL_FinishArenaPool(&displayArena);

  localcx.swap(*aRenderedContext);
  return NS_OK;
}

Here is the call graph for this function:

void nsViewManager::RenderViews ( nsView aRootView,
nsIRenderingContext aRC,
const nsRegion &  aRegion,
nsIDrawingSurface aRCSurface,
const nsVoidArray aDisplayList 
) [private]

Definition at line 1311 of file nsViewManager.cpp.

{
#ifdef DEBUG_roc
  if (getenv("MOZ_SHOW_DISPLAY_LIST")) ShowDisplayList(&aDisplayList);
#endif

  PRInt32 index = 0;
  nsRect fakeClipRect;
  PRBool anyRendered;
  OptimizeDisplayListClipping(&aDisplayList, PR_FALSE, fakeClipRect, index, anyRendered);

  index = 0;
  OptimizeTranslucentRegions(aDisplayList, &index, nsnull);

  nsIWidget* widget = aRootView->GetWidget();
  PRBool translucentWindow = PR_FALSE;
  if (widget) {
    widget->GetWindowTranslucency(translucentWindow);
    if (translucentWindow) {
      NS_WARNING("Transparent window enabled");
      NS_ASSERTION(aRCSurface, "Cannot support transparent windows with doublebuffering disabled");
    }
  }

  // Create a buffer wrapping aRC (which is usually the double-buffering offscreen buffer).
  BlendingBuffers* buffers =
    CreateBlendingBuffers(&aRC, PR_TRUE, aRCSurface, translucentWindow, aRegion.GetBounds());
  NS_ASSERTION(buffers, "Failed to create rendering buffers");
  if (!buffers)
    return;

  nsAutoVoidArray filterStack;

  // draw all views in the display list, from back to front.
  for (PRInt32 i = 0; i < aDisplayList.Count(); i++) {
    DisplayListElement2* element = NS_STATIC_CAST(DisplayListElement2*, aDisplayList.ElementAt(i));

    nsIRenderingContext* RCs[2] = { buffers->mBlackCX, buffers->mWhiteCX };

    if (element->mFlags & PUSH_CLIP) {
      PushStateAndClip(RCs, 2, element->mBounds);
    }
    if (element->mFlags & PUSH_FILTER) {
      NS_ASSERTION(aRCSurface,
                   "Cannot support translucent elements with doublebuffering disabled");
      if (aRCSurface) {
        // Save current buffer on the stack and start rendering into a new
        // offscreen buffer
        filterStack.AppendElement(buffers);
        buffers = CreateBlendingBuffers(&aRC, PR_FALSE, nsnull,
                                        (element->mFlags & VIEW_TRANSPARENT) != 0,
                                        element->mBounds);
      }
    }

    if (element->mFlags & VIEW_RENDERED) {
      if (element->mFlags & VIEW_CLIPPED) {
        PushStateAndClip(RCs, 2, element->mBounds);
      }
      
      RenderDisplayListElement(element, RCs[0]);
      // RenderDisplayListElement won't do anything if the context is null
      RenderDisplayListElement(element, RCs[1]);

      if (element->mFlags & VIEW_CLIPPED) {
        PopState(RCs, 2);
      }
    }

    if (element->mFlags & POP_FILTER) {
      if (aRCSurface) {
        // Pop the last buffer off the stack and composite the current buffer into
        // the last buffer
        BlendingBuffers* doneBuffers = buffers;
        buffers = NS_STATIC_CAST(BlendingBuffers*,
                                 filterStack.ElementAt(filterStack.Count() - 1));
        filterStack.RemoveElementAt(filterStack.Count() - 1);
        
        // perform the blend itself.
        nsRect damageRectInPixels = element->mBounds;
        damageRectInPixels -= buffers->mOffset;
        damageRectInPixels *= mTwipsToPixels;
        if (damageRectInPixels.width > 0 && damageRectInPixels.height > 0) {
          nsIRenderingContext* targets[2] = { buffers->mBlackCX, buffers->mWhiteCX };
          for (int j = 0; j < 2; j++) {
            if (targets[j]) {
              mBlender->Blend(0, 0,
                              damageRectInPixels.width, damageRectInPixels.height,
                              doneBuffers->mBlackCX, targets[j],
                              damageRectInPixels.x, damageRectInPixels.y,
                              element->mView->GetOpacity(), doneBuffers->mWhiteCX,
                              NS_RGB(0, 0, 0), NS_RGB(255, 255, 255));
            }
          }
        }
        // probably should recycle these so we don't eat the cost of graphics memory
        // allocation
        delete doneBuffers;
      }
    }
    if (element->mFlags & POP_CLIP) {
      PopState(RCs, 2);
    }
      
    // The element is destroyed when the pool is finished
    // delete element;
  }
    
  if (translucentWindow) {
    // Get the alpha channel into an array so we can send it to the widget
    nsRect r = aRegion.GetBounds();
    r *= mTwipsToPixels;
    nsRect bufferRect(0, 0, r.width, r.height);
    PRUint8* alphas = nsnull;
    nsresult rv = mBlender->GetAlphas(bufferRect, buffers->mBlack,
                                      buffers->mWhite, &alphas);
    
    if (NS_SUCCEEDED(rv)) {
      widget->UpdateTranslucentWindowAlpha(r, alphas);
    }
    delete[] alphas;
  }

  delete buffers;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewManager::ReparentChildWidgets ( nsIView aView,
nsIWidget aNewWidget 
) [private]

Definition at line 2640 of file nsViewManager.cpp.

{
  if (aView->HasWidget()) {
    // Check to see if the parent widget is the
    // same as the new parent. If not then reparent
    // the widget, otherwise there is nothing more
    // to do for the view and its descendants
    nsIWidget* widget = aView->GetWidget();
    nsCOMPtr<nsIWidget> parentWidget = getter_AddRefs(widget->GetParent());
    if (parentWidget.get() != aNewWidget) {
#ifdef DEBUG
      nsresult rv =
#endif
        widget->SetParent(aNewWidget);
      NS_ASSERTION(NS_SUCCEEDED(rv), "SetParent failed!");
    }
    return;
  }

  // Need to check each of the views children to see
  // if they have a widget and reparent it.

  nsView* view = NS_STATIC_CAST(nsView*, aView);
  for (nsView *kid = view->GetFirstChild(); kid; kid = kid->GetNextSibling()) {
    ReparentChildWidgets(kid, aNewWidget);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewManager::ReparentViews ( DisplayZTreeNode aNode,
nsHashtable &  aMapPlaceholderViewToZTreeNode 
) [private]

Definition at line 2289 of file nsViewManager.cpp.

{
  DisplayZTreeNode* child;
  DisplayZTreeNode** prev = &aNode->mZChild;
  for (child = aNode->mZChild; nsnull != child; child = *prev) {
    ReparentViews(child, aMapPlaceholderViewToZTreeNode);

    nsZPlaceholderView *zParent = nsnull;
    if (nsnull != child->mView) {
      zParent = child->mView->GetZParent();
    }
    if (nsnull != zParent) {
      nsVoidKey key(zParent);
      DisplayZTreeNode* placeholder = (DisplayZTreeNode *)aMapPlaceholderViewToZTreeNode.Get(&key);

      if (placeholder == child) {
        // don't do anything if we already reparented this node;
        // just advance to the next child
        prev = &child->mZSibling;
      } else {
        // unlink the child from the tree
        *prev = child->mZSibling;
        child->mZSibling = nsnull;
        
        if (nsnull != placeholder) {
          NS_ASSERTION((placeholder->mDisplayElement == nsnull), "placeholder already has elements?");
          NS_ASSERTION((placeholder->mZChild == nsnull), "placeholder already has Z-children?");
          placeholder->mDisplayElement = child->mDisplayElement;
          placeholder->mView = child->mView;
          placeholder->mZChild = child->mZChild;
          // We used to delete the child, but since we switched to Arenas just unreference it
          // delete child;
        } else {
          // the placeholder was not added to the display list
          // we don't need the real view then, either

          // We used to call DestroyZTreeNode which would delete the child
          // and its children/siblings and remove them from the Placeholder
          // hash.  However, we now use an Arena to build the tree.  This
          // means that we will never reuse a node (because it is never
          // freed), thus we can just leave it in the hash.  It will never
          // be looked up again.
          // DestroyZTreeNode(child);
        }
      }
    } else {
      prev = &child->mZSibling;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewManager::ReparentWidgets ( nsIView aView,
nsIView aParent 
) [private]

Definition at line 2670 of file nsViewManager.cpp.

{
  NS_PRECONDITION(aParent, "Must have a parent");
  NS_PRECONDITION(aView, "Must have a view");
  
  // Quickly determine whether the view has pre-existing children or a
  // widget. In most cases the view will not have any pre-existing 
  // children when this is called.  Only in the case
  // where a view has been reparented by removing it from
  // a reinserting it into a new location in the view hierarchy do we
  // have to consider reparenting the existing widgets for the view and
  // it's descendants.
  nsView* view = NS_STATIC_CAST(nsView*, aView);
  if (view->HasWidget() || view->GetFirstChild()) {
    nsIWidget* parentWidget = aParent->GetNearestWidget(nsnull);
    if (parentWidget) {
      ReparentChildWidgets(aView, parentWidget);
      return;
    }
    NS_WARNING("Can not find a widget for the parent view");
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsViewManager::ResizeView ( nsIView aView,
const nsRect aRect,
PRBool  aRepaintExposedAreaOnly = PR_FALSE 
) [virtual]

Resize a view.

In addition to setting the width and height, you can set the x and y of its bounds relative to its position. Negative x and y will let the view extend above and to the left of the (0,0) point in its coordinate system. The view manager generates the appropriate dirty regions.

Parameters:
aViewview to move
thenew bounds relative to the current position
RepaintExposedAreaOnlyif PR_TRUE Repaint only the expanded or contracted region, if PR_FALSE Repaint the union of the old and new rectangles.

Implements nsIViewManager.

Definition at line 2883 of file nsViewManager.cpp.

{
  nsView* view = NS_STATIC_CAST(nsView*, aView);
  nsRect oldDimensions;

  view->GetDimensions(oldDimensions);
  // Don't use nsRect's operator== here, since it returns true when
  // both rects are empty even if they have different widths and we
  // have cases where that sort of thing matters to us.
  if (oldDimensions.TopLeft() != aRect.TopLeft() ||
      oldDimensions.Size() != aRect.Size()) {
    nsView* parentView = view->GetParent();
    if (parentView == nsnull)
      parentView = view;

    // resize the view.
    // Prevent Invalidation of hidden views 
    if (view->GetVisibility() == nsViewVisibility_kHide) {  
      view->SetDimensions(aRect, PR_FALSE);
    } else {
      if (!aRepaintExposedAreaOnly) {
        //Invalidate the union of the old and new size
        view->SetDimensions(aRect, PR_TRUE);

        UpdateView(view, aRect, NS_VMREFRESH_NO_SYNC);
        view->ConvertToParentCoords(&oldDimensions.x, &oldDimensions.y);
        UpdateView(parentView, oldDimensions, NS_VMREFRESH_NO_SYNC);
      } else {
        view->SetDimensions(aRect, PR_TRUE);

        InvalidateRectDifference(view, aRect, oldDimensions, NS_VMREFRESH_NO_SYNC);
        nsRect r = aRect;
        view->ConvertToParentCoords(&r.x, &r.y);
        view->ConvertToParentCoords(&oldDimensions.x, &oldDimensions.y);
        InvalidateRectDifference(parentView, oldDimensions, r, NS_VMREFRESH_NO_SYNC);
      } 
    }
  }

  // Note that if layout resizes the view and the view has a custom clip
  // region set, then we expect layout to update the clip region too. Thus
  // in the case where mClipRect has been optimized away to just be a null
  // pointer, and this resize is implicitly changing the clip rect, it's OK
  // because layout will change it back again if necessary.

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 461 of file nsViewManager.h.

{ return mRootViewManager; }

Here is the caller graph for this function:

Set the default background color that the view manager should use to paint otherwise unowned areas.

If the color isn't known, just set it to zero (which means 'transparent' since the color is RGBA).

Parameters:
aColorthe default background color

Implements nsIViewManager.

Definition at line 4456 of file nsViewManager.cpp.

{
  mDefaultBackgroundColor = aColor;
  return NS_OK;
}
void nsViewManager::SetPainting ( PRBool  aPainting) [inline, private]

Definition at line 451 of file nsViewManager.h.

                                     {
    RootViewManager()->mPainting = aPainting;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

set the view that is is considered to be the root scrollable view for the document.

Parameters:
aScrollableroot scrollable view
Returns:
error status

Implements nsIViewManager.

Definition at line 3500 of file nsViewManager.cpp.

{
  if (mRootScrollable) {
    NS_STATIC_CAST(nsScrollPortView*, mRootScrollable)->
      SetClipPlaceholdersToBounds(PR_FALSE);
  }
  mRootScrollable = aScrollable;
  if (mRootScrollable) {
    NS_STATIC_CAST(nsScrollPortView*, mRootScrollable)->
      SetClipPlaceholdersToBounds(PR_TRUE);
  }
  return NS_OK;
}

Here is the caller graph for this function:

Set the root of the view tree.

Does not destroy the current root view. aView may have a parent view managed by a different view manager. aView may have a widget (anything but printing) or may not (printing).

Parameters:
aViewview to set as root

Implements nsIViewManager.

Definition at line 640 of file nsViewManager.cpp.

{
  nsView* view = NS_STATIC_CAST(nsView*, aView);

  NS_PRECONDITION(!view || view->GetViewManager() == this,
                  "Unexpected viewmanager on root view");
  
  // Do NOT destroy the current root view. It's the caller's responsibility
  // to destroy it
  mRootView = view;

  if (mRootView) {
    nsView* parent = mRootView->GetParent();
    if (parent) {
      // Calling InsertChild on |parent| will InvalidateHierarchy() on us, so
      // no need to set mRootViewManager ourselves here.
      parent->InsertChild(mRootView, nsnull);
    } else {
      InvalidateHierarchy();
    }

    mRootView->SetZIndex(PR_FALSE, 0, PR_FALSE);
  }
  // Else don't touch mRootViewManager

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsViewManager::SetViewBitBltEnabled ( nsIView aView,
PRBool  aEnable 
) [virtual]

Set whether the view can be bitblitted during scrolling.

Implements nsIViewManager.

Definition at line 3145 of file nsViewManager.cpp.

{
  nsView* view = NS_STATIC_CAST(nsView*, aView);

  NS_ASSERTION(!(nsnull == view), "no view");

  if (aEnable) {
    view->SetViewFlags(view->GetViewFlags() & ~NS_VIEW_FLAG_DONT_BITBLT);
  } else {
    view->SetViewFlags(view->GetViewFlags() | NS_VIEW_FLAG_DONT_BITBLT);
  }

  return NS_OK;
}

Here is the call graph for this function:

Set whether the view's children should be searched during event processing.

Implements nsIViewManager.

Definition at line 3160 of file nsViewManager.cpp.

{
  nsView* view = NS_STATIC_CAST(nsView*, aView);

  NS_ASSERTION(!(nsnull == view), "no view");

  if (aEnable) {
    view->SetViewFlags(view->GetViewFlags() & ~NS_VIEW_FLAG_DONT_CHECK_CHILDREN);
  } else {
    view->SetViewFlags(view->GetViewFlags() | NS_VIEW_FLAG_DONT_CHECK_CHILDREN);
  }

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsViewManager::SetViewChildClipRegion ( nsIView aView,
const nsRegion *  aRegion 
) [virtual]

Set the region to which a view's descendants are clipped.

The view itself is not clipped to this region; this allows for effects where part of the view is drawn outside the clip region (e.g., its borders and background). The view manager generates the appropriate dirty regions.

Parameters:
aViewview to set clipping for
aRegionif null then no clipping is required. In this case all descendant views (but not descendants through placeholder edges) must have their bounds inside the bounds of this view if non-null, then we will clip this view's descendant views --- including descendants through placeholder edges --- to the region. The region's bounds must be within the bounds of this view. The descendant views' bounds need not be inside the bounds of this view (because we're going to clip them anyway).

XXX Currently we only support regions consisting of a single rectangle.

Implements nsIViewManager.

Definition at line 2931 of file nsViewManager.cpp.

{
  nsView* view = NS_STATIC_CAST(nsView*, aView);
 
  NS_ASSERTION(!(nsnull == view), "no view");

  const nsRect* oldClipRect = view->GetClipChildrenToRect();

  nsRect newClipRectStorage = view->GetDimensions();
  nsRect* newClipRect = nsnull;
  if (aRegion) {
    newClipRectStorage = aRegion->GetBounds();
    newClipRect = &newClipRectStorage;
  }

  if ((oldClipRect != nsnull) == (newClipRect != nsnull)
      && (!newClipRect || *newClipRect == *oldClipRect)) {
    return NS_OK;
  }
  nsRect oldClipRectStorage =
    oldClipRect ? *oldClipRect : view->GetDimensions();
 
  // Update the view properties
  view->SetClipChildrenToRect(newClipRect);

  if (IsViewInserted(view)) {
    // Invalidate changed areas
    // Paint (new - old) in the current view
    InvalidateRectDifference(view, newClipRectStorage, oldClipRectStorage, NS_VMREFRESH_NO_SYNC);
    // Paint (old - new) in the parent view, since it'll be clipped out of the current view
    nsView* parent = view->GetParent();
    if (parent) {
      oldClipRectStorage += view->GetPosition();
      newClipRectStorage += view->GetPosition();
      InvalidateRectDifference(parent, oldClipRectStorage, newClipRectStorage, NS_VMREFRESH_NO_SYNC);
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsViewManager::SetViewContentTransparency ( nsIView aView,
PRBool  aTransparent 
) [virtual]

Used set the transparency status of the content in a view.

see nsIView.HasTransparency().

Parameters:
aTransparentPR_TRUE if there are transparent areas, PR_FALSE otherwise.

Implements nsIViewManager.

Definition at line 3289 of file nsViewManager.cpp.

{
  nsView* view = NS_STATIC_CAST(nsView*, aView);

  if (view->IsTransparent() != aTransparent) {
    view->SetContentTransparency(aTransparent);

    if (IsViewInserted(view)) {
      UpdateView(view, NS_VMREFRESH_NO_SYNC);
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsViewManager::SetViewFloating ( nsIView aView,
PRBool  aFloatingView 
) [virtual]

Set whether the view "floats" above all other views, which tells the compositor not to consider higher views in the view hierarchy that would geometrically intersect with this view.

This is a hack, but it fixes some problems with views that need to be drawn in front of all other views.

Implements nsIViewManager.

Definition at line 3175 of file nsViewManager.cpp.

{
  nsView* view = NS_STATIC_CAST(nsView*, aView);

  NS_ASSERTION(!(nsnull == view), "no view");

  view->SetFloating(aFloating);

  return NS_OK;
}

Here is the call graph for this function:

Set the view observer associated with this manager.

Parameters:
aObserver- new observer
Returns:
error status

Implements nsIViewManager.

Definition at line 3320 of file nsViewManager.cpp.

{
  mObserver = aObserver;
  return NS_OK;
}
NS_IMETHODIMP nsViewManager::SetViewOpacity ( nsIView aView,
float  aOpacity 
) [virtual]

Note: This didn't exist in 4.0.

Called to set the opacity of a view. A value of 0.0 means completely transparent. A value of 1.0 means completely opaque.

Parameters:
opacitynew opacity value

Implements nsIViewManager.

Definition at line 3304 of file nsViewManager.cpp.

{
  nsView* view = NS_STATIC_CAST(nsView*, aView);

  if (view->GetOpacity() != aOpacity)
    {
      view->SetOpacity(aOpacity);

      if (IsViewInserted(view)) {
        UpdateView(view, NS_VMREFRESH_NO_SYNC);
      }
    }

  return NS_OK;
}

Here is the call graph for this function:

Set the visibility of a view.

The view manager generates the appropriate dirty regions.

Parameters:
aViewview to change visibility state of
visiblenew visibility state

Implements nsIViewManager.

Definition at line 3186 of file nsViewManager.cpp.

{
  nsView* view = NS_STATIC_CAST(nsView*, aView);

  if (aVisible != view->GetVisibility()) {
    view->SetVisibility(aVisible);

    if (IsViewInserted(view)) {
      if (!view->HasWidget()) {
        if (nsViewVisibility_kHide == aVisible) {
          nsView* parentView = view->GetParent();
          if (parentView) {
            UpdateView(parentView, view->GetBounds(), NS_VMREFRESH_NO_SYNC);
          }
        }
        else {
          UpdateView(view, NS_VMREFRESH_NO_SYNC);
        }
      }
    }

    // Any child views not associated with frames might not get their visibility
    // updated, so propagate our visibility to them. This is important because
    // hidden views should have all hidden children.
    for (nsView* childView = view->GetFirstChild(); childView;
         childView = childView->GetNextSibling()) {
      if (!childView->GetClientData()) {
        childView->SetVisibility(aVisible);
      }
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsViewManager::SetViewZIndex ( nsIView aView,
PRBool  aAutoZIndex,
PRInt32  aZindex,
PRBool  aTopMost = PR_FALSE 
) [virtual]

Set the z-index of a view.

Positive z-indices mean that a view is above its parent in z-order. Negative z-indices mean that a view is below its parent. The view manager generates the appropriate dirty regions.

Parameters:
aAutoZIndexindicate that the z-index of a view is "auto". An "auto" z-index means that the view does not define a new stacking context, which means that the z-indicies of the view's children are relative to the view's siblings.
aViewview to change z depth of
aZindexexplicit z depth
aTopMostused when this view is z-index:auto to compare against other z-index:auto views. PR_TRUE if the view should be topmost when compared with other z-index:auto views.

Implements nsIViewManager.

Definition at line 3253 of file nsViewManager.cpp.

{
  nsView* view = NS_STATIC_CAST(nsView*, aView);
  nsresult  rv = NS_OK;

  NS_ASSERTION((view != nsnull), "no view");

  // don't allow the root view's z-index to be changed. It should always be zero.
  // This could be removed and replaced with a style rule, or just removed altogether, with interesting consequences
  if (aView == mRootView) {
    return rv;
  }

  PRBool oldTopMost = view->IsTopMost();
  PRBool oldIsAuto = view->GetZIndexIsAuto();

  if (aAutoZIndex) {
    aZIndex = 0;
  }

  PRInt32 oldidx = view->GetZIndex();
  view->SetZIndex(aAutoZIndex, aZIndex, aTopMost);

  if (CompareZIndex(oldidx, oldTopMost, oldIsAuto,
                    aZIndex, aTopMost, aAutoZIndex) != 0) {
    UpdateView(view, NS_VMREFRESH_NO_SYNC);
  }

  nsZPlaceholderView* zParentView = view->GetZParent();
  if (nsnull != zParentView) {
    SetViewZIndex(zParentView, aAutoZIndex, aZIndex, aTopMost);
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsViewManager::SetWindowDimensions ( nscoord  aWidth,
nscoord  aHeight 
) [virtual]

Set the dimensions of the root window.

Called if the root window is resized. The dimensions are in twips

Parameters:
aWidthof window in twips
aHeightof window in twips

Implements nsIViewManager.

Definition at line 689 of file nsViewManager.cpp.

{
  if (mRootView) {
    if (IsViewVisible(mRootView)) {
      mDelayedResize.SizeTo(NSCOORD_NONE, NSCOORD_NONE);
      DoSetWindowDimensions(aWidth, aHeight);
    } else {
      mDelayedResize.SizeTo(aWidth, aHeight);
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewManager::ShowDisplayList ( const nsVoidArray aDisplayList) [private]

Definition at line 4172 of file nsViewManager.cpp.

{
#ifdef NS_DEBUG
  printf("### display list length=%d ###\n", aDisplayList->Count());

  PRInt32 nestcnt = 0;
  for (PRInt32 cnt = 0; cnt < aDisplayList->Count(); cnt++) {
    DisplayListElement2* element = (DisplayListElement2*)aDisplayList->ElementAt(cnt);
    nestcnt = PrintDisplayListElement(element, nestcnt);
  }
#endif
}

Here is the caller graph for this function:

Dispatch a mouse move event based on the most recent mouse position.

This is used when the contents of the page moved (aFromScroll is false) or scrolled (aFromScroll is true).

Implements nsIViewManager.

Definition at line 4492 of file nsViewManager.cpp.

{
  if (mMouseLocation == nsPoint(NSCOORD_NONE, NSCOORD_NONE))
    return NS_OK;

  nsCOMPtr<nsIEventQueue> eventQueue;
  mEventQueueService->GetSpecialEventQueue(
    nsIEventQueueService::UI_THREAD_EVENT_QUEUE, getter_AddRefs(eventQueue));
  NS_ASSERTION(nsnull != eventQueue, "Event queue is null");

  if (eventQueue != mSynthMouseMoveEventQueue) {
    nsSynthMouseMoveEvent *ev = new nsSynthMouseMoveEvent(this, aFromScroll);
    eventQueue->PostEvent(ev);
    mSynthMouseMoveEventQueue = eventQueue;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Called to inform the view manager that it should redraw all views.

Parameters:
aViewview to paint. should be root view
aUpdateFlagssee bottom of nsIViewManager.h for description

Implements nsIViewManager.

Definition at line 1902 of file nsViewManager.cpp.

{
  if (RootViewManager() != this) {
    return RootViewManager()->UpdateAllViews(aUpdateFlags);
  }
  
  UpdateViews(mRootView, aUpdateFlags);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsViewManager::UpdateCount ( ) const [inline, private]

Definition at line 435 of file nsViewManager.h.

                              {
    NS_ASSERTION(IsRootVM(),
                 "DecrementUpdateCount called on non-root viewmanager");
    return mUpdateCnt;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsViewManager::UpdateView ( nsIView aView,
PRUint32  aUpdateFlags 
) [virtual]

Called to inform the view manager that the entire area of a view is dirty and needs to be redrawn.

Parameters:
aViewview to paint. should be root view
aUpdateFlagssee bottom of nsIViewManager.h for description

Implements nsIViewManager.

Definition at line 1638 of file nsViewManager.cpp.

{
  // Mark the entire view as damaged
  nsView* view = NS_STATIC_CAST(nsView*, aView);

  nsRect bounds = view->GetBounds();
  view->ConvertFromParentCoords(&bounds.x, &bounds.y);
  return UpdateView(view, bounds, aUpdateFlags);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsViewManager::UpdateView ( nsIView aView,
const nsRect aRect,
PRUint32  aUpdateFlags 
) [virtual]

Called to inform the view manager that some portion of a view is dirty and needs to be redrawn.

The rect passed in should be in the view's coordinate space.

Parameters:
aViewview to paint. should be root view
rectrect to mark as damaged
aUpdateFlagssee bottom of nsIViewManager.h for description

Implements nsIViewManager.

Definition at line 1839 of file nsViewManager.cpp.

{
  NS_PRECONDITION(nsnull != aView, "null view");

  nsView* view = NS_STATIC_CAST(nsView*, aView);

  // Only Update the rectangle region of the rect that intersects the view's non clipped rectangle
  nsRect clippedRect = view->GetClippedRect();
  if (clippedRect.IsEmpty()) {
    return NS_OK;
  }

  nsRect damagedRect;
  damagedRect.IntersectRect(aRect, clippedRect);

   // If the rectangle is not visible then abort
   // without invalidating. This is a performance 
   // enhancement since invalidating a native widget
   // can be expensive.
   // This also checks for silly request like damagedRect.width = 0 or damagedRect.height = 0
  nsRectVisibility rectVisibility;
  GetRectVisibility(view, damagedRect, 0, &rectVisibility);
  if (rectVisibility != nsRectVisibility_kVisible) {
    return NS_OK;
  }

  // if this is a floating view, it isn't covered by any widgets other than
  // its children. In that case we walk up to its parent widget and use
  // that as the root to update from. This also means we update areas that
  // may be outside the parent view(s), which is necessary for floats.
  if (view->GetFloating()) {
    nsView* widgetParent = view;

    while (!widgetParent->HasWidget()) {
      widgetParent->ConvertToParentCoords(&damagedRect.x, &damagedRect.y);
      widgetParent = widgetParent->GetParent();
    }

    UpdateWidgetArea(widgetParent, nsRegion(damagedRect), nsnull);
  } else {
    // Propagate the update to the root widget of the root view manager, since
    // iframes, for example, can overlap each other and be translucent.  So we
    // have to possibly invalidate our rect in each of the widgets we have
    // lying about.
    damagedRect.MoveBy(ComputeViewOffset(view));

    UpdateWidgetArea(RootViewManager()->GetRootView(), nsRegion(damagedRect), nsnull);
  }

  RootViewManager()->IncrementUpdateCount();

  if (!IsRefreshEnabled()) {
    return NS_OK;
  }

  // See if we should do an immediate refresh or wait
  if (aUpdateFlags & NS_VMREFRESH_IMMEDIATE) {
    Composite();
  } 

  return NS_OK;
}

Here is the call graph for this function:

Called to inform the view manager that a view has scrolled.

The view manager will invalidate any widgets which may need to be rerendered.

Parameters:
aViewview to paint. should be the nsScrollPortView that got scrolled.

Definition at line 1715 of file nsViewManager.cpp.

{
  NS_ASSERTION(RootViewManager()->mScrollCnt > 0,
               "Someone forgot to call WillBitBlit()");
  // Look at the view's clipped rect. It may be that part of the view is clipped out
  // in which case we don't need to worry about invalidating the clipped-out part.
  nsRect damageRect = aView->GetClippedRect();
  if (damageRect.IsEmpty()) {
    return;
  }
  damageRect.MoveBy(ComputeViewOffset(aView));

  // if this is a floating view, it isn't covered by any widgets other than
  // its children, which are handled by the widget scroller.
  if (aView->GetFloating()) {
    return;
  }

  UpdateWidgetArea(RootViewManager()->GetRootView(), nsRegion(damageRect), aView);

  Composite();
  --RootViewManager()->mScrollCnt;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewManager::UpdateViews ( nsView aView,
PRUint32  aUpdateFlags 
) [private]

Definition at line 1912 of file nsViewManager.cpp.

{
  // update this view.
  UpdateView(aView, aUpdateFlags);

  // update all children as well.
  nsView* childView = aView->GetFirstChild();
  while (nsnull != childView)  {
    UpdateViews(childView, aUpdateFlags);
    childView = childView->GetNextSibling();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewManager::UpdateWidgetArea ( nsView aWidgetView,
const nsRegion &  aDamagedRegion,
nsView aIgnoreWidgetView 
) [private]
Parameters:
aDamagedRegionthis region, relative to aWidgetView, is invalidated in every widget child of aWidgetView, plus aWidgetView's own widget
aIgnoreWidgetViewif non-null, the aIgnoreWidgetView's widget and its children are not updated.

Definition at line 1746 of file nsViewManager.cpp.

{
  if (!IsRefreshEnabled()) {
    // accumulate this rectangle in the view's dirty region, so we can
    // process it later.
    nsRegion* dirtyRegion = aWidgetView->GetDirtyRegion();
    if (!dirtyRegion) return;

    dirtyRegion->Or(*dirtyRegion, aDamagedRegion);
    // Don't let dirtyRegion grow beyond 8 rects
    dirtyRegion->SimplifyOutward(8);
    nsViewManager* rootVM = RootViewManager();
    rootVM->mHasPendingUpdates = PR_TRUE;
    rootVM->IncrementUpdateCount();
    return;
    // this should only happen at the top level, and this result
    // should not be consumed by top-level callers, so it doesn't
    // really matter what we return
  }

  // If the bounds don't overlap at all, there's nothing to do
  nsRegion intersection;
  intersection.And(aWidgetView->GetDimensions(), aDamagedRegion);
  if (intersection.IsEmpty()) {
    return;
  }

  // If the widget is hidden, it don't cover nothing
  if (nsViewVisibility_kHide == aWidgetView->GetVisibility()) {
#ifdef DEBUG
    // Assert if view is hidden but widget is visible
    nsIWidget* widget = aWidgetView->GetNearestWidget(nsnull);
    if (widget) {
      PRBool visible;
      widget->IsVisible(visible);
      NS_ASSERTION(!visible, "View is hidden but widget is visible!");
    }
#endif
    return;
  }

  if (aWidgetView == aIgnoreWidgetView) {
    // the widget for aIgnoreWidgetView (and its children) should be treated as already updated.
    return;
  }

  nsIWidget* widget = aWidgetView->GetNearestWidget(nsnull);
  if (!widget) {
    // The root view or a scrolling view might not have a widget
    // (for example, during printing). We get here when we scroll
    // during printing to show selected options in a listbox, for example.
    return;
  }

  // Update all child widgets with the damage. In the process,
  // accumulate the union of all the child widget areas, or at least
  // some subset of that.
  nsRegion children;
  for (nsIWidget* childWidget = widget->GetFirstChild();
       childWidget;
       childWidget = childWidget->GetNextSibling()) {
    nsView* view = nsView::GetViewFor(childWidget);
    if (view && view->GetVisibility() == nsViewVisibility_kShow) {
      // Don't mess with views that are in completely different view
      // manager trees
      if (view->GetViewManager()->RootViewManager() == RootViewManager()) {
        // get the damage region into 'view's coordinate system
        nsRegion damage = intersection;
        nsPoint offset = view->GetOffsetTo(aWidgetView);
        damage.MoveBy(-offset);
        UpdateWidgetArea(view, damage, aIgnoreWidgetView);
        children.Or(children, view->GetDimensions() + offset);
        children.SimplifyInward(20);
      }
    }
  }

  nsRegion leftOver;
  leftOver.Sub(intersection, children);

  if (!leftOver.IsEmpty()) {
    NS_ASSERTION(IsRefreshEnabled(), "Can only get here with refresh enabled, I hope");

    const nsRect* r;
    for (nsRegionRectIterator iter(leftOver); (r = iter.Next());) {
      nsRect bounds = *r;
      ViewToWidget(aWidgetView, aWidgetView, bounds);
      widget->Invalidate(bounds, PR_FALSE);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Function to recursively call Update() on all widgets belonging to a view or its kids.

Definition at line 3220 of file nsViewManager.cpp.

{
  NS_PRECONDITION(aView, "Must have view!");

  if (aView->HasWidget()) {
    aView->GetWidget()->Update();
  }

  for (nsView* childView = aView->GetFirstChild();
       childView;
       childView = childView->GetNextSibling()) {
    UpdateWidgetsForView(childView);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewManager::ViewToWidget ( nsView aView,
nsView aWidgetView,
nsRect aRect 
) const [private]

Transforms a rectangle from specified view's coordinate system to the first parent that has an attached widget.

Definition at line 4226 of file nsViewManager.cpp.

{
  while (aView != aWidgetView) {
    aView->ConvertToParentCoords(&aRect.x, &aRect.y);
    aView = aView->GetParent();
  }
  
  // intersect aRect with bounds of aWidgetView, to prevent generating any illegal rectangles.
  nsRect bounds;
  aWidgetView->GetDimensions(bounds);
  aRect.IntersectRect(aRect, bounds);
  // account for the view's origin not lining up with the widget's
  aRect.x -= bounds.x;
  aRect.y -= bounds.y;
  
  // finally, convert to device coordinates.
  float t2p;
  t2p = mContext->AppUnitsToDevUnits();
  aRect.ScaleRoundOut(t2p);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsViewManager::WillBitBlit ( nsView aView,
nsPoint  aScrollAmount 
)

Called to inform the view manager that a view is about to bit-blit.

Parameters:
aViewthe view that will bit-blit
aScrollAmounthow much aView will scroll by

Definition at line 1692 of file nsViewManager.cpp.

{
  if (!IsRootVM()) {
    RootViewManager()->WillBitBlit(aView, aScrollAmount);
    return;
  }

  NS_PRECONDITION(aView, "Must have a view");
  NS_PRECONDITION(aView->HasWidget(), "View must have a widget");

  ++mScrollCnt;
  
  // Since the view is actually moving the widget by -aScrollAmount, that's the
  // offset we want to use when accumulating dirty rects.
  AccumulateIntersectionsIntoDirtyRegion(aView, GetRootView(), -aScrollAmount);
}

Here is the call graph for this function: