From 06d956a0b3b0a21e8a2b2ca926b6ff4376ad8418 Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Wed, 7 Nov 2001 04:05:38 +0000 Subject: [PATCH] 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 --- view/public/nsIView.h | 61 --- view/public/nsIViewManager.h | 16 - view/src/nsScrollPortView.cpp | 47 ++- view/src/nsScrollPortView.h | 36 +- view/src/nsScrollingView.cpp | 54 ++- view/src/nsScrollingView.h | 20 +- view/src/nsView.cpp | 225 +++-------- view/src/nsView.h | 42 ++- view/src/nsViewManager.cpp | 688 ++++++++++++---------------------- view/src/nsViewManager.h | 277 ++++++++------ 10 files changed, 550 insertions(+), 916 deletions(-) diff --git a/view/public/nsIView.h b/view/public/nsIView.h index 4e04263678e..e49cbd7582e 100644 --- a/view/public/nsIView.h +++ b/view/public/nsIView.h @@ -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; diff --git a/view/public/nsIViewManager.h b/view/public/nsIViewManager.h index c3e74eb9eaf..d4d2415d55f 100644 --- a/view/public/nsIViewManager.h +++ b/view/public/nsIViewManager.h @@ -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(). diff --git a/view/src/nsScrollPortView.cpp b/view/src/nsScrollPortView.cpp index efd6821e478..aeab0f10695 100644 --- a/view/src/nsScrollPortView.cpp +++ b/view/src/nsScrollPortView.cpp @@ -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,13 +199,8 @@ NS_IMETHODIMP nsScrollPortView::GetContainerSize(nscoord *aWidth, nscoord *aHeig *aWidth = 0; *aHeight = 0; - nsIView *scrolledView = 0; + nsView *scrolledView = GetScrolledView(); - nsresult result = GetScrolledView(scrolledView); - - if (NS_FAILED(result)) - return result; - 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; +} diff --git a/view/src/nsScrollPortView.h b/view/src/nsScrollPortView.h index 833c787ead1..7bc8a9c8b19 100644 --- a/view/src/nsScrollPortView.h +++ b/view/src/nsScrollPortView.h @@ -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; diff --git a/view/src/nsScrollingView.cpp b/view/src/nsScrollingView.cpp index e0da88b5bfc..49a7b9d031a 100644 --- a/view/src/nsScrollingView.cpp +++ b/view/src/nsScrollingView.cpp @@ -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,15 +1521,19 @@ 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; - return NS_OK; - } + 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)) { diff --git a/view/src/nsScrollingView.h b/view/src/nsScrollingView.h index 6bd8d89a534..5744d6b8036 100644 --- a/view/src/nsScrollingView.h +++ b/view/src/nsScrollingView.h @@ -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 mScrollingTimer; diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index 8c21fd1f6c5..ee3713bf894 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -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; + 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) -{ - NS_PRECONDITION(nsnull != child, "null ptr"); - if (nsnull != child) + if (nsnull != aChild) { - 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 -{ - aCount = mNumKids; - return NS_OK; -} - -NS_IMETHODIMP nsView :: GetChild(PRInt32 index, nsIView *&aChild) const +nsView* nsView :: GetChild(PRInt32 aIndex) 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); + for (nsView* child = GetFirstChild(); child != nsnull; child = child->GetNextSibling()) { + if (aIndex == 0) { + return child; } + --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 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 PR_FALSE; + return mViewManager->GetRootView() == this; } -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; diff --git a/view/src/nsView.h b/view/src/nsView.h index 85918f9e9e0..107c24418da 100644 --- a/view/src/nsView.h +++ b/view/src/nsView.h @@ -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; diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index 1fbbcd1aef1..4830134add9 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -85,10 +85,6 @@ static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); #define VIEW_TRANSLUCENT 0x00000010 #define VIEW_CLIPPED 0x00000020 -// compositor per-view flags -#define IS_PARENT_OF_REFRESHED_VIEW 0x00000001 -#define IS_Z_PLACEHOLDER_VIEW 0x80000000 - #define SUPPORT_TRANSLUCENT_VIEWS // A DisplayListElement2 records the information needed to paint one view. @@ -96,7 +92,7 @@ static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); // paints that view's frame and all its child frames EXCEPT for the child frames // that have their own views. struct DisplayListElement2 { - nsIView* mView; + nsView* mView; nsRect mBounds; // coordinates relative to the view manager root nscoord mAbsX, mAbsY; // coordinates relative to the view that we're Refreshing PRUint32 mFlags; // see above @@ -160,7 +156,7 @@ struct DisplayListElement2 { */ struct DisplayZTreeNode { - nsIView* mView; // Null for tree leaf nodes + nsView* mView; // Null for tree leaf nodes DisplayZTreeNode* mZSibling; // We can't have BOTH an mZChild and an mDisplayElement @@ -191,7 +187,7 @@ void nsViewManager::DestroyZTreeNode(DisplayZTreeNode* aNode) //-------------- Begin Invalidate Event Definition ------------------------ struct nsInvalidateEvent : public PLEvent { - nsInvalidateEvent(nsIViewManager* aViewManager); + nsInvalidateEvent(nsViewManager* aViewManager); ~nsInvalidateEvent() { } void HandleEvent() { @@ -206,21 +202,20 @@ struct nsInvalidateEvent : public PLEvent { PRInt32 count = nsViewManager::GetViewManagerCount(); const nsVoidArray* viewManagers = nsViewManager::GetViewManagerArray(); for (index = 0; index < count; index++) { - nsIViewManager* vm = (nsIViewManager*)viewManagers->ElementAt(index); + nsViewManager* vm = (nsViewManager*)viewManagers->ElementAt(index); if (vm == mViewManager) { found = PR_TRUE; } } if (found) { - ((nsViewManager *)mViewManager)->ProcessInvalidateEvent(); + mViewManager->ProcessInvalidateEvent(); } else { NS_ASSERTION(PR_FALSE, "bad view manager asked to process invalidate event"); } - }; - nsIViewManager* mViewManager; // Weak Reference. The viewmanager will destroy any pending + nsViewManager* mViewManager; // Weak Reference. The viewmanager will destroy any pending // invalidate events in it's destructor. }; @@ -236,7 +231,7 @@ static void PR_CALLBACK DestroyPLEvent(nsInvalidateEvent* aEvent) delete aEvent; } -nsInvalidateEvent::nsInvalidateEvent(nsIViewManager* aViewManager) +nsInvalidateEvent::nsInvalidateEvent(nsViewManager* aViewManager) { NS_ASSERTION(aViewManager, "null parameter"); mViewManager = aViewManager; // Assign weak reference @@ -252,7 +247,7 @@ void nsViewManager::PostInvalidateEvent() { if (!mPendingInvalidateEvent) { - nsInvalidateEvent* ev = new nsInvalidateEvent(NS_STATIC_CAST(nsIViewManager*, this)); + nsInvalidateEvent* ev = new nsInvalidateEvent(this); NS_ASSERTION(nsnull != ev,"InvalidateEvent is null"); NS_ASSERTION(nsnull != mEventQueue,"Event queue is null"); mEventQueue->PostEvent(ev); @@ -260,228 +255,6 @@ nsViewManager::PostInvalidateEvent() } } -/** - 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 nsIView -{ -public: - nsZPlaceholderView(nsIView* aParent) { mParent = aParent; } - - NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW - - // nsISupports - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr) { - if (nsnull == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - *aInstancePtr = nsnull; - - if (aIID.Equals(NS_GET_IID(nsIView)) || (aIID.Equals(NS_GET_IID(nsISupports)))) { - *aInstancePtr = (void*)(nsIView*)this; - return NS_OK; - } - - return NS_NOINTERFACE; - } - - // nsIView - NS_IMETHOD Init(nsIViewManager* aManager, - const nsRect &aBounds, - const nsIView *aParent, - nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow) - { return NS_OK; } - - NS_IMETHOD Destroy() - { delete this; return NS_OK; } - NS_IMETHOD GetViewManager(nsIViewManager *&aViewMgr) const - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD Paint(nsIRenderingContext& rc, const nsRect& rect, - PRUint32 aPaintFlags, PRBool &aResult) - { aResult = PR_TRUE; return NS_OK; } - NS_IMETHOD Paint(nsIRenderingContext& rc, const nsIRegion& region, - PRUint32 aPaintFlags, PRBool &aResult) - { aResult = PR_TRUE; return NS_OK; } - NS_IMETHOD HandleEvent(nsGUIEvent *event, PRUint32 aEventFlags, nsEventStatus* aStatus, PRBool aForceHandle, PRBool& aHandled) - { aHandled = PR_FALSE; return NS_OK; } - NS_IMETHOD SetPosition(nscoord x, nscoord y) - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD GetPosition(nscoord *x, nscoord *y) const - { *x = 0; *y = 0; return NS_OK; } - NS_IMETHOD SetDimensions(nscoord width, nscoord height, PRBool aPaint = PR_TRUE) - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD GetDimensions(nscoord *width, nscoord *height) const - { *width = 0; *height = 0; return NS_OK; } - NS_IMETHOD SetBounds(const nsRect &aBounds, PRBool aPaint = PR_TRUE) - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD SetBounds(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, PRBool aPaint = PR_TRUE) - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD GetBounds(nsRect &aBounds) const - { aBounds.SetRect(0, 0, 0, 0); return NS_OK; } - NS_IMETHOD SetChildClip(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD GetChildClip(nscoord *aLeft, nscoord *aTop, nscoord *aRight, nscoord *aBottom) const - { *aLeft = 0; *aTop = 0; *aRight = 0; *aBottom = 0; return NS_OK; } - NS_IMETHOD SetVisibility(nsViewVisibility visibility) - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD GetVisibility(nsViewVisibility &aVisibility) const - { aVisibility = nsViewVisibility_kHide; return NS_OK; } - NS_IMETHOD SetZParent(nsIView *aZParent) - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD GetZParent(nsIView *&aZParent) const - { aZParent = nsnull; return NS_OK; } - NS_IMETHOD SetZIndex(PRInt32 aZIndex) - { mZindex = aZIndex; return NS_OK; } - NS_IMETHOD GetZIndex(PRInt32 &aZIndex) const - { aZIndex = mZindex; return NS_OK; } - NS_IMETHOD SetAutoZIndex(PRBool aAutoZIndex) - { if (aAutoZIndex) - mVFlags |= NS_VIEW_PUBLIC_FLAG_AUTO_ZINDEX; - else - mVFlags &= ~NS_VIEW_PUBLIC_FLAG_AUTO_ZINDEX; - return NS_OK; - } - NS_IMETHOD GetAutoZIndex(PRBool &aAutoZIndex) const - { aAutoZIndex = ((mVFlags & NS_VIEW_PUBLIC_FLAG_AUTO_ZINDEX) != 0); - return NS_OK; - } - NS_IMETHOD SetFloating(PRBool aFloatingView) - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD GetFloating(PRBool &aFloatingView) const - { aFloatingView = PR_FALSE; return NS_OK; } - NS_IMETHOD SetParent(nsIView *aParent) - { mParent = aParent; return NS_OK; } - NS_IMETHOD GetParent(nsIView *&aParent) const - { aParent = mParent; return NS_OK; } - NS_IMETHOD GetNextSibling(nsIView *&aNextSibling) const - { aNextSibling = mNextSibling; return NS_OK; } - NS_IMETHOD SetNextSibling(nsIView* aNextSibling) - { mNextSibling = aNextSibling; return NS_OK; } - NS_IMETHOD InsertChild(nsIView *child, nsIView *sibling) - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD RemoveChild(nsIView *child) - { NS_ASSERTION(mReparentedChild == child, "Removing incorrect child"); - mReparentedChild = nsnull; - return NS_ERROR_NOT_IMPLEMENTED; - } - NS_IMETHOD GetChildCount(PRInt32 &aCount) const - { aCount = 0; return NS_OK; } - NS_IMETHOD GetChild(PRInt32 index, nsIView*& aChild) const - { aChild = nsnull; return NS_OK; } - NS_IMETHOD SetTransform(nsTransform2D &aXForm) - { return NS_OK; } - NS_IMETHOD GetTransform(nsTransform2D &aXForm) const - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD SetOpacity(float opacity) - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD GetOpacity(float &aOpacity) const - { return NS_OK; } - NS_IMETHOD HasTransparency(PRBool &aTransparent) const - { return NS_OK; } - NS_IMETHOD SetContentTransparency(PRBool aTransparent) - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD SetClientData(void *aData) - { return NS_OK; } - NS_IMETHOD GetClientData(void *&aData) const - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD GetOffsetFromWidget(nscoord *aDx, nscoord *aDy, nsIWidget *&aWidget) - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD GetDirtyRegion(nsIRegion*& aRegion) const - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD CreateWidget(const nsIID &aWindowIID, - nsWidgetInitData *aWidgetInitData = nsnull, - nsNativeWidget aNative = nsnull, - PRBool aEnableDragDrop = PR_TRUE, - PRBool aResetVisibility = PR_TRUE) - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD SetWidget(nsIWidget *aWidget) - { return NS_OK; } - NS_IMETHOD GetWidget(nsIWidget *&aWidget) const - { aWidget = nsnull; return NS_OK; } - NS_IMETHOD HasWidget(PRBool *aHasWidget) const - { *aHasWidget = PR_FALSE; return NS_OK; } - NS_IMETHOD List(FILE* out, PRInt32 aIndent) const - { return NS_OK; } - NS_IMETHOD SetViewFlags(PRUint32 aFlags) - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD ClearViewFlags(PRUint32 aFlags) - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD GetViewFlags(PRUint32 *aFlags) const - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD SetCompositorFlags(PRUint32 aFlags) - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD GetCompositorFlags(PRUint32 *aFlags) - { *aFlags = IS_Z_PLACEHOLDER_VIEW; return NS_OK; } - NS_IMETHOD GetExtents(nsRect *aExtents) - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD GetClippedRect(nsRect& aClippedRect, PRBool& aIsClipped, PRBool& aEmpty) const - { aClippedRect.SetRect(0, 0, 0, 0); aIsClipped = PR_TRUE; aEmpty = PR_TRUE; return NS_OK; } - - NS_IMETHOD IgnoreSetPosition(PRBool aShouldIgnore) - { return NS_OK; } - NS_IMETHOD SynchWidgetSizePosition() - { return NS_OK; } - - NS_IMETHOD SetReparentedZChild(nsIView *aChild) - { mReparentedChild = aChild; return NS_OK; } - -protected: - virtual ~nsZPlaceholderView() { - if (nsnull != mReparentedChild) { - mReparentedChild->SetZParent(nsnull); - } - if (nsnull != mParent) - { - nsCOMPtr vm; - mParent->GetViewManager(*getter_AddRefs(vm)); - if (vm) - { - vm->RemoveChild(mParent, this); - } - else - { - mParent->RemoveChild(this); - } - } - } - -protected: - nsIView *mParent; - - nsIView *mNextSibling; - nsIView *mReparentedChild; - PRInt32 mZindex; - PRInt32 mVFlags; - -private: - NS_IMETHOD_(nsrefcnt) AddRef(void) - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD_(nsrefcnt) Release(void) - { NS_ASSERTION(PR_FALSE, "Unimplemented"); return NS_ERROR_NOT_IMPLEMENTED; } -}; - - - PRInt32 nsViewManager::mVMCount = 0; nsDrawingSurface nsViewManager::mDrawingSurface = nsnull; nsRect nsViewManager::mDSBounds = nsRect(0, 0, 0, 0); @@ -709,10 +482,12 @@ NS_IMETHODIMP nsViewManager::GetRootView(nsIView *&aView) NS_IMETHODIMP nsViewManager :: SetRootView(nsIView *aView, nsIWidget* aWidget) { - UpdateTransCnt(mRootView, aView); + nsView* view = NS_STATIC_CAST(nsView*, aView); + + UpdateTransCnt(mRootView, view); // Do NOT destroy the current root view. It's the caller's responsibility // to destroy it - mRootView = aView; + mRootView = view; //now get the window too. NS_IF_RELEASE(mRootWindow); @@ -780,7 +555,7 @@ NS_IMETHODIMP nsViewManager::ResetScrolling(void) /** aRegion is given in device coordinates!! */ -void nsViewManager::Refresh(nsIView *aView, nsIRenderingContext *aContext, nsIRegion *aRegion, PRUint32 aUpdateFlags) +void nsViewManager::Refresh(nsView *aView, nsIRenderingContext *aContext, nsIRegion *aRegion, PRUint32 aUpdateFlags) { nsRect wrect; nsCOMPtr localcx; @@ -916,7 +691,7 @@ void nsViewManager::Refresh(nsIView *aView, nsIRenderingContext *aContext, nsIRe } -void nsViewManager::DefaultRefresh(nsIView* aView, const nsRect* aRect) +void nsViewManager::DefaultRefresh(nsView* aView, const nsRect* aRect) { nsCOMPtr widget; GetWidgetForView(aView, getter_AddRefs(widget)); @@ -1125,7 +900,7 @@ static void PopState(nsIRenderingContext **aRCs, PRInt32 aRCCount) { } void nsViewManager::AddCoveringWidgetsToOpaqueRegion(nsIRegion* aRgn, nsIDeviceContext* aContext, - nsIView* aRootView) { + nsView* aRootView) { // We accumulate the bounds of widgets obscuring aRootView's widget into mOpaqueRgn. // In OptimizeDisplayList, display list elements which lie behind obscuring native // widgets are dropped. @@ -1151,7 +926,7 @@ void nsViewManager::AddCoveringWidgetsToOpaqueRegion(nsIRegion* aRgn, nsIDeviceC if (NS_SUCCEEDED(children->CurrentItem(getter_AddRefs(child)))) { nsCOMPtr childWidget = do_QueryInterface(child); if (childWidget) { - nsIView* view = nsView::GetViewFor(childWidget); + nsView* view = nsView::GetViewFor(childWidget); if (view) { nsViewVisibility visible = nsViewVisibility_kHide; view->GetVisibility(visible); @@ -1162,8 +937,7 @@ void nsViewManager::AddCoveringWidgetsToOpaqueRegion(nsIRegion* aRgn, nsIDeviceC nsRect bounds; view->GetBounds(bounds); if (bounds.width > 0 && bounds.height > 0) { - nsIView* viewParent = nsnull; - view->GetParent(viewParent); + nsView* viewParent = view->GetParent(); while (viewParent && viewParent != aRootView) { nsRect parentBounds; @@ -1171,7 +945,7 @@ void nsViewManager::AddCoveringWidgetsToOpaqueRegion(nsIRegion* aRgn, nsIDeviceC viewParent->GetBounds(parentBounds); bounds.x += parentBounds.x; bounds.y += parentBounds.y; - viewParent->GetParent(viewParent); + viewParent = viewParent->GetParent(); } // maybe we couldn't get the view into the coordinate @@ -1192,19 +966,18 @@ void nsViewManager::AddCoveringWidgetsToOpaqueRegion(nsIRegion* aRgn, nsIDeviceC } } -void nsViewManager::RenderViews(nsIView *aRootView, nsIRenderingContext& aRC, const nsRect& aRect, PRBool &aResult) +void nsViewManager::RenderViews(nsView *aRootView, nsIRenderingContext& aRC, const nsRect& aRect, PRBool &aResult) { // compute this view's origin nsPoint origin(0, 0); ComputeViewOffset(aRootView, &origin); - nsIView *displayRoot = aRootView; + nsView *displayRoot = aRootView; for (;;) { // Mark the view as a parent of the rendered view. displayRoot->SetCompositorFlags(IS_PARENT_OF_REFRESHED_VIEW); - nsIView *displayParent = nsnull; - displayRoot->GetParent(displayParent); + nsView *displayParent = displayRoot->GetParent(); if (nsnull == displayParent) { break; @@ -1360,15 +1133,16 @@ void nsViewManager::RenderViews(nsIView *aRootView, nsIRenderingContext& aRC, co mDisplayList.Clear(); - nsIView *marker = aRootView; + nsView *marker = aRootView; while (marker != nsnull) { // Mark the view with specified flags. marker->SetCompositorFlags(0); - marker->GetParent(marker); + marker = marker->GetParent(); } } -void nsViewManager::RenderView(nsIView *aView, nsIRenderingContext &aRC, const nsRect &aDamageRect, nsRect &aGlobalRect, PRBool &aResult) +void nsViewManager::RenderView(nsView *aView, nsIRenderingContext &aRC, const nsRect &aDamageRect, + nsRect &aGlobalRect, PRBool &aResult) { nsRect drect; @@ -1425,7 +1199,7 @@ void nsViewManager::RenderDisplayListElement(DisplayListElement2* element, nsIRe damageRect.x -= x, damageRect.y -= y; if (element->mFlags & VIEW_TRANSLUCENT) { - nsIView* view = element->mView; + nsView* view = element->mView; // paint the view twice, first in the black buffer, then the white; // the blender will pick up the touched pixels only. @@ -1474,7 +1248,7 @@ void nsViewManager::RenderDisplayListElement(DisplayListElement2* element, nsIRe #endif } -void nsViewManager::PaintView(nsIView *aView, nsIRenderingContext &aRC, nscoord x, nscoord y, +void nsViewManager::PaintView(nsView *aView, nsIRenderingContext &aRC, nscoord x, nscoord y, const nsRect &aDamageRect) { aRC.PushState(); @@ -1598,7 +1372,7 @@ nsresult nsViewManager::CreateBlendingBuffers(nsIRenderingContext &aRC) return NS_OK; } -void nsViewManager::ProcessPendingUpdates(nsIView* aView) +void nsViewManager::ProcessPendingUpdates(nsView* aView) { // Protect against a null-view. if (nsnull == aView) { @@ -1620,11 +1394,10 @@ void nsViewManager::ProcessPendingUpdates(nsIView* aView) } // process pending updates in child view. - nsIView* childView = nsnull; - aView->GetChild(0, childView); + nsView* childView = aView->GetFirstChild(); while (nsnull != childView) { ProcessPendingUpdates(childView); - childView->GetNextSibling(childView); + childView = childView->GetNextSibling(); } } @@ -1645,10 +1418,12 @@ NS_IMETHODIMP nsViewManager::Composite() NS_IMETHODIMP nsViewManager::UpdateView(nsIView *aView, PRUint32 aUpdateFlags) { // Mark the entire view as damaged + nsView* view = NS_STATIC_CAST(nsView*, aView); + nsRect bounds; - aView->GetBounds(bounds); + view->GetBounds(bounds); bounds.x = bounds.y = 0; - return UpdateView(aView, bounds, aUpdateFlags); + return UpdateView(view, bounds, aUpdateFlags); } @@ -1656,8 +1431,10 @@ NS_IMETHODIMP nsViewManager::UpdateView(nsIView *aView, PRUint32 aUpdateFlags) NS_IMETHODIMP nsViewManager::UpdateViewAfterScroll(nsIView *aView, PRInt32 aDX, PRInt32 aDY) { + nsView* view = NS_STATIC_CAST(nsView*, aView); + nsPoint origin(0, 0); - ComputeViewOffset(aView, &origin); + ComputeViewOffset(view, &origin); nsRect damageRect; aView->GetBounds(damageRect); damageRect.x = origin.x; @@ -1671,7 +1448,7 @@ nsViewManager::UpdateViewAfterScroll(nsIView *aView, PRInt32 aDX, PRInt32 aDY) return NS_OK; } - UpdateAllCoveringWidgets(mRootView, aView, damageRect, PR_FALSE); + UpdateAllCoveringWidgets(mRootView, view, damageRect, PR_FALSE); Composite(); return NS_OK; } @@ -1680,7 +1457,7 @@ nsViewManager::UpdateViewAfterScroll(nsIView *aView, PRInt32 aDX, PRInt32 aDY) // The specified rectangle, relative to aView, is invalidated in every widget child of aView. // If non-null, aTarget and its children are ignored and only widgets above aTarget's widget // in Z-order are invalidated (if possible). -PRBool nsViewManager::UpdateAllCoveringWidgets(nsIView *aView, nsIView *aTarget, +PRBool nsViewManager::UpdateAllCoveringWidgets(nsView *aView, nsView *aTarget, nsRect &aDamagedRect, PRBool aRepaintOnlyUnblittableViews) { if (aView == aTarget) { @@ -1710,8 +1487,7 @@ PRBool nsViewManager::UpdateAllCoveringWidgets(nsIView *aView, nsIView *aTarget, aView->GetViewFlags(&flags); PRBool isBlittable = (flags & NS_VIEW_PUBLIC_FLAG_DONT_BITBLT) == 0; - nsIView* childView = nsnull; - aView->GetChild(0, childView); + nsView* childView = aView->GetFirstChild(); PRBool childCovers = PR_FALSE; while (nsnull != childView) { nsRect childRect = bounds; @@ -1725,7 +1501,7 @@ PRBool nsViewManager::UpdateAllCoveringWidgets(nsIView *aView, nsIView *aTarget, // widgets are z-ordered, and we can't risk failing to invalidate the top-most // one. } - childView->GetNextSibling(childView); + childView = childView->GetNextSibling(); } if (!childCovers && (!isBlittable || (hasWidget && !aRepaintOnlyUnblittableViews))) { @@ -1736,7 +1512,7 @@ PRBool nsViewManager::UpdateAllCoveringWidgets(nsIView *aView, nsIView *aTarget, AddRectToDirtyRegion(aView, bounds); mHasPendingInvalidates = PR_TRUE; } else { - nsIView* widgetView = GetWidgetView(aView); + nsView* widgetView = GetWidgetView(aView); if (widgetView != nsnull) { ViewToWidget(aView, widgetView, bounds); @@ -1763,11 +1539,13 @@ NS_IMETHODIMP nsViewManager::UpdateView(nsIView *aView, const nsRect &aRect, PRU { NS_PRECONDITION(nsnull != aView, "null view"); + nsView* view = NS_STATIC_CAST(nsView*, aView); + // Only Update the rectangle region of the rect that intersects the view's non clipped rectangle nsRect clippedRect; PRBool isClipped; PRBool isEmpty; - aView->GetClippedRect(clippedRect, isClipped, isEmpty); + view->GetClippedRect(clippedRect, isClipped, isEmpty); if (isEmpty) { return NS_OK; } @@ -1787,7 +1565,7 @@ NS_IMETHODIMP nsViewManager::UpdateView(nsIView *aView, const nsRect &aRect, PRU // can be expensive. // This also checks for silly request like damagedRect.width = 0 or damagedRect.height = 0 PRBool isVisible; - IsRectVisible(aView, damagedRect, PR_FALSE, &isVisible); + IsRectVisible(view, damagedRect, PR_FALSE, &isVisible); if (!isVisible) { return NS_OK; } @@ -1797,9 +1575,9 @@ NS_IMETHODIMP nsViewManager::UpdateView(nsIView *aView, const nsRect &aRect, PRU // that as the root to update from. This also means we update areas that // may be outside the parent view(s), which is necessary for floaters. PRBool viewIsFloating = PR_FALSE; - aView->GetFloating(viewIsFloating); + view->GetFloating(viewIsFloating); if (viewIsFloating) { - nsIView* widgetParent = aView; + nsView* widgetParent = view; PRBool hasWidget = PR_FALSE; widgetParent->HasWidget(&hasWidget); @@ -1809,14 +1587,14 @@ NS_IMETHODIMP nsViewManager::UpdateView(nsIView *aView, const nsRect &aRect, PRU damagedRect.x += bounds.x; damagedRect.y += bounds.y; - widgetParent->GetParent(widgetParent); + widgetParent = widgetParent->GetParent(); widgetParent->HasWidget(&hasWidget); } UpdateAllCoveringWidgets(widgetParent, nsnull, damagedRect, PR_FALSE); } else { nsPoint origin(damagedRect.x, damagedRect.y); - ComputeViewOffset(aView, &origin); + ComputeViewOffset(view, &origin); damagedRect.x = origin.x; damagedRect.y = origin.y; @@ -1843,17 +1621,16 @@ NS_IMETHODIMP nsViewManager::UpdateAllViews(PRUint32 aUpdateFlags) return NS_OK; } -void nsViewManager::UpdateViews(nsIView *aView, PRUint32 aUpdateFlags) +void nsViewManager::UpdateViews(nsView *aView, PRUint32 aUpdateFlags) { // update this view. UpdateView(aView, aUpdateFlags); // update all children as well. - nsIView* childView = nsnull; - aView->GetChild(0, childView); + nsView* childView = aView->GetFirstChild(); while (nsnull != childView) { UpdateViews(childView, aUpdateFlags); - childView->GetNextSibling(childView); + childView = childView->GetNextSibling(); } } @@ -1886,7 +1663,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS { case NS_SIZE: { - nsIView* view = nsView::GetViewFor(aEvent->widget); + nsView* view = nsView::GetViewFor(aEvent->widget); if (nsnull != view) { @@ -1916,7 +1693,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS case NS_PAINT: { - nsIView *view = nsView::GetViewFor(aEvent->widget); + nsView *view = nsView::GetViewFor(aEvent->widget); if (nsnull != view) { @@ -2015,8 +1792,8 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS default: { - nsIView* baseView; - nsIView* view; + nsView* baseView; + nsView* view; nsPoint offset; nsIScrollbar* sb; @@ -2048,7 +1825,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS offset.x = offset.y = 0; if (baseView != view) { //Get offset from root of baseView - nsIView *parent; + nsView *parent; nsRect bounds; parent = baseView; @@ -2056,7 +1833,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS parent->GetBounds(bounds); offset.x += bounds.x; offset.y += bounds.y; - parent->GetParent(parent); + parent = parent->GetParent(); } //Subtract back offset from root of view @@ -2065,7 +1842,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS parent->GetBounds(bounds); offset.x -= bounds.x; offset.y -= bounds.y; - parent->GetParent(parent); + parent = parent->GetParent(); } } @@ -2135,14 +1912,14 @@ NS_IMETHODIMP nsViewManager::GrabMouseEvents(nsIView *aView, PRBool &aResult) printf("removing mouse capture from view %x\n",mMouseGrabber); #endif - mMouseGrabber = aView; + mMouseGrabber = NS_STATIC_CAST(nsView*, aView); aResult = PR_TRUE; return NS_OK; } NS_IMETHODIMP nsViewManager::GrabKeyEvents(nsIView *aView, PRBool &aResult) { - mKeyGrabber = aView; + mKeyGrabber = NS_STATIC_CAST(nsView*, aView); aResult = PR_TRUE; return NS_OK; } @@ -2159,21 +1936,23 @@ NS_IMETHODIMP nsViewManager::GetKeyEventGrabber(nsIView *&aView) return NS_OK; } -NS_IMETHODIMP nsViewManager::InsertChild(nsIView *parent, nsIView *child, nsIView *sibling, - PRBool above) +NS_IMETHODIMP nsViewManager::InsertChild(nsIView *aParent, nsIView *aChild, nsIView *aSibling, + PRBool aAbove) { + nsView* parent = NS_STATIC_CAST(nsView*, aParent); + nsView* child = NS_STATIC_CAST(nsView*, aChild); + nsView* sibling = NS_STATIC_CAST(nsView*, aSibling); + NS_PRECONDITION(nsnull != parent, "null ptr"); NS_PRECONDITION(nsnull != child, "null ptr"); if ((nsnull != parent) && (nsnull != child)) { - nsIView *kid; - nsIView *prev = nsnull; + nsView *kid = parent->GetFirstChild(); + nsView *prev = nsnull; //verify that the sibling exists... - parent->GetChild(0, kid); - while (nsnull != kid) { if (kid == sibling) @@ -2182,14 +1961,14 @@ NS_IMETHODIMP nsViewManager::InsertChild(nsIView *parent, nsIView *child, nsIVie //get the next sibling view prev = kid; - kid->GetNextSibling(kid); + kid = kid->GetNextSibling(); } if (nsnull != kid) { //it's there, so do the insertion - if (PR_TRUE == above) + if (PR_TRUE == aAbove) parent->InsertChild(child, prev); else parent->InsertChild(child, sibling); @@ -2214,70 +1993,74 @@ NS_IMETHODIMP nsViewManager::InsertChild(nsIView *parent, nsIView *child, nsIVie return NS_OK; } -NS_IMETHODIMP nsViewManager::InsertZPlaceholder(nsIView *parent, nsIView *child, PRInt32 zindex) +NS_IMETHODIMP nsViewManager::InsertZPlaceholder(nsIView *aParent, nsIView *aChild, PRInt32 aZIndex) { + nsView* parent = NS_STATIC_CAST(nsView*, aParent); + nsView* child = NS_STATIC_CAST(nsView*, aChild); + NS_PRECONDITION(nsnull != parent, "null ptr"); NS_PRECONDITION(nsnull != child, "null ptr"); if ((nsnull != parent) && (nsnull != child)) { - nsIView *kid; - nsIView *prev = nsnull; + nsView *kid = parent->GetFirstChild(); + nsView *prev = nsnull; - parent->GetChild(0, kid); while (nsnull != kid) { PRInt32 idx; kid->GetZIndex(idx); - if (zindex >= idx) + if (aZIndex >= idx) break; prev = kid; - kid->GetNextSibling(kid); + kid = kid->GetNextSibling(); } nsZPlaceholderView* placeholder = new nsZPlaceholderView(parent); - placeholder->SetReparentedZChild(child); + placeholder->SetReparentedView(child); child->SetZParent(placeholder); + placeholder->SetZIndex(aZIndex); parent->InsertChild(placeholder, prev); } return NS_OK; } -NS_IMETHODIMP nsViewManager::InsertChild(nsIView *parent, nsIView *child, PRInt32 zindex) +NS_IMETHODIMP nsViewManager::InsertChild(nsIView *aParent, nsIView *aChild, PRInt32 aZIndex) { + nsView* parent = NS_STATIC_CAST(nsView*, aParent); + nsView* child = NS_STATIC_CAST(nsView*, aChild); + NS_PRECONDITION(nsnull != parent, "null ptr"); NS_PRECONDITION(nsnull != child, "null ptr"); if ((nsnull != parent) && (nsnull != child)) { - nsIView *kid; - nsIView *prev = nsnull; + nsView *kid = parent->GetFirstChild(); + nsView *prev = nsnull; //find the right insertion point... - parent->GetChild(0, kid); - while (nsnull != kid) { PRInt32 idx; kid->GetZIndex(idx); - if (zindex >= idx) + if (aZIndex >= idx) break; //get the next sibling view prev = kid; - kid->GetNextSibling(kid); + kid = kid->GetNextSibling(); } //in case this hasn't been set yet... maybe we should not do this? MMP - child->SetZIndex(zindex); + child->SetZIndex(aZIndex); parent->InsertChild(child, prev); UpdateTransCnt(nsnull, child); @@ -2298,8 +2081,11 @@ NS_IMETHODIMP nsViewManager::InsertChild(nsIView *parent, nsIView *child, PRInt3 return NS_OK; } -NS_IMETHODIMP nsViewManager::RemoveChild(nsIView *parent, nsIView *child) +NS_IMETHODIMP nsViewManager::RemoveChild(nsIView *aParent, nsIView *aChild) { + nsView* parent = NS_STATIC_CAST(nsView*, aParent); + nsView* child = NS_STATIC_CAST(nsView*, aChild); + NS_PRECONDITION(nsnull != parent, "null ptr"); NS_PRECONDITION(nsnull != child, "null ptr"); @@ -2316,29 +2102,30 @@ NS_IMETHODIMP nsViewManager::RemoveChild(nsIView *parent, nsIView *child) NS_IMETHODIMP nsViewManager::MoveViewBy(nsIView *aView, nscoord aX, nscoord aY) { nscoord x, y; + nsView* view = NS_STATIC_CAST(nsView*, aView); - aView->GetPosition(&x, &y); - MoveViewTo(aView, aX + x, aY + y); + view->GetPosition(&x, &y); + MoveViewTo(view, aX + x, aY + y); return NS_OK; } NS_IMETHODIMP nsViewManager::MoveViewTo(nsIView *aView, nscoord aX, nscoord aY) { nscoord oldX, oldY; - aView->GetPosition(&oldX, &oldY); - aView->SetPosition(aX, aY); + nsView* view = NS_STATIC_CAST(nsView*, aView); + view->GetPosition(&oldX, &oldY); + view->SetPosition(aX, aY); // only do damage control if the view is visible if ((aX != oldX) || (aY != oldY)) { nsViewVisibility visibility; - aView->GetVisibility(visibility); + view->GetVisibility(visibility); if (visibility != nsViewVisibility_kHide) { nsRect bounds; - aView->GetBounds(bounds); + view->GetBounds(bounds); nsRect oldArea(oldX, oldY, bounds.width, bounds.height); - nsIView* parentView; - aView->GetParent(parentView); + nsView* parentView = view->GetParent(); UpdateView(parentView, oldArea, NS_VMREFRESH_NO_SYNC); nsRect newArea(aX, aY, bounds.width, bounds.height); UpdateView(parentView, newArea, NS_VMREFRESH_NO_SYNC); @@ -2350,27 +2137,28 @@ NS_IMETHODIMP nsViewManager::MoveViewTo(nsIView *aView, nscoord aX, nscoord aY) NS_IMETHODIMP nsViewManager::ResizeView(nsIView *aView, nscoord width, nscoord height, PRBool aRepaintExposedAreaOnly) { nscoord oldWidth, oldHeight; - aView->GetDimensions(&oldWidth, &oldHeight); + nsView* view = NS_STATIC_CAST(nsView*, aView); + + view->GetDimensions(&oldWidth, &oldHeight); if ((width != oldWidth) || (height != oldHeight)) { nscoord x = 0, y = 0; - nsIView* parentView = nsnull; - aView->GetParent(parentView); + nsView* parentView = view->GetParent(); if (parentView != nsnull) - aView->GetPosition(&x, &y); + view->GetPosition(&x, &y); else - parentView = aView; + parentView = view; // resize the view. nsViewVisibility visibility; - aView->GetVisibility(visibility); + view->GetVisibility(visibility); // Prevent Invalidation of hidden views if (visibility == nsViewVisibility_kHide) { - aView->SetDimensions(width, height, PR_FALSE); + view->SetDimensions(width, height, PR_FALSE); } else { if (!aRepaintExposedAreaOnly) { //Invalidate the union of the old and new size - aView->SetDimensions(width, height, PR_TRUE); + view->SetDimensions(width, height, PR_TRUE); nscoord maxWidth = (oldWidth < width ? width : oldWidth); nscoord maxHeight = (oldHeight < height ? height : oldHeight); nsRect boundingArea(x, y, maxWidth, maxHeight); @@ -2413,7 +2201,7 @@ NS_IMETHODIMP nsViewManager::ResizeView(nsIView *aView, nscoord width, nscoord h UpdateView(parentView, damageRect, NS_VMREFRESH_NO_SYNC); - aView->SetDimensions(width, height); + view->SetDimensions(width, height); } } } @@ -2423,37 +2211,40 @@ NS_IMETHODIMP nsViewManager::ResizeView(nsIView *aView, nscoord width, nscoord h NS_IMETHODIMP nsViewManager::SetViewChildClip(nsIView *aView, nsRect *aRect) { - NS_ASSERTION(!(nsnull == aView), "no view"); + nsView* view = NS_STATIC_CAST(nsView*, aView); + + NS_ASSERTION(!(nsnull == view), "no view"); NS_ASSERTION(!(nsnull == aRect), "no clip"); - aView->SetChildClip(aRect->x, aRect->y, aRect->XMost(), aRect->YMost()); + view->SetChildClip(aRect->x, aRect->y, aRect->XMost(), aRect->YMost()); - UpdateView(aView, *aRect, NS_VMREFRESH_NO_SYNC); + UpdateView(view, *aRect, NS_VMREFRESH_NO_SYNC); return NS_OK; } NS_IMETHODIMP nsViewManager::SetViewVisibility(nsIView *aView, nsViewVisibility aVisible) { + nsView* view = NS_STATIC_CAST(nsView*, aView); + nsViewVisibility oldVisible; - aView->GetVisibility(oldVisible); + view->GetVisibility(oldVisible); if (aVisible != oldVisible) { - aView->SetVisibility(aVisible); + view->SetVisibility(aVisible); PRBool hasWidget = PR_FALSE; - aView->HasWidget(&hasWidget); + view->HasWidget(&hasWidget); if (!hasWidget) { if (nsViewVisibility_kHide == aVisible) { - nsIView* parentView = nsnull; - aView->GetParent(parentView); + nsView* parentView = view->GetParent(); if (parentView) { nsRect bounds; - aView->GetBounds(bounds); + view->GetBounds(bounds); UpdateView(parentView, bounds, NS_VMREFRESH_NO_SYNC); } } else { - UpdateView(aView, NS_VMREFRESH_NO_SYNC); + UpdateView(view, NS_VMREFRESH_NO_SYNC); } } } @@ -2462,36 +2253,35 @@ NS_IMETHODIMP nsViewManager::SetViewVisibility(nsIView *aView, nsViewVisibility NS_IMETHODIMP nsViewManager::SetViewZIndex(nsIView *aView, PRInt32 aZIndex) { + nsView* view = NS_STATIC_CAST(nsView*, aView); nsresult rv = NS_OK; - NS_ASSERTION((aView != nsnull), "no view"); + NS_ASSERTION((view != nsnull), "no view"); PRInt32 oldidx; - aView->GetZIndex(oldidx); + view->GetZIndex(oldidx); if (oldidx != aZIndex) { - nsIView *parent; - aView->GetParent(parent); + nsView *parent = view->GetParent(); if (nsnull != parent) { //we don't just call the view manager's RemoveChild() //so that we can avoid two trips trough the UpdateView() //code (one for removal, one for insertion). MMP - parent->RemoveChild(aView); - UpdateTransCnt(aView, nsnull); - rv = InsertChild(parent, aView, aZIndex); + parent->RemoveChild(view); + UpdateTransCnt(view, nsnull); + rv = InsertChild(parent, view, aZIndex); } // XXX The following else block is a workaround and should be cleaned up (bug 43410) } else { nsCOMPtr widget; - aView->GetWidget(*getter_AddRefs(widget)); + view->GetWidget(*getter_AddRefs(widget)); if (widget) { widget->SetZIndex(aZIndex); } } - nsIView* zParentView = nsnull; - aView->GetZParent(zParentView); + nsZPlaceholderView* zParentView = view->GetZParent(); if (nsnull != zParentView) { SetViewZIndex(zParentView, aZIndex); } @@ -2501,25 +2291,24 @@ NS_IMETHODIMP nsViewManager::SetViewZIndex(nsIView *aView, PRInt32 aZIndex) NS_IMETHODIMP nsViewManager::SetViewAutoZIndex(nsIView *aView, PRBool aAutoZIndex) { - return aView->SetAutoZIndex(aAutoZIndex); + nsView* view = NS_STATIC_CAST(nsView*, aView); + return view->SetAutoZIndex(aAutoZIndex); } NS_IMETHODIMP nsViewManager::MoveViewAbove(nsIView *aView, nsIView *aOther) { + nsView* view = NS_STATIC_CAST(nsView*, aView); + nsView* other = NS_STATIC_CAST(nsView*, aOther); nsresult rv; - NS_ASSERTION(!(nsnull == aView), "no view"); - NS_ASSERTION(!(nsnull == aOther), "no view"); + NS_ASSERTION(!(nsnull == view), "no view"); + NS_ASSERTION(!(nsnull == other), "no view"); - nsIView *nextview; + nsView *nextview = view->GetNextSibling(); - aView->GetNextSibling(nextview); - - if (nextview != aOther) + if (nextview != other) { - nsIView *parent; - - aView->GetParent(parent); + nsView *parent = view->GetParent(); if (nsnull != parent) { @@ -2527,9 +2316,9 @@ NS_IMETHODIMP nsViewManager::MoveViewAbove(nsIView *aView, nsIView *aOther) //so that we can avoid two trips trough the UpdateView() //code (one for removal, one for insertion). MMP - parent->RemoveChild(aView); - UpdateTransCnt(aView, nsnull); - rv = InsertChild(parent, aView, aOther, PR_TRUE); + parent->RemoveChild(view); + UpdateTransCnt(view, nsnull); + rv = InsertChild(parent, view, other, PR_TRUE); } else rv = NS_OK; @@ -2543,19 +2332,17 @@ NS_IMETHODIMP nsViewManager::MoveViewAbove(nsIView *aView, nsIView *aOther) NS_IMETHODIMP nsViewManager::MoveViewBelow(nsIView *aView, nsIView *aOther) { nsresult rv; + nsView* view = NS_STATIC_CAST(nsView*, aView); + nsView* other = NS_STATIC_CAST(nsView*, aOther); - NS_ASSERTION(!(nsnull == aView), "no view"); - NS_ASSERTION(!(nsnull == aOther), "no view"); + NS_ASSERTION(!(nsnull == view), "no view"); + NS_ASSERTION(!(nsnull == other), "no view"); - nsIView *nextview; - - aOther->GetNextSibling(nextview); + nsView *nextview = other->GetNextSibling(); - if (nextview != aView) + if (nextview != view) { - nsIView *parent; - - aView->GetParent(parent); + nsView *parent = view->GetParent(); if (nsnull != parent) { @@ -2563,9 +2350,9 @@ NS_IMETHODIMP nsViewManager::MoveViewBelow(nsIView *aView, nsIView *aOther) //so that we can avoid two trips trough the UpdateView() //code (one for removal, one for insertion). MMP - parent->RemoveChild(aView); - UpdateTransCnt(aView, nsnull); - rv = InsertChild(parent, aView, aOther, PR_FALSE); + parent->RemoveChild(view); + UpdateTransCnt(view, nsnull); + rv = InsertChild(parent, view, other, PR_FALSE); } else rv = NS_OK; @@ -2576,30 +2363,19 @@ NS_IMETHODIMP nsViewManager::MoveViewBelow(nsIView *aView, nsIView *aOther) return rv; } -NS_IMETHODIMP nsViewManager::IsViewShown(nsIView *aView, PRBool &aResult) -{ - aResult = PR_TRUE; - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP nsViewManager::GetViewClipAbsolute(nsIView *aView, nsRect *rect, PRBool &aResult) -{ - aResult = PR_TRUE; - return NS_ERROR_NOT_IMPLEMENTED; -} - NS_IMETHODIMP nsViewManager::SetViewContentTransparency(nsIView *aView, PRBool aTransparent) { + nsView* view = NS_STATIC_CAST(nsView*, aView); PRBool trans; - aView->HasTransparency(trans); + view->HasTransparency(trans); if (trans != aTransparent) { - UpdateTransCnt(aView, nsnull); - aView->SetContentTransparency(aTransparent); - UpdateTransCnt(nsnull, aView); - UpdateView(aView, NS_VMREFRESH_NO_SYNC); + UpdateTransCnt(view, nsnull); + view->SetContentTransparency(aTransparent); + UpdateTransCnt(nsnull, view); + UpdateView(view, NS_VMREFRESH_NO_SYNC); } return NS_OK; @@ -2607,16 +2383,17 @@ NS_IMETHODIMP nsViewManager::SetViewContentTransparency(nsIView *aView, PRBool a NS_IMETHODIMP nsViewManager::SetViewOpacity(nsIView *aView, float aOpacity) { + nsView* view = NS_STATIC_CAST(nsView*, aView); float opacity; - aView->GetOpacity(opacity); + view->GetOpacity(opacity); if (opacity != aOpacity) { - UpdateTransCnt(aView, nsnull); - aView->SetOpacity(aOpacity); - UpdateTransCnt(nsnull, aView); - UpdateView(aView, NS_VMREFRESH_NO_SYNC); + UpdateTransCnt(view, nsnull); + view->SetOpacity(aOpacity); + UpdateTransCnt(nsnull, view); + UpdateView(view, NS_VMREFRESH_NO_SYNC); } return NS_OK; @@ -2654,7 +2431,7 @@ void nsViewManager::GetMaxWidgetBounds(nsRect& aMaxWidgetBounds) const PRInt32 index = 0; for (index = 0; index < mVMCount; index++) { - nsIViewManager* vm = (nsIViewManager*)gViewManagers->ElementAt(index); + nsViewManager* vm = (nsViewManager*)gViewManagers->ElementAt(index); nsCOMPtr rootWidget; if(NS_SUCCEEDED(vm->GetWidget(getter_AddRefs(rootWidget))) && rootWidget) @@ -2845,9 +2622,9 @@ NS_IMETHODIMP nsViewManager::SetQuality(nsContentQuality aQuality) return NS_OK; } -nsIRenderingContext * nsViewManager::CreateRenderingContext(nsIView &aView) +nsIRenderingContext * nsViewManager::CreateRenderingContext(nsView &aView) { - nsIView *par = &aView; + nsView *par = &aView; nsCOMPtr win; nsIRenderingContext *cx = nsnull; nscoord x, y, ax = 0, ay = 0; @@ -2872,7 +2649,7 @@ nsIRenderingContext * nsViewManager::CreateRenderingContext(nsIView &aView) ay += y; } - par->GetParent(par); + par = par->GetParent(); } while (nsnull != par); @@ -2887,12 +2664,12 @@ nsIRenderingContext * nsViewManager::CreateRenderingContext(nsIView &aView) return cx; } -void nsViewManager::AddRectToDirtyRegion(nsIView* aView, const nsRect &aRect) const +void nsViewManager::AddRectToDirtyRegion(nsView* aView, const nsRect &aRect) const { // Find a view with an associated widget. We'll transform this rect from the // current view's coordinate system to a "heavyweight" parent view, then convert // the rect to pixel coordinates, and accumulate the rect into that view's dirty region. - nsIView* widgetView = GetWidgetView(aView); + nsView* widgetView = GetWidgetView(aView); if (widgetView != nsnull) { nsRect widgetRect = aRect; ViewToWidget(aView, widgetView, widgetRect); @@ -2906,7 +2683,7 @@ void nsViewManager::AddRectToDirtyRegion(nsIView* aView, const nsRect &aRect) co } } -void nsViewManager::UpdateTransCnt(nsIView *oldview, nsIView *newview) +void nsViewManager::UpdateTransCnt(nsView *oldview, nsView *newview) { if (nsnull != oldview) { @@ -3015,6 +2792,7 @@ NS_IMETHODIMP nsViewManager::GetRootScrollableView(nsIScrollableView **aScrollab NS_IMETHODIMP nsViewManager::Display(nsIView* aView, nscoord aX, nscoord aY, const nsRect& aClipRect) { + nsView *view = NS_STATIC_CAST(nsView*, aView); nsIRenderingContext *localcx = nsnull; nsRect trect; @@ -3034,7 +2812,7 @@ NS_IMETHODIMP nsViewManager::Display(nsIView* aView, nscoord aX, nscoord aY, con return NS_ERROR_FAILURE; } - aView->GetBounds(trect); + view->GetBounds(trect); localcx->Translate(aX, aY); @@ -3045,7 +2823,7 @@ NS_IMETHODIMP nsViewManager::Display(nsIView* aView, nscoord aX, nscoord aY, con // Paint the view. The clipping rect was set above set don't clip again. //aView->Paint(*localcx, trect, NS_VIEW_FLAG_CLIP_SET, result); - RenderViews(aView,*localcx,trect,result); + RenderViews(view, *localcx, trect, result); NS_RELEASE(localcx); @@ -3075,14 +2853,15 @@ NS_IMETHODIMP nsViewManager::RemoveCompositeListener(nsICompositeListener* aList NS_IMETHODIMP nsViewManager::GetWidgetForView(nsIView *aView, nsIWidget **aWidget) { + nsView *view = NS_STATIC_CAST(nsView*, aView); + *aWidget = nsnull; - nsIView *view = aView; PRBool hasWidget = PR_FALSE; while (!hasWidget && view) { view->HasWidget(&hasWidget); if (!hasWidget) - view->GetParent(view); + view = view->GetParent(); } if (hasWidget) { @@ -3092,10 +2871,8 @@ NS_IMETHODIMP nsViewManager::GetWidgetForView(nsIView *aView, nsIWidget **aWidge // No widget was found in the view hierachy, so use try to use the mRootWindow if (nsnull != mRootWindow) { #ifdef NS_DEBUG - nsCOMPtr vm; - nsCOMPtr thisInstance(this); - aView->GetViewManager(*getter_AddRefs(vm)); - NS_ASSERTION(thisInstance == vm, "Must use the view instances view manager when calling GetWidgetForView"); + nsViewManager* vm = view->GetViewManager(); + NS_ASSERTION(this == vm, "Must use the view instances view manager when calling GetWidgetForView"); #endif *aWidget = mRootWindow; NS_ADDREF(mRootWindow); @@ -3130,7 +2907,7 @@ NS_IMETHODIMP nsViewManager::GetOffset(nscoord *aX, nscoord *aY) return NS_OK; } -static nsresult EnsureZTreeNodeCreated(nsIView* aView, DisplayZTreeNode* &aNode) { +static nsresult EnsureZTreeNodeCreated(nsView* aView, DisplayZTreeNode* &aNode) { if (nsnull == aNode) { aNode = new DisplayZTreeNode; @@ -3145,10 +2922,10 @@ static nsresult EnsureZTreeNodeCreated(nsIView* aView, DisplayZTreeNode* &aNode) return NS_OK; } -PRBool nsViewManager::CreateDisplayList(nsIView *aView, PRBool aReparentedViewsPresent, +PRBool nsViewManager::CreateDisplayList(nsView *aView, PRBool aReparentedViewsPresent, DisplayZTreeNode* &aResult, PRBool aInsideRealView, - nscoord aOriginX, nscoord aOriginY, nsIView *aRealView, - const nsRect *aDamageRect, nsIView *aTopView, + nscoord aOriginX, nscoord aOriginY, nsView *aRealView, + const nsRect *aDamageRect, nsView *aTopView, nscoord aX, nscoord aY, PRBool aPaintFloaters) { PRBool retval = PR_FALSE; @@ -3210,10 +2987,9 @@ PRBool nsViewManager::CreateDisplayList(nsIView *aView, PRBool aReparentedViewsP } if (!aReparentedViewsPresent) { - nsIView *childView = nsnull; - for (aView->GetChild(0, childView); nsnull != childView; childView->GetNextSibling(childView)) { - nsIView *zParent = nsnull; - childView->GetZParent(zParent); + for (nsView* childView = aView->GetFirstChild(); nsnull != childView; + childView = childView->GetNextSibling()) { + nsZPlaceholderView *zParent = childView->GetZParent(); if (nsnull != zParent) { aReparentedViewsPresent = PR_TRUE; break; @@ -3225,9 +3001,9 @@ PRBool nsViewManager::CreateDisplayList(nsIView *aView, PRBool aReparentedViewsP } } - PRInt32 childCount; - nsIView *childView = nsnull; - aView->GetChildCount(childCount); + PRInt32 childCount = aView->GetChildCount(); + nsView *childView = nsnull; + if (childCount > 0) { if (isClipView) { // -> to refresh-frame coordinates (relative to aRealView) @@ -3244,7 +3020,8 @@ PRBool nsViewManager::CreateDisplayList(nsIView *aView, PRBool aReparentedViewsP bounds.y += aOriginY; } - for (aView->GetChild(0, childView); nsnull != childView; childView->GetNextSibling(childView)) { + for (childView = aView->GetFirstChild(); nsnull != childView; + childView = childView->GetNextSibling()) { PRInt32 zindex; childView->GetZIndex(zindex); if (zindex < 0) @@ -3305,7 +3082,7 @@ PRBool nsViewManager::CreateDisplayList(nsIView *aView, PRBool aReparentedViewsP // any children with negative z-indices? if (!retval && nsnull != childView) { - for (; nsnull != childView; childView->GetNextSibling(childView)) { + for (; nsnull != childView; childView = childView->GetNextSibling()) { DisplayZTreeNode* createdNode; retval = CreateDisplayList(childView, aReparentedViewsPresent, createdNode, aInsideRealView || aRealView == aView, @@ -3337,9 +3114,9 @@ PRBool nsViewManager::CreateDisplayList(nsIView *aView, PRBool aReparentedViewsP DisplayZTreeNode* child; DisplayZTreeNode** prev = &aResult->mZChild; for (child = aResult->mZChild; nsnull != child; child = *prev) { - nsIView *zParent = nsnull; + nsZPlaceholderView *zParent = nsnull; if (nsnull != child->mView) { - child->mView->GetZParent(zParent); + zParent = child->mView->GetZParent(); } if (nsnull != zParent) { // unlink the child from the tree @@ -3358,7 +3135,7 @@ PRBool nsViewManager::CreateDisplayList(nsIView *aView, PRBool aReparentedViewsP delete child; } else { // the placeholder was never added to the display list ... - // we don't need to display, then + // we don't need to display this then DestroyZTreeNode(child); } } else { @@ -3370,7 +3147,8 @@ PRBool nsViewManager::CreateDisplayList(nsIView *aView, PRBool aReparentedViewsP return retval; } -PRBool nsViewManager::AddToDisplayList(nsIView *aView, DisplayZTreeNode* &aParent, nsRect &aClipRect, nsRect& aDirtyRect, PRUint32 aFlags,nscoord aAbsX, nscoord aAbsY) +PRBool nsViewManager::AddToDisplayList(nsView *aView, DisplayZTreeNode* &aParent, + nsRect &aClipRect, nsRect& aDirtyRect, PRUint32 aFlags,nscoord aAbsX, nscoord aAbsY) { PRBool empty; PRBool clipped; @@ -3588,20 +3366,17 @@ void nsViewManager::ShowDisplayList(PRInt32 flatlen) printf("### display list length=%d ###\n", flatlen); for (cnt = 0; cnt < flatlen; cnt++) { - nsIView *view, *parent; - nsRect rect; - PRUint32 flags; - PRInt32 zindex; - DisplayListElement2* element = (DisplayListElement2*) mDisplayList.ElementAt(cnt); - view = element->mView; - rect = element->mBounds; - flags = element->mFlags; + nsView* view = element->mView; + nsRect rect = element->mBounds; + PRUint32 flags = element->mFlags; + + nsView* parent = view->GetParent(); + PRInt32 zindex; + view->GetZIndex(zindex); nest[nestcnt << 1] = 0; - view->GetParent(parent); - view->GetZIndex(zindex); rect *= t2p; printf("%snsIView@%p [z=%d, x=%d, y=%d, w=%d, h=%d, p=%p]\n", nest, (void*)view, zindex, @@ -3636,7 +3411,7 @@ void nsViewManager::ShowDisplayList(PRInt32 flatlen) } #endif -void nsViewManager::ComputeViewOffset(nsIView *aView, nsPoint *aOrigin) +void nsViewManager::ComputeViewOffset(nsView *aView, nsPoint *aOrigin) { if (aOrigin) { while (aView != nsnull) { @@ -3646,14 +3421,12 @@ void nsViewManager::ComputeViewOffset(nsIView *aView, nsPoint *aOrigin) aOrigin->x += bounds.x; aOrigin->y += bounds.y; - nsIView *parent; - aView->GetParent(parent); - aView = parent; + aView = aView->GetParent(); } } } -PRBool nsViewManager::DoesViewHaveNativeWidget(nsIView* aView) +PRBool nsViewManager::DoesViewHaveNativeWidget(nsView* aView) { nsCOMPtr widget; aView->GetWidget(*getter_AddRefs(widget)); @@ -3662,7 +3435,7 @@ PRBool nsViewManager::DoesViewHaveNativeWidget(nsIView* aView) return PR_FALSE; } -PRBool nsViewManager::IsClipView(nsIView* aView) +PRBool nsViewManager::IsClipView(nsView* aView) { nsIClipView *clipView = nsnull; nsresult rv = aView->QueryInterface(NS_GET_IID(nsIClipView), (void **)&clipView); @@ -3670,25 +3443,25 @@ PRBool nsViewManager::IsClipView(nsIView* aView) } -nsIView* nsViewManager::GetWidgetView(nsIView *aView) const +nsView* nsViewManager::GetWidgetView(nsView *aView) const { while (aView != nsnull) { PRBool hasWidget; aView->HasWidget(&hasWidget); if (hasWidget) return aView; - aView->GetParent(aView); + aView = aView->GetParent(); } return nsnull; } -void nsViewManager::ViewToWidget(nsIView *aView, nsIView* aWidgetView, nsRect &aRect) const +void nsViewManager::ViewToWidget(nsView *aView, nsView* aWidgetView, nsRect &aRect) const { while (aView != aWidgetView) { nscoord x, y; aView->GetPosition(&x, &y); aRect.MoveBy(x, y); - aView->GetParent(aView); + aView = aView->GetParent(); } // intersect aRect with bounds of aWidgetView, to prevent generating any illegal rectangles. @@ -3726,27 +3499,29 @@ nsresult nsViewManager::GetVisibleRect(nsRect& aVisibleRect) return rv; } -nsresult nsViewManager::GetAbsoluteRect(nsIView *aView, const nsRect &aRect, +nsresult nsViewManager::GetAbsoluteRect(nsView *aView, const nsRect &aRect, nsRect& aAbsRect) { nsIScrollableView* scrollingView = nsnull; - nsIView* scrolledView = nsnull; GetRootScrollableView(&scrollingView); if (nsnull == scrollingView) { return NS_ERROR_FAILURE; } - scrollingView->GetScrolledView(scrolledView); + nsIView* scrolledIView = nsnull; + scrollingView->GetScrolledView(scrolledIView); + + nsView* scrolledView = NS_STATIC_CAST(nsView*, scrolledIView); // Calculate the absolute coordinates of the aRect passed in. // aRects values are relative to aView aAbsRect = aRect; - nsIView *parentView = aView; + nsView *parentView = aView; while ((parentView != nsnull) && (parentView != scrolledView)) { nscoord x, y; parentView->GetPosition(&x, &y); aAbsRect.MoveBy(x, y); - parentView->GetParent(parentView); + parentView = parentView->GetParent(); } if (parentView != scrolledView) { @@ -3759,6 +3534,8 @@ nsresult nsViewManager::GetAbsoluteRect(nsIView *aView, const nsRect &aRect, NS_IMETHODIMP nsViewManager::IsRectVisible(nsIView *aView, const nsRect &aRect, PRBool aMustBeEntirelyVisible, PRBool *aIsVisible) { + nsView* view = NS_STATIC_CAST(nsView*, aView); + // The parameter PRBool aMustBeEntirelyVisible determines if rectangle that is partially on the screen // and partially off the screen should be counted as visible @@ -3769,7 +3546,7 @@ NS_IMETHODIMP nsViewManager::IsRectVisible(nsIView *aView, const nsRect &aRect, // is this view even visible? nsViewVisibility visibility; - aView->GetVisibility(visibility); + view->GetVisibility(visibility); if (visibility == nsViewVisibility_kHide) { return NS_OK; } @@ -3784,7 +3561,7 @@ NS_IMETHODIMP nsViewManager::IsRectVisible(nsIView *aView, const nsRect &aRect, // Calculate the absolute coordinates of the aRect passed in. // aRects values are relative to aView nsRect absRect; - if ((GetAbsoluteRect(aView, aRect, absRect)) == NS_ERROR_FAILURE) { + if ((GetAbsoluteRect(view, aRect, absRect)) == NS_ERROR_FAILURE) { *aIsVisible = PR_TRUE; return NS_OK; } @@ -3863,21 +3640,20 @@ nsViewManager::ProcessInvalidateEvent() { } nsresult -nsViewManager::ProcessWidgetChanges(nsIView* aView) +nsViewManager::ProcessWidgetChanges(nsView* aView) { //printf("---------Begin Sync----------\n"); nsresult rv = aView->SynchWidgetSizePosition(); if (NS_FAILED(rv)) return rv; - nsIView *child; - aView->GetChild(0, child); + nsView *child = aView->GetFirstChild(); while (nsnull != child) { rv = ProcessWidgetChanges(child); if (NS_FAILED(rv)) return rv; - child->GetNextSibling(child); + child = child->GetNextSibling(); } //printf("---------End Sync----------\n"); diff --git a/view/src/nsViewManager.h b/view/src/nsViewManager.h index aed736be0bc..dfa011ae741 100644 --- a/view/src/nsViewManager.h +++ b/view/src/nsViewManager.h @@ -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,94 +226,6 @@ public: static PRInt32 GetViewManagerCount(); static const nsVoidArray* GetViewManagerArray(); static PRUint32 gLastUserEventTime; -protected: - virtual ~nsViewManager(); - void ProcessPendingUpdates(nsIView *aView); - -private: - nsIRenderingContext *CreateRenderingContext(nsIView &aView); - void AddRectToDirtyRegion(nsIView* aView, const nsRect &aRect) const; - void UpdateTransCnt(nsIView *oldview, nsIView *newview); - - PRBool UpdateAllCoveringWidgets(nsIView *aView, nsIView *aTarget, nsRect &aDamagedRect, PRBool aOnlyRepaintIfUnblittable); - - - void UpdateViews(nsIView *aView, PRUint32 aUpdateFlags); - - void Refresh(nsIView *aView, nsIRenderingContext *aContext, - nsIRegion *region, PRUint32 aUpdateFlags); - void DefaultRefresh(nsIView* aView, const nsRect* aRect); - void RenderViews(nsIView *aRootView, nsIRenderingContext& aRC, const nsRect& aRect, - PRBool &aResult); - - void RenderView(nsIView *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, - 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); - void ReapplyClipInstructions(PRBool aHaveClip, nsRect& aClipRect, PRInt32& aIndex); - nsresult OptimizeDisplayList(const nsRect& aDamageRect, nsRect& aFinalTransparentRect); - // Remove redundant PUSH/POP_CLIP pairs. - 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 - - /** - * Returns the nearest parent view with an attached widget. Can be the - * same view as passed-in. - */ - nsIView* GetWidgetView(nsIView *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); - - /** - * Transforms a rectangle from specified view's coordinate system to - * an absolute coordinate rectangle which can be compared against the - * rectangle returned by GetVisibleRect to determine visibility. - * @param aView view that aRect coordinates are specified relative to - * @param aRect rectangle in twips to convert to absolute coordinates - * @param aAbsRect rectangle in absolute coorindates. - * @returns NS_OK if successful otherwise, NS_ERROR_FAILURE - */ - - nsresult GetAbsoluteRect(nsIView *aView, const nsRect &aRect, - nsRect& aAbsRect); - /** - * Determine the visible rect - * @param aVisibleRect visible rectangle in twips - * @returns NS_OK if successful, otherwise NS_ERROR_FAILURE. - */ - - nsresult GetVisibleRect(nsRect& aVisibleRect); /** * Determine if a rectangle specified in the view's coordinate system @@ -275,68 +236,160 @@ private: */ NS_IMETHOD IsRectVisible(nsIView *aView, const nsRect &aRect, PRBool aMustBeFullyVisible, PRBool *isVisible); +protected: + virtual ~nsViewManager(); + void ProcessPendingUpdates(nsView *aView); + +private: + nsIRenderingContext *CreateRenderingContext(nsView &aView); + void AddRectToDirtyRegion(nsView* aView, const nsRect &aRect) const; + void UpdateTransCnt(nsView *oldview, nsView *newview); + + PRBool UpdateAllCoveringWidgets(nsView *aView, nsView *aTarget, nsRect &aDamagedRect, PRBool aOnlyRepaintIfUnblittable); + + + void UpdateViews(nsView *aView, PRUint32 aUpdateFlags); + + void Refresh(nsView *aView, nsIRenderingContext *aContext, + nsIRegion *region, PRUint32 aUpdateFlags); + void DefaultRefresh(nsView* aView, const nsRect* aRect); + void RenderViews(nsView *aRootView, nsIRenderingContext& aRC, const nsRect& aRect, + PRBool &aResult); + + void RenderView(nsView *aView, nsIRenderingContext &aRC, + const nsRect &aDamageRect, nsRect &aGlobalRect, PRBool &aResult); + + void RenderDisplayListElement(DisplayListElement2* element, nsIRenderingContext &aRC); + + void PaintView(nsView *aView, nsIRenderingContext &aRC, nscoord x, nscoord y, + const nsRect &aDamageRect); + + nsresult CreateBlendingBuffers(nsIRenderingContext &aRC); + + 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 + + // Utilities + + /** + * Returns the nearest parent view with an attached widget. Can be the + * same view as passed-in. + */ + 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(nsView *aView, nsView* aWidgetView, nsRect &aRect) const; + + /** + * Transforms a rectangle from specified view's coordinate system to + * an absolute coordinate rectangle which can be compared against the + * rectangle returned by GetVisibleRect to determine visibility. + * @param aView view that aRect coordinates are specified relative to + * @param aRect rectangle in twips to convert to absolute coordinates + * @param aAbsRect rectangle in absolute coorindates. + * @returns NS_OK if successful otherwise, NS_ERROR_FAILURE + */ + + nsresult GetAbsoluteRect(nsView *aView, const nsRect &aRect, + nsRect& aAbsRect); + /** + * Determine the visible rect + * @param aVisibleRect visible rectangle in twips + * @returns NS_OK if successful, otherwise NS_ERROR_FAILURE. + */ + + nsresult GetVisibleRect(nsRect& aVisibleRect); + + 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 /** - * Determine the maximum and width and height of all of the + * Determine the maximum and width and height of all of the * view manager's widgets. * * @param aMaxWidgetBounds the maximum width and height of all view managers * widgets on exit. - */ + */ void GetMaxWidgetBounds(nsRect& aMaxWidgetBounds) const; /** - * Determine if a rect's width and height will fit within a specified width and height + * Determine if a rect's width and height will fit within a specified width and height * @param aRect rectangle to test * @param aWidth width to determine if the rectangle's width will fit within * @param aHeight height to determine if the rectangles height will fit within * @returns PR_TRUE if the rect width and height fits with aWidth, aHeight, PR_FALSE * otherwise. - */ + */ PRBool RectFitsInside(nsRect& aRect, PRInt32 aWidth, PRInt32 aHeight) const; /** - * Determine if two rectangles width and height will fit within a specified width and height + * Determine if two rectangles width and height will fit within a specified width and height * @param aRect1 first rectangle to test * @param aRect1 second rectangle to test * @param aWidth width to determine if both rectangle's width will fit within * @param aHeight height to determine if both rectangles height will fit within * @returns PR_TRUE if the rect1's and rect2's width and height fits with aWidth, * aHeight, PR_FALSE otherwise. - */ + */ PRBool BothRectsFitInside(nsRect& aRect1, nsRect& aRect2, PRInt32 aWidth, PRInt32 aHeight, nsRect& aNewSize) const; /** - * Return an offscreen surface size from a set of discrete surface sizes. + * Return an offscreen surface size from a set of discrete surface sizes. * The smallest discrete surface size that can enclose both the Maximum widget * size (@see GetMaxWidgetBounds) and the requested size is returned. * * @param aRequestedSize Requested size for the offscreen. * @param aSurfaceSize contains the surface size - */ + */ void CalculateDiscreteSurfaceSize(nsRect& aRequestedSize, nsRect& aSize) const; /** - * Get the size of the offscreen drawing surface.. + * Get the size of the offscreen drawing surface.. * * @param aRequestedSize Desired size for the offscreen. * @param aSurfaceSize Offscreen adjusted to a discrete size which encloses aRequestedSize. - */ + */ 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; - float mPixelsToTwips; + float mTwipsToPixels; + float mPixelsToTwips; nsIViewObserver *mObserver; nsIWidget *mRootWindow; PRIntervalTime mLastRefresh; @@ -344,13 +397,13 @@ private: PRBool mRefreshEnabled; PRBool mPainting; PRBool mRecursiveRefreshPending; - nsIView *mMouseGrabber; - nsIView *mKeyGrabber; + nsView *mMouseGrabber; + nsView *mKeyGrabber; PRInt32 mUpdateCnt; PRInt32 mUpdateBatchCnt; PRInt32 mDisplayListCount; nsAutoVoidArray mDisplayList; - PRInt32 mTranslucentViewCount; + PRInt32 mTranslucentViewCount; nsRect mTranslucentArea; // bounding box of all translucent views. nsIScrollableView *mRootScrollable; PRInt32 mCachingWidgetChanges; @@ -391,7 +444,7 @@ private: nsISupportsArray *mCompositeListeners; void DestroyZTreeNode(DisplayZTreeNode* aNode); protected: - nsIView *mRootView; + nsView *mRootView; nscoord mX; nscoord mY; PRBool mAllowDoubleBuffering;