Skip to content

Commit

Permalink
Move CursorLoader and support code to ui/aura/cursor/
Browse files Browse the repository at this point in the history
CursorLoader code is Aura-specific. This CL moves that code to a new
directory ui/aura/cursor/. This allows to simplify the unittests,
by relying on AuraTestBase for the cursor factories initialization, and
moving platform-specific tests to other directories, so that some
disallowed dependencies are fixed.

The namespace rename is left for a follow-up CL.

Bug: 1270302
Change-Id: Idb7d26fd0055ce08209edd2908c510e97bc93434
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3284990
Reviewed-by: Colin Blundell <blundell@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Joe Downing <joedow@chromium.org>
Reviewed-by: Finnur Thorarinsson <finnur@chromium.org>
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Cr-Commit-Position: refs/heads/main@{#945627}
  • Loading branch information
hferreiro authored and Chromium LUCI CQ committed Nov 26, 2021
1 parent 3355536 commit 5f38439
Show file tree
Hide file tree
Showing 44 changed files with 181 additions and 211 deletions.
2 changes: 1 addition & 1 deletion ash/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,7 @@ component("ash") {
"//services/media_session/public/mojom",
"//skia",
"//ui/aura",
"//ui/base/cursor",
"//ui/aura/cursor",
"//ui/base/cursor:cursor_base",
"//ui/base/cursor/mojom:cursor_type",
"//ui/base/dragdrop:types",
Expand Down
2 changes: 1 addition & 1 deletion ash/capture_mode/capture_mode_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
#include "base/strings/stringprintf.h"
#include "cc/paint/paint_flags.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/cursor/cursor_util.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_tracker.h"
#include "ui/base/cursor/cursor_factory.h"
#include "ui/base/cursor/cursor_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_element.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/capture_mode/video_recording_watcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#include "base/notreached.h"
#include "base/time/time.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/aura/cursor/cursor_lookup.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/cursor/cursor_lookup.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/paint_recorder.h"
#include "ui/display/screen.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/display/cursor_window_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
#include "base/command_line.h"
#include "base/metrics/histogram_macros.h"
#include "components/prefs/pref_service.h"
#include "ui/aura/cursor/cursors_aura.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/base/cursor/cursors_aura.h"
#include "ui/base/hit_test.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/compositor/paint_recorder.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/wm/native_cursor_manager_ash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
#include "ash/display/window_tree_host_manager.h"
#include "ash/shell.h"
#include "base/check.h"
#include "ui/aura/cursor/cursor_loader.h"
#include "ui/aura/env.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/cursor_loader.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/base/layout.h"
#include "ui/wm/core/native_cursor_manager_delegate.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/wm/native_cursor_manager_ash.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define ASH_WM_NATIVE_CURSOR_MANAGER_ASH_H_

#include "ash/ash_export.h"
#include "ui/base/cursor/cursor_loader.h"
#include "ui/aura/cursor/cursor_loader.h"
#include "ui/display/display.h"
#include "ui/wm/core/native_cursor_manager.h"

Expand Down
1 change: 0 additions & 1 deletion chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5454,7 +5454,6 @@ static_library("browser") {
"//third_party/wtl",
"//ui/aura_extra",
"//ui/base:fullscreen_win",
"//ui/base/cursor",
]
allow_circular_includes_from +=
[ "//chrome/browser/safe_browsing/chrome_cleaner" ]
Expand Down
2 changes: 1 addition & 1 deletion components/exo/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static_library("exo") {
"//third_party/blink/public/common",
"//ui/accessibility:ax_base",
"//ui/aura",
"//ui/base/cursor",
"//ui/aura/cursor",
"//ui/base/dragdrop:types",
"//ui/base/dragdrop/mojom",
"//ui/base/ime",
Expand Down
2 changes: 1 addition & 1 deletion components/exo/pointer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/cursor/cursor_util.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/base/cursor/cursor_factory.h"
#include "ui/base/cursor/cursor_size.h"
#include "ui/base/cursor/cursor_util.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/base/layout.h"
#include "ui/base/resource/resource_scale_factor.h"
Expand Down
2 changes: 1 addition & 1 deletion content/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2467,7 +2467,7 @@ source_set("browser") {
"media/capture/aura_window_video_capture_device.h",
"media/capture/mouse_cursor_overlay_controller_aura.cc",
]
deps += [ "//ui/base/cursor" ]
deps += [ "//ui/aura/cursor" ]
}

if (is_mac) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

#include "content/browser/media/capture/mouse_cursor_overlay_controller.h"

#include "ui/aura/cursor/cursor_lookup.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/cursor_loader.h"
#include "ui/base/cursor/cursor_lookup.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/events/event.h"
#include "ui/events/event_handler.h"
Expand Down
2 changes: 1 addition & 1 deletion content/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ source_set("common") {
}

if (use_aura) {
deps += [ "//ui/base/cursor" ]
deps += [ "//ui/aura/cursor" ]
} else {
sources -= [ "cursors/webcursor_aura.cc" ]
}
Expand Down
2 changes: 1 addition & 1 deletion content/common/cursors/webcursor_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "content/common/cursors/webcursor.h"

#include "base/check_op.h"
#include "ui/aura/cursor/cursor_util.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/cursor_factory.h"
#include "ui/base/cursor/cursor_util.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"

namespace content {
Expand Down
2 changes: 1 addition & 1 deletion extensions/shell/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ source_set("app_shell_lib") {
"browser/shell_native_app_window_aura.h",
]
deps += [
"//ui/base/cursor",
"//ui/aura/cursor",
"//ui/base/cursor/mojom:cursor_type",
"//ui/platform_window",
"//ui/wm",
Expand Down
2 changes: 1 addition & 1 deletion extensions/shell/browser/shell_desktop_controller_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#include "extensions/browser/app_window/native_app_window.h"
#include "extensions/shell/browser/shell_app_window_client.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/cursor/cursor_loader.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/cursor_loader.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/base/ime/init/input_method_factory.h"
#include "ui/base/ime/input_method.h"
Expand Down
2 changes: 1 addition & 1 deletion remoting/host/chromeos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ source_set("chromeos") {
deps = [
"//remoting/base:base",
"//remoting/host:clipboard",
"//ui/base/cursor",
"//ui/aura/cursor",
"//ui/base/cursor/mojom:cursor_type",
]
}
Expand Down
2 changes: 1 addition & 1 deletion remoting/host/chromeos/mouse_cursor_monitor_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#include "base/location.h"
#include "remoting/host/chromeos/skia_bitmap_desktop_frame.h"
#include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h"
#include "ui/aura/cursor/cursor_lookup.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/cursor/cursor_lookup.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"

namespace {
Expand Down
1 change: 1 addition & 0 deletions ui/aura/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ test("aura_unittests") {
"//mojo/core/embedder",
"//skia",
"//testing/gtest",
"//ui/aura/cursor:unittests",
"//ui/aura_extra",
"//ui/aura_extra:tests",
"//ui/base:test_support",
Expand Down
49 changes: 49 additions & 0 deletions ui/aura/cursor/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2021 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

component("cursor") {
output_name = "ui_aura_cursor"
sources = [
"cursor_loader.cc",
"cursor_loader.h",
"cursor_lookup.cc",
"cursor_lookup.h",
"cursor_util.cc",
"cursor_util.h",
"cursors_aura.cc",
"cursors_aura.h",
]
defines = [ "IS_UI_AURA_CURSOR_IMPL" ]
public_deps = [
"//base",
"//ui/base/cursor:cursor_base",
"//ui/base/cursor/mojom:cursor_type",
"//ui/display",
]
deps = [
"//skia",
"//ui/base",
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/resources:ui_resources_grd",
]
}

source_set("unittests") {
testonly = true
sources = [
"cursor_loader_unittest.cc",
"cursor_util_unittest.cc",
]
deps = [
":cursor",
"//base",
"//skia",
"//testing/gtest",
"//ui/aura:test_support",
"//ui/base/cursor:cursor_base",
"//ui/base/cursor/mojom:cursor_type",
"//ui/gfx/geometry",
]
}
3 changes: 3 additions & 0 deletions ui/aura/cursor/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include_rules = [
"+ui/resources",
]
1 change: 1 addition & 0 deletions ui/aura/cursor/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
file://ui/base/cursor/OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/base/cursor/cursor_loader.h"
#include "ui/aura/cursor/cursor_loader.h"

#include <map>
#include <vector>

#include "base/check.h"
#include "base/memory/scoped_refptr.h"
#include "base/time/time.h"
#include "ui/aura/cursor/cursor_util.h"
#include "ui/aura/cursor/cursors_aura.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/cursor_factory.h"
#include "ui/base/cursor/cursor_size.h"
#include "ui/base/cursor/cursor_util.h"
#include "ui/base/cursor/cursors_aura.h"
#include "ui/base/cursor/mojom/cursor_type.mojom.h"
#include "ui/base/cursor/platform_cursor.h"
#include "ui/gfx/geometry/point.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_BASE_CURSOR_CURSOR_LOADER_H_
#define UI_BASE_CURSOR_CURSOR_LOADER_H_
#ifndef UI_AURA_CURSOR_CURSOR_LOADER_H_
#define UI_AURA_CURSOR_CURSOR_LOADER_H_

#include <map>
#include <memory>
Expand All @@ -23,7 +23,7 @@ class Point;
namespace ui {
class PlatformCursor;

class COMPONENT_EXPORT(UI_BASE_CURSOR) CursorLoader
class COMPONENT_EXPORT(UI_AURA_CURSOR) CursorLoader
: public CursorFactoryObserver {
public:
explicit CursorLoader(bool use_platform_cursors = true);
Expand Down Expand Up @@ -80,4 +80,4 @@ class COMPONENT_EXPORT(UI_BASE_CURSOR) CursorLoader

} // namespace ui

#endif // UI_BASE_CURSOR_CURSOR_LOADER_H_
#endif // UI_AURA_CURSOR_CURSOR_LOADER_H_
32 changes: 32 additions & 0 deletions ui/aura/cursor/cursor_loader_unittest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/aura/cursor/cursor_loader.h"

#include "base/memory/scoped_refptr.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/cursor_factory.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/base/cursor/platform_cursor.h"

namespace ui {
namespace {

using mojom::CursorType;
using CursorLoaderTest = ::aura::test::AuraTestBase;

} // namespace

TEST_F(CursorLoaderTest, InvisibleCursor) {
CursorLoader cursor_loader;
Cursor invisible_cursor(CursorType::kNone);
cursor_loader.SetPlatformCursor(&invisible_cursor);

ASSERT_EQ(invisible_cursor.platform(),
CursorFactory::GetInstance()->GetDefaultCursor(CursorType::kNone));
}

} // namespace ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/base/cursor/cursor_lookup.h"
#include "ui/aura/cursor/cursor_lookup.h"

#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/aura/cursor/cursors_aura.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/gfx/geometry/point.h"

#if defined(USE_AURA)
#include "ui/base/cursor/cursors_aura.h"
#endif

namespace ui {

SkBitmap GetCursorBitmap(const Cursor& cursor) {
if (cursor.type() == mojom::CursorType::kCustom)
return cursor.custom_bitmap();
#if defined(USE_AURA)
return GetDefaultBitmap(cursor);
#else
return SkBitmap();
#endif
}

gfx::Point GetCursorHotspot(const Cursor& cursor) {
if (cursor.type() == mojom::CursorType::kCustom)
return cursor.custom_hotspot();
#if defined(USE_AURA)
return GetDefaultHotspot(cursor);
#else
return gfx::Point();
#endif
}

} // namespace ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_BASE_CURSOR_CURSOR_LOOKUP_H_
#define UI_BASE_CURSOR_CURSOR_LOOKUP_H_
#ifndef UI_AURA_CURSOR_CURSOR_LOOKUP_H_
#define UI_AURA_CURSOR_CURSOR_LOOKUP_H_

#include "base/component_export.h"

Expand All @@ -16,12 +16,12 @@ class Point;
namespace ui {
class Cursor;

COMPONENT_EXPORT(UI_BASE_CURSOR)
COMPONENT_EXPORT(UI_AURA_CURSOR)
SkBitmap GetCursorBitmap(const Cursor& cursor);

COMPONENT_EXPORT(UI_BASE_CURSOR)
COMPONENT_EXPORT(UI_AURA_CURSOR)
gfx::Point GetCursorHotspot(const Cursor& cursor);

} // namespace ui

#endif // UI_BASE_CURSOR_CURSOR_LOOKUP_H_
#endif // UI_AURA_CURSOR_CURSOR_LOOKUP_H_
Loading

0 comments on commit 5f38439

Please sign in to comment.