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

Side by Side Diff: content/browser/renderer_host/render_widget_host_input_event_router.cc

Issue 1643063002: Revert of Handle pointer-events: none in browser process hittesting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
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 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" 5 #include "content/browser/renderer_host/render_widget_host_input_event_router.h"
6 6
7 #include "cc/quads/surface_draw_quad.h"
8 #include "cc/surfaces/surface_id_allocator.h"
9 #include "cc/surfaces/surface_manager.h" 7 #include "cc/surfaces/surface_manager.h"
10 #include "content/browser/renderer_host/render_widget_host_view_base.h" 8 #include "content/browser/renderer_host/render_widget_host_view_base.h"
11 #include "content/common/frame_messages.h"
12 #include "third_party/WebKit/public/web/WebInputEvent.h" 9 #include "third_party/WebKit/public/web/WebInputEvent.h"
13 10
14 namespace content { 11 namespace content {
15 12
16 RenderWidgetHostInputEventRouter::HittestDelegate::HittestDelegate(
17 const std::unordered_map<cc::SurfaceId, HittestData, cc::SurfaceIdHash>&
18 hittest_data)
19 : hittest_data_(hittest_data) {}
20
21 bool RenderWidgetHostInputEventRouter::HittestDelegate::RejectHitTarget(
22 const cc::SurfaceDrawQuad* surface_quad,
23 const gfx::Point& point_in_quad_space) {
24 auto it = hittest_data_.find(surface_quad->surface_id);
25 if (it != hittest_data_.end() && it->second.ignored_for_hittest)
26 return true;
27 return false;
28 }
29
30 RenderWidgetHostInputEventRouter::RenderWidgetHostInputEventRouter() 13 RenderWidgetHostInputEventRouter::RenderWidgetHostInputEventRouter()
31 : active_touches_(0) {} 14 : active_touches_(0) {}
32 15
33 RenderWidgetHostInputEventRouter::~RenderWidgetHostInputEventRouter() { 16 RenderWidgetHostInputEventRouter::~RenderWidgetHostInputEventRouter() {
34 owner_map_.clear(); 17 owner_map_.clear();
35 } 18 }
36 19
37 RenderWidgetHostViewBase* RenderWidgetHostInputEventRouter::FindEventTarget( 20 RenderWidgetHostViewBase* RenderWidgetHostInputEventRouter::FindEventTarget(
38 RenderWidgetHostViewBase* root_view, 21 RenderWidgetHostViewBase* root_view,
39 const gfx::Point& point, 22 const gfx::Point& point,
40 gfx::Point* transformed_point) { 23 gfx::Point* transformed_point) {
41 // Short circuit if owner_map has only one RenderWidgetHostView, no need for 24 // Short circuit if owner_map has only one RenderWidgetHostView, no need for
42 // hit testing. 25 // hit testing.
43 if (owner_map_.size() <= 1) { 26 if (owner_map_.size() <= 1) {
44 *transformed_point = point; 27 *transformed_point = point;
45 return root_view; 28 return root_view;
46 } 29 }
47 30
48 // The hittest delegate is used to reject hittesting quads based on extra
49 // hittesting data send by the renderer.
50 HittestDelegate delegate(hittest_data_);
51
52 // The conversion of point to transform_point is done over the course of the 31 // The conversion of point to transform_point is done over the course of the
53 // hit testing, and reflect transformations that would normally be applied in 32 // hit testing, and reflect transformations that would normally be applied in
54 // the renderer process if the event was being routed between frames within a 33 // the renderer process if the event was being routed between frames within a
55 // single process with only one RenderWidgetHost. 34 // single process with only one RenderWidgetHost.
56 uint32_t surface_id_namespace = 35 uint32_t surface_id_namespace =
57 root_view->SurfaceIdNamespaceAtPoint(&delegate, point, transformed_point); 36 root_view->SurfaceIdNamespaceAtPoint(point, transformed_point);
58 const SurfaceIdNamespaceOwnerMap::iterator iter = 37 const SurfaceIdNamespaceOwnerMap::iterator iter =
59 owner_map_.find(surface_id_namespace); 38 owner_map_.find(surface_id_namespace);
60 // If the point hit a Surface whose namspace is no longer in the map, then 39 // If the point hit a Surface whose namspace is no longer in the map, then
61 // it likely means the RenderWidgetHostView has been destroyed but its 40 // it likely means the RenderWidgetHostView has been destroyed but its
62 // parent frame has not sent a new compositor frame since that happened. 41 // parent frame has not sent a new compositor frame since that happened.
63 if (iter == owner_map_.end()) 42 if (iter == owner_map_.end())
64 return root_view; 43 return root_view;
65 RenderWidgetHostViewBase* target = iter->second.get(); 44 RenderWidgetHostViewBase* target = iter->second.get();
66 // If we find the weak pointer is now null, it means the map entry is stale 45 // If we find the weak pointer is now null, it means the map entry is stale
67 // and should be removed to free space. 46 // and should be removed to free space.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 void RenderWidgetHostInputEventRouter::AddSurfaceIdNamespaceOwner( 127 void RenderWidgetHostInputEventRouter::AddSurfaceIdNamespaceOwner(
149 uint32_t id, 128 uint32_t id,
150 RenderWidgetHostViewBase* owner) { 129 RenderWidgetHostViewBase* owner) {
151 DCHECK(owner_map_.find(id) == owner_map_.end()); 130 DCHECK(owner_map_.find(id) == owner_map_.end());
152 owner_map_.insert(std::make_pair(id, owner->GetWeakPtr())); 131 owner_map_.insert(std::make_pair(id, owner->GetWeakPtr()));
153 } 132 }
154 133
155 void RenderWidgetHostInputEventRouter::RemoveSurfaceIdNamespaceOwner( 134 void RenderWidgetHostInputEventRouter::RemoveSurfaceIdNamespaceOwner(
156 uint32_t id) { 135 uint32_t id) {
157 owner_map_.erase(id); 136 owner_map_.erase(id);
158
159 for (auto it = hittest_data_.begin(); it != hittest_data_.end();) {
160 if (cc::SurfaceIdAllocator::NamespaceForId(it->first) == id)
161 it = hittest_data_.erase(it);
162 else
163 ++it;
164 }
165 }
166
167 void RenderWidgetHostInputEventRouter::OnHittestData(
168 const FrameHostMsg_HittestData_Params& params) {
169 if (owner_map_.find(cc::SurfaceIdAllocator::NamespaceForId(
170 params.surface_id)) == owner_map_.end()) {
171 return;
172 }
173 HittestData data;
174 data.ignored_for_hittest = params.ignored_for_hittest;
175 hittest_data_[params.surface_id] = data;
176 } 137 }
177 138
178 } // namespace content 139 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698