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

This commit is contained in:
Markus Stange 2010-11-27 14:52:33 +01:00
parent c64ca1686b
commit 7564a1242b
2 changed files with 2 additions and 28 deletions

View File

@ -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

View File

@ -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.