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 "ui/base/cursor/cursor.h" | 5 #include "ui/base/cursor/cursor.h" |
6 | 6 |
7 namespace ui { | 7 namespace ui { |
8 | 8 |
9 Cursor::Cursor() | 9 Cursor::Cursor() |
10 : native_type_(0), | 10 : native_type_(CursorType::kNull), |
11 platform_cursor_(0), | 11 platform_cursor_(0), |
12 device_scale_factor_(0.0f) { | 12 device_scale_factor_(0.0f) {} |
13 } | |
14 | 13 |
15 Cursor::Cursor(int type) | 14 Cursor::Cursor(CursorType type) |
16 : native_type_(type), | 15 : native_type_(type), platform_cursor_(0), device_scale_factor_(0.0f) {} |
17 platform_cursor_(0), | |
18 device_scale_factor_(0.0f) { | |
19 } | |
20 | 16 |
21 Cursor::Cursor(const Cursor& cursor) | 17 Cursor::Cursor(const Cursor& cursor) |
22 : native_type_(cursor.native_type_), | 18 : native_type_(cursor.native_type_), |
23 platform_cursor_(cursor.platform_cursor_), | 19 platform_cursor_(cursor.platform_cursor_), |
24 device_scale_factor_(cursor.device_scale_factor_) { | 20 device_scale_factor_(cursor.device_scale_factor_) { |
25 if (native_type_ == kCursorCustom) | 21 if (native_type_ == CursorType::kCustom) |
26 RefCustomCursor(); | 22 RefCustomCursor(); |
27 } | 23 } |
28 | 24 |
29 Cursor::~Cursor() { | 25 Cursor::~Cursor() { |
30 if (native_type_ == kCursorCustom) | 26 if (native_type_ == CursorType::kCustom) |
31 UnrefCustomCursor(); | 27 UnrefCustomCursor(); |
32 } | 28 } |
33 | 29 |
34 void Cursor::SetPlatformCursor(const PlatformCursor& platform) { | 30 void Cursor::SetPlatformCursor(const PlatformCursor& platform) { |
35 if (native_type_ == kCursorCustom) | 31 if (native_type_ == CursorType::kCustom) |
36 UnrefCustomCursor(); | 32 UnrefCustomCursor(); |
37 platform_cursor_ = platform; | 33 platform_cursor_ = platform; |
38 if (native_type_ == kCursorCustom) | 34 if (native_type_ == CursorType::kCustom) |
39 RefCustomCursor(); | 35 RefCustomCursor(); |
40 } | 36 } |
41 | 37 |
42 void Cursor::Assign(const Cursor& cursor) { | 38 void Cursor::Assign(const Cursor& cursor) { |
43 if (*this == cursor) | 39 if (*this == cursor) |
44 return; | 40 return; |
45 if (native_type_ == kCursorCustom) | 41 if (native_type_ == CursorType::kCustom) |
46 UnrefCustomCursor(); | 42 UnrefCustomCursor(); |
47 native_type_ = cursor.native_type_; | 43 native_type_ = cursor.native_type_; |
48 platform_cursor_ = cursor.platform_cursor_; | 44 platform_cursor_ = cursor.platform_cursor_; |
49 if (native_type_ == kCursorCustom) | 45 if (native_type_ == CursorType::kCustom) |
50 RefCustomCursor(); | 46 RefCustomCursor(); |
51 device_scale_factor_ = cursor.device_scale_factor_; | 47 device_scale_factor_ = cursor.device_scale_factor_; |
52 } | 48 } |
53 | 49 |
54 } // namespace ui | 50 } // namespace ui |
OLD | NEW |