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

Side by Side Diff: content/common/input/web_event.cc

Issue 19624005: Add InputEvent and EventPacket types for batched input delivery (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Separate InputEvent types for events based on WebKit::WebInputEvent Created 7 years, 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013 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 #include "content/common/input/web_event.h"
6
7 #include "base/logging.h"
8 #include "third_party/WebKit/public/web/WebInputEvent.h"
9
10 namespace content {
11 namespace {
12 // TODO(jdduke): Destroy this and WebEvent entirely when we find a suitable
13 // replacement for input event types in content/.
14 static scoped_ptr<WebKit::WebInputEvent> CloneWebInputEvent(
15 const WebKit::WebInputEvent& event) {
16 scoped_ptr<WebKit::WebInputEvent> clone;
17 if (WebKit::WebInputEvent::isMouseEventType(event.type))
18 clone.reset(new WebKit::WebMouseEvent());
19 else if (event.type == WebKit::WebInputEvent::MouseWheel)
20 clone.reset(new WebKit::WebMouseWheelEvent());
21 else if (WebKit::WebInputEvent::isKeyboardEventType(event.type))
22 clone.reset(new WebKit::WebKeyboardEvent());
23 else if (WebKit::WebInputEvent::isTouchEventType(event.type))
24 clone.reset(new WebKit::WebTouchEvent());
25 else if (WebKit::WebInputEvent::isGestureEventType(event.type))
26 clone.reset(new WebKit::WebGestureEvent());
27 else
28 NOTREACHED() << "Unknown webkit event type " << event.type;
29
30 if (clone) {
31 DCHECK(clone->size == event.size);
32 memcpy(clone.get(), &event, event.size);
33 }
34
35 return clone.Pass();
36 }
37 } // namespace
38
39 WebEvent::WebEvent(int64 id)
40 : InputEvent(InputEvent::WEB, id),
41 is_keyboard_shortcut(false),
42 creates_followup_events(false) {}
43
44 scoped_ptr<WebEvent> WebEvent::Create() {
45 return make_scoped_ptr(new WebEvent(0));
46 }
47
48 scoped_ptr<WebEvent> WebEvent::Create(int64 id,
49 const WebKit::WebInputEvent& event,
50 const ui::LatencyInfo& latency_info,
51 bool is_keyboard_shortcut,
52 bool creates_followup_events) {
53 scoped_ptr<WebEvent> web_event(new WebEvent(id));
54 web_event->SetAll(event,
55 latency_info,
56 is_keyboard_shortcut,
57 creates_followup_events);
58 return web_event.Pass();
59 }
60
61 void WebEvent::SetAll(const WebKit::WebInputEvent& event,
62 const ui::LatencyInfo& latency_info,
63 bool is_keyboard_shortcut,
64 bool creates_followup_events) {
65 this->event = CloneWebInputEvent(event);
66 this->latency_info = latency_info;
67 this->is_keyboard_shortcut = is_keyboard_shortcut;
68 this->creates_followup_events = creates_followup_events;
69 }
70
71 const WebEvent* WebEvent::EventCast(const InputEvent* event) {
72 DCHECK_EQ(InputEvent::WEB, event->type);
73 return static_cast<const WebEvent*>(event);
74 }
75
76 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698