Bug 729246: Fix clang warnings in Cocoa widgets. r=smichaud
authorJosh Aas <joshmoz@gmail.com>
Tue, 21 Feb 2012 20:44:40 -0500
changeset 90244 40d9e3a8a4cfa519950411ca45812491a515c6a0
parent 90243 7851cea42b143766b459479160b1a443e8d564d7
child 90245 715b6b383b4df854aacb069405cd81d102f5101e
push idunknown
push userunknown
push dateunknown
reviewerssmichaud
bugs729246
milestone13.0a1
Bug 729246: Fix clang warnings in Cocoa widgets. r=smichaud
widget/cocoa/nsCursorManager.mm
widget/cocoa/nsIdleServiceX.h
widget/cocoa/nsLookAndFeel.mm
widget/cocoa/nsMenuBarX.h
widget/cocoa/nsMenuItemIconX.h
widget/cocoa/nsNativeThemeCocoa.mm
widget/cocoa/nsScreenManagerCocoa.h
--- a/widget/cocoa/nsCursorManager.mm
+++ b/widget/cocoa/nsCursorManager.mm
@@ -293,18 +293,18 @@ static const nsCursor sCustomCursor = eC
 
   NSImage *cursorImage;
   nsresult rv = nsCocoaUtils::CreateNSImageFromImageContainer(aCursorImage, imgIContainer::FRAME_FIRST, &cursorImage);
   if (NS_FAILED(rv) || !cursorImage) {
     return NS_ERROR_FAILURE;
   }
 
   // if the hotspot is nonsensical, make it 0,0
-  aHotspotX = (aHotspotX < 0 || aHotspotX > (PRUint32) width - 1) ? 0 :aHotspotX;
-  aHotspotY = (aHotspotY < 0 || aHotspotY > (PRUint32) height - 1) ? 0 :aHotspotY;
+  aHotspotX = (aHotspotX > (PRUint32)width - 1) ? 0 : aHotspotX;
+  aHotspotY = (aHotspotY > (PRUint32)height - 1) ? 0 : aHotspotY;
 
   NSPoint hotSpot = ::NSMakePoint(aHotspotX, aHotspotY);
   [self setMacCursor:[nsMacCursor cursorWithCursor:[[NSCursor alloc] initWithImage:cursorImage hotSpot:hotSpot] type:sCustomCursor]];
   [cursorImage release];
   
   NS_IF_RELEASE(sCursorImgContainer);
   sCursorImgContainer = aCursorImage;
   NS_ADDREF(sCursorImgContainer);
--- a/widget/cocoa/nsIdleServiceX.h
+++ b/widget/cocoa/nsIdleServiceX.h
@@ -39,15 +39,18 @@
 
 #include "nsIdleService.h"
 
 class nsIdleServiceX : public nsIdleService
 {
 public:
   NS_DECL_ISUPPORTS
 
+  nsIdleServiceX() {}
+  virtual ~nsIdleServiceX() {}
+
   bool PollIdleTime(PRUint32* aIdleTime);
 
 protected:
     bool UsePollMode();
 };
 
 #endif // nsIdleServiceX_h_
--- a/widget/cocoa/nsLookAndFeel.mm
+++ b/widget/cocoa/nsLookAndFeel.mm
@@ -561,16 +561,18 @@ nsLookAndFeel::GetFontImpl(FontID aID, n
             break;
         // moz
         case eFont_Tooltips:
             font = [NSFont toolTipsFontOfSize:0.0];
             break;
         case eFont_Widget:
             font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
             break;
+        default:
+            break;
     }
 
     if (!font) {
         NS_WARNING("failed to find a system font!");
         return false;
     }
 
     NSFontSymbolicTraits traits = [[font fontDescriptor] symbolicTraits];
--- a/widget/cocoa/nsMenuBarX.h
+++ b/widget/cocoa/nsMenuBarX.h
@@ -54,16 +54,20 @@ class nsIWidget;
 class nsIContent;
 class nsIDocument;
 
 // The native menu service for creating native menu bars.
 class nsNativeMenuServiceX : public nsINativeMenuService
 {
 public:
   NS_DECL_ISUPPORTS
+
+  nsNativeMenuServiceX() {}
+  virtual ~nsNativeMenuServiceX() {}
+
   NS_IMETHOD CreateNativeMenuBar(nsIWidget* aParent, nsIContent* aMenuBarNode);
 };
 
 // Objective-C class used to allow us to intervene with keyboard event handling.
 // We allow mouse actions to work normally.
 @interface GeckoNSMenu : NSMenu
 {
 }
--- a/widget/cocoa/nsMenuItemIconX.h
+++ b/widget/cocoa/nsMenuItemIconX.h
@@ -55,17 +55,17 @@ class nsMenuObjectX;
 
 class nsMenuItemIconX : public imgIDecoderObserver
 {
 public:
   nsMenuItemIconX(nsMenuObjectX* aMenuItem,
                   nsIContent*    aContent,
                   NSMenuItem*    aNativeMenuItem);
 private:
-  ~nsMenuItemIconX();
+  virtual ~nsMenuItemIconX();
 
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_IMGICONTAINEROBSERVER
   NS_DECL_IMGIDECODEROBSERVER
 
   // SetupIcon succeeds if it was able to set up the icon, or if there should
   // be no icon, in which case it clears any existing icon but still succeeds.
--- a/widget/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/cocoa/nsNativeThemeCocoa.mm
@@ -1854,22 +1854,22 @@ nsNativeThemeCocoa::DrawWidgetBackground
   switch (aWidgetType) {
     case NS_THEME_DIALOG: {
       HIThemeSetFill(kThemeBrushDialogBackgroundActive, NULL, cgContext, HITHEME_ORIENTATION);
       CGContextFillRect(cgContext, macRect);
     }
       break;
 
     case NS_THEME_MENUPOPUP: {
-      HIThemeMenuDrawInfo mdi = {
-        version: 0,
-        menuType: IsDisabled(aFrame, eventState) ?
-            static_cast<ThemeMenuType>(kThemeMenuTypeInactive) :
-            static_cast<ThemeMenuType>(kThemeMenuTypePopUp)
-      };
+      HIThemeMenuDrawInfo mdi;
+      memset(&mdi, 0, sizeof(mdi));
+      mdi.version = 0;
+      mdi.menuType = IsDisabled(aFrame, eventState) ?
+                       static_cast<ThemeMenuType>(kThemeMenuTypeInactive) :
+                       static_cast<ThemeMenuType>(kThemeMenuTypePopUp);
 
       bool isLeftOfParent = false;
       if (IsSubmenu(aFrame, &isLeftOfParent) && !isLeftOfParent) {
         mdi.menuType = kThemeMenuTypeHierarchical;
       }
       
       // The rounded corners draw outside the frame.
       CGRect deflatedRect = CGRectMake(macRect.origin.x, macRect.origin.y + 4,
@@ -1878,24 +1878,25 @@ nsNativeThemeCocoa::DrawWidgetBackground
     }
       break;
 
     case NS_THEME_MENUITEM: {
       // Clear the background to get correct transparency.
       CGContextClearRect(cgContext, macRect);
 
       // maybe use kThemeMenuItemHierBackground or PopUpBackground instead of just Plain?
-      HIThemeMenuItemDrawInfo drawInfo = {
-        version: 0,
-        itemType: kThemeMenuItemPlain,
-        state: (IsDisabled(aFrame, eventState) ? static_cast<ThemeMenuState>(kThemeMenuDisabled) :
-                 CheckBooleanAttr(aFrame, nsGkAtoms::menuactive) ?
-                    static_cast<ThemeMenuState>(kThemeMenuSelected) :
-                    static_cast<ThemeMenuState>(kThemeMenuActive))
-      };
+      HIThemeMenuItemDrawInfo drawInfo;
+      memset(&drawInfo, 0, sizeof(drawInfo));
+      drawInfo.version = 0;
+      drawInfo.itemType = kThemeMenuItemPlain;
+      drawInfo.state = (IsDisabled(aFrame, eventState) ?
+                         static_cast<ThemeMenuState>(kThemeMenuDisabled) :
+                         CheckBooleanAttr(aFrame, nsGkAtoms::menuactive) ?
+                           static_cast<ThemeMenuState>(kThemeMenuSelected) :
+                           static_cast<ThemeMenuState>(kThemeMenuActive));
 
       // XXX pass in the menu rect instead of always using the item rect
       HIRect ignored;
       HIThemeDrawMenuItem(&macRect, &macRect, &drawInfo, cgContext, HITHEME_ORIENTATION, &ignored);
     }
       break;
 
     case NS_THEME_MENUSEPARATOR: {
--- a/widget/cocoa/nsScreenManagerCocoa.h
+++ b/widget/cocoa/nsScreenManagerCocoa.h
@@ -44,23 +44,21 @@
 #include "nsTArray.h"
 #include "nsAutoPtr.h"
 #include "nsIScreenManager.h"
 #include "nsScreenCocoa.h"
 
 class nsScreenManagerCocoa : public nsIScreenManager
 {
 public:
-    nsScreenManagerCocoa ();
-    ~nsScreenManagerCocoa ();
+    nsScreenManagerCocoa();
+    virtual ~nsScreenManagerCocoa();
 
     NS_DECL_ISUPPORTS
-
     NS_DECL_NSISCREENMANAGER
 
 private:
 
-    nsScreenCocoa *ScreenForCocoaScreen (NSScreen *screen);
-
+    nsScreenCocoa *ScreenForCocoaScreen(NSScreen *screen);
     nsTArray< nsRefPtr<nsScreenCocoa> > mScreenList;
 };
 
 #endif // nsScreenManagerCocoa_h_