OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/input/input_router_impl.h" | 5 #include "content/browser/renderer_host/input/input_router_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 OfferToHandlers(input_event, latency_info); | 357 OfferToHandlers(input_event, latency_info); |
358 } | 358 } |
359 | 359 |
360 void InputRouterImpl::OfferToHandlers(const WebInputEvent& input_event, | 360 void InputRouterImpl::OfferToHandlers(const WebInputEvent& input_event, |
361 const ui::LatencyInfo& latency_info) { | 361 const ui::LatencyInfo& latency_info) { |
362 output_stream_validator_.Validate(input_event); | 362 output_stream_validator_.Validate(input_event); |
363 | 363 |
364 if (OfferToClient(input_event, latency_info)) | 364 if (OfferToClient(input_event, latency_info)) |
365 return; | 365 return; |
366 | 366 |
367 OfferToRenderer(input_event, latency_info); | |
368 | |
369 // Touch events should always indicate in the event whether they are | 367 // Touch events should always indicate in the event whether they are |
370 // cancelable (respect ACK disposition) or not except touchmove. | 368 // cancelable (respect ACK disposition) or not except touchmove. |
371 bool needs_synthetic_ack = | 369 bool should_block = WebInputEventTraits::ShouldBlockEventStream(input_event); |
372 !WebInputEventTraits::WillReceiveAckFromRenderer(input_event); | 370 |
| 371 OfferToRenderer(input_event, latency_info, |
| 372 should_block |
| 373 ? InputEventDispatchType::DISPATCH_TYPE_BLOCKING |
| 374 : InputEventDispatchType::DISPATCH_TYPE_NON_BLOCKING); |
373 | 375 |
374 if (WebInputEvent::isTouchEventType(input_event.type) && | 376 if (WebInputEvent::isTouchEventType(input_event.type) && |
375 input_event.type != WebInputEvent::TouchMove) { | 377 input_event.type != WebInputEvent::TouchMove) { |
376 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(input_event); | 378 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(input_event); |
377 DCHECK_EQ(needs_synthetic_ack, !touch.cancelable); | 379 DCHECK_EQ(should_block, touch.cancelable); |
378 } | 380 } |
379 | 381 |
380 // The synthetic acks are sent immediately. | 382 // Generate a synthetic ack if the event was sent so it doesn't block. |
381 if (needs_synthetic_ack) { | 383 if (!should_block) { |
382 ProcessInputEventAck( | 384 ProcessInputEventAck( |
383 input_event.type, INPUT_EVENT_ACK_STATE_IGNORED, latency_info, | 385 input_event.type, INPUT_EVENT_ACK_STATE_IGNORED, latency_info, |
384 WebInputEventTraits::GetUniqueTouchEventId(input_event), | 386 WebInputEventTraits::GetUniqueTouchEventId(input_event), |
385 IGNORING_DISPOSITION); | 387 IGNORING_DISPOSITION); |
386 } | 388 } |
387 } | 389 } |
388 | 390 |
389 bool InputRouterImpl::OfferToClient(const WebInputEvent& input_event, | 391 bool InputRouterImpl::OfferToClient(const WebInputEvent& input_event, |
390 const ui::LatencyInfo& latency_info) { | 392 const ui::LatencyInfo& latency_info) { |
391 bool consumed = false; | 393 bool consumed = false; |
(...skipping 16 matching lines...) Expand all Loading... |
408 consumed = true; | 410 consumed = true; |
409 break; | 411 break; |
410 default: | 412 default: |
411 break; | 413 break; |
412 } | 414 } |
413 | 415 |
414 return consumed; | 416 return consumed; |
415 } | 417 } |
416 | 418 |
417 bool InputRouterImpl::OfferToRenderer(const WebInputEvent& input_event, | 419 bool InputRouterImpl::OfferToRenderer(const WebInputEvent& input_event, |
418 const ui::LatencyInfo& latency_info) { | 420 const ui::LatencyInfo& latency_info, |
| 421 InputEventDispatchType dispatch_type) { |
419 // This conversion is temporary. WebInputEvent should be generated | 422 // This conversion is temporary. WebInputEvent should be generated |
420 // directly from ui::Event with the viewport coordinates. See | 423 // directly from ui::Event with the viewport coordinates. See |
421 // crbug.com/563730. | 424 // crbug.com/563730. |
422 scoped_ptr<blink::WebInputEvent> event_in_viewport = | 425 scoped_ptr<blink::WebInputEvent> event_in_viewport = |
423 ui::ScaleWebInputEvent(input_event, device_scale_factor_); | 426 ui::ScaleWebInputEvent(input_event, device_scale_factor_); |
424 const WebInputEvent* event_to_send = | 427 const WebInputEvent* event_to_send = |
425 event_in_viewport ? event_in_viewport.get() : &input_event; | 428 event_in_viewport ? event_in_viewport.get() : &input_event; |
426 | 429 |
427 if (Send(new InputMsg_HandleInputEvent( | 430 if (Send(new InputMsg_HandleInputEvent(routing_id(), event_to_send, |
428 routing_id(), event_to_send, latency_info, | 431 latency_info, dispatch_type))) { |
429 InputEventDispatchType::DISPATCH_TYPE_NORMAL))) { | |
430 // Ack messages for ignored ack event types should never be sent by the | 432 // Ack messages for ignored ack event types should never be sent by the |
431 // renderer. Consequently, such event types should not affect event time | 433 // renderer. Consequently, such event types should not affect event time |
432 // or in-flight event count metrics. | 434 // or in-flight event count metrics. |
433 if (WebInputEventTraits::WillReceiveAckFromRenderer(*event_to_send)) { | 435 if (dispatch_type == InputEventDispatchType::DISPATCH_TYPE_BLOCKING) { |
434 input_event_start_time_ = TimeTicks::Now(); | 436 input_event_start_time_ = TimeTicks::Now(); |
435 client_->IncrementInFlightEventCount(); | 437 client_->IncrementInFlightEventCount(); |
436 } | 438 } |
437 return true; | 439 return true; |
438 } | 440 } |
439 return false; | 441 return false; |
440 } | 442 } |
441 | 443 |
442 void InputRouterImpl::OnInputEventAck(const InputEventAck& ack) { | 444 void InputRouterImpl::OnInputEventAck(const InputEventAck& ack) { |
443 client_->DecrementInFlightEventCount(); | 445 client_->DecrementInFlightEventCount(); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 | 638 |
637 flush_requested_ = false; | 639 flush_requested_ = false; |
638 client_->DidFlush(); | 640 client_->DidFlush(); |
639 } | 641 } |
640 | 642 |
641 void InputRouterImpl::SetFrameTreeNodeId(int frameTreeNodeId) { | 643 void InputRouterImpl::SetFrameTreeNodeId(int frameTreeNodeId) { |
642 frame_tree_node_id_ = frameTreeNodeId; | 644 frame_tree_node_id_ = frameTreeNodeId; |
643 } | 645 } |
644 | 646 |
645 } // namespace content | 647 } // namespace content |
OLD | NEW |