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

Side by Side Diff: sky/viewer/document_view.cc

Issue 1198493003: Send gesture events to SkyView in sky_viewer (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | 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/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 } 387 }
388 388
389 void DocumentView::OnViewInputEvent( 389 void DocumentView::OnViewInputEvent(
390 mojo::View* view, const mojo::EventPtr& event) { 390 mojo::View* view, const mojo::EventPtr& event) {
391 float device_pixel_ratio = GetDevicePixelRatio(); 391 float device_pixel_ratio = GetDevicePixelRatio();
392 scoped_ptr<blink::WebInputEvent> web_event = 392 scoped_ptr<blink::WebInputEvent> web_event =
393 ConvertEvent(event, device_pixel_ratio); 393 ConvertEvent(event, device_pixel_ratio);
394 if (!web_event) 394 if (!web_event)
395 return; 395 return;
396 396
397 if (sky_view_) {
398 sky_view_->HandleInputEvent(*web_event);
399 return;
400 }
401
402 ui::GestureRecognizer* recognizer = ui::GestureRecognizer::Get(); 397 ui::GestureRecognizer* recognizer = ui::GestureRecognizer::Get();
403 scoped_ptr<ui::TouchEvent> touch_event = 398 scoped_ptr<ui::TouchEvent> touch_event =
404 ConvertToUITouchEvent(*web_event, device_pixel_ratio); 399 ConvertToUITouchEvent(*web_event, device_pixel_ratio);
405 if (touch_event) 400 if (touch_event)
406 recognizer->ProcessTouchEventPreDispatch(*touch_event, this); 401 recognizer->ProcessTouchEventPreDispatch(*touch_event, this);
407 402
408 bool handled = web_view_->handleInputEvent(*web_event); 403 bool handled = false;
404
405 if (web_view_)
406 handled = web_view_->handleInputEvent(*web_event);
407 if (sky_view_)
408 sky_view_->HandleInputEvent(*web_event);
409 409
410 if (touch_event) { 410 if (touch_event) {
411 ui::EventResult result = handled ? ui::ER_UNHANDLED : ui::ER_UNHANDLED; 411 ui::EventResult result = handled ? ui::ER_UNHANDLED : ui::ER_UNHANDLED;
412 if (auto gestures = recognizer->ProcessTouchEventPostDispatch( 412 if (auto gestures = recognizer->ProcessTouchEventPostDispatch(
413 *touch_event, result, this)) { 413 *touch_event, result, this)) {
414 for (auto& gesture : *gestures) { 414 for (auto& gesture : *gestures) {
415 scoped_ptr<blink::WebInputEvent> gesture_event = 415 scoped_ptr<blink::WebInputEvent> gesture_event =
416 ConvertEvent(*gesture, device_pixel_ratio); 416 ConvertEvent(*gesture, device_pixel_ratio);
417 if (gesture_event) 417 if (gesture_event) {
418 web_view_->handleInputEvent(*gesture_event); 418 if (web_view_)
419 web_view_->handleInputEvent(*gesture_event);
420 if (sky_view_)
421 sky_view_->HandleInputEvent(*gesture_event);
422 }
419 } 423 }
420 } 424 }
421 } 425 }
422 } 426 }
423 427
424 void DocumentView::StartDebuggerInspectorBackend() { 428 void DocumentView::StartDebuggerInspectorBackend() {
425 // FIXME: Do we need this for dart? 429 // FIXME: Do we need this for dart?
426 } 430 }
427 431
428 void DocumentView::InitServiceRegistry() { 432 void DocumentView::InitServiceRegistry() {
429 mojo::ConnectToService(imported_services_.get(), &service_registry_); 433 mojo::ConnectToService(imported_services_.get(), &service_registry_);
430 mojo::Array<mojo::String> interface_names(1); 434 mojo::Array<mojo::String> interface_names(1);
431 interface_names[0] = mojo::ViewManagerClient::Name_; 435 interface_names[0] = mojo::ViewManagerClient::Name_;
432 mojo::ServiceProviderImpl* sp_impl(new mojo::ServiceProviderImpl()); 436 mojo::ServiceProviderImpl* sp_impl(new mojo::ServiceProviderImpl());
433 sp_impl->AddService(&view_manager_client_factory_); 437 sp_impl->AddService(&view_manager_client_factory_);
434 mojo::ServiceProviderPtr sp; 438 mojo::ServiceProviderPtr sp;
435 service_registry_service_provider_binding_.reset( 439 service_registry_service_provider_binding_.reset(
436 new mojo::StrongBinding<mojo::ServiceProvider>(sp_impl, &sp)); 440 new mojo::StrongBinding<mojo::ServiceProvider>(sp_impl, &sp));
437 service_registry_->AddServices(interface_names.Pass(), sp.Pass()); 441 service_registry_->AddServices(interface_names.Pass(), sp.Pass());
438 } 442 }
439 443
440 void DocumentView::ScheduleFrame() { 444 void DocumentView::ScheduleFrame() {
441 DCHECK(sky_view_); 445 DCHECK(sky_view_);
442 layer_host_->SetNeedsAnimate(); 446 layer_host_->SetNeedsAnimate();
443 } 447 }
444 448
445 } // namespace sky 449 } // namespace sky
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698