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

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

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