File: input_router.h

package info (click to toggle)
chromium-browser 70.0.3538.110-1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,619,476 kB
  • sloc: cpp: 13,024,755; ansic: 1,349,823; python: 916,672; xml: 314,489; java: 280,047; asm: 276,936; perl: 75,771; objc: 66,634; sh: 45,860; cs: 28,354; php: 11,064; makefile: 10,911; yacc: 9,109; tcl: 8,403; ruby: 4,065; lex: 1,779; pascal: 1,411; lisp: 1,055; awk: 41; jsp: 39; sed: 17; sql: 3
file content (91 lines) | stat: -rw-r--r-- 3,783 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright 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.

#ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_ROUTER_H_
#define CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_ROUTER_H_

#include "cc/input/touch_action.h"
#include "content/browser/renderer_host/event_with_latency_info.h"
#include "content/browser/renderer_host/input/gesture_event_queue.h"
#include "content/browser/renderer_host/input/passthrough_touch_event_queue.h"
#include "content/common/widget.mojom.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/common/input_event_ack_state.h"
#include "ipc/ipc_listener.h"
#include "third_party/blink/public/platform/web_input_event.h"

namespace content {

// The InputRouter allows the embedder to customize how input events are
// sent to the renderer, and how responses are dispatched to the browser.
// While the router should respect the relative order in which events are
// received, it is free to customize when those events are dispatched.
class InputRouter : public IPC::Listener {
 public:
  struct CONTENT_EXPORT Config {
    Config();
    GestureEventQueue::Config gesture_config;
    PassthroughTouchEventQueue::Config touch_config;
  };

  ~InputRouter() override {}

  // WebInputEvents
  virtual void SendMouseEvent(
      const MouseEventWithLatencyInfo& mouse_event) = 0;
  virtual void SendWheelEvent(
      const MouseWheelEventWithLatencyInfo& wheel_event) = 0;
  virtual void SendKeyboardEvent(
      const NativeWebKeyboardEventWithLatencyInfo& key_event) = 0;
  virtual void SendGestureEvent(
      const GestureEventWithLatencyInfo& gesture_event) = 0;
  virtual void SendTouchEvent(
      const TouchEventWithLatencyInfo& touch_event) = 0;

  // Notify the router about whether the current page is mobile-optimized (i.e.,
  // the site has a mobile-friendly viewport).
  virtual void NotifySiteIsMobileOptimized(bool is_mobile_optimized) = 0;

  // Whether there are any events pending dispatch to or ack from the renderer.
  virtual bool HasPendingEvents() const = 0;

  // A scale factor to scale the coordinate in WebInputEvent from DIP
  // to viewport.
  virtual void SetDeviceScaleFactor(float device_scale_factor) = 0;

  // Sets the frame tree node id of associated frame, used when tracing
  // input event latencies to relate events to their target frames. Since
  // input always flows to Local Frame Roots, the |frameTreeNodeId| is
  // relative to the Frame associated with the Local Frame Root for the
  // widget owning this InputRouter.
  virtual void SetFrameTreeNodeId(int frameTreeNodeId) = 0;

  // Return the currently allowed touch-action.
  virtual base::Optional<cc::TouchAction> AllowedTouchAction() = 0;

  virtual void SetForceEnableZoom(bool enabled) = 0;

  // Associate this InputRouter with a remote host channel.
  virtual void BindHost(mojom::WidgetInputHandlerHostRequest request,
                        bool frame_handler) = 0;

  // Used to stop an active fling if such exists.
  virtual void StopFling() = 0;

  // Used to check if a fling cancellation is deferred due to boosting or not.
  virtual bool FlingCancellationIsDeferred() = 0;

  // Called when a set-touch-action message is received from the renderer
  // for a touch start event that is currently in flight.
  virtual void OnSetTouchAction(cc::TouchAction touch_action) = 0;

  // In the case when a gesture event is bubbled from a child frame to the main
  // frame, we set the touch action in the main frame Auto even if there is no
  // pending touch start.
  virtual void ForceSetTouchActionAuto() = 0;
};

}  // namespace content

#endif  // CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_ROUTER_H_