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 "content/common/cursors/webcursor.h" | 5 #include "content/common/cursors/webcursor.h" |
6 | 6 |
7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/mac/mac_util.h" | 11 #include "base/mac/mac_util.h" |
tapted
2016/04/25 21:25:46
maybe unneeded
| |
12 #include "base/mac/scoped_cftyperef.h" | 12 #include "base/mac/scoped_cftyperef.h" |
13 #include "base/mac/sdk_forward_declarations.h" | 13 #include "base/mac/sdk_forward_declarations.h" |
14 #include "content/app/resources/grit/content_resources.h" | 14 #include "content/app/resources/grit/content_resources.h" |
15 #include "content/public/common/content_client.h" | 15 #include "content/public/common/content_client.h" |
16 #include "skia/ext/skia_utils_mac.h" | 16 #include "skia/ext/skia_utils_mac.h" |
17 #include "third_party/WebKit/public/platform/WebCursorInfo.h" | 17 #include "third_party/WebKit/public/platform/WebCursorInfo.h" |
18 #include "third_party/WebKit/public/platform/WebSize.h" | 18 #include "third_party/WebKit/public/platform/WebSize.h" |
19 #include "ui/gfx/geometry/point_conversions.h" | 19 #include "ui/gfx/geometry/point_conversions.h" |
20 #include "ui/gfx/geometry/size_conversions.h" | 20 #include "ui/gfx/geometry/size_conversions.h" |
21 #include "ui/gfx/image/image.h" | 21 #include "ui/gfx/image/image.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 hotSpot:NSMakePoint(hotspot_x, | 114 hotSpot:NSMakePoint(hotspot_x, |
115 hotspot_y)] autorelease]; | 115 hotspot_y)] autorelease]; |
116 } | 116 } |
117 | 117 |
118 // Gets a specified cursor from CoreCursor, falling back to loading it from the | 118 // Gets a specified cursor from CoreCursor, falling back to loading it from the |
119 // image cache if CoreCursor cannot provide it. | 119 // image cache if CoreCursor cannot provide it. |
120 NSCursor* GetCoreCursorWithFallback(CrCoreCursorType type, | 120 NSCursor* GetCoreCursorWithFallback(CrCoreCursorType type, |
121 int resource_id, | 121 int resource_id, |
122 int hotspot_x, | 122 int hotspot_x, |
123 int hotspot_y) { | 123 int hotspot_y) { |
124 if (base::mac::IsOSLionOrLater()) { | 124 NSCursor* cursor = [CrCoreCursor cursorWithType:type]; |
125 NSCursor* cursor = [CrCoreCursor cursorWithType:type]; | 125 if (cursor) |
126 if (cursor) | 126 return cursor; |
127 return cursor; | |
128 } | |
129 | 127 |
130 return LoadCursor(resource_id, hotspot_x, hotspot_y); | 128 return LoadCursor(resource_id, hotspot_x, hotspot_y); |
131 } | 129 } |
132 | 130 |
133 NSCursor* CreateCustomCursor(const std::vector<char>& custom_data, | 131 NSCursor* CreateCustomCursor(const std::vector<char>& custom_data, |
134 const gfx::Size& custom_size, | 132 const gfx::Size& custom_size, |
135 float custom_scale, | 133 float custom_scale, |
136 const gfx::Point& hotspot) { | 134 const gfx::Point& hotspot) { |
137 // If the data is missing, leave the backing transparent. | 135 // If the data is missing, leave the backing transparent. |
138 void* data = NULL; | 136 void* data = NULL; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 namespace content { | 183 namespace content { |
186 | 184 |
187 // Match Safari's cursor choices; see platform/mac/CursorMac.mm . | 185 // Match Safari's cursor choices; see platform/mac/CursorMac.mm . |
188 gfx::NativeCursor WebCursor::GetNativeCursor() { | 186 gfx::NativeCursor WebCursor::GetNativeCursor() { |
189 switch (type_) { | 187 switch (type_) { |
190 case WebCursorInfo::TypePointer: | 188 case WebCursorInfo::TypePointer: |
191 return [NSCursor arrowCursor]; | 189 return [NSCursor arrowCursor]; |
192 case WebCursorInfo::TypeCross: | 190 case WebCursorInfo::TypeCross: |
193 return [NSCursor crosshairCursor]; | 191 return [NSCursor crosshairCursor]; |
194 case WebCursorInfo::TypeHand: | 192 case WebCursorInfo::TypeHand: |
195 // If >= 10.7, the pointingHandCursor has a shadow so use it. Otherwise | 193 return [NSCursor pointingHandCursor]; |
196 // use the custom one. | |
197 if (base::mac::IsOSLionOrLater()) | |
198 return [NSCursor pointingHandCursor]; | |
199 else | |
200 return LoadCursor(IDR_LINK_CURSOR, 6, 1); | |
201 case WebCursorInfo::TypeIBeam: | 194 case WebCursorInfo::TypeIBeam: |
202 return [NSCursor IBeamCursor]; | 195 return [NSCursor IBeamCursor]; |
203 case WebCursorInfo::TypeWait: | 196 case WebCursorInfo::TypeWait: |
204 return GetCoreCursorWithFallback(kBusyButClickableCursor, | 197 return GetCoreCursorWithFallback(kBusyButClickableCursor, |
205 IDR_WAIT_CURSOR, 7, 7); | 198 IDR_WAIT_CURSOR, 7, 7); |
206 case WebCursorInfo::TypeHelp: | 199 case WebCursorInfo::TypeHelp: |
207 return GetCoreCursorWithFallback(kHelpCursor, | 200 return GetCoreCursorWithFallback(kHelpCursor, |
208 IDR_HELP_CURSOR, 8, 8); | 201 IDR_HELP_CURSOR, 8, 8); |
209 case WebCursorInfo::TypeEastResize: | 202 case WebCursorInfo::TypeEastResize: |
210 case WebCursorInfo::TypeEastPanning: | 203 case WebCursorInfo::TypeEastPanning: |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 | 375 |
383 void WebCursor::CleanupPlatformData() { | 376 void WebCursor::CleanupPlatformData() { |
384 return; | 377 return; |
385 } | 378 } |
386 | 379 |
387 void WebCursor::CopyPlatformData(const WebCursor& other) { | 380 void WebCursor::CopyPlatformData(const WebCursor& other) { |
388 return; | 381 return; |
389 } | 382 } |
390 | 383 |
391 } // namespace content | 384 } // namespace content |
OLD | NEW |