1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
// Copyright 2013 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 "content/common/input/input_param_traits.h"
#include "content/common/content_param_traits.h"
#include "content/common/input/synthetic_pinch_gesture_params.h"
#include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
#include "content/common/input/web_input_event_traits.h"
#include "content/common/input_messages.h"
namespace IPC {
namespace {
template<typename GestureType>
scoped_ptr<content::SyntheticGestureParams> ReadGestureParams(
const Message* m,
PickleIterator* iter)
{
scoped_ptr<GestureType> gesture_params(new GestureType);
if (!ReadParam(m, iter, gesture_params.get()))
return scoped_ptr<content::SyntheticGestureParams>();
return gesture_params.template PassAs<content::SyntheticGestureParams>();
}
} // namespace
void ParamTraits<content::ScopedWebInputEvent>::Write(Message* m,
const param_type& p) {
bool valid_web_event = !!p;
WriteParam(m, valid_web_event);
if (valid_web_event)
WriteParam(m, static_cast<WebInputEventPointer>(p.get()));
}
bool ParamTraits<content::ScopedWebInputEvent>::Read(const Message* m,
PickleIterator* iter,
param_type* p) {
bool valid_web_event = false;
WebInputEventPointer web_event_pointer = NULL;
if (!ReadParam(m, iter, &valid_web_event) ||
!valid_web_event ||
!ReadParam(m, iter, &web_event_pointer) ||
!web_event_pointer)
return false;
(*p) = content::WebInputEventTraits::Clone(*web_event_pointer);
return true;
}
void ParamTraits<content::ScopedWebInputEvent>::Log(const param_type& p,
std::string* l) {
LogParam(static_cast<WebInputEventPointer>(p.get()), l);
}
void ParamTraits<content::SyntheticGesturePacket>::Write(Message* m,
const param_type& p) {
DCHECK(p.gesture_params());
WriteParam(m, p.gesture_params()->GetGestureType());
switch (p.gesture_params()->GetGestureType()) {
case content::SyntheticGestureParams::SMOOTH_SCROLL_GESTURE:
WriteParam(m, *content::SyntheticSmoothScrollGestureParams::Cast(
p.gesture_params()));
break;
case content::SyntheticGestureParams::PINCH_GESTURE:
WriteParam(m, *content::SyntheticPinchGestureParams::Cast(
p.gesture_params()));
break;
case content::SyntheticGestureParams::TAP_GESTURE:
WriteParam(m, *content::SyntheticTapGestureParams::Cast(
p.gesture_params()));
break;
}
}
bool ParamTraits<content::SyntheticGesturePacket>::Read(const Message* m,
PickleIterator* iter,
param_type* p) {
content::SyntheticGestureParams::GestureType gesture_type;
if (!ReadParam(m, iter, &gesture_type))
return false;
scoped_ptr<content::SyntheticGestureParams> gesture_params;
switch (gesture_type) {
case content::SyntheticGestureParams::SMOOTH_SCROLL_GESTURE:
gesture_params =
ReadGestureParams<content::SyntheticSmoothScrollGestureParams>(m,
iter);
break;
case content::SyntheticGestureParams::PINCH_GESTURE:
gesture_params =
ReadGestureParams<content::SyntheticPinchGestureParams>(m, iter);
break;
case content::SyntheticGestureParams::TAP_GESTURE:
gesture_params =
ReadGestureParams<content::SyntheticTapGestureParams>(m, iter);
break;
default:
return false;
}
p->set_gesture_params(gesture_params.Pass());
return p->gesture_params() != NULL;
}
void ParamTraits<content::SyntheticGesturePacket>::Log(const param_type& p,
std::string* l) {
DCHECK(p.gesture_params());
switch (p.gesture_params()->GetGestureType()) {
case content::SyntheticGestureParams::SMOOTH_SCROLL_GESTURE:
LogParam(
*content::SyntheticSmoothScrollGestureParams::Cast(
p.gesture_params()),
l);
break;
case content::SyntheticGestureParams::PINCH_GESTURE:
LogParam(
*content::SyntheticPinchGestureParams::Cast(p.gesture_params()),
l);
break;
case content::SyntheticGestureParams::TAP_GESTURE:
LogParam(
*content::SyntheticTapGestureParams::Cast(p.gesture_params()),
l);
break;
}
}
} // namespace IPC
|