blob: 83963558ad0d2ac9926df3a135ebc83b03e8a00f [file] [log] [blame]
[email protected]c7839552012-04-03 21:14:361// 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
7namespace ui {
8
9Cursor::Cursor()
10 : native_type_(0),
[email protected]151ffdff2012-09-11 20:18:3511 platform_cursor_(0),
12 device_scale_factor_(0.0f) {
[email protected]c7839552012-04-03 21:14:3613}
14
15Cursor::Cursor(int type)
16 : native_type_(type),
[email protected]151ffdff2012-09-11 20:18:3517 platform_cursor_(0),
18 device_scale_factor_(0.0f) {
[email protected]c7839552012-04-03 21:14:3619}
20
21Cursor::Cursor(const Cursor& cursor)
22 : native_type_(cursor.native_type_),
[email protected]151ffdff2012-09-11 20:18:3523 platform_cursor_(cursor.platform_cursor_),
24 device_scale_factor_(cursor.device_scale_factor_) {
[email protected]c7839552012-04-03 21:14:3625 if (native_type_ == kCursorCustom)
26 RefCustomCursor();
27}
28
29Cursor::~Cursor() {
30 if (native_type_ == kCursorCustom)
31 UnrefCustomCursor();
32}
33
34void Cursor::SetPlatformCursor(const PlatformCursor& platform) {
[email protected]151ffdff2012-09-11 20:18:3535 if (native_type_ == kCursorCustom)
[email protected]c7839552012-04-03 21:14:3636 UnrefCustomCursor();
[email protected]c7839552012-04-03 21:14:3637 platform_cursor_ = platform;
[email protected]151ffdff2012-09-11 20:18:3538 if (native_type_ == kCursorCustom)
39 RefCustomCursor();
[email protected]c7839552012-04-03 21:14:3640}
41
[email protected]4196ec80d2012-08-23 00:48:4542void Cursor::Assign(const Cursor& cursor) {
43 if (*this == cursor)
44 return;
[email protected]151ffdff2012-09-11 20:18:3545 if (native_type_ == kCursorCustom)
[email protected]4196ec80d2012-08-23 00:48:4546 UnrefCustomCursor();
[email protected]09643452012-09-13 02:34:4947 native_type_ = cursor.native_type_;
[email protected]4196ec80d2012-08-23 00:48:4548 platform_cursor_ = cursor.platform_cursor_;
[email protected]151ffdff2012-09-11 20:18:3549 if (native_type_ == kCursorCustom)
[email protected]4196ec80d2012-08-23 00:48:4550 RefCustomCursor();
[email protected]151ffdff2012-09-11 20:18:3551 device_scale_factor_ = cursor.device_scale_factor_;
[email protected]4196ec80d2012-08-23 00:48:4552}
[email protected]c7839552012-04-03 21:14:3653
54} // namespace ui