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

Unified Diff: sky/viewer/document_view.cc

Issue 868463010: Move gesture recognition from WindowManagerApp to Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 | « sky/viewer/document_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/viewer/document_view.cc
diff --git a/sky/viewer/document_view.cc b/sky/viewer/document_view.cc
index 80ae7db9e6299609f8efc89072f23ae155cb1015..d4c82e57bbbcdd3210a6cc7eb5dddb4af6f5f5cc 100644
--- a/sky/viewer/document_view.cc
+++ b/sky/viewer/document_view.cc
@@ -11,6 +11,7 @@
#include "base/strings/string_util.h"
#include "base/thread_task_runner_handle.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
+#include "mojo/converters/input_events/input_events_type_converters.h"
#include "mojo/public/cpp/application/connect.h"
#include "mojo/public/cpp/system/data_pipe.h"
#include "mojo/public/interfaces/application/shell.mojom.h"
@@ -45,6 +46,7 @@
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkDevice.h"
+#include "ui/events/gestures/gesture_recognizer.h"
#include "v8/include/v8.h"
namespace sky {
@@ -99,6 +101,7 @@ DocumentView::~DocumentView() {
web_view_->close();
if (root_)
root_->RemoveObserver(this);
+ ui::GestureRecognizer::Get()->CleanupStateForConsumer(this);
}
base::WeakPtr<DocumentView> DocumentView::GetWeakPtr() {
@@ -301,12 +304,33 @@ void DocumentView::OnViewDestroyed(mojo::View* view) {
root_ = nullptr;
}
-void DocumentView::OnViewInputEvent(
- mojo::View* view, const mojo::EventPtr& event) {
+bool DocumentView::DispatchInputEvent(const mojo::EventPtr& event) {
scoped_ptr<blink::WebInputEvent> web_event =
ConvertEvent(event, GetDevicePixelRatio());
- if (web_event)
- web_view_->handleInputEvent(*web_event);
+ return web_event && web_view_->handleInputEvent(*web_event);
+}
+
+void DocumentView::OnViewInputEvent(
+ mojo::View* view, const mojo::EventPtr& event) {
+
+ scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event>>());
+ ui::TouchEvent* touch_event = nullptr;
+ if (ui_event->IsTouchEvent()) {
+ touch_event = static_cast<ui::TouchEvent*>(ui_event.get());
+ ui::GestureRecognizer::Get()->ProcessTouchEventPreDispatch(
+ *touch_event, this);
+ }
+
+ bool handled = DispatchInputEvent(event);
+
+ if (touch_event) {
+ ui::EventResult result = handled ? ui::ER_UNHANDLED : ui::ER_UNHANDLED;
+ if (auto gestures = ui::GestureRecognizer::Get()->ProcessTouchEventPostDispatch(
+ *touch_event, result, this)) {
+ for (auto& gesture : *gestures)
+ DispatchInputEvent(mojo::Event::From(*gesture));
+ }
+ }
}
class InspectorHostImpl : public inspector::InspectorHost {
« no previous file with comments | « sky/viewer/document_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698