[email protected] | c783955 | 2012-04-03 21:14:36 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #include "ui/base/cursor/cursor.h" | ||||
6 | |||||
7 | namespace ui { | ||||
8 | |||||
9 | Cursor::Cursor() | ||||
10 | : native_type_(0), | ||||
[email protected] | 151ffdff | 2012-09-11 20:18:35 | [diff] [blame] | 11 | platform_cursor_(0), |
12 | device_scale_factor_(0.0f) { | ||||
[email protected] | c783955 | 2012-04-03 21:14:36 | [diff] [blame] | 13 | } |
14 | |||||
15 | Cursor::Cursor(int type) | ||||
16 | : native_type_(type), | ||||
[email protected] | 151ffdff | 2012-09-11 20:18:35 | [diff] [blame] | 17 | platform_cursor_(0), |
18 | device_scale_factor_(0.0f) { | ||||
[email protected] | c783955 | 2012-04-03 21:14:36 | [diff] [blame] | 19 | } |
20 | |||||
21 | Cursor::Cursor(const Cursor& cursor) | ||||
22 | : native_type_(cursor.native_type_), | ||||
[email protected] | 151ffdff | 2012-09-11 20:18:35 | [diff] [blame] | 23 | platform_cursor_(cursor.platform_cursor_), |
24 | device_scale_factor_(cursor.device_scale_factor_) { | ||||
[email protected] | c783955 | 2012-04-03 21:14:36 | [diff] [blame] | 25 | if (native_type_ == kCursorCustom) |
26 | RefCustomCursor(); | ||||
27 | } | ||||
28 | |||||
29 | Cursor::~Cursor() { | ||||
30 | if (native_type_ == kCursorCustom) | ||||
31 | UnrefCustomCursor(); | ||||
32 | } | ||||
33 | |||||
34 | void Cursor::SetPlatformCursor(const PlatformCursor& platform) { | ||||
[email protected] | 151ffdff | 2012-09-11 20:18:35 | [diff] [blame] | 35 | if (native_type_ == kCursorCustom) |
[email protected] | c783955 | 2012-04-03 21:14:36 | [diff] [blame] | 36 | UnrefCustomCursor(); |
[email protected] | c783955 | 2012-04-03 21:14:36 | [diff] [blame] | 37 | platform_cursor_ = platform; |
[email protected] | 151ffdff | 2012-09-11 20:18:35 | [diff] [blame] | 38 | if (native_type_ == kCursorCustom) |
39 | RefCustomCursor(); | ||||
[email protected] | c783955 | 2012-04-03 21:14:36 | [diff] [blame] | 40 | } |
41 | |||||
[email protected] | 4196ec80d | 2012-08-23 00:48:45 | [diff] [blame] | 42 | void Cursor::Assign(const Cursor& cursor) { |
43 | if (*this == cursor) | ||||
44 | return; | ||||
[email protected] | 151ffdff | 2012-09-11 20:18:35 | [diff] [blame] | 45 | if (native_type_ == kCursorCustom) |
[email protected] | 4196ec80d | 2012-08-23 00:48:45 | [diff] [blame] | 46 | UnrefCustomCursor(); |
[email protected] | 0964345 | 2012-09-13 02:34:49 | [diff] [blame] | 47 | native_type_ = cursor.native_type_; |
[email protected] | 4196ec80d | 2012-08-23 00:48:45 | [diff] [blame] | 48 | platform_cursor_ = cursor.platform_cursor_; |
[email protected] | 151ffdff | 2012-09-11 20:18:35 | [diff] [blame] | 49 | if (native_type_ == kCursorCustom) |
[email protected] | 4196ec80d | 2012-08-23 00:48:45 | [diff] [blame] | 50 | RefCustomCursor(); |
[email protected] | 151ffdff | 2012-09-11 20:18:35 | [diff] [blame] | 51 | device_scale_factor_ = cursor.device_scale_factor_; |
[email protected] | 4196ec80d | 2012-08-23 00:48:45 | [diff] [blame] | 52 | } |
[email protected] | c783955 | 2012-04-03 21:14:36 | [diff] [blame] | 53 | |
54 | } // namespace ui |