• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that can
3 // be found in the LICENSE file.
4 
5 #include "libcef/browser/osr/synthetic_gesture_target_osr.h"
6 
7 #include "content/browser/renderer_host/render_widget_host_impl.h"
8 #include "ui/events/gesture_detection/gesture_configuration.h"
9 
CefSyntheticGestureTargetOSR(content::RenderWidgetHostImpl * host)10 CefSyntheticGestureTargetOSR::CefSyntheticGestureTargetOSR(
11     content::RenderWidgetHostImpl* host)
12     : SyntheticGestureTargetBase(host) {}
13 
DispatchWebTouchEventToPlatform(const blink::WebTouchEvent & web_touch,const ui::LatencyInfo & latency_info)14 void CefSyntheticGestureTargetOSR::DispatchWebTouchEventToPlatform(
15     const blink::WebTouchEvent& web_touch,
16     const ui::LatencyInfo& latency_info) {
17   // We assume that platforms supporting touch have their own implementation of
18   // SyntheticGestureTarget to route the events through their respective input
19   // stack.
20   LOG(ERROR) << "Touch events not supported for this browser.";
21 }
22 
DispatchWebMouseWheelEventToPlatform(const blink::WebMouseWheelEvent & web_wheel,const ui::LatencyInfo & latency_info)23 void CefSyntheticGestureTargetOSR::DispatchWebMouseWheelEventToPlatform(
24     const blink::WebMouseWheelEvent& web_wheel,
25     const ui::LatencyInfo& latency_info) {
26   render_widget_host()->ForwardWheelEventWithLatencyInfo(web_wheel,
27                                                          latency_info);
28 }
29 
DispatchWebGestureEventToPlatform(const blink::WebGestureEvent & web_gesture,const ui::LatencyInfo & latency_info)30 void CefSyntheticGestureTargetOSR::DispatchWebGestureEventToPlatform(
31     const blink::WebGestureEvent& web_gesture,
32     const ui::LatencyInfo& latency_info) {
33   render_widget_host()->ForwardGestureEventWithLatencyInfo(web_gesture,
34                                                            latency_info);
35 }
36 
DispatchWebMouseEventToPlatform(const blink::WebMouseEvent & web_mouse,const ui::LatencyInfo & latency_info)37 void CefSyntheticGestureTargetOSR::DispatchWebMouseEventToPlatform(
38     const blink::WebMouseEvent& web_mouse,
39     const ui::LatencyInfo& latency_info) {
40   render_widget_host()->ForwardMouseEventWithLatencyInfo(web_mouse,
41                                                          latency_info);
42 }
43 
44 content::mojom::GestureSourceType
GetDefaultSyntheticGestureSourceType() const45 CefSyntheticGestureTargetOSR::GetDefaultSyntheticGestureSourceType() const {
46   return content::mojom::GestureSourceType::kMouseInput;
47 }
48 
GetTouchSlopInDips() const49 float CefSyntheticGestureTargetOSR::GetTouchSlopInDips() const {
50   return ui::GestureConfiguration::GetInstance()
51       ->max_touch_move_in_pixels_for_click();
52 }
53 
GetSpanSlopInDips() const54 float CefSyntheticGestureTargetOSR::GetSpanSlopInDips() const {
55   return ui::GestureConfiguration::GetInstance()->span_slop();
56 }
57 
GetMinScalingSpanInDips() const58 float CefSyntheticGestureTargetOSR::GetMinScalingSpanInDips() const {
59   return ui::GestureConfiguration::GetInstance()->min_scaling_span_in_pixels();
60 }
61