Backing out changeset e1983b9db75d from bug 596955 for causing bug 615858. a=backout
authorDave Townsend <dtownsend@oxymoronical.com>
Wed, 01 Dec 2010 10:20:28 -0800
changeset 58446 1b4041e3c1772d69e6ae8ba7a9b4881d183b4b8d
parent 58445 a497aacc2fa018ec664444293587986c215c459c
child 58447 ff556af5f8e9a69a91815b796652c796addbf881
push id17302
push userdtownsend@mozilla.com
push dateWed, 01 Dec 2010 18:20:35 +0000
treeherdermozilla-central@1b4041e3c177 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs596955, 615858
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backing out changeset e1983b9db75d from bug 596955 for causing bug 615858. a=backout
widget/src/cocoa/nsCocoaWindow.h
widget/src/cocoa/nsCocoaWindow.mm
--- a/widget/src/cocoa/nsCocoaWindow.h
+++ b/widget/src/cocoa/nsCocoaWindow.h
@@ -276,16 +276,21 @@ public:
 
     void DispatchSizeModeEvent();
 
     virtual gfxASurface* GetThebesSurface();
 
     // 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; }
 
     void SetMenuBar(nsMenuBarX* aMenuBar);
     nsMenuBarX *GetMenuBar();
 
     // nsIKBStateControl interface
     NS_IMETHOD ResetInputState();
@@ -328,16 +333,17 @@ protected:
   BaseWindow*          mWindow;         // our cocoa window [STRONG]
   WindowDelegate*      mDelegate;       // our delegate for processing window msgs [STRONG]
   nsRefPtr<nsMenuBarX> mMenuBar;
   NSWindow*            mSheetWindowParent; // if this is a sheet, this is the NSWindow it's attached to
   nsChildView*         mPopupContentView; // if this is a popup, this is its content widget
   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
   PRPackedBool         mFullScreen;
   PRPackedBool         mModal;
 
   PRInt32              mNumModalDescendents;
 };
--- a/widget/src/cocoa/nsCocoaWindow.mm
+++ b/widget/src/cocoa/nsCocoaWindow.mm
@@ -134,16 +134,17 @@ static void RollUpPopups()
 nsCocoaWindow::nsCocoaWindow()
 : mParent(nsnull)
 , mWindow(nil)
 , mDelegate(nil)
 , mSheetWindowParent(nil)
 , mPopupContentView(nil)
 , mShadowStyle(NS_STYLE_WINDOW_SHADOW_DEFAULT)
 , mWindowFilter(0)
+, mIsResizing(PR_FALSE)
 , mWindowMadeHere(PR_FALSE)
 , mSheetNeedsShow(PR_FALSE)
 , mFullScreen(PR_FALSE)
 , mModal(PR_FALSE)
 , mNumModalDescendents(0)
 {
 
 }
@@ -1128,26 +1129,45 @@ NS_IMETHODIMP nsCocoaWindow::Resize(PRIn
 
   nsIntRect newBounds = nsIntRect(aX, aY, aWidth, aHeight);
   FitRectToVisibleAreaForScreen(newBounds, [mWindow screen]);
 
   nsIntRect windowBounds(nsCocoaUtils::CocoaRectToGeckoRect([mWindow frame]));
   BOOL isMoving = (windowBounds.x != newBounds.x || windowBounds.y != newBounds.y);
   BOOL isResizing = (windowBounds.width != newBounds.width || windowBounds.height != newBounds.height);
 
-  if (!mWindow || (!isMoving && !isResizing))
+  if (IsResizing() || !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;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP nsCocoaWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
 {
@@ -1763,17 +1783,17 @@ PRBool nsCocoaWindow::ShouldFocusPlugin(
 {
   RollUpPopups();
   
   return proposedFrameSize;
 }
 
 - (void)windowDidResize:(NSNotification *)aNotification
 {
-  if (!mGeckoWindow)
+  if (!mGeckoWindow || mGeckoWindow->IsResizing())
     return;
 
   // Resizing might have changed our zoom state.
   mGeckoWindow->DispatchSizeModeEvent();
   mGeckoWindow->ReportSizeEvent();
 }
 
 - (void)windowDidBecomeMain:(NSNotification *)aNotification