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

Side by Side Diff: ui/events/blink/web_input_event_traits.cc

Issue 2576013002: Introducing WebCoalescedInputEvent and inclusion in content/common (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/events/blink/web_input_event_traits.h" 5 #include "ui/events/blink/web_input_event_traits.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 9
10 using base::StringAppendF; 10 using base::StringAppendF;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 template <class EventType> 128 template <class EventType>
129 bool Execute(const WebInputEvent& event, 129 bool Execute(const WebInputEvent& event,
130 ScopedWebInputEvent* scoped_event) const { 130 ScopedWebInputEvent* scoped_event) const {
131 DCHECK_EQ(sizeof(EventType), event.size); 131 DCHECK_EQ(sizeof(EventType), event.size);
132 *scoped_event = ScopedWebInputEvent( 132 *scoped_event = ScopedWebInputEvent(
133 new EventType(static_cast<const EventType&>(event))); 133 new EventType(static_cast<const EventType&>(event)));
134 return true; 134 return true;
135 } 135 }
136 }; 136 };
137 137
138 struct WebInputEventDelete {
139 template <class EventType>
140 bool Execute(WebInputEvent* event, bool* /* dummy_var */) const {
141 if (!event)
142 return false;
143 DCHECK_EQ(sizeof(EventType), event->size);
144 delete static_cast<EventType*>(event);
145 return true;
146 }
147 };
148
149 template <typename Operator, typename ArgIn, typename ArgOut> 138 template <typename Operator, typename ArgIn, typename ArgOut>
150 bool Apply(Operator op, 139 bool Apply(Operator op,
151 WebInputEvent::Type type, 140 WebInputEvent::Type type,
152 const ArgIn& arg_in, 141 const ArgIn& arg_in,
153 ArgOut* arg_out) { 142 ArgOut* arg_out) {
154 if (WebInputEvent::isMouseEventType(type)) 143 if (WebInputEvent::isMouseEventType(type))
155 return op.template Execute<WebMouseEvent>(arg_in, arg_out); 144 return op.template Execute<WebMouseEvent>(arg_in, arg_out);
156 else if (type == WebInputEvent::MouseWheel) 145 else if (type == WebInputEvent::MouseWheel)
157 return op.template Execute<WebMouseWheelEvent>(arg_in, arg_out); 146 return op.template Execute<WebMouseWheelEvent>(arg_in, arg_out);
158 else if (WebInputEvent::isKeyboardEventType(type)) 147 else if (WebInputEvent::isKeyboardEventType(type))
(...skipping 20 matching lines...) Expand all
179 Apply(WebInputEventSize(), type, type, &size); 168 Apply(WebInputEventSize(), type, type, &size);
180 return size; 169 return size;
181 } 170 }
182 171
183 ScopedWebInputEvent WebInputEventTraits::Clone(const WebInputEvent& event) { 172 ScopedWebInputEvent WebInputEventTraits::Clone(const WebInputEvent& event) {
184 ScopedWebInputEvent scoped_event; 173 ScopedWebInputEvent scoped_event;
185 Apply(WebInputEventClone(), event.type, event, &scoped_event); 174 Apply(WebInputEventClone(), event.type, event, &scoped_event);
186 return scoped_event; 175 return scoped_event;
187 } 176 }
188 177
189 void WebInputEventTraits::Delete(WebInputEvent* event) {
190 if (!event)
191 return;
192 bool dummy_var = false;
193 Apply(WebInputEventDelete(), event->type, event, &dummy_var);
194 }
195
196 bool WebInputEventTraits::ShouldBlockEventStream(const WebInputEvent& event) { 178 bool WebInputEventTraits::ShouldBlockEventStream(const WebInputEvent& event) {
197 switch (event.type) { 179 switch (event.type) {
198 case WebInputEvent::MouseDown: 180 case WebInputEvent::MouseDown:
199 case WebInputEvent::MouseUp: 181 case WebInputEvent::MouseUp:
200 case WebInputEvent::MouseEnter: 182 case WebInputEvent::MouseEnter:
201 case WebInputEvent::MouseLeave: 183 case WebInputEvent::MouseLeave:
202 case WebInputEvent::ContextMenu: 184 case WebInputEvent::ContextMenu:
203 case WebInputEvent::GestureScrollBegin: 185 case WebInputEvent::GestureScrollBegin:
204 case WebInputEvent::GestureScrollEnd: 186 case WebInputEvent::GestureScrollEnd:
205 case WebInputEvent::GestureShowPress: 187 case WebInputEvent::GestureShowPress:
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 source_event_type = SourceEventType::WHEEL; 242 source_event_type = SourceEventType::WHEEL;
261 } else if (event.sourceDevice == 243 } else if (event.sourceDevice ==
262 blink::WebGestureDevice::WebGestureDeviceTouchscreen) { 244 blink::WebGestureDevice::WebGestureDeviceTouchscreen) {
263 source_event_type = SourceEventType::TOUCH; 245 source_event_type = SourceEventType::TOUCH;
264 } 246 }
265 LatencyInfo latency_info(source_event_type); 247 LatencyInfo latency_info(source_event_type);
266 return latency_info; 248 return latency_info;
267 } 249 }
268 250
269 } // namespace ui 251 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698