diff options
-rw-r--r-- | chrome/app/framework.order | 1 | ||||
-rw-r--r-- | chrome/browser/plugin_carbon_interpose_mac.cc | 10 | ||||
-rw-r--r-- | chrome/plugin/plugin_interpose_util_mac.h | 4 | ||||
-rw-r--r-- | chrome/plugin/plugin_interpose_util_mac.mm | 6 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl.h | 2 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl_mac.mm | 4 | ||||
-rw-r--r-- | webkit/glue/webcursor.h | 4 | ||||
-rw-r--r-- | webkit/glue/webcursor_mac.mm | 45 |
8 files changed, 76 insertions, 0 deletions
diff --git a/chrome/app/framework.order b/chrome/app/framework.order index 7ef7343..2f66f38 100644 --- a/chrome/app/framework.order +++ b/chrome/app/framework.order @@ -28,6 +28,7 @@ __ZN22mac_plugin_interposing33NotifyBrowserOfPluginSelectWindowEj6CGRectb __ZN22mac_plugin_interposing31NotifyBrowserOfPluginShowWindowEj6CGRectb __ZN22mac_plugin_interposing31NotifyBrowserOfPluginHideWindowEj6CGRect __ZN22mac_plugin_interposing28NotifyPluginOfSetThemeCursorEP21WebPluginDelegateImplm +__ZN22mac_plugin_interposing23NotifyPluginOfSetCursorEP21WebPluginDelegateImplPK6Cursor __ZN22mac_plugin_interposing23GetPluginWindowHasFocusEPK21WebPluginDelegateImpl __ZN23FakePluginWindowTrackerC1Ev __ZN23FakePluginWindowTrackerC2Ev diff --git a/chrome/browser/plugin_carbon_interpose_mac.cc b/chrome/browser/plugin_carbon_interpose_mac.cc index def2515..020d9ae 100644 --- a/chrome/browser/plugin_carbon_interpose_mac.cc +++ b/chrome/browser/plugin_carbon_interpose_mac.cc @@ -151,6 +151,15 @@ static OSStatus ChromePluginSetThemeCursor(ThemeCursor cursor) { return SetThemeCursor(cursor); } +static void ChromePluginSetCursor(const Cursor* cursor) { + WebPluginDelegateImpl* delegate = mac_plugin_interposing::GetActiveDelegate(); + if (delegate) { + mac_plugin_interposing::NotifyPluginOfSetCursor(delegate, cursor); + return; + } + return SetCursor(cursor); +} + #pragma mark - struct interpose_substitution { @@ -175,4 +184,5 @@ __attribute__((used)) static const interpose_substitution substitutions[] INTERPOSE_FUNCTION(DisposeDialog), INTERPOSE_FUNCTION(FindWindow), INTERPOSE_FUNCTION(SetThemeCursor), + INTERPOSE_FUNCTION(SetCursor), }; diff --git a/chrome/plugin/plugin_interpose_util_mac.h b/chrome/plugin/plugin_interpose_util_mac.h index 4942bb6..0806007 100644 --- a/chrome/plugin/plugin_interpose_util_mac.h +++ b/chrome/plugin/plugin_interpose_util_mac.h @@ -42,6 +42,10 @@ void NotifyBrowserOfPluginHideWindow(uint32 window_id, CGRect bounds); void NotifyPluginOfSetThemeCursor(WebPluginDelegateImpl* delegate, ThemeCursor cursor); +// Sends a message to the plugin that a cursor was set. +void NotifyPluginOfSetCursor(WebPluginDelegateImpl* delegate, + const Cursor* cursor); + // Returns true if the window containing the given plugin delegate is focused. bool GetPluginWindowHasFocus(const WebPluginDelegateImpl* delegate); diff --git a/chrome/plugin/plugin_interpose_util_mac.mm b/chrome/plugin/plugin_interpose_util_mac.mm index 801efbe..7dd20ad 100644 --- a/chrome/plugin/plugin_interpose_util_mac.mm +++ b/chrome/plugin/plugin_interpose_util_mac.mm @@ -76,6 +76,12 @@ void NotifyPluginOfSetThemeCursor(WebPluginDelegateImpl* delegate, } __attribute__((visibility("default"))) +void NotifyPluginOfSetCursor(WebPluginDelegateImpl* delegate, + const Cursor* cursor) { + delegate->SetCursor(cursor); +} + +__attribute__((visibility("default"))) bool GetPluginWindowHasFocus(const WebPluginDelegateImpl* delegate) { return delegate->GetWindowHasFocus(); } diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h index d4b5e56..6864e31 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.h +++ b/webkit/glue/plugins/webplugin_delegate_impl.h @@ -139,6 +139,8 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate { bool GetWindowHasFocus() const { return containing_window_has_focus_; } // Informs the delegate that the plugin set a Carbon ThemeCursor. void SetThemeCursor(ThemeCursor cursor); + // Informs the delegate that the plugin set a Carbon Cursor. + void SetCursor(const Cursor* cursor); // Informs the delegate that the plugin set a Cocoa NSCursor. void SetNSCursor(NSCursor* cursor); diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm index b79248f..f7ef0af 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm +++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm @@ -514,6 +514,10 @@ void WebPluginDelegateImpl::SetThemeCursor(ThemeCursor cursor) { current_windowless_cursor_.InitFromThemeCursor(cursor); } +void WebPluginDelegateImpl::SetCursor(const Cursor* cursor) { + current_windowless_cursor_.InitFromCursor(cursor); +} + void WebPluginDelegateImpl::SetNSCursor(NSCursor* cursor) { current_windowless_cursor_.InitFromNSCursor(cursor); } diff --git a/webkit/glue/webcursor.h b/webkit/glue/webcursor.h index 341a92a..e7cc413 100644 --- a/webkit/glue/webcursor.h +++ b/webkit/glue/webcursor.h @@ -24,6 +24,7 @@ typedef struct _GdkCursor GdkCursor; class NSCursor; #endif typedef UInt32 ThemeCursor; +struct Cursor; #endif class Pickle; @@ -92,6 +93,9 @@ class WebCursor { // Initialize this from the given Carbon ThemeCursor. void InitFromThemeCursor(ThemeCursor cursor); + // Initialize this from the given Carbon Cursor. + void InitFromCursor(const Cursor* cursor); + // Initialize this from the given Cocoa NSCursor. void InitFromNSCursor(NSCursor* cursor); #endif diff --git a/webkit/glue/webcursor_mac.mm b/webkit/glue/webcursor_mac.mm index 4a82327..a6e7fc0 100644 --- a/webkit/glue/webcursor_mac.mm +++ b/webkit/glue/webcursor_mac.mm @@ -224,6 +224,51 @@ void WebCursor::InitFromThemeCursor(ThemeCursor cursor) { InitFromCursorInfo(cursor_info); } +void WebCursor::InitFromCursor(const Cursor* cursor) { + // This conversion isn't perfect (in particular, the inversion effect of + // data==1, mask==0 won't work). Not planning on fixing it. + + gfx::Size custom_size(16, 16); + std::vector<char> raw_data; + for (int row = 0; row < 16; ++row) { + unsigned short data = cursor->data[row]; + unsigned short mask = cursor->mask[row]; + + // The Core Endian flipper callback for 'CURS' doesn't flip Bits16 as if it + // were a short (which it is), so we flip it here. + data = ((data << 8) & 0xFF00) | ((data >> 8) & 0x00FF); + mask = ((mask << 8) & 0xFF00) | ((mask >> 8) & 0x00FF); + + for (int bit = 0; bit < 16; ++bit) { + if (data & 0x8000) { + raw_data.push_back(0x00); + raw_data.push_back(0x00); + raw_data.push_back(0x00); + } else { + raw_data.push_back(0xFF); + raw_data.push_back(0xFF); + raw_data.push_back(0xFF); + } + if (mask & 0x8000) + raw_data.push_back(0xFF); + else + raw_data.push_back(0x00); + data <<= 1; + mask <<= 1; + } + } + + scoped_cftyperef<CGImageRef> cg_image( + CreateCGImageFromCustomData(raw_data, custom_size)); + + WebKit::WebCursorInfo cursor_info; + cursor_info.type = WebCursorInfo::TypeCustom; + cursor_info.hotSpot = WebKit::WebPoint(cursor->hotSpot.h, cursor->hotSpot.v); + cursor_info.customImage = cg_image.get(); + + InitFromCursorInfo(cursor_info); +} + void WebCursor::InitFromNSCursor(NSCursor* cursor) { WebKit::WebCursorInfo cursor_info; |