| OLD | NEW | 
|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_INPUT_EVENT_ROUTER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_INPUT_EVENT_ROUTER_H_ | 
| 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_INPUT_EVENT_ROUTER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_INPUT_EVENT_ROUTER_H_ | 
| 7 | 7 | 
| 8 #include <stdint.h> | 8 #include <stdint.h> | 
| 9 #include <unordered_map> | 9 #include <unordered_map> | 
| 10 | 10 | 
| 11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" | 
| 12 #include "base/macros.h" | 12 #include "base/macros.h" | 
| 13 #include "base/memory/weak_ptr.h" |  | 
| 14 #include "cc/surfaces/surface_hittest_delegate.h" | 13 #include "cc/surfaces/surface_hittest_delegate.h" | 
| 15 #include "cc/surfaces/surface_id.h" | 14 #include "cc/surfaces/surface_id.h" | 
|  | 15 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h" | 
| 16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" | 
| 17 | 17 | 
| 18 struct FrameHostMsg_HittestData_Params; | 18 struct FrameHostMsg_HittestData_Params; | 
| 19 | 19 | 
| 20 namespace blink { | 20 namespace blink { | 
| 21 class WebMouseEvent; | 21 class WebMouseEvent; | 
| 22 class WebMouseWheelEvent; | 22 class WebMouseWheelEvent; | 
| 23 class WebTouchEvent; | 23 class WebTouchEvent; | 
| 24 } | 24 } | 
| 25 | 25 | 
| 26 namespace gfx { | 26 namespace gfx { | 
| 27 class Point; | 27 class Point; | 
| 28 } | 28 } | 
| 29 | 29 | 
| 30 namespace ui { | 30 namespace ui { | 
| 31 class LatencyInfo; | 31 class LatencyInfo; | 
| 32 } | 32 } | 
| 33 | 33 | 
| 34 namespace content { | 34 namespace content { | 
| 35 | 35 | 
| 36 class RenderWidgetHostViewBase; | 36 class RenderWidgetHostViewBase; | 
| 37 | 37 | 
| 38 // Class owned by WebContentsImpl for the purpose of directing input events | 38 // Class owned by WebContentsImpl for the purpose of directing input events | 
| 39 // to the correct RenderWidgetHost on pages with multiple RenderWidgetHosts. | 39 // to the correct RenderWidgetHost on pages with multiple RenderWidgetHosts. | 
| 40 // It maintains a mapping of RenderWidgetHostViews to Surface IDs that they | 40 // It maintains a mapping of RenderWidgetHostViews to Surface IDs that they | 
| 41 // own. When an input event requires routing based on window coordinates, | 41 // own. When an input event requires routing based on window coordinates, | 
| 42 // this class requests a Surface hit test from the provided |root_view| and | 42 // this class requests a Surface hit test from the provided |root_view| and | 
| 43 // forwards the event to the owning RWHV of the returned Surface ID. | 43 // forwards the event to the owning RWHV of the returned Surface ID. | 
| 44 class CONTENT_EXPORT RenderWidgetHostInputEventRouter { | 44 class CONTENT_EXPORT RenderWidgetHostInputEventRouter | 
|  | 45     : public RenderWidgetHostViewBaseObserver { | 
| 45  public: | 46  public: | 
| 46   RenderWidgetHostInputEventRouter(); | 47   RenderWidgetHostInputEventRouter(); | 
| 47   ~RenderWidgetHostInputEventRouter(); | 48   ~RenderWidgetHostInputEventRouter() final; | 
|  | 49 | 
|  | 50   void OnRenderWidgetHostViewBaseDestroyed( | 
|  | 51       RenderWidgetHostViewBase* view) override; | 
| 48 | 52 | 
| 49   void RouteMouseEvent(RenderWidgetHostViewBase* root_view, | 53   void RouteMouseEvent(RenderWidgetHostViewBase* root_view, | 
| 50                        blink::WebMouseEvent* event); | 54                        blink::WebMouseEvent* event); | 
| 51   void RouteMouseWheelEvent(RenderWidgetHostViewBase* root_view, | 55   void RouteMouseWheelEvent(RenderWidgetHostViewBase* root_view, | 
| 52                             blink::WebMouseWheelEvent* event); | 56                             blink::WebMouseWheelEvent* event); | 
| 53   void RouteTouchEvent(RenderWidgetHostViewBase* root_view, | 57   void RouteTouchEvent(RenderWidgetHostViewBase* root_view, | 
| 54                        blink::WebTouchEvent *event, | 58                        blink::WebTouchEvent *event, | 
| 55                        const ui::LatencyInfo& latency); | 59                        const ui::LatencyInfo& latency); | 
| 56 | 60 | 
| 57   void AddSurfaceIdNamespaceOwner(uint32_t id, RenderWidgetHostViewBase* owner); | 61   void AddSurfaceIdNamespaceOwner(uint32_t id, RenderWidgetHostViewBase* owner); | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 75             hittest_data); | 79             hittest_data); | 
| 76     bool RejectHitTarget(const cc::SurfaceDrawQuad* surface_quad, | 80     bool RejectHitTarget(const cc::SurfaceDrawQuad* surface_quad, | 
| 77                          const gfx::Point& point_in_quad_space) override; | 81                          const gfx::Point& point_in_quad_space) override; | 
| 78     bool AcceptHitTarget(const cc::SurfaceDrawQuad* surface_quad, | 82     bool AcceptHitTarget(const cc::SurfaceDrawQuad* surface_quad, | 
| 79                          const gfx::Point& point_in_quad_space) override; | 83                          const gfx::Point& point_in_quad_space) override; | 
| 80 | 84 | 
| 81     const std::unordered_map<cc::SurfaceId, HittestData, cc::SurfaceIdHash>& | 85     const std::unordered_map<cc::SurfaceId, HittestData, cc::SurfaceIdHash>& | 
| 82         hittest_data_; | 86         hittest_data_; | 
| 83   }; | 87   }; | 
| 84 | 88 | 
| 85   using WeakTarget = base::WeakPtr<RenderWidgetHostViewBase>; |  | 
| 86   using SurfaceIdNamespaceOwnerMap = | 89   using SurfaceIdNamespaceOwnerMap = | 
| 87       base::hash_map<uint32_t, base::WeakPtr<RenderWidgetHostViewBase>>; | 90       base::hash_map<uint32_t, RenderWidgetHostViewBase*>; | 
|  | 91 | 
|  | 92   void ClearAllObserverRegistrations(); | 
| 88 | 93 | 
| 89   RenderWidgetHostViewBase* FindEventTarget(RenderWidgetHostViewBase* root_view, | 94   RenderWidgetHostViewBase* FindEventTarget(RenderWidgetHostViewBase* root_view, | 
| 90                                             const gfx::Point& point, | 95                                             const gfx::Point& point, | 
| 91                                             gfx::Point* transformed_point); | 96                                             gfx::Point* transformed_point); | 
| 92 | 97 | 
| 93   SurfaceIdNamespaceOwnerMap owner_map_; | 98   SurfaceIdNamespaceOwnerMap owner_map_; | 
| 94   WeakTarget current_touch_target_; | 99   RenderWidgetHostViewBase* current_touch_target_; | 
| 95   int active_touches_; | 100   int active_touches_; | 
| 96   std::unordered_map<cc::SurfaceId, HittestData, cc::SurfaceIdHash> | 101   std::unordered_map<cc::SurfaceId, HittestData, cc::SurfaceIdHash> | 
| 97       hittest_data_; | 102       hittest_data_; | 
| 98 | 103 | 
| 99   DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostInputEventRouter); | 104   DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostInputEventRouter); | 
| 100 }; | 105 }; | 
| 101 | 106 | 
| 102 }  // namespace content | 107 }  // namespace content | 
| 103 | 108 | 
| 104 #endif  // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_INPUT_EVENT_ROUTER_H
     _ | 109 #endif  // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_INPUT_EVENT_ROUTER_H
     _ | 
| OLD | NEW | 
|---|