OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the 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 #include <Carbon/Carbon.h> | 8 #include <Carbon/Carbon.h> |
9 | 9 |
10 #include "app/mac/nsimage_cache.h" | 10 #include "app/mac/nsimage_cache.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 case WebCursorInfo::TypeCopy: | 146 case WebCursorInfo::TypeCopy: |
147 return LoadCursor("copyCursor", 3, 2); | 147 return LoadCursor("copyCursor", 3, 2); |
148 case WebCursorInfo::TypeNone: | 148 case WebCursorInfo::TypeNone: |
149 return LoadCursor("noneCursor", 7, 7); | 149 return LoadCursor("noneCursor", 7, 7); |
150 case WebCursorInfo::TypeNotAllowed: | 150 case WebCursorInfo::TypeNotAllowed: |
151 return LoadCursor("notAllowedCursor", 11, 11); | 151 return LoadCursor("notAllowedCursor", 11, 11); |
152 case WebCursorInfo::TypeZoomIn: | 152 case WebCursorInfo::TypeZoomIn: |
153 return LoadCursor("zoomInCursor", 7, 7); | 153 return LoadCursor("zoomInCursor", 7, 7); |
154 case WebCursorInfo::TypeZoomOut: | 154 case WebCursorInfo::TypeZoomOut: |
155 return LoadCursor("zoomOutCursor", 7, 7); | 155 return LoadCursor("zoomOutCursor", 7, 7); |
| 156 case WebCursorInfo::TypeGrab: |
| 157 return [NSCursor openHandCursor]; |
| 158 case WebCursorInfo::TypeGrabbing: |
| 159 return [NSCursor closedHandCursor]; |
156 case WebCursorInfo::TypeCustom: | 160 case WebCursorInfo::TypeCustom: |
157 return CreateCustomCursor(custom_data_, custom_size_, hotspot_); | 161 return CreateCustomCursor(custom_data_, custom_size_, hotspot_); |
158 } | 162 } |
159 NOTREACHED(); | 163 NOTREACHED(); |
160 return nil; | 164 return nil; |
161 } | 165 } |
162 | 166 |
163 gfx::NativeCursor WebCursor::GetNativeCursor() { | 167 gfx::NativeCursor WebCursor::GetNativeCursor() { |
164 return GetCursor(); | 168 return GetCursor(); |
165 } | 169 } |
(...skipping 19 matching lines...) Expand all Loading... |
185 break; | 189 break; |
186 case kThemeCrossCursor: | 190 case kThemeCrossCursor: |
187 case kThemePlusCursor: | 191 case kThemePlusCursor: |
188 cursor_info.type = WebCursorInfo::TypeCross; | 192 cursor_info.type = WebCursorInfo::TypeCross; |
189 break; | 193 break; |
190 case kThemeWatchCursor: | 194 case kThemeWatchCursor: |
191 case kThemeSpinningCursor: | 195 case kThemeSpinningCursor: |
192 cursor_info.type = WebCursorInfo::TypeWait; | 196 cursor_info.type = WebCursorInfo::TypeWait; |
193 break; | 197 break; |
194 case kThemeClosedHandCursor: | 198 case kThemeClosedHandCursor: |
| 199 cursor_info.type = WebCursorInfo::TypeGrabbing; |
| 200 break; |
195 case kThemeOpenHandCursor: | 201 case kThemeOpenHandCursor: |
| 202 cursor_info.type = WebCursorInfo::TypeGrab; |
| 203 break; |
196 case kThemePointingHandCursor: | 204 case kThemePointingHandCursor: |
197 case kThemeCountingUpHandCursor: | 205 case kThemeCountingUpHandCursor: |
198 case kThemeCountingDownHandCursor: | 206 case kThemeCountingDownHandCursor: |
199 case kThemeCountingUpAndDownHandCursor: | 207 case kThemeCountingUpAndDownHandCursor: |
200 cursor_info.type = WebCursorInfo::TypeHand; | 208 cursor_info.type = WebCursorInfo::TypeHand; |
201 break; | 209 break; |
202 case kThemeResizeLeftCursor: | 210 case kThemeResizeLeftCursor: |
203 cursor_info.type = WebCursorInfo::TypeWestResize; | 211 cursor_info.type = WebCursorInfo::TypeWestResize; |
204 break; | 212 break; |
205 case kThemeResizeRightCursor: | 213 case kThemeResizeRightCursor: |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 } else if ([cursor isEqual:[NSCursor resizeRightCursor]]) { | 298 } else if ([cursor isEqual:[NSCursor resizeRightCursor]]) { |
291 cursor_info.type = WebCursorInfo::TypeEastResize; | 299 cursor_info.type = WebCursorInfo::TypeEastResize; |
292 } else if ([cursor isEqual:[NSCursor resizeLeftRightCursor]]) { | 300 } else if ([cursor isEqual:[NSCursor resizeLeftRightCursor]]) { |
293 cursor_info.type = WebCursorInfo::TypeEastWestResize; | 301 cursor_info.type = WebCursorInfo::TypeEastWestResize; |
294 } else if ([cursor isEqual:[NSCursor resizeUpCursor]]) { | 302 } else if ([cursor isEqual:[NSCursor resizeUpCursor]]) { |
295 cursor_info.type = WebCursorInfo::TypeNorthResize; | 303 cursor_info.type = WebCursorInfo::TypeNorthResize; |
296 } else if ([cursor isEqual:[NSCursor resizeDownCursor]]) { | 304 } else if ([cursor isEqual:[NSCursor resizeDownCursor]]) { |
297 cursor_info.type = WebCursorInfo::TypeSouthResize; | 305 cursor_info.type = WebCursorInfo::TypeSouthResize; |
298 } else if ([cursor isEqual:[NSCursor resizeUpDownCursor]]) { | 306 } else if ([cursor isEqual:[NSCursor resizeUpDownCursor]]) { |
299 cursor_info.type = WebCursorInfo::TypeNorthSouthResize; | 307 cursor_info.type = WebCursorInfo::TypeNorthSouthResize; |
| 308 } else if ([cursor isEqual:[NSCursor openHandCursor]]) { |
| 309 cursor_info.type = WebCursorInfo::TypeGrab; |
| 310 } else if ([cursor isEqual:[NSCursor closedHandCursor]]) { |
| 311 cursor_info.type = WebCursorInfo::TypeGrabbing; |
300 } else { | 312 } else { |
301 // Also handles the [NSCursor closedHandCursor], [NSCursor openHandCursor], | 313 // Also handles the [NSCursor disappearingItemCursor] case. Quick-and-dirty |
302 // and [NSCursor disappearingItemCursor] cases. Quick-and-dirty image | 314 // image conversion; TODO(avi): do better. |
303 // conversion; TODO(avi): do better. | |
304 CGImageRef cg_image = nil; | 315 CGImageRef cg_image = nil; |
305 NSImage* image = [cursor image]; | 316 NSImage* image = [cursor image]; |
306 for (id rep in [image representations]) { | 317 for (id rep in [image representations]) { |
307 if ([rep isKindOfClass:[NSBitmapImageRep class]]) { | 318 if ([rep isKindOfClass:[NSBitmapImageRep class]]) { |
308 cg_image = [rep CGImage]; | 319 cg_image = [rep CGImage]; |
309 break; | 320 break; |
310 } | 321 } |
311 } | 322 } |
312 | 323 |
313 if (cg_image) { | 324 if (cg_image) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 return true; | 391 return true; |
381 } | 392 } |
382 | 393 |
383 void WebCursor::CleanupPlatformData() { | 394 void WebCursor::CleanupPlatformData() { |
384 return; | 395 return; |
385 } | 396 } |
386 | 397 |
387 void WebCursor::CopyPlatformData(const WebCursor& other) { | 398 void WebCursor::CopyPlatformData(const WebCursor& other) { |
388 return; | 399 return; |
389 } | 400 } |
OLD | NEW |