From 9179ab11a74ae4f4aeeb2c6e9b884ad7fa9f276a Mon Sep 17 00:00:00 2001 From: Josh Aas Date: Tue, 21 Feb 2012 20:44:40 -0500 Subject: [PATCH] Bug 729246: Fix clang warnings in Cocoa widgets. r=smichaud --- widget/cocoa/nsCursorManager.mm | 4 ++-- widget/cocoa/nsIdleServiceX.h | 3 +++ widget/cocoa/nsLookAndFeel.mm | 2 ++ widget/cocoa/nsMenuBarX.h | 4 ++++ widget/cocoa/nsMenuItemIconX.h | 2 +- widget/cocoa/nsNativeThemeCocoa.mm | 29 +++++++++++++++-------------- widget/cocoa/nsScreenManagerCocoa.h | 8 +++----- 7 files changed, 30 insertions(+), 22 deletions(-) diff --git a/widget/cocoa/nsCursorManager.mm b/widget/cocoa/nsCursorManager.mm index 008d53aa812..8b302973034 100644 --- a/widget/cocoa/nsCursorManager.mm +++ b/widget/cocoa/nsCursorManager.mm @@ -298,8 +298,8 @@ static const nsCursor sCustomCursor = eCursorCount; } // 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]]; diff --git a/widget/cocoa/nsIdleServiceX.h b/widget/cocoa/nsIdleServiceX.h index 4989f6f6f0c..aeb405513dd 100644 --- a/widget/cocoa/nsIdleServiceX.h +++ b/widget/cocoa/nsIdleServiceX.h @@ -44,6 +44,9 @@ class nsIdleServiceX : public nsIdleService public: NS_DECL_ISUPPORTS + nsIdleServiceX() {} + virtual ~nsIdleServiceX() {} + bool PollIdleTime(PRUint32* aIdleTime); protected: diff --git a/widget/cocoa/nsLookAndFeel.mm b/widget/cocoa/nsLookAndFeel.mm index a7d26ad2330..59051efbf16 100644 --- a/widget/cocoa/nsLookAndFeel.mm +++ b/widget/cocoa/nsLookAndFeel.mm @@ -566,6 +566,8 @@ nsLookAndFeel::GetFontImpl(FontID aID, nsString &aFontName, case eFont_Widget: font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; break; + default: + break; } if (!font) { diff --git a/widget/cocoa/nsMenuBarX.h b/widget/cocoa/nsMenuBarX.h index 1ce8b5e8fd2..5974fce92b8 100644 --- a/widget/cocoa/nsMenuBarX.h +++ b/widget/cocoa/nsMenuBarX.h @@ -59,6 +59,10 @@ class nsNativeMenuServiceX : public nsINativeMenuService { public: NS_DECL_ISUPPORTS + + nsNativeMenuServiceX() {} + virtual ~nsNativeMenuServiceX() {} + NS_IMETHOD CreateNativeMenuBar(nsIWidget* aParent, nsIContent* aMenuBarNode); }; diff --git a/widget/cocoa/nsMenuItemIconX.h b/widget/cocoa/nsMenuItemIconX.h index 4f4f424d943..1d2ce98c88b 100644 --- a/widget/cocoa/nsMenuItemIconX.h +++ b/widget/cocoa/nsMenuItemIconX.h @@ -60,7 +60,7 @@ public: nsIContent* aContent, NSMenuItem* aNativeMenuItem); private: - ~nsMenuItemIconX(); + virtual ~nsMenuItemIconX(); public: NS_DECL_ISUPPORTS diff --git a/widget/cocoa/nsNativeThemeCocoa.mm b/widget/cocoa/nsNativeThemeCocoa.mm index 7611c84aca1..26dad73361a 100644 --- a/widget/cocoa/nsNativeThemeCocoa.mm +++ b/widget/cocoa/nsNativeThemeCocoa.mm @@ -1859,12 +1859,12 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext, break; case NS_THEME_MENUPOPUP: { - HIThemeMenuDrawInfo mdi = { - version: 0, - menuType: IsDisabled(aFrame, eventState) ? - static_cast(kThemeMenuTypeInactive) : - static_cast(kThemeMenuTypePopUp) - }; + HIThemeMenuDrawInfo mdi; + memset(&mdi, 0, sizeof(mdi)); + mdi.version = 0; + mdi.menuType = IsDisabled(aFrame, eventState) ? + static_cast(kThemeMenuTypeInactive) : + static_cast(kThemeMenuTypePopUp); bool isLeftOfParent = false; if (IsSubmenu(aFrame, &isLeftOfParent) && !isLeftOfParent) { @@ -1883,14 +1883,15 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext, CGContextClearRect(cgContext, macRect); // maybe use kThemeMenuItemHierBackground or PopUpBackground instead of just Plain? - HIThemeMenuItemDrawInfo drawInfo = { - version: 0, - itemType: kThemeMenuItemPlain, - state: (IsDisabled(aFrame, eventState) ? static_cast(kThemeMenuDisabled) : - CheckBooleanAttr(aFrame, nsGkAtoms::menuactive) ? - static_cast(kThemeMenuSelected) : - static_cast(kThemeMenuActive)) - }; + HIThemeMenuItemDrawInfo drawInfo; + memset(&drawInfo, 0, sizeof(drawInfo)); + drawInfo.version = 0; + drawInfo.itemType = kThemeMenuItemPlain; + drawInfo.state = (IsDisabled(aFrame, eventState) ? + static_cast(kThemeMenuDisabled) : + CheckBooleanAttr(aFrame, nsGkAtoms::menuactive) ? + static_cast(kThemeMenuSelected) : + static_cast(kThemeMenuActive)); // XXX pass in the menu rect instead of always using the item rect HIRect ignored; diff --git a/widget/cocoa/nsScreenManagerCocoa.h b/widget/cocoa/nsScreenManagerCocoa.h index 44ec960e59f..8be5c66077c 100644 --- a/widget/cocoa/nsScreenManagerCocoa.h +++ b/widget/cocoa/nsScreenManagerCocoa.h @@ -49,17 +49,15 @@ 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 > mScreenList; };