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

Unified Diff: ui/events/mojo/event_struct_traits.cc

Issue 2728883002: Adding LatencyInfo to mojom::Event. (Closed)
Patch Set: Adding handling for invalid event types. Created 3 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
« no previous file with comments | « ui/events/mojo/event_struct_traits.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/mojo/event_struct_traits.cc
diff --git a/ui/events/mojo/event_struct_traits.cc b/ui/events/mojo/event_struct_traits.cc
index 21ae98f1201a0488c4c0b4fd7379e4eaef77198c..1e81158df599a44f0af2a026a83690895e7366b3 100644
--- a/ui/events/mojo/event_struct_traits.cc
+++ b/ui/events/mojo/event_struct_traits.cc
@@ -8,6 +8,7 @@
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/events/mojo/event_constants.mojom.h"
+#include "ui/events/mojo/latency_info_struct_traits.h"
namespace mojo {
namespace {
@@ -137,6 +138,12 @@ int64_t StructTraits<ui::mojom::EventDataView, EventUniquePtr>::time_stamp(
return event->time_stamp().ToInternalValue();
}
+const ui::LatencyInfo&
+StructTraits<ui::mojom::EventDataView, EventUniquePtr>::latency(
+ const EventUniquePtr& event) {
+ return *event->latency();
+}
+
ui::mojom::KeyDataPtr
StructTraits<ui::mojom::EventDataView, EventUniquePtr>::key_data(
const EventUniquePtr& event) {
@@ -231,6 +238,8 @@ StructTraits<ui::mojom::EventDataView, EventUniquePtr>::pointer_data(
bool StructTraits<ui::mojom::EventDataView, EventUniquePtr>::Read(
ui::mojom::EventDataView event,
EventUniquePtr* out) {
+ DCHECK(!out->get());
+
switch (event.action()) {
case ui::mojom::EventType::KEY_PRESSED:
case ui::mojom::EventType::KEY_RELEASED: {
@@ -242,15 +251,15 @@ bool StructTraits<ui::mojom::EventDataView, EventUniquePtr>::Read(
out->reset(new ui::KeyEvent(
static_cast<base::char16>(key_data->character),
static_cast<ui::KeyboardCode>(key_data->key_code), event.flags()));
- return true;
- }
- out->reset(new ui::KeyEvent(
- event.action() == ui::mojom::EventType::KEY_PRESSED
- ? ui::ET_KEY_PRESSED
- : ui::ET_KEY_RELEASED,
- static_cast<ui::KeyboardCode>(key_data->key_code), event.flags()));
- return true;
+ } else {
+ out->reset(new ui::KeyEvent(
+ event.action() == ui::mojom::EventType::KEY_PRESSED
+ ? ui::ET_KEY_PRESSED
+ : ui::ET_KEY_RELEASED,
+ static_cast<ui::KeyboardCode>(key_data->key_code), event.flags()));
+ }
+ break;
}
case ui::mojom::EventType::POINTER_DOWN:
case ui::mojom::EventType::POINTER_UP:
@@ -283,7 +292,7 @@ bool StructTraits<ui::mojom::EventDataView, EventUniquePtr>::Read(
: ui::PointerDetails(
ui::EventPointerType::POINTER_TYPE_MOUSE),
ui::EventTimeForNow()));
- return true;
+ break;
}
case ui::mojom::PointerKind::TOUCH: {
out->reset(new ui::PointerEvent(
@@ -297,18 +306,22 @@ bool StructTraits<ui::mojom::EventDataView, EventUniquePtr>::Read(
pointer_data->brush_data->tilt_x,
pointer_data->brush_data->tilt_y),
ui::EventTimeForNow()));
- return true;
+ break;
}
case ui::mojom::PointerKind::PEN:
NOTIMPLEMENTED();
return false;
}
+ break;
}
case ui::mojom::EventType::UNKNOWN:
return false;
}
- return false;
+ if (!out->get())
+ return false;
+
+ return event.ReadLatency((*out)->latency());
}
} // namespace mojo
« no previous file with comments | « ui/events/mojo/event_struct_traits.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698