Bug 73382. Let the view code work with nsView*/nsViewManager* internally and migrate some methods from public to private to the view module. Also deCOMify those methods for speed. r=kmmclusk,sr=attinasi

This commit is contained in:
roc+%cs.cmu.edu 2001-11-07 04:05:38 +00:00
Родитель 85f7b66d24
Коммит 393683ec75
10 изменённых файлов: 550 добавлений и 916 удалений

Просмотреть файл

@ -255,15 +255,6 @@ public:
*/
NS_IMETHOD GetVisibility(nsViewVisibility &aVisibility) const = 0;
/**
* Called to set the Z-order parent of the view. This is the
* parent from which we derive our Z-order grouping. It might not
* be the same as the geometric parent.
* @param aParent new parent
*/
NS_IMETHOD SetZParent(nsIView *aZParent) = 0;
NS_IMETHOD GetZParent(nsIView *&aZParent) const = 0;
/**
* Called to indicate that the z-index of a view has been changed.
* The z-index is relative to all siblings of the view.
@ -304,13 +295,6 @@ public:
NS_IMETHOD SetFloating(PRBool aFloatingView) = 0;
NS_IMETHOD GetFloating(PRBool &aFloatingView) const = 0;
/**
* Called to set the parent of the view. This is the geometric parent
* (from which we derive our coordinate system).
* @param aParent new parent
*/
NS_IMETHOD SetParent(nsIView *aParent) = 0;
/**
* Called to query the parent of the view.
* @result view's parent
@ -323,43 +307,6 @@ public:
*/
NS_IMETHOD GetNextSibling(nsIView *&aNextSibling) const = 0;
/**
* Called to set the next sibling of the view.
* @param aNextSibling new next sibling
*/
NS_IMETHOD SetNextSibling(nsIView* aNextSibling) = 0;
/**
* Used to insert a child after the specified sibling. In general,
* child insertion will happen through the view manager and it
* will determine the ordering of children in the child list.
* @param child to insert in this view's child list
* @param sibling view to set as previous sibling of child
* if nsnull, then child is inserted at head of list
*/
NS_IMETHOD InsertChild(nsIView *aChild, nsIView *aSibling) = 0;
/**
* Remove a child from the child list. The removal will be driven
* through the view manager.
* @param child to remove
*/
NS_IMETHOD RemoveChild(nsIView *aChild) = 0;
/**
* Get the number of children for this view.
* @result child count
*/
NS_IMETHOD GetChildCount(PRInt32 &aCount) const = 0;
/**
* Get a child at a specific index. Could be replaced by some sort of
* enumeration API.
* @param index of desired child view
* @result the view at index or nsnull if there is no such child
*/
NS_IMETHOD GetChild(PRInt32 index, nsIView*& aChild) const = 0;
/**
* 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
@ -500,14 +447,6 @@ public:
NS_IMETHOD SetCompositorFlags(PRUint32 aFlags) = 0;
NS_IMETHOD GetCompositorFlags(PRUint32 *aFlags) = 0;
/**
* Get the extents of the view tree from 'this' down.
* 'this' is the coordinate system origin.
* @param aExtents out paramemter for extents
* @return error status
*/
NS_IMETHOD GetExtents(nsRect *aExtents) = 0;
// XXX Temporary for Bug #19416
NS_IMETHOD IgnoreSetPosition(PRBool aShouldIgnore) = 0;

Просмотреть файл

@ -320,22 +320,6 @@ public:
*/
NS_IMETHOD MoveViewBelow(nsIView *aView, nsIView *aOther) = 0;
/**
* Returns whether a view is actually shown (based on its visibility
* and that of its ancestors).
* @param aView view to query visibilty of
* @result PR_TRUE if visible, else PR_FALSE
*/
NS_IMETHOD IsViewShown(nsIView *aView, PRBool &aResult) = 0;
/**
* Returns the clipping area of a view in absolute coordinates.
* @param aView view to query clip rect of
* @param rect to set with view's clipping rect
* @result PR_TRUE if there is a clip rect, else PR_FALSE
*/
NS_IMETHOD GetViewClipAbsolute(nsIView *aView, nsRect *aRect, PRBool &aResult) = 0;
/**
* Used set the transparency status of the content in a view. see
* nsIView.HasTransparency().

Просмотреть файл

@ -38,7 +38,6 @@
#include "nsScrollPortView.h"
#include "nsIWidget.h"
#include "nsUnitConversion.h"
#include "nsIViewManager.h"
#include "nsIPresContext.h"
#include "nsIScrollbar.h"
#include "nsIDeviceContext.h"
@ -52,6 +51,7 @@
#include "nsISupportsArray.h"
#include "nsIScrollPositionListener.h"
#include "nsIRegion.h"
#include "nsViewManager.h"
static NS_DEFINE_IID(kWidgetCID, NS_CHILD_CID);
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
@ -199,12 +199,7 @@ NS_IMETHODIMP nsScrollPortView::GetContainerSize(nscoord *aWidth, nscoord *aHeig
*aWidth = 0;
*aHeight = 0;
nsIView *scrolledView = 0;
nsresult result = GetScrolledView(scrolledView);
if (NS_FAILED(result))
return result;
nsView *scrolledView = GetScrolledView();
if (!scrolledView)
return NS_ERROR_FAILURE;
@ -248,7 +243,6 @@ NS_IMETHODIMP nsScrollPortView::ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdat
PRInt32 dxPx = 0, dyPx = 0;
nsIView *scrolledView;
// convert to pixels
nsIDeviceContext *dev;
@ -264,7 +258,7 @@ NS_IMETHODIMP nsScrollPortView::ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdat
// Update the scrolled view's position
// make sure the new position in in bounds
GetScrolledView(scrolledView);
nsView* scrolledView = GetScrolledView();
#ifdef DEBUG_pollmann
NS_ASSERTION(scrolledView, "no scrolled view");
@ -374,7 +368,7 @@ NS_IMETHODIMP nsScrollPortView::GetScrollbarVisibility(PRBool *aVerticalVisible,
}
void nsScrollPortView::AdjustChildWidgets(nsScrollPortView *aScrolling, nsIView *aView, nscoord aDx, nscoord aDy, float scale)
void nsScrollPortView::AdjustChildWidgets(nsScrollPortView *aScrolling, nsView *aView, nscoord aDx, nscoord aDy, float scale)
{
nscoord offx, offy;
@ -391,8 +385,8 @@ void nsScrollPortView::AdjustChildWidgets(nsScrollPortView *aScrolling, nsIView
aDx += offx;
aDy += offy;
nsIView *kid;
for (aView->GetChild(0, kid); kid != nsnull; kid->GetNextSibling(kid))
nsView *kid;
for (kid = aView->GetFirstChild(); kid != nsnull; kid = kid->GetNextSibling())
{
nsIWidget *win;
kid->GetWidget(win);
@ -425,16 +419,14 @@ void nsScrollPortView::AdjustChildWidgets(nsScrollPortView *aScrolling, nsIView
NS_IMETHODIMP nsScrollPortView::SetScrolledView(nsIView *aScrolledView)
{
PRInt32 count = 0;
GetChildCount(count);
PRInt32 count = GetChildCount();
NS_ASSERTION(count <= 1,"Error scroll port has too many children");
// if there is already a child so remove it
if (count == 1)
{
nsIView* child = nsnull;
GetChild(0, child);
nsView* child = GetFirstChild();
mViewManager->RemoveChild(this, child);
}
@ -444,7 +436,8 @@ NS_IMETHODIMP nsScrollPortView::SetScrolledView(nsIView *aScrolledView)
NS_IMETHODIMP nsScrollPortView::GetScrolledView(nsIView *&aScrolledView) const
{
return GetChild(0, aScrolledView);
aScrolledView = GetScrolledView();
return NS_OK;
}
NS_IMETHODIMP nsScrollPortView::GetScrollPosition(nscoord &aX, nscoord &aY) const
@ -523,7 +516,7 @@ NS_IMETHODIMP nsScrollPortView::ScrollByWhole(PRBool aTop)
return NS_OK;
}
PRBool nsScrollPortView::CannotBitBlt(nsIView* aScrolledView)
PRBool nsScrollPortView::CannotBitBlt(nsView* aScrolledView)
{
PRBool trans;
float opacity;
@ -539,7 +532,7 @@ PRBool nsScrollPortView::CannotBitBlt(nsIView* aScrolledView)
}
void nsScrollPortView::Scroll(nsIView *aScrolledView, PRInt32 aDx, PRInt32 aDy, float scale, PRUint32 aUpdateFlags)
void nsScrollPortView::Scroll(nsView *aScrolledView, PRInt32 aDx, PRInt32 aDy, float scale, PRUint32 aUpdateFlags)
{
if ((aDx != 0) || (aDy != 0))
{
@ -588,3 +581,19 @@ NS_IMETHODIMP nsScrollPortView::Paint(nsIRenderingContext& rc, const nsRect& rec
return rv;
}
NS_IMETHODIMP nsScrollPortView::Paint(nsIRenderingContext& aRC, const nsIRegion& aRegion,
PRUint32 aPaintFlags, PRBool &aResult)
{
PRBool clipEmpty;
aRC.PushState();
nsRect bounds = mBounds;
bounds.x = bounds.y = 0;
aRC.SetClipRect(bounds, nsClipCombine_kIntersect, clipEmpty);
nsresult rv = nsView::Paint(aRC, aRegion, aPaintFlags, aResult);
aRC.PopState(clipEmpty);
return rv;
}

Просмотреть файл

@ -98,25 +98,12 @@ public:
NS_IMETHOD AddScrollPositionListener(nsIScrollPositionListener* aListener);
NS_IMETHOD RemoveScrollPositionListener(nsIScrollPositionListener* aListener);
//locals
//void HandleScrollEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags);
// Set the visibility of a nsScrollPortView's component
// @param aView nsScrollPortView component to set visibility for or nsnull.
// @param aViewVisibility new setting for the component view If not the same as the current setting
// @returns the result of calling the SetVisibility on the component.
//nsresult SetComponentVisibility(nsIView* aView, nsViewVisibility aViewVisibility);
// Update the visibility of the nsScrollPortView's components (ClipView, CornerView, ScrollBarView's)
// @param aScrollingViewVisibility Visibility setting of the ScrollingView to consider when
// setting the visibility of the components. If aScrollingViewVisibility == nsViewVisibility_kInherit then
// UpdateComponent has no effect.
// @returns the result of calling SetComponentVisibility for each component.
//nsresult UpdateComponentVisibility(nsViewVisibility aScrollingViewVisibility);
// local to the view module
NS_IMETHOD Paint(nsIRenderingContext& rc, const nsRect& rect,
PRUint32 aPaintFlags, PRBool &Result);
NS_IMETHOD Paint(nsIRenderingContext& aRC, const nsIRegion& aRegion,
PRUint32 aPaintFlags, PRBool &Result);
private:
NS_IMETHOD_(nsrefcnt) AddRef(void);
@ -129,22 +116,13 @@ protected:
//NS_IMETHOD_(void) Notify(nsITimer *timer);
//private
void AdjustChildWidgets(nsScrollPortView *aScrolling, nsIView *aView, nscoord aDx, nscoord aDy, float aScale);
//void UpdateScrollControls(PRBool aPaint);
void Scroll(nsIView *aScrolledView, PRInt32 aDx, PRInt32 aDy, float scale, PRUint32 aUpdateFlags);
PRBool CannotBitBlt(nsIView* aScrolledView);
nsView* GetScrolledView() const { return GetFirstChild(); }
void AdjustChildWidgets(nsScrollPortView *aScrolling, nsView *aView, nscoord aDx, nscoord aDy, float aScale);
void Scroll(nsView *aScrolledView, PRInt32 aDx, PRInt32 aDy, float scale, PRUint32 aUpdateFlags);
PRBool CannotBitBlt(nsView* aScrolledView);
protected:
//nscoord mSizeX, mSizeY;
nscoord mOffsetX, mOffsetY;
nscoord mOffsetXpx, mOffsetYpx;
//nsIView *mClipView;
//nsIView *mVScrollBarView;
//nsIView *mHScrollBarView;
//nsIView *mCornerView;
//nsScrollPreference mScrollPref;
//nsMargin mInsets;
//nsITimer *mScrollingTimer;
//nscoord mScrollingDelta;
PRUint32 mScrollProperties;
nscoord mLineHeight;
nsISupportsArray *mListeners;

Просмотреть файл

@ -38,7 +38,6 @@
#include "nsScrollingView.h"
#include "nsIWidget.h"
#include "nsUnitConversion.h"
#include "nsIViewManager.h"
#include "nsIPresContext.h"
#include "nsIScrollbar.h"
#include "nsIDeviceContext.h"
@ -52,6 +51,7 @@
#include "nsISupportsArray.h"
#include "nsIScrollPositionListener.h"
#include "nsIRegion.h"
#include "nsViewManager.h"
static NS_DEFINE_IID(kWidgetCID, NS_CHILD_CID);
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
@ -535,7 +535,6 @@ NS_IMETHODIMP nsScrollingView::SetPosition(nscoord aX, nscoord aY)
nsIWidget *thiswin;
GetWidget(thiswin);
float t2p;
nsIView *scrolledView;
if (nsnull == thiswin)
GetOffsetFromWidget(nsnull, nsnull, thiswin);
@ -548,8 +547,7 @@ NS_IMETHODIMP nsScrollingView::SetPosition(nscoord aX, nscoord aY)
mViewManager->GetDeviceContext(dx);
dx->GetAppUnitsToDevUnits(t2p);
GetScrolledView(scrolledView);
nsView* scrolledView = GetScrolledView();
if (scrolledView)
{
// Adjust the positions of the scrollbars and clip view's widget
@ -568,7 +566,7 @@ NS_IMETHODIMP nsScrollingView::SetPosition(nscoord aX, nscoord aY)
}
nsresult
nsScrollingView::SetComponentVisibility(nsIView* aView, nsViewVisibility aViewVisibility)
nsScrollingView::SetComponentVisibility(nsView* aView, nsViewVisibility aViewVisibility)
{
nsresult rv = NS_OK;
if (nsnull != aView) {
@ -757,8 +755,7 @@ void nsScrollingView::HandleScrollEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags
mOffsetY = offsetY;
// Position the scrolled view
nsIView *scrolledView;
GetScrolledView(scrolledView);
nsView *scrolledView = GetScrolledView();
if(scrolledView) {
scrolledView->SetPosition(-mOffsetX, -mOffsetY);
Scroll(scrolledView, dx, dy, t2p, 0);
@ -769,8 +766,6 @@ void nsScrollingView::HandleScrollEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags
NS_IMETHODIMP_(void) nsScrollingView::Notify(nsITimer * aTimer)
{
nscoord xoff, yoff;
nsIView *view;
GetScrolledView(view);
// First do the scrolling of the view
xoff = mOffsetX;
@ -896,11 +891,10 @@ NS_IMETHODIMP nsScrollingView::CreateScrollControls(nsNativeWidget aNative)
// Find Parent view with window and remember the window
nsIWidget * win = nsnull;
nsIView * view = (nsIView *)this;
nsView * view = this;
view->GetWidget(win);
while (win == nsnull) {
nsIView * parent;
view->GetParent(parent);
nsView * parent = view->GetParent();
if (nsnull == parent) {
break;
}
@ -973,8 +967,7 @@ NS_IMETHODIMP nsScrollingView::SetZIndex(PRInt32 aZIndex)
NS_IMETHODIMP nsScrollingView::ComputeScrollOffsets(PRBool aAdjustWidgets)
{
nsIView *scrolledView;
GetScrolledView(scrolledView);
nsView *scrolledView = GetScrolledView();
nsIScrollbar *scrollv = nsnull, *scrollh = nsnull;
PRBool hasVertical = PR_TRUE, hasHorizontal = PR_FALSE;
nsIWidget *win;
@ -1280,7 +1273,6 @@ NS_IMETHODIMP nsScrollingView::ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdate
nsSize clipSize;
nsIWidget *widget;
PRInt32 dx = 0, dy = 0;
nsIView *scrolledView;
mViewManager->GetDeviceContext(dev);
dev->GetAppUnitsToDevUnits(t2p);
@ -1353,7 +1345,7 @@ NS_IMETHODIMP nsScrollingView::ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdate
// Update the scrolled view's position
GetScrolledView(scrolledView);
nsView* scrolledView = GetScrolledView();
NotifyScrollPositionWillChange(aX, aY);
@ -1392,7 +1384,8 @@ NS_IMETHODIMP nsScrollingView::GetScrollbarVisibility(PRBool *aVerticalVisible,
return NS_OK;
}
void nsScrollingView::AdjustChildWidgets(nsScrollingView *aScrolling, nsIView *aView, nscoord aDx, nscoord aDy, float scale)
void nsScrollingView::AdjustChildWidgets(nsScrollingView *aScrolling, nsView *aView,
nscoord aDx, nscoord aDy, float scale)
{
nscoord offx, offy;
PRBool isscroll = PR_FALSE;
@ -1409,8 +1402,8 @@ void nsScrollingView::AdjustChildWidgets(nsScrollingView *aScrolling, nsIView *a
aDx += offx;
aDy += offy;
nsIView *kid;
for (aView->GetChild(0, kid); kid != nsnull; kid->GetNextSibling(kid))
nsView* kid;
for (kid = aView->GetFirstChild(); kid != nsnull; kid = kid->GetNextSibling())
{
nsIWidget *win;
kid->GetWidget(win);
@ -1528,16 +1521,20 @@ NS_IMETHODIMP nsScrollingView::SetScrolledView(nsIView *aScrolledView)
return mViewManager->InsertChild(mClipView, aScrolledView, 0);
}
nsView* nsScrollingView::GetScrolledView() const
{
if (nsnull != mClipView) {
return mClipView->GetFirstChild();
} else {
return nsnull;
}
}
NS_IMETHODIMP nsScrollingView::GetScrolledView(nsIView *&aScrolledView) const
{
if (nsnull != mClipView)
return mClipView->GetChild(0, aScrolledView);
else
{
aScrolledView = nsnull;
aScrolledView = GetScrolledView();
return NS_OK;
}
}
NS_IMETHODIMP nsScrollingView::GetScrollPosition(nscoord &aX, nscoord &aY) const
{
@ -1673,7 +1670,7 @@ NS_IMETHODIMP nsScrollingView::ScrollByWhole(PRBool aTop)
return NS_OK;
}
PRBool nsScrollingView::CannotBitBlt(nsIView* aScrolledView)
PRBool nsScrollingView::CannotBitBlt(nsView* aScrolledView)
{
PRBool trans;
float opacity;
@ -1688,7 +1685,8 @@ PRBool nsScrollingView::CannotBitBlt(nsIView* aScrolledView)
(scrolledViewFlags & NS_VIEW_PUBLIC_FLAG_DONT_BITBLT);
}
void nsScrollingView::Scroll(nsIView *aScrolledView, PRInt32 aDx, PRInt32 aDy, float scale, PRUint32 aUpdateFlags)
void nsScrollingView::Scroll(nsView *aScrolledView, PRInt32 aDx, PRInt32 aDy,
float scale, PRUint32 aUpdateFlags)
{
if ((aDx != 0) || (aDy != 0))
{

Просмотреть файл

@ -102,14 +102,14 @@ public:
NS_IMETHOD AddScrollPositionListener(nsIScrollPositionListener* aListener);
NS_IMETHOD RemoveScrollPositionListener(nsIScrollPositionListener* aListener);
//locals
// local to view module
void HandleScrollEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags);
// Set the visibility of a nsScrollingView's component
// @param aView nsScrollingView component to set visibility for or nsnull.
// @param aViewVisibility new setting for the component view If not the same as the current setting
// @returns the result of calling the SetVisibility on the component.
nsresult SetComponentVisibility(nsIView* aView, nsViewVisibility aViewVisibility);
nsresult SetComponentVisibility(nsView* aView, nsViewVisibility aViewVisibility);
// Update the visibility of the nsScrollingView's components (ClipView, CornerView, ScrollBarView's)
// @param aScrollingViewVisibility Visibility setting of the ScrollingView to consider when
@ -121,6 +121,7 @@ public:
nsresult NotifyScrollPositionWillChange(nscoord aX, nscoord aY);
nsresult NotifyScrollPositionDidChange(nscoord aX, nscoord aY);
nsView* GetScrolledView() const;
private:
NS_IMETHOD_(nsrefcnt) AddRef(void);
@ -133,19 +134,18 @@ protected:
NS_IMETHOD_(void) Notify(nsITimer *timer);
//private
void AdjustChildWidgets(nsScrollingView *aScrolling, nsIView *aView, nscoord aDx, nscoord aDy, float aScale);
void AdjustChildWidgets(nsScrollingView *aScrolling, nsView *aView, nscoord aDx, nscoord aDy, float aScale);
void UpdateScrollControls(PRBool aPaint);
void Scroll(nsIView *aScrolledView, PRInt32 aDx, PRInt32 aDy, float scale, PRUint32 aUpdateFlags);
PRBool CannotBitBlt(nsIView* aScrolledView);
void Scroll(nsView *aScrolledView, PRInt32 aDx, PRInt32 aDy, float scale, PRUint32 aUpdateFlags);
PRBool CannotBitBlt(nsView* aScrolledView);
protected:
nscoord mSizeX, mSizeY;
nscoord mOffsetX, mOffsetY;
nsIView *mClipView;
nsIView *mVScrollBarView;
nsIView *mHScrollBarView;
nsIView *mCornerView;
nsView *mClipView;
nsView *mVScrollBarView;
nsView *mHScrollBarView;
nsView *mCornerView;
nsScrollPreference mScrollPref;
nsMargin mInsets;
nsCOMPtr<nsITimer> mScrollingTimer;

Просмотреть файл

@ -37,7 +37,7 @@
#include "nsView.h"
#include "nsIWidget.h"
#include "nsIViewManager.h"
#include "nsViewManager.h"
#include "nsIFrame.h"
#include "nsIPresContext.h"
#include "nsIWidget.h"
@ -72,15 +72,13 @@ nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent)
//printf(" %d %d %d (%d,%d) \n", aEvent->widget, aEvent->widgetSupports,
// aEvent->message, aEvent->point.x, aEvent->point.y);
nsEventStatus result = nsEventStatus_eIgnore;
nsIView *view = nsView::GetViewFor(aEvent->widget);
nsView *view = nsView::GetViewFor(aEvent->widget);
if (nsnull != view)
{
nsIViewManager *vm;
nsViewManager *vm = view->GetViewManager();
view->GetViewManager(vm);
vm->DispatchEvent(aEvent, &result);
NS_RELEASE(vm);
}
return result;
@ -105,24 +103,14 @@ nsView :: ~nsView()
mVFlags |= NS_VIEW_PUBLIC_FLAG_DYING;
PRInt32 numKids;
GetChildCount(numKids);
if (numKids > 0)
while (GetFirstChild() != nsnull)
{
nsIView *kid;
//nuke the kids
do {
GetChild(0, kid);
if (nsnull != kid)
kid->Destroy();
} while (nsnull != kid);
GetFirstChild()->Destroy();
}
if (nsnull != mViewManager)
{
nsIView *rootView;
mViewManager->GetRootView(rootView);
nsView *rootView = mViewManager->GetRootView();
if (nsnull != rootView)
{
@ -144,8 +132,7 @@ nsView :: ~nsView()
mParent->RemoveChild(this);
}
nsIView* grabbingView; //check to see if we are capturing!!!
mViewManager->GetMouseEventGrabber(grabbingView);
nsView* grabbingView = mViewManager->GetMouseEventGrabber(); //check to see if we are capturing!!!
if (grabbingView == this)
{
PRBool boolResult;//not used
@ -203,26 +190,24 @@ nsrefcnt nsView::Release()
return 1;
}
nsIView* nsView::GetViewFor(nsIWidget* aWidget)
nsView* nsView::GetViewFor(nsIWidget* aWidget)
{
nsIView* view = nsnull;
void* clientData;
NS_PRECONDITION(nsnull != aWidget, "null widget ptr");
// The widget's client data points back to the owning view
if (aWidget && NS_SUCCEEDED(aWidget->GetClientData(clientData))) {
view = (nsIView*)clientData;
nsISupports* data = (nsISupports*)clientData;
if (nsnull != data) {
if (NS_FAILED(data->QueryInterface(NS_GET_IID(nsIView), (void **)&view))) {
return nsnull; // return null if client data isn't a view
nsIView* view = nsnull;
if (NS_SUCCEEDED(data->QueryInterface(NS_GET_IID(nsIView), (void **)&view))) {
return NS_STATIC_CAST(nsView*, view);
}
}
}
return view;
return nsnull;
}
NS_IMETHODIMP nsView :: Init(nsIViewManager* aManager,
@ -239,7 +224,7 @@ NS_IMETHODIMP nsView :: Init(nsIViewManager* aManager,
return NS_ERROR_ALREADY_INITIALIZED;
}
// we don't hold a reference to the view manager
mViewManager = aManager;
mViewManager = NS_STATIC_CAST(nsViewManager*, aManager);
mChildClip.mLeft = 0;
mChildClip.mRight = 0;
@ -249,7 +234,7 @@ NS_IMETHODIMP nsView :: Init(nsIViewManager* aManager,
SetBounds(aBounds);
//temporarily set it...
SetParent((nsIView *)aParent);
SetParent(NS_CONST_CAST(nsView*, NS_STATIC_CAST(const nsView*, aParent)));
SetVisibility(aVisibilityFlag);
@ -335,18 +320,16 @@ NS_IMETHODIMP nsView :: HandleEvent(nsGUIEvent *event, PRUint32 aEventFlags,
//see if any of this view's children can process the event
if ( !(mVFlags & NS_VIEW_PUBLIC_FLAG_DONT_CHECK_CHILDREN) ) {
PRInt32 numkids;
PRInt32 numkids = GetChildCount();
nsRect trect;
nscoord x, y;
GetChildCount(numkids);
x = event->point.x;
y = event->point.y;
for (PRInt32 cnt = 0; cnt < numkids && !aHandled; cnt++)
{
nsIView *pKid;
GetChild(cnt, pKid);
nsView *pKid = GetChild(cnt);
if (!pKid) break;
pKid->GetBounds(trect);
@ -555,11 +538,9 @@ NS_IMETHODIMP nsView :: SynchWidgetSizePosition()
NS_IMETHODIMP nsView :: GetPosition(nscoord *x, nscoord *y) const
{
nsIView *rootView;
nsView *rootView = mViewManager->GetRootView();
mViewManager->GetRootView(rootView);
if (this == ((const nsView*)rootView))
if (this == rootView)
*x = *y = 0;
else
{
@ -648,18 +629,16 @@ NS_IMETHODIMP nsView :: SetBounds(nscoord aX, nscoord aY, nscoord aWidth, nscoor
NS_IMETHODIMP nsView :: GetBounds(nsRect &aBounds) const
{
nsIView *rootView = nsnull;
NS_ASSERTION(mViewManager, "mViewManager is null!");
if (!mViewManager) {
aBounds.x = aBounds.y = 0;
return NS_ERROR_FAILURE;
}
mViewManager->GetRootView(rootView);
nsView *rootView = mViewManager->GetRootView();
aBounds = mBounds;
if ((nsIView *)this == rootView)
if (this == rootView)
aBounds.x = aBounds.y = 0;
return NS_OK;
@ -692,8 +671,7 @@ NS_IMETHODIMP nsView :: SetVisibility(nsViewVisibility aVisibility)
if (aVisibility == nsViewVisibility_kHide)
{
nsIView* grabbingView; //check to see if we are grabbing events
mViewManager->GetMouseEventGrabber(grabbingView);
nsView* grabbingView = mViewManager->GetMouseEventGrabber(); //check to see if we are grabbing events
if (grabbingView == this)
{
//if yes then we must release them before we become hidden and can't get them
@ -721,18 +699,6 @@ NS_IMETHODIMP nsView :: GetVisibility(nsViewVisibility &aVisibility) const
return NS_OK;
}
NS_IMETHODIMP nsView :: SetZParent(nsIView *aZParent)
{
mZParent = aZParent;
return NS_OK;
}
NS_IMETHODIMP nsView :: GetZParent(nsIView *&aZParent) const
{
aZParent = mZParent;
return NS_OK;
}
NS_IMETHODIMP nsView::SetZIndex(PRInt32 aZIndex)
{
mZindex = aZIndex;
@ -791,12 +757,6 @@ NS_IMETHODIMP nsView::GetFloating(PRBool &aFloatingView) const
return NS_OK;
}
NS_IMETHODIMP nsView :: SetParent(nsIView *aParent)
{
mParent = aParent;
return NS_OK;
}
NS_IMETHODIMP nsView :: GetParent(nsIView *&aParent) const
{
aParent = mParent;
@ -809,59 +769,49 @@ NS_IMETHODIMP nsView :: GetNextSibling(nsIView *&aNextSibling) const
return NS_OK;
}
NS_IMETHODIMP nsView::SetNextSibling(nsIView* aView)
void nsView :: InsertChild(nsView *aChild, nsView *aSibling)
{
mNextSibling = aView;
return NS_OK;
}
NS_PRECONDITION(nsnull != aChild, "null ptr");
NS_IMETHODIMP nsView :: InsertChild(nsIView *child, nsIView *sibling)
if (nsnull != aChild)
{
NS_PRECONDITION(nsnull != child, "null ptr");
if (nsnull != child)
{
if (nsnull != sibling)
if (nsnull != aSibling)
{
#ifdef NS_DEBUG
nsIView* siblingParent;
sibling->GetParent(siblingParent);
nsView* siblingParent = aSibling->GetParent();
NS_ASSERTION(siblingParent == this, "tried to insert view with invalid sibling");
#endif
//insert after sibling
nsIView* siblingNextSibling;
sibling->GetNextSibling(siblingNextSibling);
child->SetNextSibling(siblingNextSibling);
sibling->SetNextSibling(child);
nsView* siblingNextSibling = aSibling->GetNextSibling();
aChild->SetNextSibling(siblingNextSibling);
aSibling->SetNextSibling(aChild);
}
else
{
child->SetNextSibling(mFirstChild);
mFirstChild = child;
aChild->SetNextSibling(mFirstChild);
mFirstChild = aChild;
}
child->SetParent(this);
aChild->SetParent(this);
mNumKids++;
}
return NS_OK;
}
NS_IMETHODIMP nsView :: RemoveChild(nsIView *child)
void nsView :: RemoveChild(nsView *child)
{
NS_PRECONDITION(nsnull != child, "null ptr");
if (nsnull != child)
{
nsIView* prevKid = nsnull;
nsIView* kid = mFirstChild;
nsView* prevKid = nsnull;
nsView* kid = mFirstChild;
PRBool found = PR_FALSE;
while (nsnull != kid) {
if (kid == child) {
if (nsnull != prevKid) {
nsIView* kidNextSibling;
kid->GetNextSibling(kidNextSibling);
nsView* kidNextSibling = kid->GetNextSibling();
prevKid->SetNextSibling(kidNextSibling);
} else {
kid->GetNextSibling(mFirstChild);
mFirstChild = kid->GetNextSibling();
}
child->SetParent(nsnull);
mNumKids--;
@ -869,34 +819,21 @@ NS_IMETHODIMP nsView :: RemoveChild(nsIView *child)
break;
}
prevKid = kid;
kid->GetNextSibling(kid);
kid = kid->GetNextSibling();
}
NS_ASSERTION(found, "tried to remove non child");
}
return NS_OK;
}
NS_IMETHODIMP nsView :: GetChildCount(PRInt32 &aCount) const
nsView* nsView :: GetChild(PRInt32 aIndex) const
{
aCount = mNumKids;
return NS_OK;
for (nsView* child = GetFirstChild(); child != nsnull; child = child->GetNextSibling()) {
if (aIndex == 0) {
return child;
}
NS_IMETHODIMP nsView :: GetChild(PRInt32 index, nsIView *&aChild) const
{
NS_PRECONDITION(!(index > mNumKids), "bad index");
aChild = nsnull;
if (index < mNumKids)
{
aChild = mFirstChild;
for (PRInt32 cnt = 0; (cnt < index) && (nsnull != aChild); cnt++) {
aChild->GetNextSibling(aChild);
--aIndex;
}
}
return NS_OK;
return nsnull;
}
NS_IMETHODIMP nsView :: SetOpacity(float opacity)
@ -1042,7 +979,7 @@ NS_IMETHODIMP nsView::List(FILE* out, PRInt32 aIndent) const
{
PRInt32 i;
for (i = aIndent; --i >= 0; ) fputs(" ", out);
fprintf(out, "%p ", this);
fprintf(out, "%p ", (void*)this);
if (nsnull != mWindow) {
nsRect windowBounds;
nsRect nonclientBounds;
@ -1058,7 +995,7 @@ NS_IMETHODIMP nsView::List(FILE* out, PRInt32 aIndent) const
nsrefcnt widgetRefCnt = mWindow->AddRef() - 1;
mWindow->Release();
fprintf(out, "(widget=%p[%d] pos={%d,%d,%d,%d}) ",
mWindow, widgetRefCnt,
(void*)mWindow, widgetRefCnt,
nonclientBounds.x, nonclientBounds.y,
windowBounds.width, windowBounds.height);
}
@ -1069,10 +1006,10 @@ NS_IMETHODIMP nsView::List(FILE* out, PRInt32 aIndent) const
PRBool hasTransparency;
HasTransparency(hasTransparency);
fprintf(out, " z=%d vis=%d opc=%1.3f tran=%d clientData=%p <\n", mZindex, mVis, mOpacity, hasTransparency, mClientData);
nsIView* kid = mFirstChild;
nsView* kid = mFirstChild;
while (nsnull != kid) {
kid->List(out, aIndent + 1);
kid->GetNextSibling(kid);
kid = kid->GetNextSibling();
}
for (i = aIndent; --i >= 0; ) fputs(" ", out);
fputs(">\n", out);
@ -1100,12 +1037,11 @@ NS_IMETHODIMP nsView :: GetViewFlags(PRUint32 *aFlags) const
NS_IMETHODIMP nsView :: GetOffsetFromWidget(nscoord *aDx, nscoord *aDy, nsIWidget *&aWidget)
{
nsIView *ancestor;
nsView *ancestor = GetParent();
aWidget = nsnull;
// XXX aDx and aDy are OUT parameters and so we should initialize them
// to 0 rather than relying on the caller to do so...
GetParent(ancestor);
while (nsnull != ancestor)
{
ancestor->GetWidget(aWidget);
@ -1122,16 +1058,14 @@ NS_IMETHODIMP nsView :: GetOffsetFromWidget(nscoord *aDx, nscoord *aDy, nsIWidge
*aDy += offy;
}
ancestor->GetParent(ancestor);
ancestor = ancestor->GetParent();
}
if (nsnull == aWidget) {
// The root view doesn't have a widget
// but maybe the view manager does.
nsCOMPtr<nsIViewManager> vm;
GetViewManager(*getter_AddRefs(vm));
vm->GetWidget(&aWidget);
GetViewManager()->GetWidget(&aWidget);
}
return NS_OK;
@ -1174,59 +1108,13 @@ NS_IMETHODIMP nsView::GetCompositorFlags(PRUint32 *aFlags)
return NS_OK;
}
static void calc_extents(nsIView *view, nsRect *extents, nscoord ox, nscoord oy)
{
nsIView *kid;
nsRect bounds;
nsIClipView *cview;
view->GetChild(0, kid);
while (nsnull != kid)
{
kid->GetBounds(bounds);
bounds.x += ox;
bounds.y += oy;
extents->UnionRect(*extents, bounds);
cview = nsnull;
kid->QueryInterface(NS_GET_IID(nsIClipView), (void **)&cview);
if (!cview)
calc_extents(kid, extents, bounds.x, bounds.y);
kid->GetNextSibling(kid);
}
}
NS_IMETHODIMP nsView :: GetExtents(nsRect *aExtents)
{
GetBounds(*aExtents);
aExtents->x = 0;
aExtents->y = 0;
calc_extents(this, aExtents, 0, 0);
return NS_OK;
}
PRBool nsView :: IsRoot()
{
nsIView *rootView;
NS_ASSERTION(mViewManager != nsnull," View manager is null in nsView::IsRoot()");
mViewManager->GetRootView(rootView);
if (rootView == this) {
return PR_TRUE;
return mViewManager->GetRootView() == this;
}
return PR_FALSE;
}
PRBool nsView::PointIsInside(nsIView& aView, nscoord x, nscoord y) const
PRBool nsView::PointIsInside(nsView& aView, nscoord x, nscoord y) const
{
nsRect clippedRect;
PRBool empty;
@ -1258,8 +1146,7 @@ NS_IMETHODIMP nsView::GetClippedRect(nsRect& aClippedRect, PRBool& aIsClipped, P
aIsClipped = PR_FALSE;
GetBounds(aClippedRect);
nsIView* parentView;
GetParent(parentView);
nsView* parentView = GetParent();
// Walk all of the way up the views to see if any
// ancestor sets the NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN
@ -1292,7 +1179,7 @@ NS_IMETHODIMP nsView::GetClippedRect(nsRect& aClippedRect, PRBool& aIsClipped, P
ancestorX -= bounds.x;
ancestorY -= bounds.y;
parentView->GetParent(parentView);
parentView = parentView->GetParent();
}
return NS_OK;

Просмотреть файл

@ -49,6 +49,8 @@
class nsIPresContext;
class nsIViewManager;
class nsViewManager;
class nsZPlaceholderView;
class nsView : public nsIView
{
@ -88,22 +90,14 @@ public:
NS_IMETHOD GetChildClip(nscoord *aLeft, nscoord *aTop, nscoord *aRight, nscoord *aBottom) const;
NS_IMETHOD SetVisibility(nsViewVisibility visibility);
NS_IMETHOD GetVisibility(nsViewVisibility &aVisibility) const;
NS_IMETHOD SetZParent(nsIView *aZParent);
NS_IMETHOD GetZParent(nsIView *&aZParent) const;
NS_IMETHOD SetZIndex(PRInt32 aZIndex);
NS_IMETHOD GetZIndex(PRInt32 &aZIndex) const;
NS_IMETHOD SetAutoZIndex(PRBool aAutoZIndex);
NS_IMETHOD GetAutoZIndex(PRBool &aAutoZIndex) const;
NS_IMETHOD SetFloating(PRBool aFloatingView);
NS_IMETHOD GetFloating(PRBool &aFloatingView) const;
NS_IMETHOD SetParent(nsIView *aParent);
NS_IMETHOD GetParent(nsIView *&aParent) const;
NS_IMETHOD GetNextSibling(nsIView *&aNextSibling) const;
NS_IMETHOD SetNextSibling(nsIView* aNextSibling);
NS_IMETHOD InsertChild(nsIView *child, nsIView *sibling);
NS_IMETHOD RemoveChild(nsIView *child);
NS_IMETHOD GetChildCount(PRInt32 &aCount) const;
NS_IMETHOD GetChild(PRInt32 index, nsIView*& aChild) const;
NS_IMETHOD SetOpacity(float opacity);
NS_IMETHOD GetOpacity(float &aOpacity) const;
NS_IMETHOD HasTransparency(PRBool &aTransparent) const;
@ -126,7 +120,6 @@ public:
NS_IMETHOD GetViewFlags(PRUint32 *aFlags) const;
NS_IMETHOD SetCompositorFlags(PRUint32 aFlags);
NS_IMETHOD GetCompositorFlags(PRUint32 *aFlags);
NS_IMETHOD GetExtents(nsRect *aExtents);
NS_IMETHOD GetClippedRect(nsRect& aClippedRect, PRBool& aIsClipped, PRBool& aEmpty) const;
@ -137,13 +130,30 @@ public:
// Helper function to get the view that's associated with a widget
static nsIView* GetViewFor(nsIWidget* aWidget);
static nsView* GetViewFor(nsIWidget* aWidget);
// Helper function to determine if the view instance is the root view
PRBool IsRoot();
// Helper function to determine if the view point is inside of a view
PRBool PointIsInside(nsIView& aView, nscoord x, nscoord y) const;
PRBool PointIsInside(nsView& aView, nscoord x, nscoord y) const;
public: // NOT in nsIView, so only available in view module
nsView* GetFirstChild() const { return mFirstChild; }
nsView* GetNextSibling() const { return mNextSibling; }
nsView* GetParent() const { return mParent; }
nsZPlaceholderView* GetZParent() const { return mZParent; }
nsViewManager* GetViewManager() const { return mViewManager; }
PRInt32 GetChildCount() const { return mNumKids; }
nsView* GetChild(PRInt32 aIndex) const;
void InsertChild(nsView *aChild, nsView *aSibling);
void RemoveChild(nsView *aChild);
void SetParent(nsView *aParent) { mParent = aParent; }
void SetZParent(nsZPlaceholderView *aZParent) { mZParent = aZParent; }
void SetNextSibling(nsView *aSibling) { mNextSibling = aSibling; }
protected:
virtual ~nsView();
@ -151,15 +161,15 @@ protected:
virtual nsresult LoadWidget(const nsCID &aClassIID);
protected:
nsIViewManager *mViewManager;
nsIView *mParent;
nsViewManager *mViewManager;
nsView *mParent;
nsIWidget *mWindow;
nsIView *mZParent;
nsZPlaceholderView*mZParent;
//XXX should there be pointers to last child so backward walking is fast?
nsIView *mNextSibling;
nsIView *mFirstChild;
nsView *mNextSibling;
nsView *mFirstChild;
void *mClientData;
PRInt32 mZindex;
nsViewVisibility mVis;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: true; c-basic-offset: 4 -*- */
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
@ -51,11 +51,13 @@
#include "nsIRegion.h"
#include "nsIBlender.h"
#include "nsIEventQueue.h"
#include "nsView.h"
#include "nsIEventProcessor.h"
class nsISupportsArray;
struct DisplayListElement2;
struct DisplayZTreeNode;
class nsView;
//Uncomment the following line to enable generation of viewmanager performance data.
#ifdef MOZ_PERF_METRICS
@ -66,6 +68,57 @@ struct DisplayZTreeNode;
#include "nsTimer.h"
#endif
// compositor per-view flags
#define IS_PARENT_OF_REFRESHED_VIEW 0x00000001
#define IS_Z_PLACEHOLDER_VIEW 0x80000000
/**
FIXED-POSITION FRAMES AND Z-ORDERING
Fixed-position frames are special. They have TWO views. There is the "real" view, which is
a child of the root view for the viewport (which is the root view of the view manager).
There is also a "placeholder" view (of class nsZPlaceholderView) which never really
participates in any view operations. It is a child of the view that would have contained
the fixed-position element if it had not been fixed-position. The real view keeps track
of the placeholder view and returns the placeholder view when you call GetZParent on the
real view.
(Although currently all views which have a placeholder view are themselves children of the
root view, we don't want to depend on this. Later we might want to support views that
are fixed relative to some container other than the viewport.)
As we build the display list in CreateDisplayList, once we've processed the parent of
real views (i.e., the root), we move those real views from their current position in the
display list over to where their placeholder views are in the display list. This ensures that
views get repainted in the order they would have been repainted in the absence of
fixed-position frames.
*/
class nsZPlaceholderView : public nsView
{
public:
nsZPlaceholderView(nsView* aParent) : nsView() {
SetParent(aParent);
SetVisibility(nsViewVisibility_kHide);
}
void RemoveReparentedView() { mReparentedView = nsnull; }
void SetReparentedView(nsView* aView) { mReparentedView = aView; }
nsView* GetReparentedView() { return mReparentedView; }
NS_IMETHOD GetCompositorFlags(PRUint32 *aFlags)
{ nsView::GetCompositorFlags(aFlags); *aFlags |= IS_Z_PLACEHOLDER_VIEW; return NS_OK; }
protected:
virtual ~nsZPlaceholderView() {
if (nsnull != mReparentedView) {
mReparentedView->SetZParent(nsnull);
}
}
protected:
nsView *mReparentedView;
};
class nsViewManager : public nsIViewManager {
public:
@ -128,10 +181,6 @@ public:
NS_IMETHOD MoveViewAbove(nsIView *aView, nsIView *aOther);
NS_IMETHOD MoveViewBelow(nsIView *aView, nsIView *aOther);
NS_IMETHOD IsViewShown(nsIView *aView, PRBool& aResult);
NS_IMETHOD GetViewClipAbsolute(nsIView *aView, nsRect *aRect, PRBool &aResult);
NS_IMETHOD SetViewContentTransparency(nsIView *aView, PRBool aTransparent);
NS_IMETHOD SetViewOpacity(nsIView *aView, float aOpacity);
@ -177,59 +226,69 @@ public:
static PRInt32 GetViewManagerCount();
static const nsVoidArray* GetViewManagerArray();
static PRUint32 gLastUserEventTime;
/**
* Determine if a rectangle specified in the view's coordinate system
* is completely, or partially visible.
* @param aView view that aRect coordinates are specified relative to
* @param aRect rectangle in twips to test for visibility
* @returns PR_TRUE if the rect is visible, PR_FALSE otherwise.
*/
NS_IMETHOD IsRectVisible(nsIView *aView, const nsRect &aRect, PRBool aMustBeFullyVisible, PRBool *isVisible);
protected:
virtual ~nsViewManager();
void ProcessPendingUpdates(nsIView *aView);
void ProcessPendingUpdates(nsView *aView);
private:
nsIRenderingContext *CreateRenderingContext(nsIView &aView);
void AddRectToDirtyRegion(nsIView* aView, const nsRect &aRect) const;
void UpdateTransCnt(nsIView *oldview, nsIView *newview);
nsIRenderingContext *CreateRenderingContext(nsView &aView);
void AddRectToDirtyRegion(nsView* aView, const nsRect &aRect) const;
void UpdateTransCnt(nsView *oldview, nsView *newview);
PRBool UpdateAllCoveringWidgets(nsIView *aView, nsIView *aTarget, nsRect &aDamagedRect, PRBool aOnlyRepaintIfUnblittable);
PRBool UpdateAllCoveringWidgets(nsView *aView, nsView *aTarget, nsRect &aDamagedRect, PRBool aOnlyRepaintIfUnblittable);
void UpdateViews(nsIView *aView, PRUint32 aUpdateFlags);
void UpdateViews(nsView *aView, PRUint32 aUpdateFlags);
void Refresh(nsIView *aView, nsIRenderingContext *aContext,
void Refresh(nsView *aView, nsIRenderingContext *aContext,
nsIRegion *region, PRUint32 aUpdateFlags);
void DefaultRefresh(nsIView* aView, const nsRect* aRect);
void RenderViews(nsIView *aRootView, nsIRenderingContext& aRC, const nsRect& aRect,
void DefaultRefresh(nsView* aView, const nsRect* aRect);
void RenderViews(nsView *aRootView, nsIRenderingContext& aRC, const nsRect& aRect,
PRBool &aResult);
void RenderView(nsIView *aView, nsIRenderingContext &aRC,
void RenderView(nsView *aView, nsIRenderingContext &aRC,
const nsRect &aDamageRect, nsRect &aGlobalRect, PRBool &aResult);
void RenderDisplayListElement(DisplayListElement2* element, nsIRenderingContext &aRC);
void PaintView(nsIView *aView, nsIRenderingContext &aRC, nscoord x, nscoord y,
void PaintView(nsView *aView, nsIRenderingContext &aRC, nscoord x, nscoord y,
const nsRect &aDamageRect);
nsresult CreateBlendingBuffers(nsIRenderingContext &aRC);
PRBool CreateDisplayList(nsIView *aView, PRBool aReparentedViewsPresent, DisplayZTreeNode* &aResult, nscoord aOriginX, nscoord aOriginY,
PRBool aInsideRealView, nsIView *aRealView, const nsRect *aDamageRect,
nsIView *aTopView, nscoord aX, nscoord aY, PRBool aPaintFloaters);
PRBool AddToDisplayList(nsIView *aView, DisplayZTreeNode* &aParent, nsRect &aClipRect, nsRect& aDirtyRect, PRUint32 aFlags, nscoord aAbsX, nscoord aAbsY);
PRBool CreateDisplayList(nsView *aView, PRBool aReparentedViewsPresent, DisplayZTreeNode* &aResult, nscoord aOriginX, nscoord aOriginY,
PRBool aInsideRealView, nsView *aRealView, const nsRect *aDamageRect,
nsView *aTopView, nscoord aX, nscoord aY, PRBool aPaintFloaters);
PRBool AddToDisplayList(nsView *aView, DisplayZTreeNode* &aParent, nsRect &aClipRect, nsRect& aDirtyRect, PRUint32 aFlags, nscoord aAbsX, nscoord aAbsY);
void ReapplyClipInstructions(PRBool aHaveClip, nsRect& aClipRect, PRInt32& aIndex);
nsresult OptimizeDisplayList(const nsRect& aDamageRect, nsRect& aFinalTransparentRect);
// Remove redundant PUSH/POP_CLIP pairs.
void ComputeViewOffset(nsView *aView, nsPoint *aOrigin);
void AddCoveringWidgetsToOpaqueRegion(nsIRegion* aRgn, nsIDeviceContext* aContext,
nsView* aRootView);
// Predicates
PRBool DoesViewHaveNativeWidget(nsView* aView);
PRBool IsClipView(nsView* aView);
void PauseTimer(void);
void RestartTimer(void);
void OptimizeDisplayListClipping(PRBool aHaveClip, nsRect& aClipRect, PRInt32& aIndex,
PRBool& aAnyRendered);
#ifdef NS_DEBUG
void ShowDisplayList(PRInt32 flatlen);
#endif
void ComputeViewOffset(nsIView *aView, nsPoint *aOrigin);
void AddCoveringWidgetsToOpaqueRegion(nsIRegion* aRgn, nsIDeviceContext* aContext,
nsIView* aRootView);
// Predicates
PRBool DoesViewHaveNativeWidget(nsIView* aView);
PRBool IsClipView(nsIView* aView);
void PauseTimer(void);
void RestartTimer(void);
// Utilities
@ -237,14 +296,13 @@ private:
* Returns the nearest parent view with an attached widget. Can be the
* same view as passed-in.
*/
nsIView* GetWidgetView(nsIView *aView) const;
nsView* GetWidgetView(nsView *aView) const;
/**
* Transforms a rectangle from specified view's coordinate system to
* the first parent that has an attached widget.
*/
void ViewToWidget(nsIView *aView, nsIView* aWidgetView, nsRect &aRect) const;
// void WidgetToView(nsIView* aView, nsRect &aWidgetRect);
void ViewToWidget(nsView *aView, nsView* aWidgetView, nsRect &aRect) const;
/**
* Transforms a rectangle from specified view's coordinate system to
@ -256,7 +314,7 @@ private:
* @returns NS_OK if successful otherwise, NS_ERROR_FAILURE
*/
nsresult GetAbsoluteRect(nsIView *aView, const nsRect &aRect,
nsresult GetAbsoluteRect(nsView *aView, const nsRect &aRect,
nsRect& aAbsRect);
/**
* Determine the visible rect
@ -266,23 +324,13 @@ private:
nsresult GetVisibleRect(nsRect& aVisibleRect);
/**
* Determine if a rectangle specified in the view's coordinate system
* is completely, or partially visible.
* @param aView view that aRect coordinates are specified relative to
* @param aRect rectangle in twips to test for visibility
* @returns PR_TRUE if the rect is visible, PR_FALSE otherwise.
*/
NS_IMETHOD IsRectVisible(nsIView *aView, const nsRect &aRect, PRBool aMustBeFullyVisible, PRBool *isVisible);
nsresult ProcessWidgetChanges(nsView* aView);
/**
* Installs event processor
*/
NS_IMETHOD SetEventProcessor(nsIEventProcessor* aEventProcessor) { mEventProcessor = aEventProcessor; return NS_OK; }
nsresult ProcessWidgetChanges(nsIView* aView);
// Utilities used to size the offscreen drawing surface
/**
@ -333,6 +381,11 @@ private:
*/
void GetDrawingSurfaceSize(nsRect& aRequestedSize, nsRect& aSurfaceSize) const;
public: // NOT in nsIViewManager, so private to the view module
nsView* GetRootView() const { return mRootView; }
nsView* GetMouseEventGrabber() const { return mMouseGrabber; }
nsView* GetKeyEventGrabber() const { return mKeyGrabber; }
private:
nsIDeviceContext *mContext;
float mTwipsToPixels;
@ -344,8 +397,8 @@ private:
PRBool mRefreshEnabled;
PRBool mPainting;
PRBool mRecursiveRefreshPending;
nsIView *mMouseGrabber;
nsIView *mKeyGrabber;
nsView *mMouseGrabber;
nsView *mKeyGrabber;
PRInt32 mUpdateCnt;
PRInt32 mUpdateBatchCnt;
PRInt32 mDisplayListCount;
@ -391,7 +444,7 @@ private:
nsISupportsArray *mCompositeListeners;
void DestroyZTreeNode(DisplayZTreeNode* aNode);
protected:
nsIView *mRootView;
nsView *mRootView;
nscoord mX;
nscoord mY;
PRBool mAllowDoubleBuffering;