OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include "webkit/glue/webcursor.h" | 5 #include "webkit/glue/webcursor.h" |
6 | 6 |
7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/nsimage_cache_mac.h" |
10 #include "base/scoped_cftyperef.h" | 11 #include "base/scoped_cftyperef.h" |
11 #include "webkit/api/public/WebCursorInfo.h" | 12 #include "webkit/api/public/WebCursorInfo.h" |
12 #include "webkit/api/public/WebImage.h" | 13 #include "webkit/api/public/WebImage.h" |
13 #include "webkit/api/public/WebSize.h" | 14 #include "webkit/api/public/WebSize.h" |
14 | 15 |
15 using WebKit::WebCursorInfo; | 16 using WebKit::WebCursorInfo; |
16 using WebKit::WebImage; | 17 using WebKit::WebImage; |
17 using WebKit::WebSize; | 18 using WebKit::WebSize; |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 // TODO(avi): Is loading resources what we want to do here? | 22 // TODO: This image fech can (and probably should) be serviced by the resource |
| 23 // resource bundle instead of going through nsimage_cache. |
22 NSCursor* LoadCursor(const char* name, int x, int y) { | 24 NSCursor* LoadCursor(const char* name, int x, int y) { |
23 NSString* file_name = [NSString stringWithUTF8String:name]; | 25 NSString* file_name = [NSString stringWithUTF8String:name]; |
24 DCHECK(file_name); | 26 DCHECK(file_name); |
25 NSImage* cursor_image = [NSImage imageNamed:file_name]; | 27 NSImage* cursor_image = nsimage_cache::ImageNamed(file_name); |
26 DCHECK(cursor_image); | 28 DCHECK(cursor_image); |
27 return [[[NSCursor alloc] initWithImage:cursor_image | 29 return [[[NSCursor alloc] initWithImage:cursor_image |
28 hotSpot:NSMakePoint(x, y)] autorelease]; | 30 hotSpot:NSMakePoint(x, y)] autorelease]; |
29 } | 31 } |
30 | 32 |
31 CGImageRef CreateCGImageFromCustomData(const std::vector<char>& custom_data, | 33 CGImageRef CreateCGImageFromCustomData(const std::vector<char>& custom_data, |
32 const gfx::Size& custom_size) { | 34 const gfx::Size& custom_size) { |
33 scoped_cftyperef<CGColorSpaceRef> cg_color(CGColorSpaceCreateDeviceRGB()); | 35 scoped_cftyperef<CGColorSpaceRef> cg_color(CGColorSpaceCreateDeviceRGB()); |
34 // this is safe since we're not going to draw into the context we're creating | 36 // this is safe since we're not going to draw into the context we're creating |
35 void* data = const_cast<char*>(&custom_data[0]); | 37 void* data = const_cast<char*>(&custom_data[0]); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 return true; | 215 return true; |
214 } | 216 } |
215 | 217 |
216 void WebCursor::CleanupPlatformData() { | 218 void WebCursor::CleanupPlatformData() { |
217 return; | 219 return; |
218 } | 220 } |
219 | 221 |
220 void WebCursor::CopyPlatformData(const WebCursor& other) { | 222 void WebCursor::CopyPlatformData(const WebCursor& other) { |
221 return; | 223 return; |
222 } | 224 } |
OLD | NEW |