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

Side by Side 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, 10 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
« no previous file with comments | « sky/viewer/document_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "sky/viewer/document_view.h" 5 #include "sky/viewer/document_view.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/thread_task_runner_handle.h" 12 #include "base/thread_task_runner_handle.h"
13 #include "mojo/converters/geometry/geometry_type_converters.h" 13 #include "mojo/converters/geometry/geometry_type_converters.h"
14 #include "mojo/converters/input_events/input_events_type_converters.h"
14 #include "mojo/public/cpp/application/connect.h" 15 #include "mojo/public/cpp/application/connect.h"
15 #include "mojo/public/cpp/system/data_pipe.h" 16 #include "mojo/public/cpp/system/data_pipe.h"
16 #include "mojo/public/interfaces/application/shell.mojom.h" 17 #include "mojo/public/interfaces/application/shell.mojom.h"
17 #include "mojo/services/surfaces/public/interfaces/surfaces_service.mojom.h" 18 #include "mojo/services/surfaces/public/interfaces/surfaces_service.mojom.h"
18 #include "mojo/services/view_manager/public/cpp/view.h" 19 #include "mojo/services/view_manager/public/cpp/view.h"
19 #include "mojo/services/view_manager/public/cpp/view_manager.h" 20 #include "mojo/services/view_manager/public/cpp/view_manager.h"
20 #include "skia/ext/refptr.h" 21 #include "skia/ext/refptr.h"
21 #include "sky/compositor/layer.h" 22 #include "sky/compositor/layer.h"
22 #include "sky/compositor/layer_host.h" 23 #include "sky/compositor/layer_host.h"
23 #include "sky/compositor/rasterizer_bitmap.h" 24 #include "sky/compositor/rasterizer_bitmap.h"
(...skipping 14 matching lines...) Expand all
38 #include "sky/engine/v8_inspector/inspector_host.h" 39 #include "sky/engine/v8_inspector/inspector_host.h"
39 #include "sky/viewer/converters/input_event_types.h" 40 #include "sky/viewer/converters/input_event_types.h"
40 #include "sky/viewer/converters/url_request_types.h" 41 #include "sky/viewer/converters/url_request_types.h"
41 #include "sky/viewer/internals.h" 42 #include "sky/viewer/internals.h"
42 #include "sky/viewer/platform/weburlloader_impl.h" 43 #include "sky/viewer/platform/weburlloader_impl.h"
43 #include "sky/viewer/runtime_flags.h" 44 #include "sky/viewer/runtime_flags.h"
44 #include "sky/viewer/script/script_runner.h" 45 #include "sky/viewer/script/script_runner.h"
45 #include "third_party/skia/include/core/SkCanvas.h" 46 #include "third_party/skia/include/core/SkCanvas.h"
46 #include "third_party/skia/include/core/SkColor.h" 47 #include "third_party/skia/include/core/SkColor.h"
47 #include "third_party/skia/include/core/SkDevice.h" 48 #include "third_party/skia/include/core/SkDevice.h"
49 #include "ui/events/gestures/gesture_recognizer.h"
48 #include "v8/include/v8.h" 50 #include "v8/include/v8.h"
49 51
50 namespace sky { 52 namespace sky {
51 namespace { 53 namespace {
52 54
53 void ConfigureSettings(blink::WebSettings* settings) { 55 void ConfigureSettings(blink::WebSettings* settings) {
54 settings->setDefaultFixedFontSize(13); 56 settings->setDefaultFixedFontSize(13);
55 settings->setDefaultFontSize(16); 57 settings->setDefaultFontSize(16);
56 settings->setLoadsImagesAutomatically(true); 58 settings->setLoadsImagesAutomatically(true);
57 } 59 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 weak_factory_(this) { 94 weak_factory_(this) {
93 exported_services_.AddService(&view_manager_client_factory_); 95 exported_services_.AddService(&view_manager_client_factory_);
94 inspector_service_provider_impl_.AddService(&inspector_service_factory_); 96 inspector_service_provider_impl_.AddService(&inspector_service_factory_);
95 } 97 }
96 98
97 DocumentView::~DocumentView() { 99 DocumentView::~DocumentView() {
98 if (web_view_) 100 if (web_view_)
99 web_view_->close(); 101 web_view_->close();
100 if (root_) 102 if (root_)
101 root_->RemoveObserver(this); 103 root_->RemoveObserver(this);
104 ui::GestureRecognizer::Get()->CleanupStateForConsumer(this);
102 } 105 }
103 106
104 base::WeakPtr<DocumentView> DocumentView::GetWeakPtr() { 107 base::WeakPtr<DocumentView> DocumentView::GetWeakPtr() {
105 return weak_factory_.GetWeakPtr(); 108 return weak_factory_.GetWeakPtr();
106 } 109 }
107 110
108 void DocumentView::OnEmbed( 111 void DocumentView::OnEmbed(
109 mojo::View* root, 112 mojo::View* root,
110 mojo::InterfaceRequest<mojo::ServiceProvider> services, 113 mojo::InterfaceRequest<mojo::ServiceProvider> services,
111 mojo::ServiceProviderPtr exposed_services) { 114 mojo::ServiceProviderPtr exposed_services) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 web_view_->setFocus(true); 297 web_view_->setFocus(true);
295 } 298 }
296 } 299 }
297 300
298 void DocumentView::OnViewDestroyed(mojo::View* view) { 301 void DocumentView::OnViewDestroyed(mojo::View* view) {
299 DCHECK_EQ(view, root_); 302 DCHECK_EQ(view, root_);
300 303
301 root_ = nullptr; 304 root_ = nullptr;
302 } 305 }
303 306
307 bool DocumentView::DispatchInputEvent(const mojo::EventPtr& event) {
308 scoped_ptr<blink::WebInputEvent> web_event =
309 ConvertEvent(event, GetDevicePixelRatio());
310 return web_event && web_view_->handleInputEvent(*web_event);
311 }
312
304 void DocumentView::OnViewInputEvent( 313 void DocumentView::OnViewInputEvent(
305 mojo::View* view, const mojo::EventPtr& event) { 314 mojo::View* view, const mojo::EventPtr& event) {
306 scoped_ptr<blink::WebInputEvent> web_event = 315
307 ConvertEvent(event, GetDevicePixelRatio()); 316 scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event>>());
308 if (web_event) 317 ui::TouchEvent* touch_event = nullptr;
309 web_view_->handleInputEvent(*web_event); 318 if (ui_event->IsTouchEvent()) {
319 touch_event = static_cast<ui::TouchEvent*>(ui_event.get());
320 ui::GestureRecognizer::Get()->ProcessTouchEventPreDispatch(
321 *touch_event, this);
322 }
323
324 bool handled = DispatchInputEvent(event);
325
326 if (touch_event) {
327 ui::EventResult result = handled ? ui::ER_UNHANDLED : ui::ER_UNHANDLED;
328 if (auto gestures = ui::GestureRecognizer::Get()->ProcessTouchEventPostDispa tch(
329 *touch_event, result, this)) {
330 for (auto& gesture : *gestures)
331 DispatchInputEvent(mojo::Event::From(*gesture));
332 }
333 }
310 } 334 }
311 335
312 class InspectorHostImpl : public inspector::InspectorHost { 336 class InspectorHostImpl : public inspector::InspectorHost {
313 public: 337 public:
314 InspectorHostImpl(blink::WebView* web_view, mojo::Shell* shell) 338 InspectorHostImpl(blink::WebView* web_view, mojo::Shell* shell)
315 : web_view_(web_view), shell_(shell) {} 339 : web_view_(web_view), shell_(shell) {}
316 340
317 virtual ~InspectorHostImpl() {} 341 virtual ~InspectorHostImpl() {}
318 342
319 mojo::Shell* GetShell() override { return shell_; } 343 mojo::Shell* GetShell() override { return shell_; }
(...skipping 10 matching lines...) Expand all
330 void DocumentView::StartDebuggerInspectorBackend() { 354 void DocumentView::StartDebuggerInspectorBackend() {
331 if (!inspector_backend_) { 355 if (!inspector_backend_) {
332 inspector_host_.reset(new InspectorHostImpl(web_view_, shell_)); 356 inspector_host_.reset(new InspectorHostImpl(web_view_, shell_));
333 inspector_backend_.reset( 357 inspector_backend_.reset(
334 new inspector::InspectorBackendMojo(inspector_host_.get())); 358 new inspector::InspectorBackendMojo(inspector_host_.get()));
335 } 359 }
336 inspector_backend_->Connect(); 360 inspector_backend_->Connect();
337 } 361 }
338 362
339 } // namespace sky 363 } // namespace sky
OLDNEW
« 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