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 #include "content/renderer/input/render_widget_input_handler.h" | 5 #include "content/renderer/input/render_widget_input_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 WebInputEventResult processed = prevent_default | 299 WebInputEventResult processed = prevent_default |
300 ? WebInputEventResult::HandledSuppressed | 300 ? WebInputEventResult::HandledSuppressed |
301 : WebInputEventResult::NotHandled; | 301 : WebInputEventResult::NotHandled; |
302 if (input_event.type != WebInputEvent::Char || !suppress_next_char_events_) { | 302 if (input_event.type != WebInputEvent::Char || !suppress_next_char_events_) { |
303 suppress_next_char_events_ = false; | 303 suppress_next_char_events_ = false; |
304 if (processed == WebInputEventResult::NotHandled && widget_->webwidget()) | 304 if (processed == WebInputEventResult::NotHandled && widget_->webwidget()) |
305 processed = widget_->webwidget()->handleInputEvent(input_event); | 305 processed = widget_->webwidget()->handleInputEvent(input_event); |
306 } | 306 } |
307 | 307 |
308 bool non_blocking = | 308 bool non_blocking = |
| 309 dispatch_type == |
| 310 InputEventDispatchType::DISPATCH_TYPE_NON_BLOCKING_NOTIFY_MAIN || |
309 dispatch_type == InputEventDispatchType::DISPATCH_TYPE_NON_BLOCKING; | 311 dispatch_type == InputEventDispatchType::DISPATCH_TYPE_NON_BLOCKING; |
310 // TODO(dtapuska): Use the input_event.timeStampSeconds as the start | 312 // TODO(dtapuska): Use the input_event.timeStampSeconds as the start |
311 // ideally this should be when the event was sent by the compositor to the | 313 // ideally this should be when the event was sent by the compositor to the |
312 // renderer. crbug.com/565348 | 314 // renderer. crbug.com/565348 |
313 if (input_event.type == WebInputEvent::TouchStart || | 315 if (input_event.type == WebInputEvent::TouchStart || |
314 input_event.type == WebInputEvent::TouchMove || | 316 input_event.type == WebInputEvent::TouchMove || |
315 input_event.type == WebInputEvent::TouchEnd) { | 317 input_event.type == WebInputEvent::TouchEnd) { |
316 LogPassiveEventListenersUma( | 318 LogPassiveEventListenersUma( |
317 processed, non_blocking, | 319 processed, non_blocking, |
318 static_cast<const WebTouchEvent&>(input_event).cancelable, | 320 static_cast<const WebTouchEvent&>(input_event).cancelable, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 total_input_handling_time_this_frame_ += (end_time - start_time); | 392 total_input_handling_time_this_frame_ += (end_time - start_time); |
391 rate_limiting_wanted = | 393 rate_limiting_wanted = |
392 total_input_handling_time_this_frame_.InMicroseconds() > | 394 total_input_handling_time_this_frame_.InMicroseconds() > |
393 kInputHandlingTimeThrottlingThresholdMicroseconds; | 395 kInputHandlingTimeThrottlingThresholdMicroseconds; |
394 } | 396 } |
395 | 397 |
396 TRACE_EVENT_SYNTHETIC_DELAY_END("blink.HandleInputEvent"); | 398 TRACE_EVENT_SYNTHETIC_DELAY_END("blink.HandleInputEvent"); |
397 | 399 |
398 // Note that we can't use handling_event_type_ here since it will be overriden | 400 // Note that we can't use handling_event_type_ here since it will be overriden |
399 // by reentrant calls for events after the paused one. | 401 // by reentrant calls for events after the paused one. |
400 bool no_ack = ignore_ack_for_mouse_move_from_debugger_ && | 402 bool can_send_ack = !(ignore_ack_for_mouse_move_from_debugger_ && |
401 input_event.type == WebInputEvent::MouseMove; | 403 input_event.type == WebInputEvent::MouseMove); |
402 if (non_blocking) { | 404 if (dispatch_type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN || |
| 405 dispatch_type == DISPATCH_TYPE_NON_BLOCKING_NOTIFY_MAIN) { |
403 // |non_blocking| means it was ack'd already by the InputHandlerProxy | 406 // |non_blocking| means it was ack'd already by the InputHandlerProxy |
404 // so let the delegate know the event has been handled. | 407 // so let the delegate know the event has been handled. |
405 delegate_->NonBlockingInputEventHandled(input_event.type); | 408 delegate_->NotifyInputEventHandled(input_event.type); |
406 } else if (WebInputEventTraits::WillReceiveAckFromRenderer(input_event) && | 409 } |
407 !no_ack) { | 410 |
| 411 if ((dispatch_type == DISPATCH_TYPE_BLOCKING || |
| 412 dispatch_type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN) && |
| 413 can_send_ack) { |
408 scoped_ptr<InputEventAck> response(new InputEventAck( | 414 scoped_ptr<InputEventAck> response(new InputEventAck( |
409 input_event.type, ack_result, swap_latency_info, | 415 input_event.type, ack_result, swap_latency_info, |
410 std::move(event_overscroll), | 416 std::move(event_overscroll), |
411 WebInputEventTraits::GetUniqueTouchEventId(input_event))); | 417 WebInputEventTraits::GetUniqueTouchEventId(input_event))); |
412 if (rate_limiting_wanted && frame_pending && !widget_->is_hidden()) { | 418 if (rate_limiting_wanted && frame_pending && !widget_->is_hidden()) { |
413 // We want to rate limit the input events in this case, so we'll wait for | 419 // We want to rate limit the input events in this case, so we'll wait for |
414 // painting to finish before ACKing this message. | 420 // painting to finish before ACKing this message. |
415 TRACE_EVENT_INSTANT0( | 421 TRACE_EVENT_INSTANT0( |
416 "renderer", | 422 "renderer", |
417 "RenderWidgetInputHandler::OnHandleInputEvent ack throttled", | 423 "RenderWidgetInputHandler::OnHandleInputEvent ack throttled", |
(...skipping 12 matching lines...) Expand all Loading... |
430 "input", "RenderWidgetInputHandler::ThrottledInputEventAck", | 436 "input", "RenderWidgetInputHandler::ThrottledInputEventAck", |
431 pending_input_event_ack_.get()); | 437 pending_input_event_ack_.get()); |
432 if (widget_->compositor()) | 438 if (widget_->compositor()) |
433 widget_->compositor()->NotifyInputThrottledUntilCommit(); | 439 widget_->compositor()->NotifyInputThrottledUntilCommit(); |
434 } else { | 440 } else { |
435 delegate_->OnInputEventAck(std::move(response)); | 441 delegate_->OnInputEventAck(std::move(response)); |
436 } | 442 } |
437 } else { | 443 } else { |
438 DCHECK(!event_overscroll) << "Unexpected overscroll for un-acked event"; | 444 DCHECK(!event_overscroll) << "Unexpected overscroll for un-acked event"; |
439 } | 445 } |
440 if (!no_ack && RenderThreadImpl::current()) { | 446 if (can_send_ack && RenderThreadImpl::current()) { |
441 RenderThreadImpl::current() | 447 RenderThreadImpl::current() |
442 ->GetRendererScheduler() | 448 ->GetRendererScheduler() |
443 ->DidHandleInputEventOnMainThread(input_event); | 449 ->DidHandleInputEventOnMainThread(input_event); |
444 } | 450 } |
445 if (input_event.type == WebInputEvent::MouseMove) | 451 if (input_event.type == WebInputEvent::MouseMove) |
446 ignore_ack_for_mouse_move_from_debugger_ = false; | 452 ignore_ack_for_mouse_move_from_debugger_ = false; |
447 | 453 |
448 #if defined(OS_ANDROID) | 454 #if defined(OS_ANDROID) |
449 // Allow the IME to be shown when the focus changes as a consequence | 455 // Allow the IME to be shown when the focus changes as a consequence |
450 // of a processed touch end event. | 456 // of a processed touch end event. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 if (pending_input_event_ack_) { | 532 if (pending_input_event_ack_) { |
527 TRACE_EVENT_ASYNC_END0("input", | 533 TRACE_EVENT_ASYNC_END0("input", |
528 "RenderWidgetInputHandler::ThrottledInputEventAck", | 534 "RenderWidgetInputHandler::ThrottledInputEventAck", |
529 pending_input_event_ack_.get()); | 535 pending_input_event_ack_.get()); |
530 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); | 536 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); |
531 } | 537 } |
532 total_input_handling_time_this_frame_ = base::TimeDelta(); | 538 total_input_handling_time_this_frame_ = base::TimeDelta(); |
533 } | 539 } |
534 | 540 |
535 } // namespace content | 541 } // namespace content |
OLD | NEW |