Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / base / cursor / cursor.cc
blob83963558ad0d2ac9926df3a135ebc83b03e8a00f
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.
5 #include "ui/base/cursor/cursor.h"
7 namespace ui {
9 Cursor::Cursor()
10 : native_type_(0),
11 platform_cursor_(0),
12 device_scale_factor_(0.0f) {
15 Cursor::Cursor(int type)
16 : native_type_(type),
17 platform_cursor_(0),
18 device_scale_factor_(0.0f) {
21 Cursor::Cursor(const Cursor& cursor)
22 : native_type_(cursor.native_type_),
23 platform_cursor_(cursor.platform_cursor_),
24 device_scale_factor_(cursor.device_scale_factor_) {
25 if (native_type_ == kCursorCustom)
26 RefCustomCursor();
29 Cursor::~Cursor() {
30 if (native_type_ == kCursorCustom)
31 UnrefCustomCursor();
34 void Cursor::SetPlatformCursor(const PlatformCursor& platform) {
35 if (native_type_ == kCursorCustom)
36 UnrefCustomCursor();
37 platform_cursor_ = platform;
38 if (native_type_ == kCursorCustom)
39 RefCustomCursor();
42 void Cursor::Assign(const Cursor& cursor) {
43 if (*this == cursor)
44 return;
45 if (native_type_ == kCursorCustom)
46 UnrefCustomCursor();
47 native_type_ = cursor.native_type_;
48 platform_cursor_ = cursor.platform_cursor_;
49 if (native_type_ == kCursorCustom)
50 RefCustomCursor();
51 device_scale_factor_ = cursor.device_scale_factor_;
54 } // namespace ui