From 92d57b436b44b22b684c11bfa6319c93e666f269 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Sat, 27 Nov 2010 14:52:33 +0100 Subject: [PATCH] Bug 596955 - Simplify nsCocoaWindow::Resize and no longer resize our ChildView before doing the actual window resize in order to avoid painting artifacts with OpenGL. r=josh, a=final --- widget/src/cocoa/nsCocoaWindow.h | 6 ------ widget/src/cocoa/nsCocoaWindow.mm | 24 ++---------------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/widget/src/cocoa/nsCocoaWindow.h b/widget/src/cocoa/nsCocoaWindow.h index b9673af41b7e..849fc324ec03 100644 --- a/widget/src/cocoa/nsCocoaWindow.h +++ b/widget/src/cocoa/nsCocoaWindow.h @@ -281,11 +281,6 @@ public: // be notified that a some form of drag event needs to go into Gecko virtual PRBool DragEvent(unsigned int aMessage, Point aMouseGlobal, UInt16 aKeyModifiers); - // Helpers to prevent recursive resizing during live-resize - PRBool IsResizing () const { return mIsResizing; } - void StartResizing () { mIsResizing = PR_TRUE; } - void StopResizing () { mIsResizing = PR_FALSE; } - PRBool HasModalDescendents() { return mNumModalDescendents > 0; } NSWindow *GetCocoaWindow() { return mWindow; } @@ -338,7 +333,6 @@ protected: PRInt32 mShadowStyle; NSUInteger mWindowFilter; - PRPackedBool mIsResizing; // we originated the resize, prevent infinite recursion PRPackedBool mWindowMadeHere; // true if we created the window, false for embedding PRPackedBool mSheetNeedsShow; // if this is a sheet, are we waiting to be shown? // this is used for sibling sheet contention only diff --git a/widget/src/cocoa/nsCocoaWindow.mm b/widget/src/cocoa/nsCocoaWindow.mm index 0b1fd44688af..675774a65323 100644 --- a/widget/src/cocoa/nsCocoaWindow.mm +++ b/widget/src/cocoa/nsCocoaWindow.mm @@ -139,7 +139,6 @@ nsCocoaWindow::nsCocoaWindow() , mPopupContentView(nil) , mShadowStyle(NS_STYLE_WINDOW_SHADOW_DEFAULT) , mWindowFilter(0) -, mIsResizing(PR_FALSE) , mWindowMadeHere(PR_FALSE) , mSheetNeedsShow(PR_FALSE) , mFullScreen(PR_FALSE) @@ -1134,35 +1133,16 @@ NS_IMETHODIMP nsCocoaWindow::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRIn BOOL isMoving = (windowBounds.x != newBounds.x || windowBounds.y != newBounds.y); BOOL isResizing = (windowBounds.width != newBounds.width || windowBounds.height != newBounds.height); - if (IsResizing() || !mWindow || (!isMoving && !isResizing)) + if (!mWindow || (!isMoving && !isResizing)) return NS_OK; mBounds = newBounds; NSRect newFrame = nsCocoaUtils::GeckoRectToCocoaRect(mBounds); - // We have to report the size event -first-, to make sure that content - // repositions itself. Cocoa views are anchored at the bottom left, - // so if we don't do this our child view will end up being stuck in the - // wrong place during a resize. - if (isResizing) - ReportSizeEvent(&newFrame); - - StartResizing(); // We ignore aRepaint -- we have to call display:YES, otherwise the // title bar doesn't immediately get repainted and is displayed in // the wrong place, leading to a visual jump. [mWindow setFrame:newFrame display:YES]; - StopResizing(); - - // now, check whether we got the frame that we wanted - NSRect actualFrame = [mWindow frame]; - if (newFrame.size.width != actualFrame.size.width || newFrame.size.height != actualFrame.size.height) { - // We didn't; the window must have been too big or otherwise invalid. - // Report -another- resize in this case, to make sure things are in - // the right place. This will cause some visual jitter, but - // shouldn't happen often. - ReportSizeEvent(); - } return NS_OK; @@ -1788,7 +1768,7 @@ PRBool nsCocoaWindow::ShouldFocusPlugin() - (void)windowDidResize:(NSNotification *)aNotification { - if (!mGeckoWindow || mGeckoWindow->IsResizing()) + if (!mGeckoWindow) return; // Resizing might have changed our zoom state.