Bug 708278 - Prevent recursion in ReportMoveEvent(), which can become infinite. r=bgirard a=maconly
authorSteven Michaud <smichaud@pobox.com>
Tue, 13 Dec 2011 10:55:16 -0600
changeset 84144 b0115f8271e1abf5ef791df5c9e5368158fa57ab
parent 84143 9b7c08d602b9615d36ace243bfb3616245c2ba7c
child 84145 467197e8063fe3d1a42d0b9bc80c9dcf6dfb582f
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgirard, maconly
bugs708278
milestone11.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 708278 - Prevent recursion in ReportMoveEvent(), which can become infinite. r=bgirard a=maconly
widget/src/cocoa/nsCocoaWindow.h
widget/src/cocoa/nsCocoaWindow.mm
--- a/widget/src/cocoa/nsCocoaWindow.h
+++ b/widget/src/cocoa/nsCocoaWindow.h
@@ -337,13 +337,15 @@ protected:
   NSUInteger           mWindowFilter;
 
   bool                 mWindowMadeHere; // true if we created the window, false for embedding
   bool                 mSheetNeedsShow; // if this is a sheet, are we waiting to be shown?
                                         // this is used for sibling sheet contention only
   bool                 mFullScreen;
   bool                 mModal;
 
+  bool                 mInReportMoveEvent; // true if in a call to ReportMoveEvent().
+
   PRInt32              mNumModalDescendents;
   InputContext         mInputContext;
 };
 
 #endif // nsCocoaWindow_h_
--- a/widget/src/cocoa/nsCocoaWindow.mm
+++ b/widget/src/cocoa/nsCocoaWindow.mm
@@ -134,16 +134,17 @@ nsCocoaWindow::nsCocoaWindow()
 , mSheetWindowParent(nil)
 , mPopupContentView(nil)
 , mShadowStyle(NS_STYLE_WINDOW_SHADOW_DEFAULT)
 , mWindowFilter(0)
 , mWindowMadeHere(false)
 , mSheetNeedsShow(false)
 , mFullScreen(false)
 , mModal(false)
+, mInReportMoveEvent(false)
 , mNumModalDescendents(0)
 {
 
 }
 
 void nsCocoaWindow::DestroyNativeWindow()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
@@ -1359,26 +1360,37 @@ GetWindowSizeMode(NSWindow* aWindow) {
   return nsSizeMode_Normal;
 }
 
 void
 nsCocoaWindow::ReportMoveEvent()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
+  // Prevent recursion, which can become infinite (see bug 708278).  This
+  // can happen when the call to [NSWindow setFrameTopLeftPoint:] in
+  // nsCocoaWindow::Move() triggers an immediate NSWindowDidMove notification
+  // (and a call to [WindowDelegate windowDidMove:]).
+  if (mInReportMoveEvent) {
+    return;
+  }
+  mInReportMoveEvent = true;
+
   UpdateBounds();
 
   // Dispatch the move event to Gecko
   nsGUIEvent guiEvent(true, NS_MOVE, this);
   guiEvent.refPoint.x = mBounds.x;
   guiEvent.refPoint.y = mBounds.y;
   guiEvent.time = PR_IntervalNow();
   nsEventStatus status = nsEventStatus_eIgnore;
   DispatchEvent(&guiEvent, status);
 
+  mInReportMoveEvent = false;
+
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 void
 nsCocoaWindow::DispatchSizeModeEvent()
 {
   nsSizeModeEvent event(true, NS_SIZEMODE, this);
   event.mSizeMode = GetWindowSizeMode(mWindow);