Commit 29b31dd7 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

events: convert MouseEvents to use MouseData

PointerData will be removed, so this converts mouse mojo serialization to use
MouseData.
Also converts to a couple of geometry types.
Also, had to fix a couple of dependencies.

BUG=865781
TEST=covered by tests

Change-Id: Iab8f2ddb5ba0f40bc43271e7135ca46f478a397d
Reviewed-on: https://chromium-review.googlesource.com/c/1267495Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597618}
parent 2361d645
......@@ -56,6 +56,7 @@ jumbo_component("display") {
public_deps = [
"//ui/display/types",
"//ui/gfx:color_space",
"//ui/gfx:gfx",
]
......
......@@ -218,6 +218,7 @@ jumbo_component("events") {
public_deps = [
":events_base",
"//ui/display",
"//ui/latency",
]
deps = [
......@@ -225,7 +226,6 @@ jumbo_component("events") {
":gesture_detection",
"//base/third_party/dynamic_annotations",
"//skia",
"//ui/display",
"//ui/gfx",
"//ui/gfx/geometry",
]
......
......@@ -34,6 +34,7 @@ class Transform;
namespace ui {
class CancelModeEvent;
class Event;
class EventTarget;
class KeyEvent;
class LocatedEvent;
......@@ -42,11 +43,9 @@ class MouseWheelEvent;
class PointerEvent;
class ScrollEvent;
class TouchEvent;
enum class DomCode;
class Event;
class MouseWheelEvent;
using ScopedEvent = std::unique_ptr<Event>;
using PointerId = int32_t;
class EVENTS_EXPORT Event {
......
......@@ -13,7 +13,7 @@ mojom("interfaces") {
public_deps = [
"//mojo/public/mojom/base",
"//ui/gfx/mojo",
"//ui/gfx/geometry/mojo",
"//ui/latency/mojo:interfaces",
]
}
......
......@@ -7,6 +7,7 @@ module ui.mojom;
import "mojo/public/mojom/base/time.mojom";
import "ui/events/mojo/event_constants.mojom";
import "ui/events/mojo/keyboard_codes.mojom";
import "ui/gfx/geometry/mojo/geometry.mojom";
import "ui/latency/mojo/latency_info.mojom";
struct KeyData {
......@@ -49,17 +50,10 @@ struct KeyData {
};
struct LocationData {
// |x| and |y| are in the coordinate system of the View.
// Typically, this will be an integer-valued translation w.r.t.
// the screen and in this case, |x| and |y| are in units of physical
// pixels. However, some View embedders may apply arbitrary transformations
// of a view w.r.t. the screen.
float x;
float y;
// |screen_x| and |screen_y| are in screen coordinates in units of
// physical pixels.
float screen_x;
float screen_y;
// |relative_location| is in the coordinate system of the target and in DIPs.
gfx.mojom.PointF relative_location;
// |root_location| is relative to the client's root and in dips.
gfx.mojom.PointF root_location;
};
// TODO(rjkroege,sadrul): Add gesture representation.
......@@ -155,6 +149,14 @@ struct PointerDetails {
int32 offset_y;
};
struct MouseData {
int32 changed_button_flags;
LocationData location;
PointerDetails pointer_details;
// Only used for mouse wheel.
gfx.mojom.Vector2d wheel_offset;
};
// This is used for TouchEvents.
struct TouchData {
bool may_cause_scrolling;
......@@ -181,5 +183,6 @@ struct Event {
GestureData? gesture_data;
ScrollData? scroll_data;
TouchData? touch_data;
MouseData? mouse_data;
map<string, array<uint8>>? properties;
};
......@@ -8,6 +8,7 @@ traits_headers = [ "//ui/events/mojo/event_struct_traits.h" ]
public_deps = [
"//ui/events",
"//ui/events:dom_keycode_converter",
"//ui/gfx/geometry/mojo",
"//ui/latency/mojo:interfaces",
]
deps = [
......
This diff is collapsed.
......@@ -46,6 +46,7 @@ struct StructTraits<ui::mojom::EventDataView, EventUniquePtr> {
static ui::mojom::GestureDataPtr gesture_data(const EventUniquePtr& event);
static ui::mojom::ScrollDataPtr scroll_data(const EventUniquePtr& event);
static ui::mojom::TouchDataPtr touch_data(const EventUniquePtr& event);
static ui::mojom::MouseDataPtr mouse_data(const EventUniquePtr& event);
static base::flat_map<std::string, std::vector<uint8_t>> properties(
const EventUniquePtr& event);
static bool Read(ui::mojom::EventDataView r, EventUniquePtr* out);
......
......@@ -64,6 +64,11 @@ void ExpectMouseEventsEqual(const MouseEvent& expected,
EXPECT_EQ(expected.changed_button_flags(), actual.changed_button_flags());
}
void ExpectMouseWheelEventsEqual(const MouseWheelEvent& expected,
const MouseWheelEvent& actual) {
EXPECT_EQ(expected.offset(), actual.offset());
}
void ExpectEventsEqual(const Event& expected, const Event& actual) {
EXPECT_EQ(expected.type(), actual.type());
EXPECT_EQ(expected.time_stamp(), actual.time_stamp());
......@@ -77,6 +82,11 @@ void ExpectEventsEqual(const Event& expected, const Event& actual) {
ASSERT_TRUE(actual.IsMouseEvent());
ExpectMouseEventsEqual(*expected.AsMouseEvent(), *actual.AsMouseEvent());
}
if (expected.IsMouseWheelEvent()) {
ASSERT_TRUE(actual.IsMouseWheelEvent());
ExpectMouseWheelEventsEqual(*expected.AsMouseWheelEvent(),
*actual.AsMouseWheelEvent());
}
if (expected.IsTouchEvent()) {
ASSERT_TRUE(actual.IsTouchEvent());
ExpectTouchEventsEqual(*expected.AsTouchEvent(), *actual.AsTouchEvent());
......@@ -330,12 +340,7 @@ TEST_F(StructTraitsTest, MouseWheelEvent) {
const MouseWheelEvent* output_event = output->AsMouseWheelEvent();
// TODO(sky): make this use ExpectEventsEqual().
EXPECT_EQ(ET_MOUSEWHEEL, output_event->type());
EXPECT_EQ(kTestData[i].flags(), output_event->flags());
EXPECT_EQ(kTestData[i].location(), output_event->location());
EXPECT_EQ(kTestData[i].root_location(), output_event->root_location());
EXPECT_EQ(kTestData[i].offset(), output_event->offset());
EXPECT_EQ(kTestData[i].time_stamp(), output_event->time_stamp());
ExpectMouseWheelEventsEqual(kTestData[i], *output_event);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment