Bug 641927: Fix a large number of compiler warnings in Mac OS X code. r=benwa,bsmedberg
authorJosh Aas <joshmoz@gmail.com>
Wed, 23 Mar 2011 11:46:57 -0700
changeset 63556 c2f9c8bad8af40d60ce4af7ea0882c63f5181464
parent 63555 a200ce37157085713e2183471ee6fe192195c182
child 63557 7e1308fc3b70b9ac4612f453d49effea67d22c08
push idunknown
push userunknown
push dateunknown
reviewersbenwa, bsmedberg
bugs641927
milestone2.2a1pre
Bug 641927: Fix a large number of compiler warnings in Mac OS X code. r=benwa,bsmedberg
widget/src/cocoa/mozView.h
widget/src/cocoa/nsChildView.mm
widget/src/cocoa/nsCocoaWindow.h
widget/src/cocoa/nsCocoaWindow.mm
widget/src/cocoa/nsMenuUtilsX.mm
widget/src/cocoa/nsNativeThemeColors.h
widget/src/cocoa/nsScreenManagerCocoa.mm
widget/src/cocoa/nsToolkit.mm
xpcom/base/nsObjCExceptions.h
--- a/widget/src/cocoa/mozView.h
+++ b/widget/src/cocoa/mozView.h
@@ -57,16 +57,18 @@ class nsIWidget;
   // Allows callers to do a delayed invalidate (e.g., if an invalidate
   // happens during drawing)
 - (void)setNeedsPendingDisplay;
 - (void)setNeedsPendingDisplayInRect:(NSRect)invalidRect;
 
   // called when our corresponding Gecko view goes away
 - (void)widgetDestroyed;
 
+- (BOOL)isDragInProgress;
+
 @end
 
 // An informal protocol implemented by the NSWindow of the host application.
 // 
 // It's used to prevent re-entrant calls to -makeKeyAndOrderFront: when gecko
 // focus/activate events propagate out to the embedder's
 // nsIEmbeddingSiteWindow::SetFocus implementation.
 @interface NSObject(mozWindow)
--- a/widget/src/cocoa/nsChildView.mm
+++ b/widget/src/cocoa/nsChildView.mm
@@ -210,18 +210,16 @@ PRUint32 nsChildView::sLastInputEventCou
 #endif
 
 #ifdef ACCESSIBILITY
 - (id<mozAccessible>)accessible;
 #endif
 
 - (BOOL)isFirstResponder;
 
-- (BOOL)isDragInProgress;
-
 - (void)fireKeyEventForFlagsChanged:(NSEvent*)theEvent keyDown:(BOOL)isKeyDown;
 
 - (BOOL)inactiveWindowAcceptsMouseEvent:(NSEvent*)aEvent;
 
 @end
 
 #pragma mark -
 
@@ -1249,17 +1247,17 @@ NS_IMETHODIMP nsChildView::GetPluginClip
   PRBool isVisible;
   IsVisible(isVisible);
   if (isVisible && [mView window] != nil) {
     outClipRect.width  = NSToIntRound(visibleBounds.origin.x + visibleBounds.size.width) - NSToIntRound(visibleBounds.origin.x);
     outClipRect.height = NSToIntRound(visibleBounds.origin.y + visibleBounds.size.height) - NSToIntRound(visibleBounds.origin.y);
 
     if (mClipRects) {
       nsIntRect clipBounds;
-      for (PRInt32 i = 0; i < mClipRectCount; ++i) {
+      for (PRUint32 i = 0; i < mClipRectCount; ++i) {
         clipBounds.UnionRect(clipBounds, mClipRects[i]);
       }
       outClipRect.IntersectRect(outClipRect, clipBounds - outOrigin);
     }
 
     // XXXroc should this be !outClipRect.IsEmpty()?
     outWidgetVisible = PR_TRUE;
   }
--- a/widget/src/cocoa/nsCocoaWindow.h
+++ b/widget/src/cocoa/nsCocoaWindow.h
@@ -251,16 +251,17 @@ public:
     NS_IMETHOD              SetCursor(nsCursor aCursor);
     NS_IMETHOD              SetCursor(imgIContainer* aCursor, PRUint32 aHotspotX, PRUint32 aHotspotY);
 
     NS_IMETHOD              SetTitle(const nsAString& aTitle);
 
     NS_IMETHOD Invalidate(const nsIntRect &aRect, PRBool aIsSynchronous);
     NS_IMETHOD Update();
     virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations);
+    virtual LayerManager* GetLayerManager(bool *aAllowRetaining = nsnull);
     virtual LayerManager* GetLayerManager(LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
                                           bool* aAllowRetaining = nsnull);
     NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus) ;
     NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, nsIMenuRollup * aMenuRollup,
                                    PRBool aDoCapture, PRBool aConsumeRollupEvent);
     NS_IMETHOD GetAttention(PRInt32 aCycleCount);
     virtual PRBool HasPendingInputEvent();
     virtual nsTransparencyMode GetTransparencyMode();
--- a/widget/src/cocoa/nsCocoaWindow.mm
+++ b/widget/src/cocoa/nsCocoaWindow.mm
@@ -928,16 +928,25 @@ nsCocoaWindow::ConfigureChildren(const n
 {
   if (mPopupContentView) {
     mPopupContentView->ConfigureChildren(aConfigurations);
   }
   return NS_OK;
 }
 
 LayerManager*
+nsCocoaWindow::GetLayerManager(bool *aAllowRetaining)
+{
+  if (mPopupContentView) {
+    return mPopupContentView->GetLayerManager(aAllowRetaining);
+  }
+  return nsnull;
+}
+
+LayerManager*
 nsCocoaWindow::GetLayerManager(LayerManagerPersistence, bool* aAllowRetaining)
 {
   if (mPopupContentView) {
     return mPopupContentView->GetLayerManager(aAllowRetaining);
   }
   return nsnull;
 }
 
--- a/widget/src/cocoa/nsMenuUtilsX.mm
+++ b/widget/src/cocoa/nsMenuUtilsX.mm
@@ -48,18 +48,16 @@
 #include "nsIDocument.h"
 #include "nsIDOMDocumentEvent.h"
 #include "nsIDOMEventTarget.h"
 #include "nsIDOMXULCommandEvent.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMAbstractView.h"
 
-#include <Carbon/Carbon.h>
-
 void nsMenuUtilsX::DispatchCommandTo(nsIContent* aTargetContent)
 {
   NS_PRECONDITION(aTargetContent, "null ptr");
 
   nsIDocument* doc = aTargetContent->GetOwnerDoc();
   nsCOMPtr<nsIDOMDocumentEvent> docEvent = do_QueryInterface(doc);
   nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(aTargetContent);
   if (docEvent && target) {
@@ -83,30 +81,21 @@ void nsMenuUtilsX::DispatchCommandTo(nsI
     }
   }
 }
 
 NSString* nsMenuUtilsX::GetTruncatedCocoaLabel(const nsString& itemLabel)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
-#ifdef __LP64__
-  // Don't do anything on 64-bit Mac OS X for now, there is no API that does
-  // what we want. We'll probably need to roll our own solution.
+  // We want to truncate long strings to some reasonable pixel length but there is no
+  // good API for doing that which works for all OS versions and architectures. For now
+  // we'll do nothing for consistency and depend on good user interface design to limit
+  // string lengths.
   return [NSString stringWithCharacters:itemLabel.get() length:itemLabel.Length()];
-#else
-  // ::TruncateThemeText() doesn't take the number of characters to truncate to, it takes a pixel with
-  // to fit the string in. Ugh. I talked it over with sfraser and we couldn't come up with an 
-  // easy way to compute what this should be given the system font, etc, so we're just going
-  // to hard code it to something reasonable and bigger fonts will just have to deal.
-  const short kMaxItemPixelWidth = 300;
-  NSMutableString *label = [NSMutableString stringWithCharacters:itemLabel.get() length:itemLabel.Length()];
-  ::TruncateThemeText((CFMutableStringRef)label, kThemeMenuItemFont, kThemeStateActive, kMaxItemPixelWidth, truncMiddle, NULL);
-  return label;
-#endif
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 PRUint8 nsMenuUtilsX::GeckoModifiersForNodeAttribute(const nsString& modifiersAttribute)
 {
   PRUint8 modifiers = knsMenuItemNoModifier;
   char* str = ToNewCString(modifiersAttribute);
--- a/widget/src/cocoa/nsNativeThemeColors.h
+++ b/widget/src/cocoa/nsNativeThemeColors.h
@@ -75,29 +75,32 @@ static const int sSnowLeopardThemeColors
   { 0xD0, 0xF1 }, // top separator line
   // statusbar:
   { 0x51, 0x99 }, // first top border
   { 0xE8, 0xF6 }, // second top border
   { 0xCB, 0xEA }, // gradient start
   { 0xA7, 0xDE }  // gradient end
 };
 
+__attribute__((unused))
 static int NativeGreyColorAsInt(ColorName name, BOOL isMain)
 {
   if (nsToolkit::OnSnowLeopardOrLater())
     return sSnowLeopardThemeColors[name][isMain ? 0 : 1];
 
   return sLeopardThemeColors[name][isMain ? 0 : 1];
 }
 
+__attribute__((unused))
 static float NativeGreyColorAsFloat(ColorName name, BOOL isMain)
 {
   return NativeGreyColorAsInt(name, isMain) / 255.0f;
 }
 
+__attribute__((unused))
 static void DrawNativeGreyColorInRect(CGContextRef context, ColorName name,
                                       CGRect rect, BOOL isMain)
 {
   float grey = NativeGreyColorAsFloat(name, isMain);
   CGContextSetRGBFillColor(context, grey, grey, grey, 1.0f);
   CGContextFillRect(context, rect);
 }
 
--- a/widget/src/cocoa/nsScreenManagerCocoa.mm
+++ b/widget/src/cocoa/nsScreenManagerCocoa.mm
@@ -47,21 +47,20 @@ nsScreenManagerCocoa::nsScreenManagerCoc
 {
 }
 
 nsScreenManagerCocoa::~nsScreenManagerCocoa()
 {
 }
 
 nsScreenCocoa*
-nsScreenManagerCocoa::ScreenForCocoaScreen (NSScreen *screen)
+nsScreenManagerCocoa::ScreenForCocoaScreen(NSScreen *screen)
 {
-    for (PRInt32 i = 0; i < mScreenList.Length(); ++i) {
+    for (PRUint32 i = 0; i < mScreenList.Length(); ++i) {
         nsScreenCocoa* sc = mScreenList[i];
-
         if (sc->CocoaScreen() == screen) {
             // doesn't addref
             return sc;
         }
     }
 
     // didn't find it; create and insert
     nsRefPtr<nsScreenCocoa> sc = new nsScreenCocoa(screen);
--- a/widget/src/cocoa/nsToolkit.mm
+++ b/widget/src/cocoa/nsToolkit.mm
@@ -778,17 +778,16 @@ void ScanImportedFunctions(const struct 
     char *stringTableItem = (char *) (stringTableOffset + symbolTableItem->n_un.n_strx);
 
     for (uint32_t j = 0; gHookedFunctions[j].name; ++j) {
       if (strcmp(stringTableItem, gHookedFunctions[j].name) != 0)
         continue;
 #ifdef __i386__
       if (jumpTable) {
         unsigned char *opcodeAddr = stubs + (i * 5);
-        unsigned char oldOpcode = opcodeAddr[0];
         int32_t *displacementAddr = (int32_t *) (opcodeAddr + 1);
         int32_t eip = (int32_t) stubs + (i + 1) * 5;
         int32_t displacement = (int32_t) (gHookedFunctions[j].newAddress) - eip;
         displacementAddr[0] = displacement;
         opcodeAddr[0] = 0xE9;
       } else
 #endif
       {
--- a/xpcom/base/nsObjCExceptions.h
+++ b/xpcom/base/nsObjCExceptions.h
@@ -60,16 +60,17 @@
  * If you actually want to log and abort, call "nsObjCExceptionLogAbort"
  * from an exception handler. At some point we will fix this by replacing
  * all macros in the tree with appropriately-named macros.
  */
 
 // See Mozilla bug 163260.
 // This file can only be included in an Objective-C context.
 
+__attribute__((unused))
 static void nsObjCExceptionLog(NSException* aException)
 {
   NSLog(@"Mozilla has caught an Obj-C exception [%@: %@]",
         [aException name], [aException reason]);
 
 #if defined(MOZ_CRASHREPORTER) && defined(__cplusplus)
   // Attach exception info to the crash report.
   nsCOMPtr<nsICrashReporter> crashReporter =
@@ -144,25 +145,27 @@ static void nsObjCExceptionLog(NSExcepti
   }
   @catch (NSException *exn) {
     NSLog(@"Failed to generate stack trace for Obj-C exception [%@: %@]",
           [exn name], [exn reason]);
   }
 #endif
 }
 
+__attribute__((unused))
 static void nsObjCExceptionAbort()
 {
   // We need to raise a mach-o signal here, the Mozilla crash reporter on
   // Mac OS X does not respond to POSIX signals. Raising mach-o signals directly
   // is tricky so we do it by just derefing a null pointer.
   int* foo = NULL;
   *foo = 1;
 }
 
+__attribute__((unused))
 static void nsObjCExceptionLogAbort(NSException *e)
 {
   nsObjCExceptionLog(e);
   nsObjCExceptionAbort();
 }
 
 #define NS_OBJC_TRY(_e, _fail)                     \
 @try { _e; }                                       \