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