From 23563dc1e18506fb1b9f53dd1762c2c69ab8a0df Mon Sep 17 00:00:00 2001 From: "stuartmorgan@chromium.org" Date: Tue, 16 Feb 2010 16:11:00 +0000 Subject: Fix some issues with compiling Mac plugin code with deprecation defines set Makes the code compile under NP_NO_QUICKDRAW and NP_NO_CARBON (modulo some gyp stuff that 64-bit builds will need to prevent compiling the shim library), and makes the tweaking of DYLD_INSERT_LIBRARIES 32-bit only. Also removes a QuickDraw variable left over from an earlier version of the QuickDraw support. BUG=none TEST=none; supports future 64-bit compilation Review URL: http://codereview.chromium.org/597053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39096 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/plugin_process_host.cc | 2 +- chrome/plugin/plugin_main.cc | 2 ++ chrome/plugin/plugin_main_mac.mm | 2 ++ third_party/npapi/bindings/npapi.h | 2 ++ webkit/glue/plugins/plugin_host.cc | 6 ++++++ webkit/glue/plugins/plugin_instance.cc | 12 ++++++++++-- webkit/glue/plugins/webplugin_delegate_impl.h | 1 - webkit/glue/plugins/webplugin_delegate_impl_mac.mm | 13 ++++++++----- 8 files changed, 31 insertions(+), 9 deletions(-) diff --git a/chrome/browser/plugin_process_host.cc b/chrome/browser/plugin_process_host.cc index 5e1afe9..203e843 100644 --- a/chrome/browser/plugin_process_host.cc +++ b/chrome/browser/plugin_process_host.cc @@ -424,7 +424,7 @@ bool PluginProcessHost::Init(const WebPluginInfo& info, #if defined(OS_POSIX) base::environment_vector env; -#if defined(OS_MACOSX) +#if defined(OS_MACOSX) && !defined(__LP64__) // Add our interposing library for Carbon. This is stripped back out in // plugin_main.cc, so changes here should be reflected there. std::string interpose_list(plugin_interpose_strings::kInterposeLibraryPath); diff --git a/chrome/plugin/plugin_main.cc b/chrome/plugin/plugin_main.cc index 1e77325..06c05b1 100644 --- a/chrome/plugin/plugin_main.cc +++ b/chrome/plugin/plugin_main.cc @@ -53,7 +53,9 @@ int PluginMain(const MainFunctionParams& parameters) { // The main thread of the plugin services UI. #if defined(OS_MACOSX) +#if !defined(__LP64__) TrimInterposeEnvironment(); +#endif InitializeChromeApplication(); #endif MessageLoop main_message_loop(MessageLoop::TYPE_UI); diff --git a/chrome/plugin/plugin_main_mac.mm b/chrome/plugin/plugin_main_mac.mm index 1f729a4..56b7c95 100644 --- a/chrome/plugin/plugin_main_mac.mm +++ b/chrome/plugin/plugin_main_mac.mm @@ -7,6 +7,7 @@ #include "chrome/common/plugin_carbon_interpose_constants_mac.h" #include "chrome/plugin/plugin_interpose_util_mac.h" +#if !defined(__LP64__) void TrimInterposeEnvironment() { const char* interpose_list = getenv(plugin_interpose_strings::kDYLDInsertLibrariesKey); @@ -37,6 +38,7 @@ void TrimInterposeEnvironment() { NOTREACHED() << "Missing Carbon interposing library"; } } +#endif void InitializeChromeApplication() { [CrApplication sharedApplication]; diff --git a/third_party/npapi/bindings/npapi.h b/third_party/npapi/bindings/npapi.h index 4f08e45..0b335e6 100644 --- a/third_party/npapi/bindings/npapi.h +++ b/third_party/npapi/bindings/npapi.h @@ -722,6 +722,7 @@ typedef struct NP_Port * Non-standard event types that can be passed to HandleEvent */ /* BEGIN GOOGLE MODIFICATIONS */ +#ifndef NP_NO_CARBON enum NPEventType { NPEventType_GetFocusEvent = (osEvt + 16), NPEventType_LoseFocusEvent, @@ -737,6 +738,7 @@ enum NPEventType { #define loseFocusEvent (osEvt + 17) #define adjustCursorEvent (osEvt + 18) #endif +#endif /* NP_NO_CARBON */ /* END GOOGLE MODIFICATIONS */ #endif /* XP_MACOSX */ diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc index c8c652d..0db965c 100644 --- a/webkit/glue/plugins/plugin_host.cc +++ b/webkit/glue/plugins/plugin_host.cc @@ -755,6 +755,7 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) { rv = NPERR_NO_ERROR; break; } +#ifndef NP_NO_QUICKDRAW case NPNVsupportsQuickDrawBool: { // we do not admit to supporting the QuickDraw drawing model. NPBool* supports_qd = reinterpret_cast(value); @@ -762,8 +763,11 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) { rv = NPERR_NO_ERROR; break; } +#endif case NPNVsupportsCoreGraphicsBool: +#ifndef NP_NO_CARBON case NPNVsupportsCarbonBool: +#endif case NPNVsupportsCocoaBool: { // we do support these drawing and event models. NPBool* supports_model = reinterpret_cast(value); @@ -849,7 +853,9 @@ NPError NPN_SetValue(NPP id, NPPVariable variable, void* value) { // we support Carbon and Cocoa event models int model = reinterpret_cast(value); switch (model) { +#ifndef NP_NO_CARBON case NPEventModelCarbon: +#endif case NPEventModelCocoa: plugin->set_event_model(model); return NPERR_NO_ERROR; diff --git a/webkit/glue/plugins/plugin_instance.cc b/webkit/glue/plugins/plugin_instance.cc index 00ac91da..e179c06b 100644 --- a/webkit/glue/plugins/plugin_instance.cc +++ b/webkit/glue/plugins/plugin_instance.cc @@ -36,8 +36,16 @@ PluginInstance::PluginInstance(PluginLib *plugin, const std::string &mime_type) mime_type_(mime_type), use_mozilla_user_agent_(false), #if defined (OS_MACOSX) - drawing_model_(0), - event_model_(0), +#ifdef NP_NO_QUICKDRAW + drawing_model_(NPDrawingModelCoreGraphics), +#else + drawing_model_(NPDrawingModelQuickDraw), +#endif +#ifdef NP_NO_CARBON + event_model_(NPEventModelCocoa), +#else + event_model_(NPEventModelCarbon), +#endif currently_handled_event_(NULL), #endif message_loop_(MessageLoop::current()), diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h index a11baa6..25f9fde 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.h +++ b/webkit/glue/plugins/webplugin_delegate_impl.h @@ -297,7 +297,6 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate { #endif #ifndef NP_NO_QUICKDRAW NP_Port qd_port_; - GWorldPtr qd_world_; #endif #endif gfx::Rect window_rect_; diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm index 58e3b3d..42e38ae 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm +++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm @@ -232,8 +232,10 @@ void WebPluginDelegateImpl::PlatformInitialize() { Rect window_bounds = { 0, 0, window_rect_.height(), window_rect_.width() }; SetWindowBounds(reinterpret_cast(cg_context_.window), kWindowContentRgn, &window_bounds); +#ifndef NP_NO_QUICKDRAW qd_port_.port = GetWindowPort(reinterpret_cast(cg_context_.window)); +#endif } #endif @@ -271,8 +273,10 @@ void WebPluginDelegateImpl::PlatformInitialize() { } void WebPluginDelegateImpl::PlatformDestroyInstance() { +#ifndef NP_NO_CARBON if (instance()->event_model() == NPEventModelCarbon) CarbonIdleEventSource::SharedInstance()->UnregisterDelegate(this); +#endif } void WebPluginDelegateImpl::UpdateContext(CGContextRef context) { @@ -417,7 +421,7 @@ void WebPluginDelegateImpl::WindowlessPaint(gfx::NativeDrawingContext context, paint_event.data.draw.y = paint_rect.y(); paint_event.data.draw.width = paint_rect.width(); paint_event.data.draw.height = paint_rect.height(); - instance()->NPP_HandleEvent(reinterpret_cast(&paint_event)); + instance()->NPP_HandleEvent(&paint_event); break; } } @@ -491,7 +495,7 @@ void WebPluginDelegateImpl::FocusChanged(bool has_focus) { memset(&focus_event, 0, sizeof(focus_event)); focus_event.type = NPCocoaEventFocusChanged; focus_event.data.focus.hasFocus = have_focus_; - instance()->NPP_HandleEvent(reinterpret_cast(&focus_event)); + instance()->NPP_HandleEvent(&focus_event); break; } } @@ -535,7 +539,7 @@ void WebPluginDelegateImpl::SetWindowHasFocus(bool has_focus) { memset(&focus_event, 0, sizeof(focus_event)); focus_event.type = NPCocoaEventWindowFocusChanged; focus_event.data.focus.hasFocus = has_focus; - instance()->NPP_HandleEvent(reinterpret_cast(&focus_event)); + instance()->NPP_HandleEvent(&focus_event); } } } @@ -1002,8 +1006,7 @@ bool WebPluginDelegateImpl::PlatformHandleInputEvent( return false; } NPAPI::ScopedCurrentPluginEvent event_scope(instance(), &np_cocoa_event); - ret = instance()->NPP_HandleEvent( - reinterpret_cast(&np_cocoa_event)) != 0; + ret = instance()->NPP_HandleEvent(&np_cocoa_event) != 0; break; } } -- cgit v1.1