Bug 600901 - [clang]: cannot initialize a parameter/variable in nsCocoaWindow.mm, r=josh, a=josh
authorScott Greenlay <sgreenlay@mozilla.com>
Wed, 17 Nov 2010 13:48:11 -0800
changeset 57862 62b716f5e267da22e4eff6e25b60786709f037b5
parent 57861 0fab20410b0ae45a8ed43a8de77099deb7407dc6
child 57864 693505bdb668ddf5851f581bda5d49fc6da208a8
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersjosh, josh
bugs600901
milestone2.0b8pre
Bug 600901 - [clang]: cannot initialize a parameter/variable in nsCocoaWindow.mm, r=josh, a=josh
widget/src/cocoa/nsCocoaWindow.h
widget/src/cocoa/nsCocoaWindow.mm
--- a/widget/src/cocoa/nsCocoaWindow.h
+++ b/widget/src/cocoa/nsCocoaWindow.h
@@ -130,17 +130,21 @@ typedef struct _nsCocoaWindowList {
 {
 }
 
 - (BOOL)canBecomeKeyWindow;
 - (BOOL)canBecomeMainWindow;
 
 @end
 
+#if defined( MAC_OS_X_VERSION_10_6 ) && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 )
+@interface WindowDelegate : NSObject <NSWindowDelegate>
+#else
 @interface WindowDelegate : NSObject
+#endif
 {
   nsCocoaWindow* mGeckoWindow; // [WEAK] (we are owned by the window)
   // Used to avoid duplication when we send NS_ACTIVATE and
   // NS_DEACTIVATE to Gecko for toplevel widgets.  Starts out
   // PR_FALSE.
   PRBool mToplevelActiveState;
   BOOL mHasEverBeenZoomed;
 }
--- a/widget/src/cocoa/nsCocoaWindow.mm
+++ b/widget/src/cocoa/nsCocoaWindow.mm
@@ -2277,18 +2277,19 @@ static const NSString* kStateShowsToolba
     [self setTitlebarNeedsDisplayInRect:[self titlebarRect] sync:YES];
   }
 }
 
 - (void)setDrawsContentsIntoWindowFrame:(BOOL)aState
 {
   BOOL stateChanged = ([self drawsContentsIntoWindowFrame] != aState);
   [super setDrawsContentsIntoWindowFrame:aState];
-  if (stateChanged) {
-    nsCocoaWindow *geckoWindow = [[self delegate] geckoWidget];
+  if (stateChanged && [[self delegate] isKindOfClass:[WindowDelegate class]]) {
+    WindowDelegate *windowDelegate = (WindowDelegate *)[self delegate];
+    nsCocoaWindow *geckoWindow = [windowDelegate geckoWidget];
     if (geckoWindow) {
       // Re-layout our contents.
       geckoWindow->ReportSizeEvent();
     }
     [self setTitlebarNeedsDisplayInRect:[self titlebarRect]];
   }
 }
 
@@ -2301,23 +2302,26 @@ static const NSString* kStateShowsToolba
 
 // Dispatch a toolbar pill button clicked message to Gecko.
 - (void)_toolbarPillButtonClicked:(id)sender
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   RollUpPopups();
 
-  nsCocoaWindow *geckoWindow = [[self delegate] geckoWidget];
-  if (!geckoWindow)
-    return;
-  nsEventStatus status = nsEventStatus_eIgnore;
-  nsGUIEvent guiEvent(PR_TRUE, NS_OS_TOOLBAR, geckoWindow);
-  guiEvent.time = PR_IntervalNow();
-  geckoWindow->DispatchEvent(&guiEvent, status);
+  if ([[self delegate] isKindOfClass:[WindowDelegate class]]) {
+    WindowDelegate *windowDelegate = (WindowDelegate *)[self delegate];
+    nsCocoaWindow *geckoWindow = [windowDelegate geckoWidget];
+    if (!geckoWindow)
+      return;
+    nsEventStatus status = nsEventStatus_eIgnore;
+    nsGUIEvent guiEvent(PR_TRUE, NS_OS_TOOLBAR, geckoWindow);
+    guiEvent.time = PR_IntervalNow();
+    geckoWindow->DispatchEvent(&guiEvent, status);
+  }
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 // Retain and release "self" to avoid crashes when our widget (and its native
 // window) is closed as a result of processing a key equivalent (e.g.
 // Command+w or Command+q).  This workaround is only needed for a window
 // that can become key.