| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/cursors/webcursor.h" | 5 #include "content/common/cursors/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/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| 11 #include "base/mac/scoped_cftyperef.h" | 11 #include "base/mac/scoped_cftyperef.h" |
| 12 #include "content/public/common/content_client.h" |
| 12 #include "grit/webkit_resources.h" | 13 #include "grit/webkit_resources.h" |
| 13 #include "skia/ext/skia_utils_mac.h" | 14 #include "skia/ext/skia_utils_mac.h" |
| 14 #include "third_party/WebKit/public/platform/WebCursorInfo.h" | 15 #include "third_party/WebKit/public/platform/WebCursorInfo.h" |
| 15 #include "third_party/WebKit/public/platform/WebSize.h" | 16 #include "third_party/WebKit/public/platform/WebSize.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/gfx/image/image.h" |
| 17 #include "ui/gfx/point_conversions.h" | 18 #include "ui/gfx/point_conversions.h" |
| 18 #include "ui/gfx/size_conversions.h" | 19 #include "ui/gfx/size_conversions.h" |
| 19 | 20 |
| 20 | 21 |
| 21 using blink::WebCursorInfo; | 22 using blink::WebCursorInfo; |
| 22 using blink::WebSize; | 23 using blink::WebSize; |
| 23 | 24 |
| 24 // Declare symbols that are part of the 10.7 SDK. | 25 // Declare symbols that are part of the 10.7 SDK. |
| 25 #if !defined(MAC_OS_X_VERSION_10_7) || \ | 26 #if !defined(MAC_OS_X_VERSION_10_7) || \ |
| 26 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 | 27 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 - (CrCoreCursorType)_coreCursorType { | 110 - (CrCoreCursorType)_coreCursorType { |
| 110 return type_; | 111 return type_; |
| 111 } | 112 } |
| 112 | 113 |
| 113 @end | 114 @end |
| 114 | 115 |
| 115 namespace { | 116 namespace { |
| 116 | 117 |
| 117 NSCursor* LoadCursor(int resource_id, int hotspot_x, int hotspot_y) { | 118 NSCursor* LoadCursor(int resource_id, int hotspot_x, int hotspot_y) { |
| 118 const gfx::Image& cursor_image = | 119 const gfx::Image& cursor_image = |
| 119 ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); | 120 content::GetContentClient()->GetNativeImageNamed(resource_id); |
| 120 DCHECK(!cursor_image.IsEmpty()); | 121 DCHECK(!cursor_image.IsEmpty()); |
| 121 return [[[NSCursor alloc] initWithImage:cursor_image.ToNSImage() | 122 return [[[NSCursor alloc] initWithImage:cursor_image.ToNSImage() |
| 122 hotSpot:NSMakePoint(hotspot_x, | 123 hotSpot:NSMakePoint(hotspot_x, |
| 123 hotspot_y)] autorelease]; | 124 hotspot_y)] autorelease]; |
| 124 } | 125 } |
| 125 | 126 |
| 126 // Gets a specified cursor from CoreCursor, falling back to loading it from the | 127 // Gets a specified cursor from CoreCursor, falling back to loading it from the |
| 127 // image cache if CoreCursor cannot provide it. | 128 // image cache if CoreCursor cannot provide it. |
| 128 NSCursor* GetCoreCursorWithFallback(CrCoreCursorType type, | 129 NSCursor* GetCoreCursorWithFallback(CrCoreCursorType type, |
| 129 int resource_id, | 130 int resource_id, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 [[[cursor_image representations] objectAtIndex:0] setSize:dip_size]; | 184 [[[cursor_image representations] objectAtIndex:0] setSize:dip_size]; |
| 184 | 185 |
| 185 NSCursor* cursor = [[NSCursor alloc] initWithImage:cursor_image | 186 NSCursor* cursor = [[NSCursor alloc] initWithImage:cursor_image |
| 186 hotSpot:dip_hotspot]; | 187 hotSpot:dip_hotspot]; |
| 187 | 188 |
| 188 return [cursor autorelease]; | 189 return [cursor autorelease]; |
| 189 } | 190 } |
| 190 | 191 |
| 191 } // namespace | 192 } // namespace |
| 192 | 193 |
| 194 namespace content { |
| 195 |
| 193 // Match Safari's cursor choices; see platform/mac/CursorMac.mm . | 196 // Match Safari's cursor choices; see platform/mac/CursorMac.mm . |
| 194 gfx::NativeCursor WebCursor::GetNativeCursor() { | 197 gfx::NativeCursor WebCursor::GetNativeCursor() { |
| 195 switch (type_) { | 198 switch (type_) { |
| 196 case WebCursorInfo::TypePointer: | 199 case WebCursorInfo::TypePointer: |
| 197 return [NSCursor arrowCursor]; | 200 return [NSCursor arrowCursor]; |
| 198 case WebCursorInfo::TypeCross: | 201 case WebCursorInfo::TypeCross: |
| 199 return [NSCursor crosshairCursor]; | 202 return [NSCursor crosshairCursor]; |
| 200 case WebCursorInfo::TypeHand: | 203 case WebCursorInfo::TypeHand: |
| 201 // If >= 10.7, the pointingHandCursor has a shadow so use it. Otherwise | 204 // If >= 10.7, the pointingHandCursor has a shadow so use it. Otherwise |
| 202 // use the custom one. | 205 // use the custom one. |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 return true; | 389 return true; |
| 387 } | 390 } |
| 388 | 391 |
| 389 void WebCursor::CleanupPlatformData() { | 392 void WebCursor::CleanupPlatformData() { |
| 390 return; | 393 return; |
| 391 } | 394 } |
| 392 | 395 |
| 393 void WebCursor::CopyPlatformData(const WebCursor& other) { | 396 void WebCursor::CopyPlatformData(const WebCursor& other) { |
| 394 return; | 397 return; |
| 395 } | 398 } |
| 399 |
| 400 } // namespace content |
| OLD | NEW |