Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Unified Diff: ui/events/event.h

Issue 1695783002: IPC::ParamTraits for ui::Event (towards ui::Events over mojo IPC) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/events/event.h
diff --git a/ui/events/event.h b/ui/events/event.h
index 90ea9d98e03f5657a946bd5a386b9aa69dc461ee..f3a5df9fba3f319dd7193a87db1e3a9e532d74f0 100644
--- a/ui/events/event.h
+++ b/ui/events/event.h
@@ -6,7 +6,6 @@
#define UI_EVENTS_EVENT_H_
#include <stdint.h>
-
#include "base/compiler_specific.h"
#include "base/event_types.h"
#include "base/gtest_prod_util.h"
@@ -14,6 +13,7 @@
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
+#include "ipc/ipc_message_utils.h"
#include "ui/events/event_constants.h"
#include "ui/events/gesture_event_details.h"
#include "ui/events/gestures/gesture_types.h"
@@ -30,6 +30,9 @@ class Transform;
namespace ui {
class EventTarget;
enum class DomCode;
+class Event;
+
+typedef scoped_ptr<Event> ScopedEvent;
Tom Sepez 2016/02/18 18:46:10 nit: using ScopedEvent = scoped_ptr<Event>;
Mark Dittmer 2016/02/18 19:12:56 Done.
class EVENTS_EXPORT Event {
public:
@@ -240,6 +243,9 @@ class EVENTS_EXPORT Event {
private:
friend class EventTestApi;
+ // For (de)serialization.
+ friend struct IPC::ParamTraits<ui::ScopedEvent>;
Tom Sepez 2016/02/18 18:46:10 jam@ and I have argued about this in the past -- i
Mark Dittmer 2016/02/18 19:12:56 What is the proposed implementation alternative? R
jam 2016/02/18 21:01:26 I care less about this now. My main question is
+
EventType type_;
std::string name_;
base::TimeDelta time_stamp_;
@@ -261,8 +267,19 @@ class EVENTS_EXPORT CancelModeEvent : public Event {
public:
CancelModeEvent();
~CancelModeEvent() override;
+
+ private:
+ // For (de)serialization.
+ explicit CancelModeEvent(EventType type,
Tom Sepez 2016/02/18 18:46:10 Nit: no |explicit| as it's not a single-arg ctor.
Mark Dittmer 2016/02/18 19:12:56 Done.
+ base::TimeDelta time_stamp,
+ int flags)
+ : Event(type, time_stamp, flags) {}
+ friend struct IPC::ParamTraits<ui::ScopedEvent>;
+ friend struct IPC::ParamTraits<ui::CancelModeEvent>;
};
+class MouseWheelEvent;
Tom Sepez 2016/02/18 18:46:10 nit: move to top
Mark Dittmer 2016/02/18 19:12:56 Done.
+
class EVENTS_EXPORT LocatedEvent : public Event {
public:
~LocatedEvent() override;
@@ -304,6 +321,13 @@ class EVENTS_EXPORT LocatedEvent : public Event {
protected:
friend class LocatedEventTestApi;
+
+ // For (de)serialization.
+ explicit LocatedEvent(EventType type, base::TimeDelta time_stamp, int flags)
+ : Event(type, time_stamp, flags) {}
+ friend struct IPC::ParamTraits<ui::ScopedEvent>;
+ friend struct IPC::ParamTraits<ui::LocatedEvent>;
+
explicit LocatedEvent(const base::NativeEvent& native_event);
// Create a new LocatedEvent which is identical to the provided model.
@@ -364,6 +388,9 @@ struct EVENTS_EXPORT PointerDetails {
tilt_y == other.tilt_y;
}
+ // For serialization.
+ friend struct IPC::ParamTraits<ui::PointerDetails>;
+
// The type of pointer device.
EventPointerType pointer_type = EventPointerType::POINTER_TYPE_UNKNOWN;
@@ -483,6 +510,13 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent {
pointer_details_ = details;
}
+ protected:
+ // For (de)serialization.
+ explicit MouseEvent(EventType type, base::TimeDelta time_stamp, int flags)
+ : LocatedEvent(type, time_stamp, flags) {}
+ friend struct IPC::ParamTraits<ui::ScopedEvent>;
+ friend struct IPC::ParamTraits<ui::MouseEvent>;
+
private:
FRIEND_TEST_ALL_PREFIXES(EventTest, DoubleClickRequiresRelease);
FRIEND_TEST_ALL_PREFIXES(EventTest, SingleClickRightLeft);
@@ -543,6 +577,14 @@ class EVENTS_EXPORT MouseWheelEvent : public MouseEvent {
const gfx::Vector2d& offset() const { return offset_; }
private:
+ // For (de)serialization.
+ explicit MouseWheelEvent(EventType type,
+ base::TimeDelta time_stamp,
+ int flags)
+ : MouseEvent(type, time_stamp, flags) {}
+ friend struct IPC::ParamTraits<ui::ScopedEvent>;
+ friend struct IPC::ParamTraits<ui::MouseWheelEvent>;
+
gfx::Vector2d offset_;
};
@@ -615,15 +657,22 @@ class EVENTS_EXPORT TouchEvent : public LocatedEvent {
}
private:
+ // For (de)serialization.
+ explicit TouchEvent(EventType type, base::TimeDelta time_stamp, int flags)
+ : LocatedEvent(type, time_stamp, flags),
+ should_remove_native_touch_id_mapping_(false) {}
+ friend struct IPC::ParamTraits<ui::ScopedEvent>;
+ friend struct IPC::ParamTraits<ui::TouchEvent>;
+
// Adjusts rotation_angle_ to within the acceptable range.
void FixRotationAngle();
// The identity (typically finger) of the touch starting at 0 and incrementing
// for each separable additional touch that the hardware can detect.
- const int touch_id_;
+ int touch_id_;
// A unique identifier for the touch event.
- const uint32_t unique_event_id_;
+ uint32_t unique_event_id_;
// Clockwise angle (in degrees) of the major axis from the X axis. Must be
// less than 180 and non-negative.
@@ -824,6 +873,11 @@ class EVENTS_EXPORT KeyEvent : public Event {
void set_is_char(bool is_char) { is_char_ = is_char; }
private:
+ // For (de)serialization.
+ explicit KeyEvent(EventType type, base::TimeDelta time_stamp, int flags);
+ friend struct IPC::ParamTraits<ui::ScopedEvent>;
+ friend struct IPC::ParamTraits<ui::KeyEvent>;
+
// Determine key_ on a keystroke event from code_ and flags().
void ApplyLayout() const;
@@ -902,6 +956,12 @@ class EVENTS_EXPORT ScrollEvent : public MouseEvent {
int finger_count() const { return finger_count_; }
private:
+ // For (de)serialization.
+ explicit ScrollEvent(EventType type, base::TimeDelta time_stamp, int flags)
+ : MouseEvent(type, time_stamp, flags) {}
+ friend struct IPC::ParamTraits<ui::ScopedEvent>;
+ friend struct IPC::ParamTraits<ui::ScrollEvent>;
+
// Potential accelerated offsets.
float x_offset_;
float y_offset_;
@@ -934,6 +994,12 @@ class EVENTS_EXPORT GestureEvent : public LocatedEvent {
const GestureEventDetails& details() const { return details_; }
private:
+ // For (de)serialization.
+ explicit GestureEvent(EventType type, base::TimeDelta time_stamp, int flags)
+ : LocatedEvent(type, time_stamp, flags) {}
+ friend struct IPC::ParamTraits<ui::ScopedEvent>;
+ friend struct IPC::ParamTraits<ui::GestureEvent>;
+
GestureEventDetails details_;
};
« no previous file with comments | « ui/events/BUILD.gn ('k') | ui/events/event.cc » ('j') | ui/events/gesture_event_details.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698