Back to index

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

#include <nsScrollPortView.h>

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

List of all members.

Public Member Functions

 nsScrollPortView (nsViewManager *aViewManager=nsnull)
virtual nsIScrollableViewToScrollableView ()
 See if this view is scrollable.
NS_IMETHOD QueryInterface (REFNSIID aIID, void **aInstancePtr)
NS_IMETHOD SetWidget (nsIWidget *aWidget)
 Set the widget associated with this view.
NS_IMETHOD CreateScrollControls (nsNativeWidget aNative=nsnull)
 Create the controls used to allow scrolling.
NS_IMETHOD GetContainerSize (nscoord *aWidth, nscoord *aHeight) const
 Get the dimensions of the container.
NS_IMETHOD SetScrolledView (nsIView *aScrolledView)
 Set the view that we are scrolling within the scrolling view.
NS_IMETHOD GetScrolledView (nsIView *&aScrolledView) const
 Get the view that we are scrolling within the scrolling view.
NS_IMETHOD GetScrollPosition (nscoord &aX, nscoord &aY) const
 Get the position of the scrolled view.
NS_IMETHOD ScrollTo (nscoord aX, nscoord aY, PRUint32 aUpdateFlags)
 Scroll the view to the given x,y, update's the scrollbar's thumb positions and the view's offset.
NS_IMETHOD SetScrollProperties (PRUint32 aProperties)
 Set the properties describing how scrolling can be performed in this scrollable.
NS_IMETHOD GetScrollProperties (PRUint32 *aProperties)
 Get the properties describing how scrolling can be performed in this scrollable.
NS_IMETHOD SetLineHeight (nscoord aHeight)
 Set the height of a line used for line scrolling.
NS_IMETHOD GetLineHeight (nscoord *aHeight)
 Get the height of a line used for line scrolling.
NS_IMETHOD ScrollByLines (PRInt32 aNumLinesX, PRInt32 aNumLinesY)
 Scroll the view left or right by aNumLinesX columns.
NS_IMETHOD GetPageScrollDistances (nsSize *aDistances)
 Get the desired size of a page scroll in each dimension.
NS_IMETHOD ScrollByPages (PRInt32 aNumPagesX, PRInt32 aNumPagesY)
 Scroll the view left or right by aNumPagesX pages.
NS_IMETHOD ScrollByWhole (PRBool aTop)
 Scroll the view to the top or bottom of the document depending on the value of aTop.
NS_IMETHOD ScrollByPixels (PRInt32 aNumPixelsX, PRInt32 aNumPixelsY)
 Scroll the view left or right by aNumLinesX pixels.
NS_IMETHOD CanScroll (PRBool aHorizontal, PRBool aForward, PRBool &aResult)
 Check the view can scroll from current offset.
 NS_IMETHOD_ (nsIView *) View()
 Returns the view as an nsIView*.
NS_IMETHOD AddScrollPositionListener (nsIScrollPositionListener *aListener)
 Adds a scroll position listener.
NS_IMETHOD RemoveScrollPositionListener (nsIScrollPositionListener *aListener)
 Removes a scroll position listener.
NS_IMETHOD Paint (nsIRenderingContext &rc, const nsRect &rect, PRUint32 aPaintFlags, PRBool &Result)
 Called to indicate that the specified rect of the view needs to be drawn via the rendering context.
NS_IMETHOD Paint (nsIRenderingContext &aRC, const nsIRegion &aRegion, PRUint32 aPaintFlags, PRBool &Result)
 Called to indicate that the specified region of the view needs to be drawn via the rendering context.
nsViewGetScrolledView () const
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_IMETHOD 
QueryInterface (const nsIID &aIID, void **aInstancePtr)
virtual void SetPosition (nscoord aX, nscoord aY)
 Called to indicate that the position of the view has been changed.
virtual void SetDimensions (const nsRect &aRect, PRBool aPaint=PR_TRUE, PRBool aResizeWidget=PR_TRUE)
 Called to indicate that the dimensions of the view have been changed.
void GetDimensions (nsRect &aRect) const
void GetDimensions (nsSize &aSize) const
nsRect GetDimensions () const
virtual PRBool IsZPlaceholderView () const
 This checks whether the view is a placeholder for some view that has been reparented to a different geometric parent.
void SetClipChildrenToRect (const nsRect *aRect)
 Called to set the clip of the children of this view.
void SetClipChildrenToBounds (PRBool aDoClip)
void SetClipPlaceholdersToBounds (PRBool aDoClip)
const nsRectGetClipChildrenToRect () const
 Called to get the dimensions and position of the clip for the children of this view.
PRBool GetClipChildrenToBounds (PRBool aPlaceholders) const
NS_IMETHOD SetVisibility (nsViewVisibility visibility)
 Called to indicate that the visibility of a view has been changed.
void SetZIndex (PRBool aAuto, PRInt32 aZIndex, PRBool aTopMost)
 Called to indicate that the z-index of a view has been changed.
NS_IMETHOD SetFloating (PRBool aFloatingView)
 Set/Get 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 SetOpacity (float opacity)
 Note: This didn't exist in 4.0.
NS_IMETHOD SetContentTransparency (PRBool aTransparent)
 Used set the transparency status of the content in a view.
nsRect GetClippedRect (nsIView *aStopAtView=nsnull)
void DropMouseGrabbing ()
nsZPlaceholderViewGetZParent () const
nsViewGetFirstChild () const
 The view's first child is the child which is earliest in document order.
nsViewGetNextSibling () const
 Called to query the next sibling of the view.
nsViewGetParent () const
 Called to query the parent of the view.
nsViewManagerGetViewManager () const
 Get the view manager which "owns" the view.
PRInt32 GetZIndex () const
 Called to query the z-index of a view.
PRBool GetZIndexIsAuto () const
PRBool HasNonEmptyDirtyRegion ()
nsRegion * GetDirtyRegion ()
void InsertChild (nsView *aChild, nsView *aSibling)
void RemoveChild (nsView *aChild)
void SetParent (nsView *aParent)
void SetZParent (nsZPlaceholderView *aZParent)
void SetNextSibling (nsView *aSibling)
PRUint32 GetViewFlags () const
void SetViewFlags (PRUint32 aFlags)
void SetTopMost (PRBool aTopMost)
PRBool IsTopMost ()
void ConvertToParentCoords (nscoord *aX, nscoord *aY) const
void ConvertFromParentCoords (nscoord *aX, nscoord *aY) const
void ResetWidgetBounds (PRBool aRecurse, PRBool aMoveOnly, PRBool aInvalidateChangedSize)
void SetPositionIgnoringChildWidgets (nscoord aX, nscoord aY)
nsresult LoadWidget (const nsCID &aClassIID)
void InvalidateHierarchy (nsViewManager *aViewManagerParent)
void SetDeletionObserver (nsWeakView *aDeletionObserver)
void Destroy ()
 Destroy the view.
nsPoint GetPosition () const
 Called to get the position of a view.
nsRect GetBounds () const
 Called to get the dimensions and position of the view's bounds.
nsPoint GetOffsetTo (const nsIView *aOther) const
 Get the offset between the coordinate systems of |this| and aOther.
nsIntPoint GetScreenPosition () const
 Get the screen position of the view.
nsViewVisibility GetVisibility () const
 Called to query the visibility state of a view.
PRBool GetFloating () const
 Get 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.
float GetOpacity () const
 Note: This didn't exist in 4.0.
PRBool IsTransparent () const
 Used to ask a view if it has any areas within its bounding box that are transparent.
void SetHasUniformBackground (PRBool aUniform)
 Indicate that this view is always painted onto a uniform field of pixels.
PRBool HasUniformBackground ()
void SetClientData (void *aData)
 Set the view's link to client owned data.
voidGetClientData () const
 Query the view for it's link to client owned data.
virtual nsIWidgetGetNearestWidget (nsPoint *aOffset) const
 Get the nearest widget in this view or a parent of this view and the offset from the widget's origin to this view's origin.
nsresult CreateWidget (const nsIID &aWindowIID, nsWidgetInitData *aWidgetInitData=nsnull, nsNativeWidget aNative=nsnull, PRBool aEnableDragDrop=PR_TRUE, PRBool aResetVisibility=PR_TRUE, nsContentType aWindowType=eContentTypeInherit)
 Create a widget to associate with this view.
nsIWidgetGetWidget () const
 In 4.0, the "cutout" nature of a view is queryable.
PRBool HasWidget () const
 Returns PR_TRUE if the view has a widget associated with it.
PRBool IsRoot () const
virtual PRBool ExternalIsRoot () const

Static Public Member Functions

static nsViewGetViewFor (nsIWidget *aWidget)
 Find the view for the given widget, if there is one.

Protected Member Functions

virtual ~nsScrollPortView ()
void Scroll (nsView *aScrolledView, nsPoint aTwipsDelta, nsPoint aPixDelta, float aT2P)
PRBool CannotBitBlt (nsView *aScrolledView)
void DoResetWidgetBounds (PRBool aMoveOnly, PRBool aInvalidateChangedSize)

Protected Attributes

nscoord mOffsetX
nscoord mOffsetY
nscoord mOffsetXpx
nscoord mOffsetYpx
PRUint32 mScrollProperties
nscoord mLineHeight
nsISupportsArraymListeners
nsZPlaceholderViewmZParent
nsRectmClipRect
nsRegion * mDirtyRegion
PRPackedBool mChildRemoved
nsWeakViewmDeletionObserver
nsViewManagermViewManager
nsViewmParent
nsIWidgetmWindow
nsViewmNextSibling
nsViewmFirstChild
voidmClientData
PRInt32 mZIndex
nsViewVisibility mVis
nscoord mPosX
nscoord mPosY
nsRect mDimBounds
float mOpacity
PRUint32 mVFlags

Private Member Functions

NS_IMETHOD ScrollToImpl (nscoord aX, nscoord aY, PRUint32 aUpdateFlags)
void IncrementalScroll ()
PRBool IsSmoothScrollingEnabled ()

Static Private Member Functions

static void SmoothScrollAnimationCallback (nsITimer *aTimer, void *aESM)

Private Attributes

SmoothScrollmSmoothScroll

Friends

class nsWeakView

Detailed Description

Definition at line 52 of file nsScrollPortView.h.


Constructor & Destructor Documentation

Definition at line 80 of file nsScrollPortView.cpp.

Here is the call graph for this function:

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

Definition at line 93 of file nsScrollPortView.cpp.

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

  if (nsnull != mViewManager) {
     nsIScrollableView* scrollingView;
     mViewManager->GetRootScrollableView(&scrollingView);
     if ((nsnull != scrollingView) && (this == scrollingView)) {
       mViewManager->SetRootScrollableView(nsnull);
     }
  }

  delete mSmoothScroll;
}

Here is the call graph for this function:


Member Function Documentation

Adds a scroll position listener.

Implements nsIScrollableView.

Definition at line 134 of file nsScrollPortView.cpp.

{
  if (nsnull == mListeners) {
    nsresult rv = NS_NewISupportsArray(&mListeners);
    if (NS_FAILED(rv))
      return rv;
  }
  return mListeners->AppendElement(aListener);
}

Here is the call graph for this function:

PRBool nsScrollPortView::CannotBitBlt ( nsView aScrolledView) [protected]

Definition at line 537 of file nsScrollPortView.cpp.

{
  PRUint32  scrolledViewFlags = aScrolledView->GetViewFlags();

  return (mScrollProperties & NS_SCROLL_PROPERTY_NEVER_BLIT) ||
         (scrolledViewFlags & NS_VIEW_FLAG_DONT_BITBLT) ||
         (!(mScrollProperties & NS_SCROLL_PROPERTY_ALWAYS_BLIT) && 
          !mViewManager->CanScrollWithBitBlt(aScrolledView));
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsScrollPortView::CanScroll ( PRBool  aHorizontal,
PRBool  aForward,
PRBool aResult 
) [virtual]

Check the view can scroll from current offset.

Parameters:
aHorizontalIf checking to Left or to Right, true. Otherwise, false.
aForwardIf checking to Right or Bottom, true. Otherwise, false.
aResultIf the view can scroll, true. Otherwise, false.
Returns:
error status

Implements nsIScrollableView.

Definition at line 488 of file nsScrollPortView.cpp.

{
  nscoord offset = aHorizontal ? mOffsetX : mOffsetY;

  // Can scroll to Top or to Left?
  if (!aForward) {
    aResult = (offset > 0) ? PR_TRUE : PR_FALSE;
    return NS_OK;
  }

  nsView* scrolledView = GetScrolledView();
  if (!scrolledView) {
    aResult = PR_FALSE;
    return NS_ERROR_FAILURE;
  }

  nsSize scrolledSize;
  scrolledView->GetDimensions(scrolledSize);

  nsSize portSize;
  GetDimensions(portSize);

  nsCOMPtr<nsIDeviceContext> dev;
  mViewManager->GetDeviceContext(*getter_AddRefs(dev));
  float t2p, p2t;
  t2p = dev->AppUnitsToDevUnits();
  p2t = dev->DevUnitsToAppUnits();

  nscoord max;
  if (aHorizontal) {
    max = scrolledSize.width - portSize.width;
    // Round by pixel
    nscoord maxPx = NSTwipsToIntPixels(max, t2p);
    max = NSIntPixelsToTwips(maxPx, p2t);
  } else {
    max = scrolledSize.height - portSize.height;
    // Round by pixel
    nscoord maxPx = NSTwipsToIntPixels(max, t2p);
    max = NSIntPixelsToTwips(maxPx, p2t);
  }

  // Can scroll to Bottom or to Right?
  aResult = (offset < max) ? PR_TRUE : PR_FALSE;

  return NS_OK;
}

Here is the call graph for this function:

void nsView::ConvertFromParentCoords ( nscoord aX,
nscoord aY 
) const [inline, inherited]

Definition at line 291 of file nsView.h.

{ *aX -= mPosX; *aY -= mPosY; }

Here is the caller graph for this function:

void nsView::ConvertToParentCoords ( nscoord aX,
nscoord aY 
) const [inline, inherited]

Definition at line 287 of file nsView.h.

{ *aX += mPosX; *aY += mPosY; }

Here is the caller graph for this function:

Create the controls used to allow scrolling.

Call this method before anything else is done with the scrollable view.

Parameters:
aNativenative widget to use as parent for control widgets
Returns:
error status

Implements nsIScrollableView.

Definition at line 152 of file nsScrollPortView.cpp.

{
  nsWidgetInitData  initData;
  initData.clipChildren = PR_TRUE;
  initData.clipSiblings = PR_TRUE;

  CreateWidget(kWidgetCID, &initData,
               mWindow ? nsnull : aNative);
  
  return NS_OK;
}

Here is the call graph for this function:

nsresult nsIView::CreateWidget ( const nsIID aWindowIID,
nsWidgetInitData aWidgetInitData = nsnull,
nsNativeWidget  aNative = nsnull,
PRBool  aEnableDragDrop = PR_TRUE,
PRBool  aResetVisibility = PR_TRUE,
nsContentType  aWindowType = eContentTypeInherit 
) [inherited]

Create a widget to associate with this view.

Parameters:
aWindowIIDIID for Widget type that this view should have associated with it. if nsull, then no width will be created for this view
aWidgetInitDatadata used to initialize this view's widget before its create is called.
aNativenative window that will be used as parent of aWindowIID. if nsnull, then parent will be derived from parent view and it's ancestors
aWindowTypeis either content, UI or inherit from parent window. This is used to expose what type of window this is to assistive technology like screen readers.
Returns:
error status

Definition at line 650 of file nsView.cpp.

{
  nsIDeviceContext  *dx;
  nsRect            trect = mDimBounds;

  if (NS_UNLIKELY(!!mWindow)) {
    NS_ERROR("We already have a window for this view? BAD");
    ViewWrapper* wrapper = GetWrapperFor(mWindow);
    NS_IF_RELEASE(wrapper);
    mWindow->SetClientData(nsnull);
    NS_RELEASE(mWindow);
  }

  mViewManager->GetDeviceContext(dx);
  float scale = dx->AppUnitsToDevUnits();

  trect *= scale;

  nsView* v = NS_STATIC_CAST(nsView*, this);
  if (NS_OK == v->LoadWidget(aWindowIID))
  {
    PRBool usewidgets;

    dx->SupportsNativeWidgets(usewidgets);

    if (PR_TRUE == usewidgets)
    {
      PRBool initDataPassedIn = PR_TRUE;
      nsWidgetInitData initData;
      if (!aWidgetInitData) {
        // No initData, we're a child window
        // Create initData to pass in params
        initDataPassedIn = PR_FALSE;
        initData.clipChildren = PR_TRUE; // Clip child window's children
        initData.clipSiblings = PR_TRUE; // Clip child window's siblings
        aWidgetInitData = &initData;
      }
      aWidgetInitData->mContentType = aContentType;

      if (aNative)
        mWindow->Create(aNative, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
      else
      {
        if (!initDataPassedIn && GetParent() && 
          GetParent()->GetViewManager() != mViewManager)
          initData.mListenForResizes = PR_TRUE;

        nsPoint offset(0, 0);
        nsIWidget* parentWidget = GetParent() ? GetParent()->GetNearestWidget(&offset)
          : nsnull;
        trect += offset;
        if (aWidgetInitData->mWindowType == eWindowType_popup) {
          mWindow->Create(parentWidget->GetNativeData(NS_NATIVE_WIDGET), trect,
                          ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
        } else {
          mWindow->Create(parentWidget, trect,
                          ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
        }
      }
      if (aEnableDragDrop) {
        mWindow->EnableDragDrop(PR_TRUE);
      }
      
      // propagate the z-index to the widget.
      UpdateNativeWidgetZIndexes(v, FindNonAutoZIndex(v));
    }
  }

  //make sure visibility state is accurate
  
  if (aResetVisibility) {
    v->SetVisibility(GetVisibility());
  }

  NS_RELEASE(dx);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIView::Destroy ( void  ) [inherited]

Destroy the view.

The view destroys its child views, and destroys and releases its widget (if it has one).

Also informs the view manager that the view is destroyed by calling SetRootView(NULL) if the view is the root view and calling RemoveChild() otherwise.

Definition at line 307 of file nsView.cpp.

{
  delete this;
}

Here is the caller graph for this function:

void nsView::DoResetWidgetBounds ( PRBool  aMoveOnly,
PRBool  aInvalidateChangedSize 
) [protected, inherited]

Definition at line 387 of file nsView.cpp.

                                                                {
  // The geometry of a root view's widget is controlled externally,
  // NOT by sizing or positioning the view
  if (mViewManager->GetRootView() == this) {
    return;
  }

  NS_PRECONDITION(mWindow, "Why was this called??");
  nsIDeviceContext  *dx;
  float             t2p, p2t;
  
  mViewManager->GetDeviceContext(dx);
  t2p = dx->AppUnitsToDevUnits();
  p2t = dx->DevUnitsToAppUnits();
  NS_RELEASE(dx);

  nsPoint offset(0, 0);
  if (GetParent()) {
    nsIWidget* parentWidget = GetParent()->GetNearestWidget(&offset);

    nsWindowType type;
    mWindow->GetWindowType(type);
    if (type == eWindowType_popup) {
      // put offset into screen coordinates
      nsRect screenRect(0,0,1,1);
      parentWidget->WidgetToScreen(screenRect, screenRect);
      offset += nsPoint(NSIntPixelsToTwips(screenRect.x, p2t),
                        NSIntPixelsToTwips(screenRect.y, p2t));
    }
  }

  nsRect newBounds(NSTwipsToIntPixels((mDimBounds.x + offset.x), t2p),
                   NSTwipsToIntPixels((mDimBounds.y + offset.y), t2p),
                   NSTwipsToIntPixels(mDimBounds.width, t2p),
                   NSTwipsToIntPixels(mDimBounds.height, t2p));
    
  PRBool changedPos = PR_TRUE;
  PRBool changedSize = PR_TRUE;
  if (!(mVFlags & NS_VIEW_FLAG_HAS_POSITIONED_WIDGET)) {
    mVFlags |= NS_VIEW_FLAG_HAS_POSITIONED_WIDGET;
  } else {
    nsRect curBounds;
    mWindow->GetBounds(curBounds);
    changedPos = curBounds.TopLeft() != newBounds.TopLeft();
    changedSize = curBounds.Size() != newBounds.Size();
  }

  if (changedPos) {
    if (changedSize && !aMoveOnly) {
      mWindow->Resize(newBounds.x, newBounds.y, newBounds.width, newBounds.height,
                      aInvalidateChangedSize);
    } else {
      mWindow->Move(newBounds.x, newBounds.y);
    }
  } else {
    if (changedSize && !aMoveOnly) {
      mWindow->Resize(newBounds.width, newBounds.height, aInvalidateChangedSize);
    } // else do nothing!
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 196 of file nsView.cpp.

                               {
  // check to see if we are grabbing events
  if (mViewManager->GetMouseEventGrabber() == this) {
    // we are grabbing events. Move the grab to the parent if we can.
    PRBool boolResult; //not used
    // if GetParent() returns null, then we release the grab, which is the best we can do
    mViewManager->GrabMouseEvents(GetParent(), boolResult);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsIView::ExternalIsRoot ( ) const [virtual, inherited]

Definition at line 916 of file nsView.cpp.

{
  return nsIView::IsRoot();
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsRect nsIView::GetBounds ( ) const [inline, inherited]

Called to get the dimensions and position of the view's bounds.

The view's bounds (x,y) are in the coordinate space of the parent view. The view's bounds (x,y) might not be the same as the view's position, if the view has content above or to the left of its origin.

Parameters:
aBoundsout parameter for bounds

Definition at line 179 of file nsIView.h.

{ return mDimBounds; }

Here is the caller graph for this function:

void* nsIView::GetClientData ( ) const [inline, inherited]

Query the view for it's link to client owned data.

Returns:
data associated with view or nsnull if there is none.

Definition at line 297 of file nsIView.h.

{ return mClientData; }

Here is the caller graph for this function:

PRBool nsView::GetClipChildrenToBounds ( PRBool  aPlaceholders) const [inline, inherited]

Definition at line 172 of file nsView.h.

Here is the caller graph for this function:

const nsRect* nsView::GetClipChildrenToRect ( ) const [inline, inherited]

Called to get the dimensions and position of the clip for the children of this view.

Definition at line 170 of file nsView.h.

  { return mClipRect; }

Here is the caller graph for this function:

nsRect nsView::GetClippedRect ( nsIView aStopAtView = nsnull) [inherited]
Returns:
the view's dimensions after clipping by ancestors is applied (the rect is relative to the view's origin)
Parameters:
aStopAtViewdo not consider clipping imposed by views above this view on the ancestor chain

Definition at line 1018 of file nsView.cpp.

{
  nsRect clip = GetDimensions();
  PRBool foundPlaceholders = ApplyClipRect(this, &clip, PR_FALSE, aStopAtView);
  if (foundPlaceholders && !clip.IsEmpty()) {
    ApplyClipRect(this, &clip, PR_TRUE, aStopAtView);
  }
  return clip;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsScrollPortView::GetContainerSize ( nscoord aWidth,
nscoord aHeight 
) const [virtual]

Get the dimensions of the container.

Parameters:
aWidthreturn value for width of container
aHeightreturn value for height of container

Implements nsIScrollableView.

Definition at line 173 of file nsScrollPortView.cpp.

{
  if (!aWidth || !aHeight)
    return NS_ERROR_NULL_POINTER;

  *aWidth  = 0;
  *aHeight = 0;

  nsView *scrolledView = GetScrolledView();

  if (!scrolledView)
    return NS_ERROR_FAILURE;

  nsSize sz;
  scrolledView->GetDimensions(sz);
  *aWidth = sz.width;
  *aHeight = sz.height;
  return NS_OK;
}

Here is the call graph for this function:

void nsView::GetDimensions ( nsRect aRect) const [inline, inherited]

Definition at line 131 of file nsView.h.

{ aRect = mDimBounds; aRect.x -= mPosX; aRect.y -= mPosY; }

Here is the caller graph for this function:

void nsView::GetDimensions ( nsSize aSize) const [inline, inherited]

Definition at line 132 of file nsView.h.

{ aSize.width = mDimBounds.width; aSize.height = mDimBounds.height; }
nsRect nsView::GetDimensions ( ) const [inline, inherited]

Definition at line 256 of file nsView.h.

{ nsRect r = mDimBounds; r.MoveBy(-mPosX, -mPosY); return r; }

Here is the call graph for this function:

Here is the caller graph for this function:

nsRegion* nsView::GetDirtyRegion ( ) [inline, inherited]

Definition at line 263 of file nsView.h.

                             {
    if (!mDirtyRegion) {
      mDirtyRegion = new nsRegion();
      NS_ASSERTION(mDirtyRegion, "Out of memory!");
    }
    return mDirtyRegion;
  }

Here is the caller graph for this function:

nsView* nsView::GetFirstChild ( ) const [inline, inherited]

The view's first child is the child which is earliest in document order.

Returns:
first child

Reimplemented from nsIView.

Definition at line 248 of file nsView.h.

{ return mFirstChild; }

Here is the caller graph for this function:

PRBool nsIView::GetFloating ( ) const [inline, inherited]

Get 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.

Returns:
PR_TRUE if the view floats, PR_FALSE otherwise.

Definition at line 230 of file nsIView.h.

{ return (mVFlags & NS_VIEW_FLAG_FLOATING) != 0; }

Here is the caller graph for this function:

Get the height of a line used for line scrolling.

Parameters:
aHeightout parameter for line height
Returns:
error status

Implements nsIScrollableView.

Definition at line 419 of file nsScrollPortView.cpp.

{
  *aHeight = mLineHeight;
  return NS_OK;
}
nsIWidget * nsIView::GetNearestWidget ( nsPoint aOffset) const [virtual, inherited]

Get the nearest widget in this view or a parent of this view and the offset from the widget's origin to this view's origin.

Parameters:
aOffsetthe offset from this view's origin to the widget's origin (usually positive)
Returns:
the widget closest to this view; can be null because some view trees don't have widgets at all (e.g., printing), but if any view in the view tree has a widget, then it's safe to assume this will not return null XXX Remove this 'virtual' when gfx+widget are merged into gklayout; Mac widget depends on this method, which is BOGUS!

Definition at line 885 of file nsView.cpp.

{
  nsPoint pt(0, 0);
  const nsView* v;
  for (v = NS_STATIC_CAST(const nsView*, this);
       v && !v->HasWidget(); v = v->GetParent()) {
    pt += v->GetPosition();
  }
  if (!v) {
    if (aOffset) {
      *aOffset = pt;
    }
    return NS_STATIC_CAST(const nsView*, this)->GetViewManager()->GetWidget();
  }

  // pt is now the offset from v's origin to this's origin
  // The widget's origin is the top left corner of v's bounds, which may
  // not coincide with v's origin
  if (aOffset) {
    nsRect vBounds = v->GetBounds();
    *aOffset = pt + v->GetPosition() -  nsPoint(vBounds.x, vBounds.y);
  }
  return v->GetWidget();
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsView* nsView::GetNextSibling ( ) const [inline, inherited]

Called to query the next sibling of the view.

Returns:
view's next sibling

Reimplemented from nsIView.

Definition at line 249 of file nsView.h.

{ return mNextSibling; }

Here is the caller graph for this function:

nsPoint nsIView::GetOffsetTo ( const nsIView aOther) const [inherited]

Get the offset between the coordinate systems of |this| and aOther.

Adding the return value to a point in the coordinate system of |this| will transform the point to the coordinate system of aOther.

If aOther is null, this will return the offset of |this| from the root of the viewmanager tree.

This function is fastest when aOther is an ancestor of |this|.

NOTE: this actually returns the offset from aOther to |this|, but that offset is added to transform coordinates from |this| to aOther.

Definition at line 845 of file nsView.cpp.

{
  nsPoint offset(0, 0);
  const nsIView* v;
  for (v = this; v != aOther && v; v = v->GetParent()) {
    offset += v->GetPosition();
  }

  if (v != aOther) {
    // Looks like aOther wasn't an ancestor of |this|.  So now we have
    // the root-VM-relative position of |this| in |offset|.  Convert back
    // to the coordinates of aOther
    while (aOther) {
      offset -= aOther->GetPosition();
      aOther = aOther->GetParent();
    }
  }

  return offset;
}

Here is the call graph for this function:

Here is the caller graph for this function:

float nsIView::GetOpacity ( ) const [inline, inherited]

Note: This didn't exist in 4.0.

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

Returns:
view's opacity value

Definition at line 256 of file nsIView.h.

{ return mOpacity; }

Here is the caller graph for this function:

Get the desired size of a page scroll in each dimension.

ScrollByPages will scroll by independent multiples of these amounts unless it hits the edge of the view.

Implements nsIScrollableView.

Definition at line 433 of file nsScrollPortView.cpp.

{
  nsSize size;
  GetDimensions(size);

  // The page increment is the size of the page, minus the smaller of
  // 10% of the size or 2 lines.
  aDistances->width  = size.width  - PR_MIN(size.width  / 10, 2 * mLineHeight);
  aDistances->height = size.height - PR_MIN(size.height / 10, 2 * mLineHeight);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsView* nsView::GetParent ( ) const [inline, inherited]

Called to query the parent of the view.

Returns:
view's parent

Reimplemented from nsIView.

Definition at line 250 of file nsView.h.

{ return mParent; }

Here is the caller graph for this function:

nsPoint nsIView::GetPosition ( ) const [inline, inherited]

Called to get the position of a view.

The specified coordinates are in the parent view's coordinate space. This is the (0, 0) origin of the coordinate space established by this view.

Parameters:
xout parameter for x position
yout parameter for y position

Definition at line 164 of file nsIView.h.

                              {
    // Call ExternalIsRoot here so that we can get to it from other
    // components
    NS_ASSERTION(!ExternalIsRoot() || (mPosX == 0 && mPosY == 0),
                 "root views should always have explicit position of (0,0)");
    return nsPoint(mPosX, mPosY);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

nsIntPoint nsIView::GetScreenPosition ( ) const [inherited]

Get the screen position of the view.

Returns:
the pixel position of the top-left of the view in screen coordinates.

Definition at line 866 of file nsView.cpp.

{
  nsIntRect screenRect(0,0,0,0);  
  nsPoint toWidgetOffset(0,0);
  nsIWidget* widget = GetNearestWidget(&toWidgetOffset);
  if (widget) {
    nsCOMPtr<nsIDeviceContext> dx;
    mViewManager->GetDeviceContext(*getter_AddRefs(dx));
    float t2p = dx->AppUnitsToDevUnits();
    nsIntRect ourRect(NSTwipsToIntPixels(toWidgetOffset.x, t2p),
                      NSTwipsToIntPixels(toWidgetOffset.y, t2p),
                      0,
                      0);
    widget->WidgetToScreen(ourRect, screenRect);
  }
  
  return nsIntPoint(screenRect.x, screenRect.y);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsScrollPortView::GetScrolledView ( nsIView *&  aScrolledView) const [virtual]

Get the view that we are scrolling within the scrolling view.

Returns:
child view

Implements nsIScrollableView.

Definition at line 387 of file nsScrollPortView.cpp.

{
  aScrolledView = GetScrolledView();
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 94 of file nsScrollPortView.h.

{ return GetFirstChild(); }

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsScrollPortView::GetScrollPosition ( nscoord aX,
nscoord aY 
) const [virtual]

Get the position of the scrolled view.

Implements nsIScrollableView.

Definition at line 393 of file nsScrollPortView.cpp.

{
  aX = mOffsetX;
  aY = mOffsetY;

  return NS_OK;
}

Get the properties describing how scrolling can be performed in this scrollable.

Parameters:
aPropertiesout parameter for current properties
Returns:
error status

Implements nsIScrollableView.

Definition at line 407 of file nsScrollPortView.cpp.

{
  *aProperties = mScrollProperties;
  return NS_OK;
}
PRUint32 nsView::GetViewFlags ( ) const [inline, inherited]

Definition at line 278 of file nsView.h.

{ return mVFlags; }

Here is the caller graph for this function:

static nsView* nsView::GetViewFor ( nsIWidget aWidget) [inline, static, inherited]

Find the view for the given widget, if there is one.

Returns:
the view the widget belongs to, or null if the widget doesn't belong to any view.

Reimplemented from nsIView.

Definition at line 235 of file nsView.h.

                                                {
    return NS_STATIC_CAST(nsView*, nsIView::GetViewFor(aWidget));
  }

Here is the call graph for this function:

Here is the caller graph for this function:

nsViewManager* nsView::GetViewManager ( ) const [inline, inherited]

Get the view manager which "owns" the view.

This method might require some expensive traversal work in the future. If you can get the view manager from somewhere else, do that instead.

Returns:
the view manager

Reimplemented from nsIView.

Definition at line 251 of file nsView.h.

{ return mViewManager; }

Here is the caller graph for this function:

nsViewVisibility nsIView::GetVisibility ( ) const [inline, inherited]

Called to query the visibility state of a view.

Returns:
current visibility state

Definition at line 207 of file nsIView.h.

{ return mVis; }

Here is the caller graph for this function:

nsIWidget* nsIView::GetWidget ( ) const [inline, inherited]

In 4.0, the "cutout" nature of a view is queryable.

If we believe that all cutout view have a native widget, this could be a replacement.

Parameters:
aWidgetout parameter for widget that this view contains, or nsnull if there is none.

Definition at line 341 of file nsIView.h.

{ return mWindow; }
PRInt32 nsView::GetZIndex ( ) const [inline, inherited]

Called to query the z-index of a view.

The z-index is relative to all siblings of the view.

Returns:
mZIndex: explicit z-index value or 0 if none is set mIsAuto: PR_TRUE if the view is zindex:auto mIsTopMost: used when this view is zindex:auto PR_TRUE if the view is topmost when compared with another z-index:auto view

Reimplemented from nsIView.

Definition at line 253 of file nsView.h.

{ return mZIndex; }

Here is the caller graph for this function:

PRBool nsView::GetZIndexIsAuto ( ) const [inline, inherited]

Definition at line 254 of file nsView.h.

{ return (mVFlags & NS_VIEW_FLAG_AUTO_ZINDEX) != 0; }

Here is the caller graph for this function:

nsZPlaceholderView* nsView::GetZParent ( ) const [inline, inherited]

Definition at line 245 of file nsView.h.

{ return mZParent; }

Here is the caller graph for this function:

PRBool nsView::HasNonEmptyDirtyRegion ( ) [inline, inherited]

Definition at line 260 of file nsView.h.

                                  {
    return mDirtyRegion && !mDirtyRegion->IsEmpty();
  }

Here is the caller graph for this function:

PRBool nsIView::HasUniformBackground ( ) [inline, inherited]

Definition at line 283 of file nsIView.h.

Here is the caller graph for this function:

PRBool nsIView::HasWidget ( ) const [inline, inherited]

Returns PR_TRUE if the view has a widget associated with it.

Definition at line 346 of file nsIView.h.

{ return mWindow != nsnull; }

Here is the caller graph for this function:

Definition at line 753 of file nsScrollPortView.cpp.

Here is the call graph for this function:

void nsView::InsertChild ( nsView aChild,
nsView aSibling 
) [inherited]

Definition at line 530 of file nsView.cpp.

{
  NS_PRECONDITION(nsnull != aChild, "null ptr");

  if (nsnull != aChild)
  {
    if (nsnull != aSibling)
    {
#ifdef NS_DEBUG
      NS_ASSERTION(aSibling->GetParent() == this, "tried to insert view with invalid sibling");
#endif
      //insert after sibling
      aChild->SetNextSibling(aSibling->GetNextSibling());
      aSibling->SetNextSibling(aChild);
    }
    else
    {
      aChild->SetNextSibling(mFirstChild);
      mFirstChild = aChild;
    }
    aChild->SetParent(this);

    // If we just inserted a root view, then update the RootViewManager
    // on all view managers in the new subtree.

    nsViewManager *vm = aChild->GetViewManager();
    if (vm->GetRootView() == aChild)
    {
      aChild->InvalidateHierarchy(nsnull); // don't care about releasing grabs
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsView::InvalidateHierarchy ( nsViewManager aViewManagerParent) [inherited]

Definition at line 512 of file nsView.cpp.

{
  if (aViewManagerParent) {
    // We're removed from the view hierarchy of aRemovalPoint, so make sure
    // we're not still grabbing mouse events.
    if (aViewManagerParent->GetMouseEventGrabber() == this) {
      PRBool res;
      aViewManagerParent->GrabMouseEvents(nsnull, res);
    }
  }

  if (mViewManager->GetRootView() == this)
    mViewManager->InvalidateHierarchy();

  for (nsView *child = mFirstChild; child; child = child->GetNextSibling())
    child->InvalidateHierarchy(aViewManagerParent);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsIView::IsRoot ( ) const [inherited]
Returns:
true iff this is the root view for its view manager

Definition at line 910 of file nsView.cpp.

{
  NS_ASSERTION(mViewManager != nsnull," View manager is null in nsView::IsRoot()");
  return mViewManager->GetRootView() == this;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 723 of file nsScrollPortView.cpp.

                                                  {
  nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
  if (prefs) {
    PRBool enabled;
    nsresult rv = prefs->GetBoolPref(SMOOTH_SCROLL_PREF_NAME, &enabled);
    if (NS_SUCCEEDED(rv)) {
      return enabled;
    }
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsView::IsTopMost ( ) [inline, inherited]

Definition at line 282 of file nsView.h.

{ return((mVFlags & NS_VIEW_FLAG_TOPMOST) != 0); }

Here is the caller graph for this function:

PRBool nsIView::IsTransparent ( ) const [inline, inherited]

Used to ask a view if it has any areas within its bounding box that are transparent.

This is not the same as opacity - opacity can be set externally, transparency is a quality of the view itself.

Returns:
Returns PR_TRUE if there are transparent areas, PR_FALSE otherwise.

Definition at line 264 of file nsIView.h.

{ return (mVFlags & NS_VIEW_FLAG_TRANSPARENT) != 0; }

Here is the caller graph for this function:

virtual PRBool nsView::IsZPlaceholderView ( ) const [inline, virtual, inherited]

This checks whether the view is a placeholder for some view that has been reparented to a different geometric parent.

Reimplemented in nsZPlaceholderView.

Definition at line 138 of file nsView.h.

{ return PR_FALSE; }

Here is the caller graph for this function:

nsresult nsView::LoadWidget ( const nsCID aClassIID) [inherited]

Definition at line 776 of file nsView.cpp.

{
  ViewWrapper* wrapper = new ViewWrapper(this);
  if (!wrapper)
    return NS_ERROR_OUT_OF_MEMORY;
  NS_ADDREF(wrapper); // Will be released in ~nsView

  nsresult rv = CallCreateInstance(aClassIID, &mWindow);

  if (NS_SUCCEEDED(rv)) {
    // Set the widget's client data
    mWindow->SetClientData(wrapper);
  } else {
    delete wrapper;
  }

  mVFlags &= ~NS_VIEW_FLAG_HAS_POSITIONED_WIDGET;
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the view as an nsIView*.

Implements nsIScrollableView.

NS_IMETHODIMP nsScrollPortView::Paint ( nsIRenderingContext rc,
const nsRect rect,
PRUint32  aPaintFlags,
PRBool aResult 
)

Called to indicate that the specified rect of the view needs to be drawn via the rendering context.

The rect is specified in view coordinates.

Parameters:
rcrendering context to paint into
rectdamage area
aPaintFlagssee nsIView.h for flag definitions
Returns:
PR_TRUE if the entire clip region has been eliminated, else PR_FALSE

Reimplemented from nsView.

Definition at line 597 of file nsScrollPortView.cpp.

{
  rc.PushState();
  nsRect bounds;
  GetDimensions(bounds);
  bounds.x = bounds.y = 0;
  rc.SetClipRect(bounds, nsClipCombine_kIntersect);

  nsresult rv = nsView::Paint(rc, rect, aPaintFlags, aResult);

  rc.PopState();
    
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsScrollPortView::Paint ( nsIRenderingContext rc,
const nsIRegion region,
PRUint32  aPaintFlags,
PRBool aResult 
)

Called to indicate that the specified region of the view needs to be drawn via the rendering context.

The region is specified in view coordinates.

Parameters:
rcrendering context to paint into
regiondamage area
aPaintFlagssee nsIView.h for flag definitions
Returns:
PR_TRUE if the entire clip region has been eliminated, else PR_FALSE

Reimplemented from nsView.

Definition at line 613 of file nsScrollPortView.cpp.

{
  aRC.PushState();
  nsRect bounds;
  GetDimensions(bounds);
  bounds.x = bounds.y = 0;
  aRC.SetClipRect(bounds, nsClipCombine_kIntersect);

  nsresult rv = nsView::Paint(aRC, aRegion, aPaintFlags, aResult);

  aRC.PopState();
    
  return rv;
}

Here is the call graph for this function:

nsresult nsScrollPortView::QueryInterface ( REFNSIID  aIID,
void **  aInstancePtr 
)

Definition at line 111 of file nsScrollPortView.cpp.

{
  if (nsnull == aInstancePtr) {
    return NS_ERROR_NULL_POINTER;
  }
  *aInstancePtr = nsnull;
  if (aIID.Equals(NS_GET_IID(nsIScrollableView))) {
    *aInstancePtr = (void*)(nsIScrollableView*)this;
    return NS_OK;
  }
  if (aIID.Equals(NS_GET_IID(nsIScrollableView_MOZILLA_1_8_BRANCH))) {
    *aInstancePtr = (void*)(nsIScrollableView_MOZILLA_1_8_BRANCH*)this;
    return NS_OK;
  }

  return nsView::QueryInterface(aIID, aInstancePtr);
}

Here is the call graph for this function:

nsresult nsView::QueryInterface ( const nsIID aIID,
void **  aInstancePtr 
) [inherited]

Definition at line 278 of file nsView.cpp.

{
  if (nsnull == aInstancePtr) {
    return NS_ERROR_NULL_POINTER;
  }

  NS_ASSERTION(!aIID.Equals(NS_GET_IID(nsISupports)),
               "Someone expects views to be ISupports-derived!");
  
  *aInstancePtr = nsnull;
  
  if (aIID.Equals(NS_GET_IID(nsIView))) {
    *aInstancePtr = (void*)(nsIView*)this;
    return NS_OK;
  }

  return NS_NOINTERFACE;
}

Here is the call graph for this function:

void nsView::RemoveChild ( nsView aChild) [inherited]

Definition at line 563 of file nsView.cpp.

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

  if (nsnull != child)
  {
    nsView* prevKid = nsnull;
    nsView* kid = mFirstChild;
    PRBool found = PR_FALSE;
    while (nsnull != kid) {
      if (kid == child) {
        if (nsnull != prevKid) {
          prevKid->SetNextSibling(kid->GetNextSibling());
        } else {
          mFirstChild = kid->GetNextSibling();
        }
        child->SetParent(nsnull);
        found = PR_TRUE;
        break;
      }
      prevKid = kid;
      mChildRemoved = PR_TRUE;
           kid = kid->GetNextSibling();
    }
    NS_ASSERTION(found, "tried to remove non child");

    // If we just removed a root view, then update the RootViewManager
    // on all view managers in the removed subtree.

    nsViewManager *vm = child->GetViewManager();
    if (vm->GetRootView() == child)
    {
      child->InvalidateHierarchy(GetViewManager());
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Removes a scroll position listener.

Implements nsIScrollableView.

Definition at line 144 of file nsScrollPortView.cpp.

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

Here is the call graph for this function:

void nsView::ResetWidgetBounds ( PRBool  aRecurse,
PRBool  aMoveOnly,
PRBool  aInvalidateChangedSize 
) [inherited]

Definition at line 367 of file nsView.cpp.

                                                              {
  if (mWindow) {
    // If our view manager has refresh disabled, then do nothing; the view
    // manager will set our position when refresh is reenabled.  Just let it
    // know that it has pending updates.
    if (!mViewManager->IsRefreshEnabled()) {
      mViewManager->PostPendingUpdate();
      return;
    }

    DoResetWidgetBounds(aMoveOnly, aInvalidateChangedSize);
  } else if (aRecurse) {
    // reposition any widgets under this view
    for (nsView* v = GetFirstChild(); v; v = v->GetNextSibling()) {
      v->ResetWidgetBounds(PR_TRUE, aMoveOnly, aInvalidateChangedSize);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsScrollPortView::Scroll ( nsView aScrolledView,
nsPoint  aTwipsDelta,
nsPoint  aPixDelta,
float  aT2P 
) [protected]

Definition at line 548 of file nsScrollPortView.cpp.

{
  if (aTwipsDelta.x != 0 || aTwipsDelta.y != 0)
  {
    nsIWidget *scrollWidget = GetWidget();
    PRBool canBitBlit = scrollWidget && !CannotBitBlt(aScrolledView);

    if (canBitBlit) {
      // We're going to bit-blit.  Let the viewmanager know so it can
      // adjust dirty regions appropriately.
      mViewManager->WillBitBlit(this, aTwipsDelta);
    }
    
    if (!scrollWidget)
    {
      NS_ASSERTION(!canBitBlit, "Someone screwed up");
      nsPoint offsetToWidget;
      GetNearestWidget(&offsetToWidget);
      // We're moving the child widgets because we are scrolling. But
      // the child widgets may stick outside our bounds, so their area
      // may include area that's not supposed to be scrolled. We need
      // to invalidate to ensure that any such area is properly
      // repainted back to the right rendering.
      AdjustChildWidgets(aScrolledView, offsetToWidget, aT2P, PR_TRUE);
      // If we don't have a scroll widget then we must just update.
      // We should call this after fixing up the widget positions to be
      // consistent with the view hierarchy.
      mViewManager->UpdateView(this, 0);
    } else if (!canBitBlit) {
      // We can't blit for some reason.
      // Just update the view and adjust widgets
      // Recall that our widget's origin is at our bounds' top-left
      nsRect bounds(GetBounds());
      nsPoint topLeft(bounds.x, bounds.y);
      AdjustChildWidgets(aScrolledView,
                         GetPosition() - topLeft, aT2P, PR_FALSE);
      // We should call this after fixing up the widget positions to be
      // consistent with the view hierarchy.
      mViewManager->UpdateView(this, 0);
    } else { // if we can blit and have a scrollwidget then scroll.
      // Scroll the contents of the widget by the specfied amount, and scroll
      // the child widgets
      scrollWidget->Scroll(aPixDelta.x, aPixDelta.y, nsnull);
      mViewManager->UpdateViewAfterScroll(this);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsScrollPortView::ScrollByLines ( PRInt32  aNumLinesX,
PRInt32  aNumLinexY 
) [virtual]

Scroll the view left or right by aNumLinesX columns.

Positive values move right. Scroll the view up or down by aNumLinesY lines. Positive values move down. Prevents scrolling off the end of the view.

Parameters:
aNumLinesXnumber of lines to scroll the view horizontally
aNumLinesYnumber of lines to scroll the view vertically
Returns:
error status

Implements nsIScrollableView.

Definition at line 425 of file nsScrollPortView.cpp.

{
  nscoord dx = mLineHeight*aNumLinesX;
  nscoord dy = mLineHeight*aNumLinesY;

  return ScrollTo(mOffsetX + dx, mOffsetY + dy, NS_VMREFRESH_SMOOTHSCROLL);
}

Here is the call graph for this function:

NS_IMETHODIMP nsScrollPortView::ScrollByPages ( PRInt32  aNumPagesX,
PRInt32  aNumPagesY 
) [virtual]

Scroll the view left or right by aNumPagesX pages.

Positive values move right. Scroll the view up or down by aNumPagesY pages. Positive values move down. A page is considered to be the amount displayed by the clip view. Prevents scrolling off the end of the view.

Parameters:
aNumPagesXnumber of pages to scroll the view horizontally
aNumPagesYnumber of pages to scroll the view vertically
Returns:
error status

Implements nsIScrollableView.

Definition at line 446 of file nsScrollPortView.cpp.

{
  nsSize delta;
  GetPageScrollDistances(&delta);
    
  // put in the number of pages.
  delta.width *= aNumPagesX;
  delta.height *= aNumPagesY;

  return ScrollTo(mOffsetX + delta.width, mOffsetY + delta.height,
                  NS_VMREFRESH_SMOOTHSCROLL);
}

Here is the call graph for this function:

NS_IMETHODIMP nsScrollPortView::ScrollByPixels ( PRInt32  aNumPixelsX,
PRInt32  aNumPixelsY 
) [virtual]

Scroll the view left or right by aNumLinesX pixels.

Positive values move right. Scroll the view up or down by aNumLinesY pixels. Positive values move down. Prevents scrolling off the end of the view.

Parameters:
aNumLinesXnumber of lines to scroll the view horizontally
aNumLinesYnumber of lines to scroll the view vertically
Returns:
error status

Implements nsIScrollableView_MOZILLA_1_8_BRANCH.

Definition at line 475 of file nsScrollPortView.cpp.

{
  nsCOMPtr<nsIDeviceContext> dev;
  mViewManager->GetDeviceContext(*getter_AddRefs(dev));
  float p2t = dev->DevUnitsToAppUnits(); 

  nscoord dx = NSIntPixelsToTwips(aNumPixelsX, p2t);
  nscoord dy = NSIntPixelsToTwips(aNumPixelsY, p2t);

  return ScrollTo(mOffsetX + dx, mOffsetY + dy, 0);
}

Here is the call graph for this function:

Scroll the view to the top or bottom of the document depending on the value of aTop.

Parameters:
aForwardindicates whether to scroll to top or bottom
Returns:
error status

Implements nsIScrollableView.

Definition at line 459 of file nsScrollPortView.cpp.

{
  nscoord   newPos = 0;

  if (!aTop) {
    nsSize scrolledSize;
    nsView* scrolledView = GetScrolledView();
    scrolledView->GetDimensions(scrolledSize);
    newPos = scrolledSize.height;
  }

  ScrollTo(mOffsetX, newPos, 0);

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsScrollPortView::ScrollTo ( nscoord  aX,
nscoord  aY,
PRUint32  aUpdateFlags 
) [virtual]

Scroll the view to the given x,y, update's the scrollbar's thumb positions and the view's offset.

Clamps the values to be legal. Updates the display based on aUpdateFlags.

Parameters:
aXleft edge to scroll to
aYtop edge to scroll to
aUpdateFlagspassed onto nsIViewManager->UpdateView()
Returns:
error status

Implements nsIScrollableView.

Definition at line 258 of file nsScrollPortView.cpp.

{
  // do nothing if the we aren't scrolling.
  if (aDestinationX == mOffsetX && aDestinationY == mOffsetY) {
    // kill any in-progress smooth scroll
    delete mSmoothScroll;
    mSmoothScroll = nsnull;
    return NS_OK;
  }
  
  if ((aUpdateFlags & NS_VMREFRESH_SMOOTHSCROLL) == 0
      || !IsSmoothScrollingEnabled()) {
    // Smooth scrolling is not allowed, so we'll kill any existing smooth-scrolling process
    // and do an instant scroll
    delete mSmoothScroll;
    mSmoothScroll = nsnull;
    return ScrollToImpl(aDestinationX, aDestinationY, aUpdateFlags);
  }

  PRInt32 currentVelocityX;
  PRInt32 currentVelocityY;

  if (mSmoothScroll) {
    currentVelocityX = mSmoothScroll->mVelocities[mSmoothScroll->mFrameIndex*2];
    currentVelocityY = mSmoothScroll->mVelocities[mSmoothScroll->mFrameIndex*2 + 1];
  } else {
    currentVelocityX = 0;
    currentVelocityY = 0;

    mSmoothScroll = new SmoothScroll;
    if (mSmoothScroll) {
      mSmoothScroll->mScrollAnimationTimer = do_CreateInstance("@mozilla.org/timer;1");
      if (!mSmoothScroll->mScrollAnimationTimer) {
        delete mSmoothScroll;
        mSmoothScroll = nsnull;
      }
    }
    if (!mSmoothScroll) {
      // some allocation failed. Scroll the normal way.
      return ScrollToImpl(aDestinationX, aDestinationY, aUpdateFlags);
    }
    mSmoothScroll->mScrollAnimationTimer->InitWithFuncCallback(
      SmoothScrollAnimationCallback, this, SMOOTH_SCROLL_MSECS_PER_FRAME,
      nsITimer::TYPE_REPEATING_PRECISE);
    mSmoothScroll->mDestinationX = mOffsetX;
    mSmoothScroll->mDestinationY = mOffsetY;
  }

  // need to store these so we know when to stop scrolling
  // Treat the desired scroll destination as an offset
  // relative to the current position. This makes things
  // work when someone starts a smooth scroll
  // while an existing smooth scroll has not yet been
  // completed.
  mSmoothScroll->mDestinationX += aDestinationX - mOffsetX;
  mSmoothScroll->mDestinationY += aDestinationY - mOffsetY;
  mSmoothScroll->mFrameIndex = 0;
  ClampScrollValues(mSmoothScroll->mDestinationX, mSmoothScroll->mDestinationY, this);

  nsCOMPtr<nsIDeviceContext> dev;
  mViewManager->GetDeviceContext(*getter_AddRefs(dev));
  float p2t, t2p;
  p2t = dev->DevUnitsToAppUnits(); 
  t2p = dev->AppUnitsToDevUnits();

  // compute velocity vectors
  ComputeVelocities(currentVelocityX, mOffsetX,
                    mSmoothScroll->mDestinationX, mSmoothScroll->mVelocities,
                    t2p, p2t);
  ComputeVelocities(currentVelocityY, mOffsetY,
                    mSmoothScroll->mDestinationY, mSmoothScroll->mVelocities + 1,
                    t2p, p2t);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsScrollPortView::ScrollToImpl ( nscoord  aX,
nscoord  aY,
PRUint32  aUpdateFlags 
) [private]

Definition at line 629 of file nsScrollPortView.cpp.

{
  PRInt32           dxPx = 0, dyPx = 0;

  // convert to pixels
  nsCOMPtr<nsIDeviceContext> dev;
  mViewManager->GetDeviceContext(*getter_AddRefs(dev));
  float t2p, p2t;
  t2p = dev->AppUnitsToDevUnits();
  p2t = dev->DevUnitsToAppUnits();

  // Update the scrolled view's position
  nsresult rv = ClampScrollValues(aX, aY, this);
  if (NS_FAILED(rv)) {
    return rv;
  }
  
  // convert aX and aY in pixels
  nscoord aXpx = NSTwipsToIntPixels(aX, t2p);
  nscoord aYpx = NSTwipsToIntPixels(aY, t2p);
  
  aX = NSIntPixelsToTwips(aXpx,p2t);
  aY = NSIntPixelsToTwips(aYpx,p2t);
  
  // do nothing if the we aren't scrolling.
  // this needs to be rechecked because of the clamping and
  // rounding
  if (aX == mOffsetX && aY == mOffsetY) {
    return NS_OK;
  }

  // figure out the diff by comparing old pos to new
  dxPx = mOffsetXpx - aXpx;
  dyPx = mOffsetYpx - aYpx;

  // notify the listeners.
  PRUint32 listenerCount;
  const nsIID& kScrollPositionListenerIID = NS_GET_IID(nsIScrollPositionListener);
  nsIScrollPositionListener* listener;
  if (nsnull != mListeners) {
    if (NS_SUCCEEDED(mListeners->Count(&listenerCount))) {
      for (PRUint32 i = 0; i < listenerCount; i++) {
        if (NS_SUCCEEDED(mListeners->QueryElementAt(i, kScrollPositionListenerIID, (void**)&listener))) {
          listener->ScrollPositionWillChange(this, aX, aY);
          NS_RELEASE(listener);
        }
      }
    }
  }
  
  nsView* scrolledView = GetScrolledView();
  if (!scrolledView) return NS_ERROR_FAILURE;

  // move the scrolled view to the new location
  // Note that child widgets may be scrolled by the native widget scrolling,
  // so don't update their positions
  scrolledView->SetPositionIgnoringChildWidgets(-aX, -aY);
      
  // store old position in pixels. We need to do this to make sure there is no
  // round off errors. This could cause weird scrolling.
  mOffsetXpx = aXpx;
  mOffsetYpx = aYpx;
      
  nsPoint twipsDelta(aX - mOffsetX, aY - mOffsetY);

  // store the new position
  mOffsetX = aX;
  mOffsetY = aY;
  
  Scroll(scrolledView, twipsDelta, nsPoint(dxPx, dyPx), t2p);

  mViewManager->SynthesizeMouseMove(PR_TRUE);
  
  // notify the listeners.
  if (nsnull != mListeners) {
    if (NS_SUCCEEDED(mListeners->Count(&listenerCount))) {
      for (PRUint32 i = 0; i < listenerCount; i++) {
        if (NS_SUCCEEDED(mListeners->QueryElementAt(i, kScrollPositionListenerIID, (void**)&listener))) {
          listener->ScrollPositionDidChange(this, aX, aY);
          NS_RELEASE(listener);
        }
      }
    }
  }
 
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIView::SetClientData ( void aData) [inline, inherited]

Set the view's link to client owned data.

Parameters:
aData- data to associate with view. nsnull to disassociate

Definition at line 291 of file nsIView.h.

Here is the caller graph for this function:

void nsView::SetClipChildrenToBounds ( PRBool  aDoClip) [inline, inherited]

Definition at line 158 of file nsView.h.

Here is the caller graph for this function:

void nsView::SetClipChildrenToRect ( const nsRect aRect) [inline, inherited]

Called to set the clip of the children of this view.

The clip is relative to the origin of the view. All of the children of this view will be clipped using the specified rectangle

Definition at line 146 of file nsView.h.

                                                  {
    if (!aRect) {
      delete mClipRect;
      mClipRect = nsnull;
    } else {
      if (mClipRect) {
        *mClipRect = *aRect;
      } else {
        mClipRect = new nsRect(*aRect);
      }
    }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void nsView::SetClipPlaceholdersToBounds ( PRBool  aDoClip) [inline, inherited]
NS_IMETHODIMP nsView::SetContentTransparency ( PRBool  aTransparent) [inherited]

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

see HasTransparency().

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

Definition at line 606 of file nsView.cpp.

{
  if (aTransparent == PR_TRUE)
    mVFlags |= NS_VIEW_FLAG_TRANSPARENT;
  else
    mVFlags &= ~NS_VIEW_FLAG_TRANSPARENT;

  return NS_OK;
}

Here is the caller graph for this function:

void nsIView_MOZILLA_1_8_BRANCH::SetDeletionObserver ( nsWeakView aDeletionObserver) [inherited]

Definition at line 922 of file nsView.cpp.

{
  if (mDeletionObserver && aDeletionObserver) {
    aDeletionObserver->SetPrevious(mDeletionObserver);
  }
  mDeletionObserver = aDeletionObserver;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsView::SetDimensions ( const nsRect aRect,
PRBool  aPaint = PR_TRUE,
PRBool  aResizeWidget = PR_TRUE 
) [virtual, inherited]

Called to indicate that the dimensions of the view have been changed.

The x and y coordinates may be < 0, indicating that the view extends above or to the left of its origin position.

Definition at line 449 of file nsView.cpp.

{
  nsRect dims = aRect;
  dims.MoveBy(mPosX, mPosY);

  // 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 (mDimBounds.TopLeft() == dims.TopLeft() &&
      mDimBounds.Size() == dims.Size()) {
    return;
  }

  mDimBounds = dims;

  if (aResizeWidget) {
    ResetWidgetBounds(PR_FALSE, PR_FALSE, aPaint);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsView::SetFloating ( PRBool  aFloatingView) [inherited]

Set/Get 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.

Returns:
PR_TRUE if the view floats, PR_FALSE otherwise.

Definition at line 495 of file nsView.cpp.

{
       if (aFloatingView)
              mVFlags |= NS_VIEW_FLAG_FLOATING;
       else
              mVFlags &= ~NS_VIEW_FLAG_FLOATING;

#if 0
       // recursively make all sub-views "floating" grr.
       for (nsView* child = mFirstChild; chlid; child = child->GetNextSibling()) {
              child->SetFloating(aFloatingView);
       }
#endif

       return NS_OK;
}

Here is the caller graph for this function:

void nsIView::SetHasUniformBackground ( PRBool  aUniform) [inline, inherited]

Indicate that this view is always painted onto a uniform field of pixels.

Thus, even if the view is transparent, it may still be bitblit scrollable because the background that shines through does not vary with position. Caller must ensure that the pixel field belongs to the same element as this view or some ancestor element, so that if the pixel field is in some opacity group, then this view is also in the opacity group (or some subgroup).

Definition at line 275 of file nsIView.h.

Here is the caller graph for this function:

Set the height of a line used for line scrolling.

Parameters:
aHeightnew line height in app units. the default height is 12 points.
Returns:
error status

Implements nsIScrollableView.

Definition at line 413 of file nsScrollPortView.cpp.

{
  mLineHeight = aHeight;
  return NS_OK;
}
void nsView::SetNextSibling ( nsView aSibling) [inline, inherited]

Definition at line 276 of file nsView.h.

{ mNextSibling = aSibling; }

Here is the caller graph for this function:

NS_IMETHODIMP nsView::SetOpacity ( float  opacity) [inherited]

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

Definition at line 600 of file nsView.cpp.

{
  mOpacity = opacity;
  return NS_OK;
}

Here is the caller graph for this function:

void nsView::SetParent ( nsView aParent) [inline, inherited]

Definition at line 274 of file nsView.h.

{ mParent = aParent; }

Here is the caller graph for this function:

void nsView::SetPosition ( nscoord  aX,
nscoord  aY 
) [virtual, inherited]

Called to indicate that the position of the view has been changed.

The specified coordinates are in the parent view's coordinate space.

Parameters:
xnew x position
ynew y position

Definition at line 344 of file nsView.cpp.

{
  mDimBounds.x += aX - mPosX;
  mDimBounds.y += aY - mPosY;
  mPosX = aX;
  mPosY = aY;

  NS_ASSERTION(GetParent() || (aX == 0 && aY == 0),
               "Don't try to move the root widget to something non-zero");

  ResetWidgetBounds(PR_TRUE, PR_TRUE, PR_FALSE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 357 of file nsView.cpp.

{
  mDimBounds.x += aX - mPosX;
  mDimBounds.y += aY - mPosY;
  mPosX = aX;
  mPosY = aY;

  ResetWidgetBounds(PR_FALSE, PR_TRUE, PR_FALSE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Set the view that we are scrolling within the scrolling view.

Implements nsIScrollableView.

Definition at line 373 of file nsScrollPortView.cpp.

{
  NS_ASSERTION(GetFirstChild() == nsnull || GetFirstChild()->GetNextSibling() == nsnull,
               "Error scroll port has too many children");

  // if there is already a child so remove it
  if (GetFirstChild() != nsnull)
  {
    mViewManager->RemoveChild(GetFirstChild());
  }

  return mViewManager->InsertChild(this, aScrolledView, 0);
}

Here is the call graph for this function:

Set the properties describing how scrolling can be performed in this scrollable.

Parameters:
aPropertiesnew properties
Returns:
error status

Implements nsIScrollableView.

Definition at line 401 of file nsScrollPortView.cpp.

{
  mScrollProperties = aProperties;
  return NS_OK;
}
void nsView::SetTopMost ( PRBool  aTopMost) [inline, inherited]

Definition at line 281 of file nsView.h.

Here is the caller graph for this function:

void nsView::SetViewFlags ( PRUint32  aFlags) [inline, inherited]

Definition at line 279 of file nsView.h.

{ mVFlags = aFlags; }

Here is the caller graph for this function:

Called to indicate that the visibility of a view has been changed.

Parameters:
visibilitynew visibility state

Definition at line 469 of file nsView.cpp.

{

  mVis = aVisibility;

  if (aVisibility == nsViewVisibility_kHide)
  {
    DropMouseGrabbing();
  }

  if (nsnull != mWindow)
  {
#ifndef HIDE_ALL_WIDGETS
    if (mVis == nsViewVisibility_kShow)
    {
      DoResetWidgetBounds(PR_FALSE, PR_TRUE);
      mWindow->Show(PR_TRUE);
    }
    else
#endif
      mWindow->Show(PR_FALSE);
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Set the widget associated with this view.

Parameters:
aWidgetwidget to associate with view. It is an error to associate a widget with more than one view. To disassociate a widget from a view, use nsnull. If there are no more references to the widget that may have been associated with the view, it will be destroyed.
Returns:
error status

Reimplemented from nsView.

Definition at line 164 of file nsScrollPortView.cpp.

{
  if (nsnull != aWidget) {
    NS_ASSERTION(PR_FALSE, "please don't try and set a widget here");
    return NS_ERROR_FAILURE;
  }
  return NS_OK;
}
void nsView::SetZIndex ( PRBool  aAuto,
PRInt32  aZIndex,
PRBool  aTopMost 
) [inherited]

Called to indicate that the z-index of a view has been changed.

The z-index is relative to all siblings of the view.

Parameters:
aAutoIndicate 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.
zindexnew z depth

Definition at line 734 of file nsView.cpp.

{
  PRBool oldIsAuto = GetZIndexIsAuto();
  mVFlags = (mVFlags & ~NS_VIEW_FLAG_AUTO_ZINDEX) | (aAuto ? NS_VIEW_FLAG_AUTO_ZINDEX : 0);
  mZIndex = aZIndex;
  SetTopMost(aTopMost);
  
  if (HasWidget() || !oldIsAuto || !aAuto) {
    UpdateNativeWidgetZIndexes(this, FindNonAutoZIndex(this));
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsView::SetZParent ( nsZPlaceholderView aZParent) [inline, inherited]

Definition at line 275 of file nsView.h.

{ mZParent = aZParent; }

Here is the caller graph for this function:

void nsScrollPortView::SmoothScrollAnimationCallback ( nsITimer aTimer,
void aESM 
) [static, private]

Definition at line 741 of file nsScrollPortView.cpp.

{
  nsScrollPortView* self = NS_STATIC_CAST(nsScrollPortView*, anInstance);
  if (self) {
    self->IncrementalScroll();
  }
}

Here is the caller graph for this function:

virtual nsIScrollableView* nsScrollPortView::ToScrollableView ( ) [inline, virtual]

See if this view is scrollable.

Returns:
an nsIScrollableView* if the view is scrollable, or nsnull if not.

Reimplemented from nsIView.

Definition at line 57 of file nsScrollPortView.h.

{ return this; }

Friends And Related Function Documentation

friend class nsWeakView [friend, inherited]

Definition at line 388 of file nsIView.h.


Member Data Documentation

PRPackedBool nsView::mChildRemoved [protected, inherited]

Definition at line 314 of file nsView.h.

void* nsIView::mClientData [protected, inherited]

Definition at line 371 of file nsIView.h.

nsRect* nsView::mClipRect [protected, inherited]

Definition at line 312 of file nsView.h.

Definition at line 389 of file nsIView.h.

nsRect nsIView::mDimBounds [protected, inherited]

Definition at line 375 of file nsIView.h.

nsRegion* nsView::mDirtyRegion [protected, inherited]

Definition at line 313 of file nsView.h.

nsView* nsIView::mFirstChild [protected, inherited]

Definition at line 370 of file nsIView.h.

Definition at line 117 of file nsScrollPortView.h.

Definition at line 118 of file nsScrollPortView.h.

nsView* nsIView::mNextSibling [protected, inherited]

Definition at line 369 of file nsIView.h.

Definition at line 114 of file nsScrollPortView.h.

Definition at line 115 of file nsScrollPortView.h.

Definition at line 114 of file nsScrollPortView.h.

Definition at line 115 of file nsScrollPortView.h.

float nsIView::mOpacity [protected, inherited]

Definition at line 376 of file nsIView.h.

nsView* nsIView::mParent [protected, inherited]

Definition at line 367 of file nsIView.h.

nscoord nsIView::mPosX [protected, inherited]

Definition at line 374 of file nsIView.h.

nscoord nsIView::mPosY [protected, inherited]

Definition at line 374 of file nsIView.h.

Definition at line 116 of file nsScrollPortView.h.

Definition at line 100 of file nsScrollPortView.h.

PRUint32 nsIView::mVFlags [protected, inherited]

Definition at line 377 of file nsIView.h.

nsViewManager* nsIView::mViewManager [protected, inherited]

Definition at line 366 of file nsIView.h.

nsViewVisibility nsIView::mVis [protected, inherited]

Definition at line 373 of file nsIView.h.

nsIWidget* nsIView::mWindow [protected, inherited]

Definition at line 368 of file nsIView.h.

PRInt32 nsIView::mZIndex [protected, inherited]

Definition at line 372 of file nsIView.h.

nsZPlaceholderView* nsView::mZParent [protected, inherited]

Definition at line 309 of file nsView.h.


The documentation for this class was generated from the following files: