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/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 blink::WebCursorInfo::Type type; | 64 blink::WebCursorInfo::Type type; |
65 gfx::Point hotspot; | 65 gfx::Point hotspot; |
66 float image_scale_factor; | 66 float image_scale_factor; |
67 SkBitmap custom_image; | 67 SkBitmap custom_image; |
68 #if defined(OS_WIN) | 68 #if defined(OS_WIN) |
69 HCURSOR external_handle; | 69 HCURSOR external_handle; |
70 #endif | 70 #endif |
71 }; | 71 }; |
72 | 72 |
73 WebCursor(); | 73 WebCursor(); |
74 explicit WebCursor(const CursorInfo& cursor_info); | |
75 ~WebCursor(); | 74 ~WebCursor(); |
76 | 75 |
77 // Copy constructor/assignment operator combine. | 76 // Copy constructor/assignment operator combine. |
78 WebCursor(const WebCursor& other); | 77 WebCursor(const WebCursor& other); |
79 const WebCursor& operator=(const WebCursor& other); | 78 const WebCursor& operator=(const WebCursor& other); |
80 | 79 |
81 // Conversion from/to CursorInfo. | 80 // Conversion from/to CursorInfo. |
82 void InitFromCursorInfo(const CursorInfo& cursor_info); | 81 void InitFromCursorInfo(const CursorInfo& cursor_info); |
83 void GetCursorInfo(CursorInfo* cursor_info) const; | 82 void GetCursorInfo(CursorInfo* cursor_info) const; |
84 | 83 |
(...skipping 19 matching lines...) Expand all Loading... | |
104 // APIs on it. | 103 // APIs on it. |
105 void InitFromExternalCursor(HCURSOR handle); | 104 void InitFromExternalCursor(HCURSOR handle); |
106 #endif | 105 #endif |
107 | 106 |
108 #if defined(USE_AURA) | 107 #if defined(USE_AURA) |
109 ui::PlatformCursor GetPlatformCursor(); | 108 ui::PlatformCursor GetPlatformCursor(); |
110 | 109 |
111 // Updates |device_scale_factor_| and |rotation_| based on |display|. | 110 // Updates |device_scale_factor_| and |rotation_| based on |display|. |
112 void SetDisplayInfo(const gfx::Display& display); | 111 void SetDisplayInfo(const gfx::Display& display); |
113 | 112 |
113 float GetCursorScaleFactor(); | |
114 void CreateScaledBitmapAndHotspotFromCustomData( | |
ananta
2015/12/15 23:28:17
Newline between functions
Bret
2015/12/16 19:03:59
Done.
| |
115 SkBitmap* bitmap, | |
ananta
2015/12/15 23:28:17
Fix indent to 4 spaces.
Bret
2015/12/16 19:03:59
Done.
| |
116 gfx::Point* hotspot); | |
117 | |
114 #elif defined(OS_WIN) | 118 #elif defined(OS_WIN) |
115 // Returns a HCURSOR representing the current WebCursor instance. | 119 // Returns a HCURSOR representing the current WebCursor instance. |
116 // The ownership of the HCURSOR (does not apply to external cursors) remains | 120 // The ownership of the HCURSOR (does not apply to external cursors) remains |
117 // with the WebCursor instance. | 121 // with the WebCursor instance. |
118 HCURSOR GetCursor(HINSTANCE module_handle); | 122 HCURSOR GetCursor(HINSTANCE module_handle); |
119 | 123 |
120 #elif defined(OS_MACOSX) | 124 #elif defined(OS_MACOSX) |
121 // Initialize this from the given Cocoa NSCursor. | 125 // Initialize this from the given Cocoa NSCursor. |
122 void InitFromNSCursor(NSCursor* cursor); | 126 void InitFromNSCursor(NSCursor* cursor); |
123 #endif | 127 #endif |
(...skipping 16 matching lines...) Expand all Loading... | |
140 // matches that of the cursor passed in. | 144 // matches that of the cursor passed in. |
141 bool IsPlatformDataEqual(const WebCursor& other) const ; | 145 bool IsPlatformDataEqual(const WebCursor& other) const ; |
142 | 146 |
143 // Copies platform specific data from the WebCursor instance passed in. | 147 // Copies platform specific data from the WebCursor instance passed in. |
144 void CopyPlatformData(const WebCursor& other); | 148 void CopyPlatformData(const WebCursor& other); |
145 | 149 |
146 // Platform specific cleanup. | 150 // Platform specific cleanup. |
147 void CleanupPlatformData(); | 151 void CleanupPlatformData(); |
148 | 152 |
149 void SetCustomData(const SkBitmap& image); | 153 void SetCustomData(const SkBitmap& image); |
154 void CreateCustomData(const SkBitmap& bitmap, | |
ananta
2015/12/15 23:28:17
Newline between functions
ananta
2015/12/15 23:28:17
Some comments for this function would be helpful.
Bret
2015/12/16 19:03:59
Done.
Bret
2015/12/16 19:03:59
Done.
| |
155 std::vector<char>& custom_data, | |
ananta
2015/12/15 23:28:17
We don't use reference parameters for output as pe
Bret
2015/12/16 19:03:59
Done.
| |
156 gfx::Size& custom_size); | |
150 void ImageFromCustomData(SkBitmap* image) const; | 157 void ImageFromCustomData(SkBitmap* image) const; |
151 | 158 |
152 // Clamp the hotspot to the custom image's bounds, if this is a custom cursor. | 159 // Clamp the hotspot to the custom image's bounds, if this is a custom cursor. |
153 void ClampHotspot(); | 160 void ClampHotspot(); |
154 | 161 |
155 // WebCore::PlatformCursor type. | 162 // WebCore::PlatformCursor type. |
156 int type_; | 163 int type_; |
157 | 164 |
158 // Hotspot in cursor image in pixels. | 165 // Hotspot in cursor image in pixels. |
159 gfx::Point hotspot_; | 166 gfx::Point hotspot_; |
160 | 167 |
161 // Custom cursor data, as 32-bit RGBA. | 168 // Custom cursor data, as 32-bit RGBA. |
162 // Platform-inspecific because it can be serialized. | 169 // Platform-inspecific because it can be serialized. |
163 gfx::Size custom_size_; // In pixels. | 170 gfx::Size custom_size_; // In pixels. |
164 float custom_scale_; | 171 float custom_scale_; |
165 std::vector<char> custom_data_; | 172 std::vector<char> custom_data_; |
166 | 173 |
167 #if defined(OS_WIN) | 174 #if defined(OS_WIN) |
168 // An externally generated HCURSOR. We assume that it remains valid, i.e we | 175 // An externally generated HCURSOR. We assume that it remains valid, i.e we |
169 // don't attempt to copy the HCURSOR. | 176 // don't attempt to copy the HCURSOR. |
170 HCURSOR external_cursor_; | 177 HCURSOR external_cursor_; |
171 #endif | 178 #endif |
172 | 179 |
173 #if defined(USE_AURA) && (defined(USE_X11) || defined(USE_OZONE)) | 180 #if defined(USE_AURA) && (defined(USE_X11) || defined(USE_OZONE)) |
174 // Only used for custom cursors. | 181 // Only used for custom cursors. |
175 ui::PlatformCursor platform_cursor_; | 182 ui::PlatformCursor platform_cursor_; |
176 float device_scale_factor_; | |
177 #elif defined(OS_WIN) | 183 #elif defined(OS_WIN) |
178 // A custom cursor created from custom bitmap data by Webkit. | 184 // A custom cursor created from custom bitmap data by Webkit. |
179 HCURSOR custom_cursor_; | 185 HCURSOR custom_cursor_; |
180 #endif | 186 #endif |
187 #if defined(USE_AURA) | |
ananta
2015/12/15 23:28:17
USE_AURA is no longer optional. So remove the ifde
Bret
2015/12/16 19:03:58
This file is used by mac so the check needs to sta
| |
188 float device_scale_factor_; | |
189 #endif | |
181 | 190 |
182 #if defined(USE_OZONE) | 191 #if defined(USE_OZONE) |
183 gfx::Display::Rotation rotation_; | 192 gfx::Display::Rotation rotation_; |
184 #endif | 193 #endif |
185 }; | 194 }; |
186 | 195 |
187 } // namespace content | 196 } // namespace content |
188 | 197 |
189 #endif // CONTENT_COMMON_CURSORS_WEBCURSOR_H_ | 198 #endif // CONTENT_COMMON_CURSORS_WEBCURSOR_H_ |
OLD | NEW |