diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-15 18:44:51 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-15 18:44:51 +0000 |
commit | 869be6ad4578dc8335383764f332aca08b0921d2 (patch) | |
tree | fb59f70270b82e1b5ba6a65f8cbacd0fffe4494e /webkit | |
parent | a7a77f13832e6bc4148595b80bc4a32efddf7b58 (diff) | |
download | chromium_src-869be6ad4578dc8335383764f332aca08b0921d2.zip chromium_src-869be6ad4578dc8335383764f332aca08b0921d2.tar.gz chromium_src-869be6ad4578dc8335383764f332aca08b0921d2.tar.bz2 |
Fix missing cursors.
BUG=92845
TEST=as in bug
Review URL: http://codereview.chromium.org/7645026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96803 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/webcursor_mac.mm | 66 |
1 files changed, 60 insertions, 6 deletions
diff --git a/webkit/glue/webcursor_mac.mm b/webkit/glue/webcursor_mac.mm index 908f10c..34f3592 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; +// Declare symbols that are part of the 10.6 SDK. +#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; ++ (NSCursor*)dragCopyCursor; ++ (NSCursor*)operationNotAllowedCursor; +@end + +#endif // MAC_OS_X_VERSION_10_6 + +// 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. + 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. |