Bug 968838 - Refuse reentrant calls to nsCocoaWindow::DoResize. r=smichaud
authorMarkus Stange <mstange@themasta.com>
Thu, 13 Mar 2014 13:21:56 +0100
changeset 173408 0daba7f5bcf7
parent 173407 7f90960c05da
child 173409 ae9df661d3a4
push id26403
push userryanvm@gmail.com
push dateThu, 13 Mar 2014 19:32:04 +0000
treeherdermozilla-central@fe40387eba1a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmichaud
bugs968838
milestone30.0a1
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
Bug 968838 - Refuse reentrant calls to nsCocoaWindow::DoResize. r=smichaud
widget/cocoa/nsCocoaWindow.h
widget/cocoa/nsCocoaWindow.mm
--- a/widget/cocoa/nsCocoaWindow.h
+++ b/widget/cocoa/nsCocoaWindow.h
@@ -394,14 +394,15 @@ protected:
                                                 // (MakeFullScreen() call) to EnteredFullScreen()
   bool                 mModal;
 
   bool                 mUsesNativeFullScreen; // only true on Lion if SetShowsFullScreenButton(true);
 
   bool                 mIsAnimationSuppressed;
 
   bool                 mInReportMoveEvent; // true if in a call to ReportMoveEvent().
+  bool                 mInResize; // true if in a call to DoResize().
 
   int32_t              mNumModalDescendents;
   InputContext         mInputContext;
 };
 
 #endif // nsCocoaWindow_h_
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -30,16 +30,17 @@
 #include "nsCocoaFeatures.h"
 #include "nsIScreenManager.h"
 #include "nsIWidgetListener.h"
 #include "nsIPresShell.h"
 
 #include "gfxPlatform.h"
 #include "qcms.h"
 
+#include "mozilla/AutoRestore.h"
 #include "mozilla/BasicEvents.h"
 #include "mozilla/Preferences.h"
 #include <algorithm>
 
 namespace mozilla {
 namespace layers {
 class LayerManager;
 }
@@ -107,16 +108,17 @@ nsCocoaWindow::nsCocoaWindow()
 , mWindowMadeHere(false)
 , mSheetNeedsShow(false)
 , mFullScreen(false)
 , mInFullScreenTransition(false)
 , mModal(false)
 , mUsesNativeFullScreen(false)
 , mIsAnimationSuppressed(false)
 , mInReportMoveEvent(false)
+, mInResize(false)
 , mNumModalDescendents(0)
 {
 
 }
 
 void nsCocoaWindow::DestroyNativeWindow()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
@@ -1328,20 +1330,23 @@ NS_METHOD nsCocoaWindow::MakeFullScreen(
 // Coordinates are global display pixels
 nsresult nsCocoaWindow::DoResize(double aX, double aY,
                                  double aWidth, double aHeight,
                                  bool aRepaint,
                                  bool aConstrainToCurrentScreen)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
-  if (!mWindow) {
+  if (!mWindow || mInResize) {
     return NS_OK;
   }
 
+  AutoRestore<bool> reentrantResizeGuard(mInResize);
+  mInResize = true;
+
   // ConstrainSize operates in device pixels, so we need to convert using
   // the backing scale factor here
   CGFloat scale = BackingScaleFactor();
   int32_t width = NSToIntRound(aWidth * scale);
   int32_t height = NSToIntRound(aHeight * scale);
   ConstrainSize(&width, &height);
 
   nsIntRect newBounds(NSToIntRound(aX), NSToIntRound(aY),