| 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 #ifndef CONTENT_COMMON_CURSORS_WEBCURSOR_H_ | 5 #ifndef CONTENT_COMMON_CURSORS_WEBCURSOR_H_ |
| 6 #define CONTENT_COMMON_CURSORS_WEBCURSOR_H_ | 6 #define CONTENT_COMMON_CURSORS_WEBCURSOR_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | |
| 11 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 12 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 13 #include "third_party/WebKit/public/platform/WebCursorInfo.h" | 12 #include "third_party/WebKit/public/platform/WebCursorInfo.h" |
| 14 #include "ui/display/display.h" | 13 #include "ui/display/display.h" |
| 15 #include "ui/gfx/geometry/point.h" | 14 #include "ui/gfx/geometry/point.h" |
| 16 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
| 17 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
| 18 | 17 |
| 19 #if defined(USE_AURA) | 18 #if defined(USE_AURA) |
| 20 #include "ui/base/cursor/cursor.h" | 19 #include "ui/base/cursor/cursor.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 42 // This class encapsulates a cross-platform description of a cursor. Platform | 41 // This class encapsulates a cross-platform description of a cursor. Platform |
| 43 // specific methods are provided to translate the cross-platform cursor into a | 42 // specific methods are provided to translate the cross-platform cursor into a |
| 44 // platform specific cursor. It is also possible to serialize / de-serialize a | 43 // platform specific cursor. It is also possible to serialize / de-serialize a |
| 45 // WebCursor. | 44 // WebCursor. |
| 46 class CONTENT_EXPORT WebCursor { | 45 class CONTENT_EXPORT WebCursor { |
| 47 public: | 46 public: |
| 48 struct CursorInfo { | 47 struct CursorInfo { |
| 49 explicit CursorInfo(blink::WebCursorInfo::Type cursor_type) | 48 explicit CursorInfo(blink::WebCursorInfo::Type cursor_type) |
| 50 : type(cursor_type), | 49 : type(cursor_type), |
| 51 image_scale_factor(1) { | 50 image_scale_factor(1) { |
| 52 #if defined(OS_WIN) | |
| 53 external_handle = NULL; | |
| 54 #endif | |
| 55 } | 51 } |
| 56 | 52 |
| 57 CursorInfo() | 53 CursorInfo() |
| 58 : type(blink::WebCursorInfo::TypePointer), | 54 : type(blink::WebCursorInfo::TypePointer), |
| 59 image_scale_factor(1) { | 55 image_scale_factor(1) { |
| 60 #if defined(OS_WIN) | |
| 61 external_handle = NULL; | |
| 62 #endif | |
| 63 } | 56 } |
| 64 | 57 |
| 65 blink::WebCursorInfo::Type type; | 58 blink::WebCursorInfo::Type type; |
| 66 gfx::Point hotspot; | 59 gfx::Point hotspot; |
| 67 float image_scale_factor; | 60 float image_scale_factor; |
| 68 SkBitmap custom_image; | 61 SkBitmap custom_image; |
| 69 #if defined(OS_WIN) | |
| 70 HCURSOR external_handle; | |
| 71 #endif | |
| 72 }; | 62 }; |
| 73 | 63 |
| 74 WebCursor(); | 64 WebCursor(); |
| 75 ~WebCursor(); | 65 ~WebCursor(); |
| 76 | 66 |
| 77 // Copy constructor/assignment operator combine. | 67 // Copy constructor/assignment operator combine. |
| 78 WebCursor(const WebCursor& other); | 68 WebCursor(const WebCursor& other); |
| 79 const WebCursor& operator=(const WebCursor& other); | 69 const WebCursor& operator=(const WebCursor& other); |
| 80 | 70 |
| 81 // Conversion from/to CursorInfo. | 71 // Conversion from/to CursorInfo. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 109 ui::PlatformCursor GetPlatformCursor(); | 99 ui::PlatformCursor GetPlatformCursor(); |
| 110 | 100 |
| 111 // Updates |device_scale_factor_| and |rotation_| based on |display|. | 101 // Updates |device_scale_factor_| and |rotation_| based on |display|. |
| 112 void SetDisplayInfo(const display::Display& display); | 102 void SetDisplayInfo(const display::Display& display); |
| 113 | 103 |
| 114 float GetCursorScaleFactor(); | 104 float GetCursorScaleFactor(); |
| 115 | 105 |
| 116 void CreateScaledBitmapAndHotspotFromCustomData( | 106 void CreateScaledBitmapAndHotspotFromCustomData( |
| 117 SkBitmap* bitmap, | 107 SkBitmap* bitmap, |
| 118 gfx::Point* hotspot); | 108 gfx::Point* hotspot); |
| 119 FRIEND_TEST_ALL_PREFIXES(WebCursorTest, | |
| 120 CreateScaledBitmapAndHotspotFromCustomData); | |
| 121 | 109 |
| 122 #elif defined(OS_WIN) | 110 #elif defined(OS_WIN) |
| 123 // Returns a HCURSOR representing the current WebCursor instance. | 111 // Returns a HCURSOR representing the current WebCursor instance. |
| 124 // The ownership of the HCURSOR (does not apply to external cursors) remains | 112 // The ownership of the HCURSOR (does not apply to external cursors) remains |
| 125 // with the WebCursor instance. | 113 // with the WebCursor instance. |
| 126 HCURSOR GetCursor(HINSTANCE module_handle); | 114 HCURSOR GetCursor(HINSTANCE module_handle); |
| 127 | 115 |
| 128 #elif defined(OS_MACOSX) | 116 #elif defined(OS_MACOSX) |
| 129 // Initialize this from the given Cocoa NSCursor. | 117 // Initialize this from the given Cocoa NSCursor. |
| 130 void InitFromNSCursor(NSCursor* cursor); | 118 void InitFromNSCursor(NSCursor* cursor); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 160 |
| 173 // Hotspot in cursor image in pixels. | 161 // Hotspot in cursor image in pixels. |
| 174 gfx::Point hotspot_; | 162 gfx::Point hotspot_; |
| 175 | 163 |
| 176 // Custom cursor data, as 32-bit RGBA. | 164 // Custom cursor data, as 32-bit RGBA. |
| 177 // Platform-inspecific because it can be serialized. | 165 // Platform-inspecific because it can be serialized. |
| 178 gfx::Size custom_size_; // In pixels. | 166 gfx::Size custom_size_; // In pixels. |
| 179 float custom_scale_; | 167 float custom_scale_; |
| 180 std::vector<char> custom_data_; | 168 std::vector<char> custom_data_; |
| 181 | 169 |
| 182 #if defined(OS_WIN) | |
| 183 // An externally generated HCURSOR. We assume that it remains valid, i.e we | |
| 184 // don't attempt to copy the HCURSOR. | |
| 185 HCURSOR external_cursor_; | |
| 186 #endif | |
| 187 | |
| 188 #if defined(USE_AURA) && (defined(USE_X11) || defined(USE_OZONE)) | 170 #if defined(USE_AURA) && (defined(USE_X11) || defined(USE_OZONE)) |
| 189 // Only used for custom cursors. | 171 // Only used for custom cursors. |
| 190 ui::PlatformCursor platform_cursor_; | 172 ui::PlatformCursor platform_cursor_; |
| 191 #elif defined(OS_WIN) | 173 #elif defined(OS_WIN) |
| 192 // A custom cursor created from custom bitmap data by Webkit. | 174 // A custom cursor created from custom bitmap data by Webkit. |
| 193 HCURSOR custom_cursor_; | 175 HCURSOR custom_cursor_; |
| 194 #endif | 176 #endif |
| 195 #if defined(USE_AURA) | 177 #if defined(USE_AURA) |
| 196 float device_scale_factor_; | 178 float device_scale_factor_; |
| 197 #endif | 179 #endif |
| 198 | 180 |
| 199 #if defined(USE_OZONE) | 181 #if defined(USE_OZONE) |
| 200 display::Display::Rotation rotation_; | 182 display::Display::Rotation rotation_; |
| 201 gfx::Size maximum_cursor_size_; | 183 gfx::Size maximum_cursor_size_; |
| 202 #endif | 184 #endif |
| 203 }; | 185 }; |
| 204 | 186 |
| 205 } // namespace content | 187 } // namespace content |
| 206 | 188 |
| 207 #endif // CONTENT_COMMON_CURSORS_WEBCURSOR_H_ | 189 #endif // CONTENT_COMMON_CURSORS_WEBCURSOR_H_ |
| OLD | NEW |