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

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

Issue 1810693002: Ignore gesture sequences that have no target. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_input_event_router.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/debug/dump_without_crashing.h"
8 #include "cc/quads/surface_draw_quad.h" 7 #include "cc/quads/surface_draw_quad.h"
9 #include "cc/surfaces/surface_id_allocator.h" 8 #include "cc/surfaces/surface_id_allocator.h"
10 #include "cc/surfaces/surface_manager.h" 9 #include "cc/surfaces/surface_manager.h"
11 #include "content/browser/renderer_host/render_widget_host_view_base.h" 10 #include "content/browser/renderer_host/render_widget_host_view_base.h"
12 #include "content/common/frame_messages.h" 11 #include "content/common/frame_messages.h"
13 #include "third_party/WebKit/public/web/WebInputEvent.h" 12 #include "third_party/WebKit/public/web/WebInputEvent.h"
14 13
15 namespace { 14 namespace {
16 15
17 void TransformEventTouchPositions(blink::WebTouchEvent* event, 16 void TransformEventTouchPositions(blink::WebTouchEvent* event,
18 const gfx::Vector2d& delta) { 17 const gfx::Vector2d& delta) {
19 for (unsigned i = 0; i < event->touchesLength; ++i) { 18 for (unsigned i = 0; i < event->touchesLength; ++i) {
20 event->touches[i].position.x += delta.x(); 19 event->touches[i].position.x += delta.x();
21 event->touches[i].position.y += delta.y(); 20 event->touches[i].position.y += delta.y();
22 } 21 }
23 } 22 }
24 23
25 } // anonymous namespace 24 } // anonymous namespace
26 25
27 namespace content { 26 namespace content {
28 27
29 // Code to assist debugging https://crbug.com/592319.
30 RenderWidgetHostInputEventRouter::GestureQueueDebugData::GestureQueueDebugData()
31 : number_of_gesture_targets_enqueued(0),
32 number_of_gesture_targets_dequeued(0),
33 next_gesture_event_index(0),
34 next_touch_event_index(0) {
35 for (unsigned i = 0; i < kNumLastEventTypes; ++i) {
36 last_gesture_event_types[i] = blink::WebInputEvent::Undefined;
37 last_touch_event_types[i] = blink::WebInputEvent::Undefined;
38 }
39 }
40
41 void RenderWidgetHostInputEventRouter::OnRenderWidgetHostViewBaseDestroyed( 28 void RenderWidgetHostInputEventRouter::OnRenderWidgetHostViewBaseDestroyed(
42 RenderWidgetHostViewBase* view) { 29 RenderWidgetHostViewBase* view) {
43 view->RemoveObserver(this); 30 view->RemoveObserver(this);
44 31
45 // Remove this view from the owner_map. 32 // Remove this view from the owner_map.
46 for (auto entry : owner_map_) { 33 for (auto entry : owner_map_) {
47 if (entry.second == view) { 34 if (entry.second == view) {
48 owner_map_.erase(entry.first); 35 owner_map_.erase(entry.first);
49 // There will only be one instance of a particular view in the map. 36 // There will only be one instance of a particular view in the map.
50 break; 37 break;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 RenderWidgetHostViewBase* root_view, 164 RenderWidgetHostViewBase* root_view,
178 blink::WebGestureEvent* event, 165 blink::WebGestureEvent* event,
179 const ui::LatencyInfo& latency) { 166 const ui::LatencyInfo& latency) {
180 // We use GestureTapDown to detect the start of a gesture sequence since there 167 // We use GestureTapDown to detect the start of a gesture sequence since there
181 // is no WebGestureEvent equivalent for ET_GESTURE_BEGIN. Note that this 168 // is no WebGestureEvent equivalent for ET_GESTURE_BEGIN. Note that this
182 // means the GestureFlingCancel that always comes between ET_GESTURE_BEGIN and 169 // means the GestureFlingCancel that always comes between ET_GESTURE_BEGIN and
183 // GestureTapDown is sent to the previous target, in case it is still in a 170 // GestureTapDown is sent to the previous target, in case it is still in a
184 // fling. 171 // fling.
185 if (event->type == blink::WebInputEvent::GestureTapDown) { 172 if (event->type == blink::WebInputEvent::GestureTapDown) {
186 if (gesture_target_queue_.empty()) { 173 if (gesture_target_queue_.empty()) {
187 // Collect data to assist debugging https://crbug.com/592319.
188 // We'll assume for now if there's no target that we should just ignore
189 // the event.
190 LOG(ERROR) << "Gesture sequence start detected with no target available."; 174 LOG(ERROR) << "Gesture sequence start detected with no target available.";
191 base::debug::DumpWithoutCrashing(); 175 // Ignore this gesture sequence as no target is available.
tdresser 2016/03/16 19:23:00 Add a TODO with a reference to the bug to get rid
176 gesture_target_ = nullptr;
192 return; 177 return;
193 } 178 }
194 179
195 const GestureTargetData& data = gesture_target_queue_.front(); 180 const GestureTargetData& data = gesture_target_queue_.front();
196 gesture_target_ = data.target; 181 gesture_target_ = data.target;
197 gesture_delta_ = data.delta; 182 gesture_delta_ = data.delta;
198 gesture_target_queue_.pop_front(); 183 gesture_target_queue_.pop_front();
199 // Code to assist debugging https://crbug.com/592319.
200 debug_data_.number_of_gesture_targets_dequeued++;
201 } 184 }
202 185
203 // Code to assist debugging https://crbug.com/592319.
204 debug_data_.last_gesture_event_types[debug_data_.next_gesture_event_index] =
205 event->type;
206 debug_data_.next_gesture_event_index =
207 (debug_data_.next_gesture_event_index + 1) % kNumLastEventTypes;
208
209 if (!gesture_target_) 186 if (!gesture_target_)
210 return; 187 return;
211 188
212 event->x += gesture_delta_.x(); 189 event->x += gesture_delta_.x();
213 event->y += gesture_delta_.y(); 190 event->y += gesture_delta_.y();
214 gesture_target_->ProcessGestureEvent(*event, latency); 191 gesture_target_->ProcessGestureEvent(*event, latency);
215 } 192 }
216 193
217 void RenderWidgetHostInputEventRouter::RouteTouchEvent( 194 void RenderWidgetHostInputEventRouter::RouteTouchEvent(
218 RenderWidgetHostViewBase* root_view, 195 RenderWidgetHostViewBase* root_view,
219 blink::WebTouchEvent* event, 196 blink::WebTouchEvent* event,
220 const ui::LatencyInfo& latency) { 197 const ui::LatencyInfo& latency) {
221 // Code to assist debugging https://crbug.com/592319.
222 debug_data_.last_touch_event_types[debug_data_.next_touch_event_index] =
223 event->type;
224 debug_data_.next_touch_event_index =
225 (debug_data_.next_touch_event_index + 1) % kNumLastEventTypes;
226
227 switch (event->type) { 198 switch (event->type) {
228 case blink::WebInputEvent::TouchStart: { 199 case blink::WebInputEvent::TouchStart: {
229 if (!active_touches_) { 200 if (!active_touches_) {
230 // Since this is the first touch, it defines the target for the rest 201 // Since this is the first touch, it defines the target for the rest
231 // of this sequence. 202 // of this sequence.
232 DCHECK(!touch_target_); 203 DCHECK(!touch_target_);
233 gfx::Point transformed_point; 204 gfx::Point transformed_point;
234 gfx::Point original_point(event->touches[0].position.x, 205 gfx::Point original_point(event->touches[0].position.x,
235 event->touches[0].position.y); 206 event->touches[0].position.y);
236 touch_target_ = 207 touch_target_ =
237 FindEventTarget(root_view, original_point, &transformed_point); 208 FindEventTarget(root_view, original_point, &transformed_point);
238 209
239 // TODO(wjmaclean): Instead of just computing a delta, we should extract 210 // TODO(wjmaclean): Instead of just computing a delta, we should extract
240 // the complete transform. We assume it doesn't change for the duration 211 // the complete transform. We assume it doesn't change for the duration
241 // of the touch sequence, though this could be wrong; a better approach 212 // of the touch sequence, though this could be wrong; a better approach
242 // might be to always transform each point to the touch_target_ 213 // might be to always transform each point to the touch_target_
243 // for the duration of the sequence. 214 // for the duration of the sequence.
244 touch_delta_ = transformed_point - original_point; 215 touch_delta_ = transformed_point - original_point;
245 gesture_target_queue_.emplace_back(touch_target_, touch_delta_); 216 gesture_target_queue_.emplace_back(touch_target_, touch_delta_);
246 // Code to assist debugging https://crbug.com/592319.
247 debug_data_.number_of_gesture_targets_enqueued++;
248 217
249 if (!touch_target_) 218 if (!touch_target_)
250 return; 219 return;
251 } 220 }
252 ++active_touches_; 221 ++active_touches_;
253 if (touch_target_) { 222 if (touch_target_) {
254 TransformEventTouchPositions(event, touch_delta_); 223 TransformEventTouchPositions(event, touch_delta_);
255 touch_target_->ProcessTouchEvent(*event, latency); 224 touch_target_->ProcessTouchEvent(*event, latency);
256 } 225 }
257 break; 226 break;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 if (owner_map_.find(cc::SurfaceIdAllocator::NamespaceForId( 281 if (owner_map_.find(cc::SurfaceIdAllocator::NamespaceForId(
313 params.surface_id)) == owner_map_.end()) { 282 params.surface_id)) == owner_map_.end()) {
314 return; 283 return;
315 } 284 }
316 HittestData data; 285 HittestData data;
317 data.ignored_for_hittest = params.ignored_for_hittest; 286 data.ignored_for_hittest = params.ignored_for_hittest;
318 hittest_data_[params.surface_id] = data; 287 hittest_data_[params.surface_id] = data;
319 } 288 }
320 289
321 } // namespace content 290 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_input_event_router.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698