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
92
93
94
95
96
97
98
99
100
101
102
|
// Copyright 2015 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_RENDER_WIDGET_HOST_INPUT_EVENT_ROUTER_H_
#define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_INPUT_EVENT_ROUTER_H_
#include <stdint.h>
#include <unordered_map>
#include "base/containers/hash_tables.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "cc/surfaces/surface_hittest_delegate.h"
#include "cc/surfaces/surface_id.h"
#include "content/common/content_export.h"
struct FrameHostMsg_HittestData_Params;
namespace blink {
class WebMouseEvent;
class WebMouseWheelEvent;
class WebTouchEvent;
}
namespace gfx {
class Point;
}
namespace ui {
class LatencyInfo;
}
namespace content {
class RenderWidgetHostViewBase;
// Class owned by WebContentsImpl for the purpose of directing input events
// to the correct RenderWidgetHost on pages with multiple RenderWidgetHosts.
// It maintains a mapping of RenderWidgetHostViews to Surface IDs that they
// own. When an input event requires routing based on window coordinates,
// this class requests a Surface hit test from the provided |root_view| and
// forwards the event to the owning RWHV of the returned Surface ID.
class CONTENT_EXPORT RenderWidgetHostInputEventRouter {
public:
RenderWidgetHostInputEventRouter();
~RenderWidgetHostInputEventRouter();
void RouteMouseEvent(RenderWidgetHostViewBase* root_view,
blink::WebMouseEvent* event);
void RouteMouseWheelEvent(RenderWidgetHostViewBase* root_view,
blink::WebMouseWheelEvent* event);
void RouteTouchEvent(RenderWidgetHostViewBase* root_view,
blink::WebTouchEvent *event,
const ui::LatencyInfo& latency);
void AddSurfaceIdNamespaceOwner(uint32_t id, RenderWidgetHostViewBase* owner);
void RemoveSurfaceIdNamespaceOwner(uint32_t id);
bool is_registered(uint32_t id) {
return owner_map_.find(id) != owner_map_.end();
}
void OnHittestData(const FrameHostMsg_HittestData_Params& params);
private:
struct HittestData {
bool ignored_for_hittest;
};
class HittestDelegate : public cc::SurfaceHittestDelegate {
public:
HittestDelegate(
const std::unordered_map<cc::SurfaceId, HittestData, cc::SurfaceIdHash>&
hittest_data);
bool RejectHitTarget(const cc::SurfaceDrawQuad* surface_quad,
const gfx::Point& point_in_quad_space) override;
const std::unordered_map<cc::SurfaceId, HittestData, cc::SurfaceIdHash>&
hittest_data_;
};
using WeakTarget = base::WeakPtr<RenderWidgetHostViewBase>;
using SurfaceIdNamespaceOwnerMap =
base::hash_map<uint32_t, base::WeakPtr<RenderWidgetHostViewBase>>;
RenderWidgetHostViewBase* FindEventTarget(RenderWidgetHostViewBase* root_view,
const gfx::Point& point,
gfx::Point* transformed_point);
SurfaceIdNamespaceOwnerMap owner_map_;
WeakTarget current_touch_target_;
int active_touches_;
std::unordered_map<cc::SurfaceId, HittestData, cc::SurfaceIdHash>
hittest_data_;
DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostInputEventRouter);
};
} // namespace content
#endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_INPUT_EVENT_ROUTER_H_
|