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

Unified Diff: content/common/input/web_input_event_payload.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: Win export fix Created 7 years, 3 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 | « content/common/input/web_input_event_payload.h ('k') | content/common/input_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/input/web_input_event_payload.cc
diff --git a/content/common/input/web_input_event_payload.cc b/content/common/input/web_input_event_payload.cc
new file mode 100644
index 0000000000000000000000000000000000000000..145be332492671a36e72678bc7594493de5cbc4e
--- /dev/null
+++ b/content/common/input/web_input_event_payload.cc
@@ -0,0 +1,98 @@
+// Copyright (c) 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/web_input_event_payload.h"
+
+#include "base/logging.h"
+#include "third_party/WebKit/public/web/WebInputEvent.h"
+
+namespace content {
+namespace {
+static WebInputEventPayload::ScopedWebInputEvent CloneWebInputEvent(
+ const WebKit::WebInputEvent& event) {
+ WebInputEventPayload::ScopedWebInputEvent clone;
+ if (WebKit::WebInputEvent::isMouseEventType(event.type))
+ clone.reset(new WebKit::WebMouseEvent());
+ else if (event.type == WebKit::WebInputEvent::MouseWheel)
+ clone.reset(new WebKit::WebMouseWheelEvent());
+ else if (WebKit::WebInputEvent::isKeyboardEventType(event.type))
+ clone.reset(new WebKit::WebKeyboardEvent());
+ else if (WebKit::WebInputEvent::isTouchEventType(event.type))
+ clone.reset(new WebKit::WebTouchEvent());
+ else if (WebKit::WebInputEvent::isGestureEventType(event.type))
+ clone.reset(new WebKit::WebGestureEvent());
+ else
+ NOTREACHED() << "Unknown webkit event type " << event.type;
+
+ if (!clone)
+ return clone.Pass();
+
+ DCHECK_EQ(event.size, clone->size);
+ memcpy(clone.get(), &event, event.size);
+ return clone.Pass();
+}
+} // namespace
+
+WebInputEventPayload::WebInputEventDeleter::WebInputEventDeleter() {}
+
+void WebInputEventPayload::WebInputEventDeleter::operator()(
+ WebKit::WebInputEvent* event) const {
+ if (!event)
+ return;
+
+ if (WebKit::WebInputEvent::isMouseEventType(event->type))
+ delete static_cast<WebKit::WebMouseEvent*>(event);
+ else if (event->type == WebKit::WebInputEvent::MouseWheel)
+ delete static_cast<WebKit::WebMouseWheelEvent*>(event);
+ else if (WebKit::WebInputEvent::isKeyboardEventType(event->type))
+ delete static_cast<WebKit::WebKeyboardEvent*>(event);
+ else if (WebKit::WebInputEvent::isTouchEventType(event->type))
+ delete static_cast<WebKit::WebTouchEvent*>(event);
+ else if (WebKit::WebInputEvent::isGestureEventType(event->type))
+ delete static_cast<WebKit::WebGestureEvent*>(event);
+ else
+ NOTREACHED() << "Unknown webkit event type " << event->type;
+}
+
+WebInputEventPayload::WebInputEventPayload() : is_keyboard_shortcut_(false) {}
+
+WebInputEventPayload::~WebInputEventPayload() {}
+
+scoped_ptr<WebInputEventPayload> WebInputEventPayload::Create() {
+ return make_scoped_ptr(new WebInputEventPayload());
+}
+
+scoped_ptr<WebInputEventPayload> WebInputEventPayload::Create(
+ const WebKit::WebInputEvent& event,
+ const ui::LatencyInfo& latency_info,
+ bool is_keyboard_shortcut) {
+ scoped_ptr<WebInputEventPayload> payload = Create();
+ payload->Initialize(event, latency_info, is_keyboard_shortcut);
+ return payload.Pass();
+}
+
+const WebInputEventPayload* WebInputEventPayload::Cast(const Payload* payload) {
+ DCHECK(payload);
+ DCHECK_EQ(WEB_INPUT_EVENT, payload->GetType());
+ return static_cast<const WebInputEventPayload*>(payload);
+}
+
+InputEvent::Payload::Type WebInputEventPayload::GetType() const {
+ return WEB_INPUT_EVENT;
+}
+
+void WebInputEventPayload::Initialize(const WebKit::WebInputEvent& web_event,
+ const ui::LatencyInfo& latency_info,
+ bool is_keyboard_shortcut) {
+ DCHECK(!web_event_) << "WebInputEventPayload already initialized";
+ web_event_ = CloneWebInputEvent(web_event);
+ latency_info_ = latency_info;
+ is_keyboard_shortcut_ = is_keyboard_shortcut;
+}
+
+bool WebInputEventPayload::CanCreateFollowupEvents() const {
+ return WebKit::WebInputEvent::isTouchEventType(web_event()->type);
+}
+
+} // namespace content
« no previous file with comments | « content/common/input/web_input_event_payload.h ('k') | content/common/input_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698