Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: webkit/glue/webcursor_mac.mm

Issue 554003: (Mac) Intercept (Cocoa) cursor setting by plugins and forward it on properly.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/webcursor.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/webcursor_mac.mm
===================================================================
--- webkit/glue/webcursor_mac.mm (revision 36524)
+++ webkit/glue/webcursor_mac.mm (working copy)
@@ -20,7 +20,7 @@
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 @@
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 @@
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;
« no previous file with comments | « webkit/glue/webcursor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698