Bug 659817 - [10.7 SDK] Build error in PluginInterposeOSX.h due to Cursor type not being defined. r=bgirard
authorSteven Michaud <smichaud@pobox.com>
Sat, 11 Jun 2011 11:55:44 +0200
changeset 71426 1b97769e6549e5053c817ed932e1bed08df524c3
parent 71425 8cae6781db4fb916b05a57bac9c667d356e591b7
child 71427 bfcc94f3fd0a854fb0769b1611aaddbfee2847a6
push id159
push usereakhgari@mozilla.com
push dateTue, 16 Aug 2011 17:53:11 +0000
treeherdermozilla-beta@8786e3e49240 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgirard
bugs659817
milestone7.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 659817 - [10.7 SDK] Build error in PluginInterposeOSX.h due to Cursor type not being defined. r=bgirard
dom/plugins/ipc/PluginInterposeOSX.h
dom/plugins/ipc/interpose/plugin_child_interpose.mm
--- a/dom/plugins/ipc/PluginInterposeOSX.h
+++ b/dom/plugins/ipc/PluginInterposeOSX.h
@@ -37,16 +37,33 @@
 
 // Make this includable from non-Objective-C code.
 #ifndef __OBJC__
 class NSCursor;
 #else
 #import <Cocoa/Cocoa.h>
 #endif
 
+// The header file QuickdrawAPI.h is missing on OS X 10.7 and up (though the
+// QuickDraw APIs defined in it are still present) -- so we need to supply the
+// relevant parts of its contents here.  It's likely that Apple will eventually
+// remove the APIs themselves (probably in OS X 10.8), so we need to make them
+// weak imports, and test for their presence before using them.
+#if !defined(__QUICKDRAWAPI__)
+
+typedef short Bits16[16];
+struct Cursor {
+  Bits16  data;
+  Bits16  mask;
+  Point   hotSpot;
+};
+typedef struct Cursor Cursor;
+
+#endif /* __QUICKDRAWAPI__ */
+
 namespace mac_plugin_interposing {
 
 // Class used to serialize NSCursor objects over IPC between processes.
 class NSCursorInfo {
 public:
   enum Type {
     TypeCustom,
     TypeArrow,
--- a/dom/plugins/ipc/interpose/plugin_child_interpose.mm
+++ b/dom/plugins/ipc/interpose/plugin_child_interpose.mm
@@ -59,16 +59,28 @@
 // browser modules when loaded.  Instead it should use dlsym() to load
 // pointers to the methods it wants to call in other modules.
 
 #if !defined(__LP64__)
 
 #include <dlfcn.h>
 #import <Carbon/Carbon.h>
 
+// The header file QuickdrawAPI.h is missing on OS X 10.7 and up (though the
+// QuickDraw APIs defined in it are still present) -- so we need to supply the
+// relevant parts of its contents here.  It's likely that Apple will eventually
+// remove the APIs themselves (probably in OS X 10.8), so we need to make them
+// weak imports, and test for their presence before using them.
+#if !defined(__QUICKDRAWAPI__)
+
+typedef struct Cursor;
+extern "C" void SetCursor(const Cursor * crsr) __attribute__((weak_import));
+
+#endif /* __QUICKDRAWAPI__ */
+
 BOOL (*OnSetThemeCursorPtr) (ThemeCursor) = NULL;
 BOOL (*OnSetCursorPtr) (const Cursor*) = NULL;
 BOOL (*OnHideCursorPtr) () = NULL;
 BOOL (*OnShowCursorPtr) () = NULL;
 
 static BOOL loadXULPtrs()
 {
   if (!OnSetThemeCursorPtr) {
@@ -101,20 +113,22 @@ static OSStatus MacPluginChildSetThemeCu
   if (loadXULPtrs()) {
     OnSetThemeCursorPtr(cursor);
   }
   return ::SetThemeCursor(cursor);
 }
 
 static void MacPluginChildSetCursor(const Cursor* cursor)
 {
-  if (loadXULPtrs()) {
-    OnSetCursorPtr(cursor);
+  if (::SetCursor) {
+    if (loadXULPtrs()) {
+      OnSetCursorPtr(cursor);
+    }
+    ::SetCursor(cursor);
   }
-  ::SetCursor(cursor);
 }
 
 static CGError MacPluginChildCGDisplayHideCursor(CGDirectDisplayID display)
 {
   if (loadXULPtrs()) {
     OnHideCursorPtr();
   }
   return ::CGDisplayHideCursor(display);
@@ -137,14 +151,18 @@ struct interpose_substitution {
 
 #define INTERPOSE_FUNCTION(function) \
     { reinterpret_cast<const void*>(MacPluginChild##function), \
       reinterpret_cast<const void*>(function) }
 
 __attribute__((used)) static const interpose_substitution substitutions[]
     __attribute__((section("__DATA, __interpose"))) = {
   INTERPOSE_FUNCTION(SetThemeCursor),
-  INTERPOSE_FUNCTION(SetCursor),
   INTERPOSE_FUNCTION(CGDisplayHideCursor),
   INTERPOSE_FUNCTION(CGDisplayShowCursor),
+  // SetCursor() and other QuickDraw APIs will probably be removed in OS X
+  // 10.8.  But this will make 'SetCursor' NULL, which will just stop the OS
+  // from interposing it (tested using an INTERPOSE_FUNCTION_BROKEN macro
+  // that just sets the second address of each tuple to NULL).
+  INTERPOSE_FUNCTION(SetCursor),
 };
 
 #endif  // !__LP64__