From f6b930c9e63eb26a6832929d20b64d9f72775720 Mon Sep 17 00:00:00 2001 From: "putterman%netscape.com" Date: Mon, 24 Apr 2000 22:05:39 +0000 Subject: [PATCH] backing out troy's changes to fix various ui not working blocker bugs. --- view/public/nsIView.h | 2 ++ view/src/nsScrollPortView.cpp | 3 +- view/src/nsScrollPortView.h | 1 + view/src/nsScrollingView.cpp | 6 ++-- view/src/nsScrollingView.h | 1 + view/src/nsView.cpp | 67 +++++++++++++++++++++++++++-------- view/src/nsView.h | 3 +- 7 files changed, 64 insertions(+), 19 deletions(-) diff --git a/view/public/nsIView.h b/view/public/nsIView.h index 18138c9e6b2d..3425d684b22b 100644 --- a/view/public/nsIView.h +++ b/view/public/nsIView.h @@ -88,12 +88,14 @@ public: * @param aParent intended parent for view. this is not actually set in the * nsIView through this method. it is only used by the initialization * code to walk up the view tree, if necessary, to find resources. + * @param aCilpRect initial clip rect of view * @param aVisibilityFlag initial visibility state of view * @result The result of the initialization, NS_OK if no errors */ NS_IMETHOD Init(nsIViewManager* aManager, const nsRect &aBounds, const nsIView *aParent, + const nsViewClip *aClip = nsnull, nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow) = 0; /** diff --git a/view/src/nsScrollPortView.cpp b/view/src/nsScrollPortView.cpp index e5de244e8877..cbe2672f3ed0 100644 --- a/view/src/nsScrollPortView.cpp +++ b/view/src/nsScrollPortView.cpp @@ -103,9 +103,10 @@ nsrefcnt nsScrollPortView::Release() NS_IMETHODIMP nsScrollPortView::Init(nsIViewManager* aManager, const nsRect &aBounds, const nsIView *aParent, + const nsViewClip *aClip, nsViewVisibility aVisibilityFlag) { - return nsView::Init(aManager, aBounds, aParent, aVisibilityFlag); + return nsView::Init(aManager, aBounds, aParent, aClip, aVisibilityFlag); } NS_IMETHODIMP nsScrollPortView::SetDimensions(nscoord width, nscoord height, PRBool aPaint) diff --git a/view/src/nsScrollPortView.h b/view/src/nsScrollPortView.h index 0cb065208eb2..fc5d0d87dc49 100644 --- a/view/src/nsScrollPortView.h +++ b/view/src/nsScrollPortView.h @@ -43,6 +43,7 @@ public: NS_IMETHOD Init(nsIViewManager* aManager, const nsRect &aBounds, const nsIView *aParent, + const nsViewClip *aClip = nsnull, nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow); NS_IMETHOD SetDimensions(nscoord width, nscoord height, PRBool aPaint = PR_TRUE); NS_IMETHOD SetPosition(nscoord aX, nscoord aY); diff --git a/view/src/nsScrollingView.cpp b/view/src/nsScrollingView.cpp index 832d922cb4fa..6e36d43e23d7 100644 --- a/view/src/nsScrollingView.cpp +++ b/view/src/nsScrollingView.cpp @@ -444,6 +444,7 @@ nsrefcnt nsScrollingView::Release() NS_IMETHODIMP nsScrollingView::Init(nsIViewManager* aManager, const nsRect &aBounds, const nsIView *aParent, + const nsViewClip *aClip, nsViewVisibility aVisibilityFlag) { nsIDeviceContext *dx = nsnull; @@ -462,7 +463,7 @@ NS_IMETHODIMP nsScrollingView::Init(nsIViewManager* aManager, NS_RELEASE(dx); } - return nsView::Init(aManager, aBounds, aParent, aVisibilityFlag); + return nsView::Init(aManager, aBounds, aParent, aClip, aVisibilityFlag); } NS_IMETHODIMP nsScrollingView::SetDimensions(nscoord width, nscoord height, PRBool aPaint) @@ -839,7 +840,8 @@ NS_IMETHODIMP nsScrollingView::CreateScrollControls(nsNativeWidget aNative) trect.height = NSToCoordRound(sbHeight); trect.y = mBounds.y + mBounds.YMost() - trect.height; - rv = mCornerView->Init(mViewManager, trect, this, nsViewVisibility_kHide); + rv = mCornerView->Init(mViewManager, trect, this, + nsnull, nsViewVisibility_kHide); mViewManager->InsertChild(this, mCornerView, mZindex); mCornerView->CreateWidget(kWidgetCID, &initData, mWindow ? nsnull : aNative); diff --git a/view/src/nsScrollingView.h b/view/src/nsScrollingView.h index dda60157e664..eae4342d927c 100644 --- a/view/src/nsScrollingView.h +++ b/view/src/nsScrollingView.h @@ -45,6 +45,7 @@ public: NS_IMETHOD Init(nsIViewManager* aManager, const nsRect &aBounds, const nsIView *aParent, + const nsViewClip *aClip = nsnull, nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow); NS_IMETHOD SetDimensions(nscoord width, nscoord height, PRBool aPaint = PR_TRUE); NS_IMETHOD SetPosition(nscoord aX, nscoord aY); diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index 9e0bce212371..feb8f4489d10 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -210,6 +210,7 @@ nsIView* nsView::GetViewFor(nsIWidget* aWidget) NS_IMETHODIMP nsView :: Init(nsIViewManager* aManager, const nsRect &aBounds, const nsIView *aParent, + const nsViewClip *aClip, nsViewVisibility aVisibilityFlag) { //printf(" \n callback=%d data=%d", aWidgetCreateCallback, aCallbackData); @@ -223,10 +224,15 @@ NS_IMETHODIMP nsView :: Init(nsIViewManager* aManager, // we don't hold a reference to the view manager mViewManager = aManager; - mChildClip.mLeft = 0; - mChildClip.mRight = 0; - mChildClip.mTop = 0; - mChildClip.mBottom = 0; + if (aClip != nsnull) + mClip = *aClip; + else + { + mClip.mLeft = 0; + mClip.mRight = 0; + mClip.mTop = 0; + mClip.mBottom = 0; + } SetBounds(aBounds); @@ -267,7 +273,18 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect, if (nsnull != mClientData) { nsCOMPtr observer; if (NS_OK == mViewManager->GetViewObserver(*getter_AddRefs(observer))) { - observer->Paint((nsIView *)this, rc, rect); + if ((mClip.mLeft != mClip.mRight) && (mClip.mTop != mClip.mBottom)) { + nsRect crect; + crect.x = mClip.mLeft; + crect.y = mClip.mTop; + crect.width = mClip.mRight - mClip.mLeft; + crect.height = mClip.mBottom - mClip.mTop; + rc.SetClipRect(crect, nsClipCombine_kIntersect, aResult); + if (!aResult) + observer->Paint((nsIView *)this, rc, rect); + } else { + observer->Paint((nsIView *)this, rc, rect); + } } } } else { @@ -291,7 +308,11 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect, { nsRect brect; GetBounds(brect); - rc.SetClipRect(brect, nsClipCombine_kIntersect, clipres); + + // what does this test mean? + if ((mClip.mLeft == mClip.mRight) || (mClip.mTop == mClip.mBottom) && (this != pRoot)) { + rc.SetClipRect(brect, nsClipCombine_kIntersect, clipres); + } } } @@ -559,6 +580,12 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect, if (nsnull != mClientData) { nsCOMPtr observer; if (NS_OK == mViewManager->GetViewObserver(*getter_AddRefs(observer))) { + if ((mClip.mLeft != mClip.mRight) && (mClip.mTop != mClip.mBottom)) { + nsRect crect(mClip.mLeft, mClip.mTop, + mClip.mRight - mClip.mLeft, + mClip.mBottom - mClip.mTop); + localcx->SetClipRect(crect, nsClipCombine_kIntersect, clipres); + } observer->Paint((nsIView *)this, *localcx, rect); } } @@ -669,7 +696,17 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect, nsRect brect; GetBounds(brect); - if (this != pRoot) + if ((mClip.mLeft != mClip.mRight) && (mClip.mTop != mClip.mBottom)) + { + nsRect crect; + + crect.x = mClip.mLeft + brect.x; + crect.y = mClip.mTop + brect.y; + crect.width = mClip.mRight - mClip.mLeft; + crect.height = mClip.mBottom - mClip.mTop; + + rc.SetClipRect(crect, nsClipCombine_kSubtract, clipres); + } else if (this != pRoot) rc.SetClipRect(brect, nsClipCombine_kSubtract, clipres); } @@ -1012,20 +1049,20 @@ NS_IMETHODIMP nsView :: GetBounds(nsRect &aBounds) const NS_IMETHODIMP nsView :: SetChildClip(nscoord aLeft, nscoord aTop, nscoord aRight, nscoord aBottom) { NS_PRECONDITION(aLeft <= aRight && aTop <= aBottom, "bad clip values"); - mChildClip.mLeft = aLeft; - mChildClip.mTop = aTop; - mChildClip.mRight = aRight; - mChildClip.mBottom = aBottom; + mClip.mLeft = aLeft; + mClip.mTop = aTop; + mClip.mRight = aRight; + mClip.mBottom = aBottom; return NS_OK; } NS_IMETHODIMP nsView :: GetChildClip(nscoord *aLeft, nscoord *aTop, nscoord *aRight, nscoord *aBottom) const { - *aLeft = mChildClip.mLeft; - *aTop = mChildClip.mTop; - *aRight = mChildClip.mRight; - *aBottom = mChildClip.mBottom; + *aLeft = mClip.mLeft; + *aTop = mClip.mTop; + *aRight = mClip.mRight; + *aBottom = mClip.mBottom; return NS_OK; } diff --git a/view/src/nsView.h b/view/src/nsView.h index f848d38d2c0c..ee94de7c9606 100644 --- a/view/src/nsView.h +++ b/view/src/nsView.h @@ -49,6 +49,7 @@ public: NS_IMETHOD Init(nsIViewManager* aManager, const nsRect &aBounds, const nsIView *aParent, + const nsViewClip *aClip = nsnull, nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow); NS_IMETHOD Destroy(); @@ -144,7 +145,7 @@ protected: nsViewVisibility mVis; PRInt32 mNumKids; nsRect mBounds; - nsViewClip mChildClip; + nsViewClip mClip; nsTransform2D *mXForm; float mOpacity; PRUint32 mVFlags;