From 6198164edbebc8d88448089f673da7639ff14e5e Mon Sep 17 00:00:00 2001 From: "pinkerton%netscape.com" Date: Mon, 17 Jan 2000 01:34:26 +0000 Subject: [PATCH] Fix for 18240, don't optimize out recalculating regions when mBounds doesn't change on a resize. r=beard, sfraser. --- widget/src/mac/nsWindow.cpp | 52 +++++++++++++++++++++++++------------ widget/src/mac/nsWindow.h | 1 + 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/widget/src/mac/nsWindow.cpp b/widget/src/mac/nsWindow.cpp index 904b66358a9c..04f5afa09a76 100644 --- a/widget/src/mac/nsWindow.cpp +++ b/widget/src/mac/nsWindow.cpp @@ -317,8 +317,7 @@ void* nsWindow::GetNativeData(PRUint32 aDataType) break; case NS_NATIVE_REGION: -// retVal = (void*)mWindowRegion; - retVal = (void*)mVisRegion; + retVal = (void*)mVisRegion; break; case NS_NATIVE_COLORMAP: @@ -648,6 +647,18 @@ NS_IMETHODIMP nsWindow::GetBounds(nsRect &aRect) return NS_OK; } + +NS_METHOD nsWindow::SetBounds(const nsRect &aRect) +{ +printf("\nsetting bounds to x y w h %ld %ld %ld %ld\n\n", aRect.x, aRect.y, aRect.width, aRect.height ); + nsresult rv = Inherited::SetBounds(aRect); + if ( NS_SUCCEEDED(rv) ) + CalcWindowRegions(); + + return rv; +} + + //------------------------------------------------------------------------- // // Move this component @@ -681,23 +692,32 @@ NS_IMETHODIMP nsWindow::Move(PRInt32 aX, PRInt32 aY) //------------------------------------------------------------------------- NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) { - if ((mBounds.width != aWidth) || (mBounds.height != aHeight)) - { - // Set the bounds - mBounds.width = aWidth; - mBounds.height = aHeight; + if ((mBounds.width != aWidth) || (mBounds.height != aHeight)) + { + // Set the bounds + mBounds.width = aWidth; + mBounds.height = aHeight; - // Recalculate the regions - CalcWindowRegions(); + // Recalculate the regions + CalcWindowRegions(); + + // Invalidate the new location + if (aRepaint) + Invalidate(PR_FALSE); - // Invalidate the new location - if (aRepaint) - Invalidate(PR_FALSE); + // Report the event + ReportSizeEvent(); + } + else { + // Recalculate the regions. We always need to do this, our parents may have + // changed, hence changing our notion of visibility. We then also should make + // sure that we invalidate ourselves correctly. Fixes bug 18240 (pinkerton). + CalcWindowRegions(); + if (aRepaint) + Invalidate(PR_FALSE); + } - // Report the event - ReportSizeEvent(); - } - return NS_OK; + return NS_OK; } //------------------------------------------------------------------------- diff --git a/widget/src/mac/nsWindow.h b/widget/src/mac/nsWindow.h index 20668a68b77e..d655ff2c580b 100644 --- a/widget/src/mac/nsWindow.h +++ b/widget/src/mac/nsWindow.h @@ -130,6 +130,7 @@ public: NS_IMETHOD Enable(PRBool bState); NS_IMETHOD SetFocus(void); + NS_IMETHOD SetBounds(const nsRect &aRect); NS_IMETHOD GetBounds(nsRect &aRect); virtual nsIFontMetrics* GetFont(void);