Chromium Code Reviews| Index: webkit/glue/webcursor_mac.mm |
| diff --git a/webkit/glue/webcursor_mac.mm b/webkit/glue/webcursor_mac.mm |
| index 908f10c7be02403aacd365e3e6f888beb68a7712..a99892df39a458efcd8a4b898405c8a3a276a15f 100644 |
| --- a/webkit/glue/webcursor_mac.mm |
| +++ b/webkit/glue/webcursor_mac.mm |
| @@ -8,6 +8,7 @@ |
| #include <Carbon/Carbon.h> |
| #include "base/logging.h" |
| +#include "base/mac/mac_util.h" |
| #include "base/mac/scoped_cftyperef.h" |
| #include "base/memory/scoped_nsobject.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
| @@ -23,6 +24,28 @@ using WebKit::WebCursorInfo; |
| using WebKit::WebImage; |
| using WebKit::WebSize; |
| +// Forward-declare symbols that are part of the 10.6 SDK. |
|
Mark Mentovai
2011/08/15 16:00:08
Nit: These are declarations, not really anything e
Avi (use Gerrit)
2011/08/15 16:09:34
Done.
|
| +#if !defined(MAC_OS_X_VERSION_10_6) || \ |
| + MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 |
| + |
| +@interface NSCursor (SnowLeopardSDKDeclarations) |
| ++ (NSCursor *)contextualMenuCursor; |
|
Mark Mentovai
2011/08/15 16:00:08
Nit: This file uses NSCursor* style, no space.
Avi (use Gerrit)
2011/08/15 16:09:34
Done.
|
| ++ (NSCursor *)dragCopyCursor; |
| ++ (NSCursor *)operationNotAllowedCursor; |
| +@end |
| + |
| +#endif // MAC_OS_X_VERSION_10_6 |
| + |
| +// Forward-declare symbols that are part of the 10.7 SDK. |
| +#if !defined(MAC_OS_X_VERSION_10_7) || \ |
| + MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 |
| + |
| +@interface NSCursor (LionSDKDeclarations) |
| ++ (NSCursor *)IBeamCursorForVerticalLayout; |
| +@end |
| + |
| +#endif // MAC_OS_X_VERSION_10_7 |
| + |
| namespace { |
| // TODO: This image fetch can (and probably should) be serviced by the resource |
| @@ -94,9 +117,14 @@ NSCursor* WebCursor::GetCursor() const { |
| case WebCursorInfo::TypePointer: |
| return [NSCursor arrowCursor]; |
| case WebCursorInfo::TypeCross: |
| - return LoadCursor("crossHairCursor", 11, 11); |
| + return [NSCursor crosshairCursor]; |
| case WebCursorInfo::TypeHand: |
| - return LoadCursor("linkCursor", 6, 1); |
| + // If >= 10.7, the pointingHandCursor has a shadow so use it. Otherwise |
| + // use the custom one. |
| + if (base::mac::IsOSLionOrLater()) |
| + return [NSCursor pointingHandCursor]; |
| + else |
| + return LoadCursor("linkCursor", 6, 1); |
| case WebCursorInfo::TypeIBeam: |
| return [NSCursor IBeamCursor]; |
| case WebCursorInfo::TypeWait: |
| @@ -143,11 +171,19 @@ NSCursor* WebCursor::GetCursor() const { |
| case WebCursorInfo::TypeMove: |
| return LoadCursor("moveCursor", 7, 7); |
| case WebCursorInfo::TypeVerticalText: |
| - return LoadCursor("verticalTextCursor", 7, 7); |
| + // IBeamCursorForVerticalLayout is >= 10.7. |
| + if ([NSCursor respondsToSelector:@selector(IBeamCursorForVerticalLayout)]) |
| + return [NSCursor IBeamCursorForVerticalLayout]; |
| + else |
| + return LoadCursor("verticalTextCursor", 7, 7); |
| case WebCursorInfo::TypeCell: |
| return LoadCursor("cellCursor", 7, 7); |
| case WebCursorInfo::TypeContextMenu: |
| - return LoadCursor("contextMenuCursor", 3, 2); |
| + // contextualMenuCursor is >= 10.6. |
| + if ([NSCursor respondsToSelector:@selector(contextualMenuCursor)]) |
| + return [NSCursor contextualMenuCursor]; |
| + else |
| + return LoadCursor("contextMenuCursor", 3, 2); |
| case WebCursorInfo::TypeAlias: |
| return LoadCursor("aliasCursor", 11, 3); |
| case WebCursorInfo::TypeProgress: |
| @@ -155,11 +191,17 @@ NSCursor* WebCursor::GetCursor() const { |
| case WebCursorInfo::TypeNoDrop: |
| return LoadCursor("noDropCursor", 3, 1); |
| case WebCursorInfo::TypeCopy: |
| - return LoadCursor("copyCursor", 3, 2); |
| + // dragCopyCursor is >= 10.6. |
| + if ([NSCursor respondsToSelector:@selector(dragCopyCursor)]) |
| + return [NSCursor dragCopyCursor]; |
| + else |
| + return LoadCursor("copyCursor", 3, 2); |
| case WebCursorInfo::TypeNone: |
| return LoadCursor("noneCursor", 7, 7); |
| case WebCursorInfo::TypeNotAllowed: |
| - return LoadCursor("notAllowedCursor", 11, 11); |
| + // Docs say that operationNotAllowedCursor is >= 10.6, and it's not in the |
| + // 10.5 SDK, but later SDKs note that it really is available on 10.5. |
|
Mark Mentovai
2011/08/15 16:00:08
Just be sure you test this.
Avi (use Gerrit)
2011/08/15 16:09:34
Tested.
|
| + return [NSCursor operationNotAllowedCursor]; |
| case WebCursorInfo::TypeZoomIn: |
| return LoadCursor("zoomInCursor", 7, 7); |
| case WebCursorInfo::TypeZoomOut: |
| @@ -324,6 +366,18 @@ void WebCursor::InitFromNSCursor(NSCursor* cursor) { |
| cursor_info.type = WebCursorInfo::TypeGrab; |
| } else if ([cursor isEqual:[NSCursor closedHandCursor]]) { |
| cursor_info.type = WebCursorInfo::TypeGrabbing; |
| + } else if ([cursor isEqual:[NSCursor operationNotAllowedCursor]]) { |
| + cursor_info.type = WebCursorInfo::TypeNotAllowed; |
| + } else if ([NSCursor respondsToSelector:@selector(dragCopyCursor)] && |
| + [cursor isEqual:[NSCursor dragCopyCursor]]) { |
| + cursor_info.type = WebCursorInfo::TypeCopy; |
| + } else if ([NSCursor respondsToSelector:@selector(contextualMenuCursor)] && |
| + [cursor isEqual:[NSCursor contextualMenuCursor]]) { |
| + cursor_info.type = WebCursorInfo::TypeContextMenu; |
| + } else if ( |
| + [NSCursor respondsToSelector:@selector(IBeamCursorForVerticalLayout)] && |
| + [cursor isEqual:[NSCursor IBeamCursorForVerticalLayout]]) { |
| + cursor_info.type = WebCursorInfo::TypeVerticalText; |
| } else { |
| // Also handles the [NSCursor disappearingItemCursor] case. Quick-and-dirty |
| // image conversion; TODO(avi): do better. |