blob: a8284037f2d413c602813851fe4323aa56657b87 [file] [log] [blame]
Avi Drissman4e1b7bc32022-09-15 14:03:501// Copyright 2019 The Chromium Authors
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commitf5b16fe2008-07-27 00:20:514
[email protected]c2809346d2014-03-20 00:11:035#ifndef CONTENT_COMMON_CURSORS_WEBCURSOR_H_
6#define CONTENT_COMMON_CURSORS_WEBCURSOR_H_
7
avia9aa7a82015-12-25 03:06:318#include "build/build_config.h"
[email protected]c2809346d2014-03-20 00:11:039#include "content/common/content_export.h"
Henrique Ferreiro35aa76ef2020-03-10 22:29:2910#include "ui/base/cursor/cursor.h"
oshima516f03b2016-04-28 15:40:1111#include "ui/display/display.h"
tfarina655f81d2014-12-23 02:38:5012#include "ui/gfx/geometry/point.h"
tfarinaebe974f02015-01-03 04:25:3213#include "ui/gfx/geometry/size.h"
[email protected]08397d52011-02-05 01:53:3814#include "ui/gfx/native_widget_types.h"
[email protected]67b25052008-10-23 21:57:5115
[email protected]84f43c972013-09-16 23:08:1916#if defined(USE_AURA)
Arthur Sonzognic686e8f2024-01-11 08:36:3717#include <optional>
[email protected]84f43c972013-09-16 23:08:1918#endif
19
[email protected]c2809346d2014-03-20 00:11:0320namespace content {
21
Henrique Ferreirofd3d14e2023-01-23 20:38:4122// NOTE(https://crbug.com/1149906): This class is deprecated and ui::Cursor
23// should be used instead.
24//
[email protected]4c870b42008-11-06 00:36:5225// This class encapsulates a cross-platform description of a cursor. Platform
26// specific methods are provided to translate the cross-platform cursor into a
27// platform specific cursor. It is also possible to serialize / de-serialize a
Mike Wassermanf95c2d9d2019-04-17 00:44:2128// WebCursor. This class is highly similar to ui::Cursor.
[email protected]c2809346d2014-03-20 00:11:0329class CONTENT_EXPORT WebCursor {
[email protected]4c870b42008-11-06 00:36:5230 public:
Mitsuru Oshimad15e37862020-01-14 07:55:2131 WebCursor();
Henrique Ferreiro35aa76ef2020-03-10 22:29:2932 explicit WebCursor(const ui::Cursor& info);
[email protected]cf4e5eb12009-01-09 01:20:3833 ~WebCursor();
34
Henrique Ferreiro35aa76ef2020-03-10 22:29:2935 const ui::Cursor& cursor() const { return cursor_; }
[email protected]7c51b0ee2009-07-08 21:49:3036
[email protected]f0b6b482010-11-23 00:55:2837 // Returns a native cursor representing the current WebCursor instance.
38 gfx::NativeCursor GetNativeCursor();
39
[email protected]c7839552012-04-03 21:14:3640#if defined(USE_AURA)
Max Ihlenfeldt9a0990a2024-07-02 16:53:1441 // Updates |device_scale_factor_| and |rotation_| based on |window|'s
42 // preferred scale (if any) and its display information.
43 void UpdateDisplayInfoForWindow(aura::Window* window);
[email protected]ee37dc652013-08-06 00:33:2744
Mitsuru Oshimad15e37862020-01-14 07:55:2145 bool has_custom_cursor_for_test() const { return !!custom_cursor_; }
[email protected]67b25052008-10-23 21:57:5146#endif
47
[email protected]4c870b42008-11-06 00:36:5248 private:
Evan Stade891067b22018-11-16 01:26:3349 float GetCursorScaleFactor(SkBitmap* bitmap);
50
Mike Wassermanf95c2d9d2019-04-17 00:44:2151 // The basic cursor info.
Henrique Ferreiro35aa76ef2020-03-10 22:29:2952 ui::Cursor cursor_;
[email protected]2b99be22008-11-14 18:45:2653
Henrique Ferreirod1e80f72023-03-20 14:31:0154#if defined(USE_AURA)
[email protected]c7839552012-04-03 21:14:3655 // Only used for custom cursors.
Mike Wassermanf95c2d9d2019-04-17 00:44:2156 float device_scale_factor_ = 1.f;
Evan Stade891067b22018-11-16 01:26:3357 display::Display::Rotation rotation_ = display::Display::ROTATE_0;
Mike Wassermanf95c2d9d2019-04-17 00:44:2158#endif
Evan Stade891067b22018-11-16 01:26:3359
Georg Neis18fc5142024-12-18 00:58:4160#if BUILDFLAG(IS_CHROMEOS)
Mike Wassermanf95c2d9d2019-04-17 00:44:2161 // This matches ozone drm_util.cc's kDefaultCursorWidth/Height.
62 static constexpr int kDefaultMaxSize = 64;
63 gfx::Size maximum_cursor_size_ = {kDefaultMaxSize, kDefaultMaxSize};
[email protected]