Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_EVENTS_DEVICES_MOJO_TOUCHSCREEN_DEVICE_STRUCT_TRAITS_H_ | |
| 6 #define UI_EVENTS_DEVICES_MOJO_TOUCHSCREEN_DEVICE_STRUCT_TRAITS_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/strings/string_piece.h" | |
| 11 #include "ui/events/devices/mojo/input_devices.mojom.h" | |
| 12 #include "ui/events/devices/touchscreen_device.h" | |
| 13 #include "ui/gfx/geometry/size.h" | |
| 14 | |
| 15 namespace mojo { | |
| 16 | |
| 17 template <> | |
| 18 struct StructTraits<ui::mojom::TouchscreenDevice, ui::TouchscreenDevice> { | |
| 19 static const ui::InputDevice& input_device( | |
| 20 const ui::TouchscreenDevice& device) { | |
| 21 return static_cast<const ui::InputDevice&>(device); | |
| 22 } | |
| 23 | |
| 24 static gfx::Size size(const ui::TouchscreenDevice& device) { | |
|
sadrul
2016/06/08 16:31:09
const &
kylechar
2016/06/08 18:13:16
Done.
| |
| 25 return device.size; | |
| 26 } | |
| 27 | |
| 28 static int32_t touch_points(const ui::TouchscreenDevice& device) { | |
| 29 return device.touch_points; | |
| 30 } | |
| 31 | |
| 32 static bool Read(ui::mojom::TouchscreenDeviceDataView data, | |
| 33 ui::TouchscreenDevice* out) { | |
| 34 if (!data.ReadInputDevice(static_cast<ui::InputDevice*>(out))) | |
| 35 return false; | |
| 36 | |
| 37 if (!data.ReadSize(&out->size)) | |
| 38 return false; | |
| 39 | |
| 40 out->touch_points = data.touch_points(); | |
| 41 | |
| 42 return true; | |
| 43 } | |
| 44 }; | |
| 45 | |
|
sadrul
2016/06/08 16:31:09
This could maybe go in the input_device_struct_tra
kylechar
2016/06/08 18:13:16
Sure, done.
| |
| 46 } // namespace mojo | |
| 47 | |
| 48 #endif // UI_EVENTS_DEVICES_MOJO_TOUCHSCREEN_DEVICE_STRUCT_TRAITS_H_ | |
| OLD | NEW |