summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.h4
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_mac.mm4
-rw-r--r--webkit/glue/webcursor.h3
-rw-r--r--webkit/glue/webcursor_mac.mm55
4 files changed, 62 insertions, 4 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h
index 4e66936..a246f60 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.h
+++ b/webkit/glue/plugins/webplugin_delegate_impl.h
@@ -133,8 +133,10 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
void SetFocusNotifier(void (*notifier)(WebPluginDelegateImpl*)) {
focus_notifier_ = notifier;
}
- // Informs the delegate that the plugin set a theme cursor.
+ // Informs the delegate that the plugin set a Carbon ThemeCursor.
void SetThemeCursor(ThemeCursor cursor);
+ // Informs the delegate that the plugin set a Cocoa NSCursor.
+ void SetNSCursor(NSCursor* cursor);
#endif
#if !defined(OS_MACOSX)
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
index 92edf23..2d6fdc6 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
+++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
@@ -440,6 +440,10 @@ void WebPluginDelegateImpl::SetThemeCursor(ThemeCursor cursor) {
current_windowless_cursor_.InitFromThemeCursor(cursor);
}
+void WebPluginDelegateImpl::SetNSCursor(NSCursor* cursor) {
+ current_windowless_cursor_.InitFromNSCursor(cursor);
+}
+
void WebPluginDelegateImpl::UpdatePluginLocation(const WebMouseEvent& event) {
instance()->set_plugin_origin(gfx::Point(event.globalX - event.x,
event.globalY - event.y));
diff --git a/webkit/glue/webcursor.h b/webkit/glue/webcursor.h
index ed59e0b..341a92a 100644
--- a/webkit/glue/webcursor.h
+++ b/webkit/glue/webcursor.h
@@ -91,6 +91,9 @@ class WebCursor {
// Initialize this from the given Carbon ThemeCursor.
void InitFromThemeCursor(ThemeCursor cursor);
+
+ // Initialize this from the given Cocoa NSCursor.
+ void InitFromNSCursor(NSCursor* cursor);
#endif
private:
diff --git a/webkit/glue/webcursor_mac.mm b/webkit/glue/webcursor_mac.mm
index 4a80d32..4a82327 100644
--- a/webkit/glue/webcursor_mac.mm
+++ b/webkit/glue/webcursor_mac.mm
@@ -20,7 +20,7 @@ using WebKit::WebSize;
namespace {
-// TODO: This image fech can (and probably should) be serviced by the resource
+// TODO: This image fetch can (and probably should) be serviced by the resource
// resource bundle instead of going through nsimage_cache.
NSCursor* LoadCursor(const char* name, int x, int y) {
NSString* file_name = [NSString stringWithUTF8String:name];
@@ -34,9 +34,9 @@ NSCursor* LoadCursor(const char* name, int x, int y) {
CGImageRef CreateCGImageFromCustomData(const std::vector<char>& custom_data,
const gfx::Size& custom_size) {
scoped_cftyperef<CGColorSpaceRef> cg_color(CGColorSpaceCreateDeviceRGB());
- // this is safe since we're not going to draw into the context we're creating
+ // This is safe since we're not going to draw into the context we're creating.
void* data = const_cast<char*>(&custom_data[0]);
- // settings here match SetCustomData() below; keep in sync
+ // The settings here match SetCustomData() below; keep in sync.
scoped_cftyperef<CGContextRef> context(
CGBitmapContextCreate(data,
custom_size.width(),
@@ -224,6 +224,55 @@ void WebCursor::InitFromThemeCursor(ThemeCursor cursor) {
InitFromCursorInfo(cursor_info);
}
+void WebCursor::InitFromNSCursor(NSCursor* cursor) {
+ WebKit::WebCursorInfo cursor_info;
+
+ if ([cursor isEqual:[NSCursor arrowCursor]]) {
+ cursor_info.type = WebCursorInfo::TypePointer;
+ } else if ([cursor isEqual:[NSCursor IBeamCursor]]) {
+ cursor_info.type = WebCursorInfo::TypeIBeam;
+ } else if ([cursor isEqual:[NSCursor crosshairCursor]]) {
+ cursor_info.type = WebCursorInfo::TypeCross;
+ } else if ([cursor isEqual:[NSCursor pointingHandCursor]]) {
+ cursor_info.type = WebCursorInfo::TypeHand;
+ } else if ([cursor isEqual:[NSCursor resizeLeftCursor]]) {
+ cursor_info.type = WebCursorInfo::TypeWestResize;
+ } else if ([cursor isEqual:[NSCursor resizeRightCursor]]) {
+ cursor_info.type = WebCursorInfo::TypeEastResize;
+ } else if ([cursor isEqual:[NSCursor resizeLeftRightCursor]]) {
+ cursor_info.type = WebCursorInfo::TypeEastWestResize;
+ } else if ([cursor isEqual:[NSCursor resizeUpCursor]]) {
+ cursor_info.type = WebCursorInfo::TypeNorthResize;
+ } else if ([cursor isEqual:[NSCursor resizeDownCursor]]) {
+ cursor_info.type = WebCursorInfo::TypeSouthResize;
+ } else if ([cursor isEqual:[NSCursor resizeUpDownCursor]]) {
+ cursor_info.type = WebCursorInfo::TypeNorthSouthResize;
+ } else {
+ // Also handles the [NSCursor closedHandCursor], [NSCursor openHandCursor],
+ // and [NSCursor disappearingItemCursor] cases. Quick-and-dirty image
+ // conversion; TODO(avi): do better.
+ CGImageRef cg_image = nil;
+ NSImage* image = [cursor image];
+ for (id rep in [image representations]) {
+ if ([rep isKindOfClass:[NSBitmapImageRep class]]) {
+ cg_image = [rep CGImage];
+ break;
+ }
+ }
+
+ if (cg_image) {
+ cursor_info.type = WebCursorInfo::TypeCustom;
+ NSPoint hot_spot = [cursor hotSpot];
+ cursor_info.hotSpot = WebKit::WebPoint(hot_spot.x, hot_spot.y);
+ cursor_info.customImage = cg_image;
+ } else {
+ cursor_info.type = WebCursorInfo::TypePointer;
+ }
+ }
+
+ InitFromCursorInfo(cursor_info);
+}
+
void WebCursor::SetCustomData(const WebImage& image) {
if (image.isNull())
return;