Chromium Code Reviews| 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 needs_synthetic_ack = |
| 372 !WebInputEventTraits::WillReceiveAckFromRenderer(input_event); | 370 !WebInputEventTraits::ShouldBlockEventOnRenderer(input_event); |
|
tdresser
2016/03/15 13:41:21
I'd consider having two bools, "should_block" and
dtapuska
2016/03/15 19:46:04
I changed it to should_block... I don't see how tw
tdresser
2016/03/16 15:34:47
Acknowledged.
| |
| 371 | |
| 372 OfferToRenderer(input_event, latency_info, | |
| 373 needs_synthetic_ack | |
| 374 ? InputEventDispatchType::DISPATCH_TYPE_NON_BLOCKING | |
| 375 : InputEventDispatchType::DISPATCH_TYPE_BLOCKING); | |
| 373 | 376 |
| 374 if (WebInputEvent::isTouchEventType(input_event.type) && | 377 if (WebInputEvent::isTouchEventType(input_event.type) && |
| 375 input_event.type != WebInputEvent::TouchMove) { | 378 input_event.type != WebInputEvent::TouchMove) { |
| 376 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(input_event); | 379 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(input_event); |
| 377 DCHECK_EQ(needs_synthetic_ack, !touch.cancelable); | 380 DCHECK_EQ(needs_synthetic_ack, !touch.cancelable); |
| 378 } | 381 } |
| 379 | 382 |
| 380 // The synthetic acks are sent immediately. | 383 // The synthetic acks are sent immediately. |
| 381 if (needs_synthetic_ack) { | 384 if (needs_synthetic_ack) { |
| 382 ProcessInputEventAck( | 385 ProcessInputEventAck( |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 408 consumed = true; | 411 consumed = true; |
| 409 break; | 412 break; |
| 410 default: | 413 default: |
| 411 break; | 414 break; |
| 412 } | 415 } |
| 413 | 416 |
| 414 return consumed; | 417 return consumed; |
| 415 } | 418 } |
| 416 | 419 |
| 417 bool InputRouterImpl::OfferToRenderer(const WebInputEvent& input_event, | 420 bool InputRouterImpl::OfferToRenderer(const WebInputEvent& input_event, |
| 418 const ui::LatencyInfo& latency_info) { | 421 const ui::LatencyInfo& latency_info, |
| 422 InputEventDispatchType dispatch_type) { | |
| 419 // This conversion is temporary. WebInputEvent should be generated | 423 // This conversion is temporary. WebInputEvent should be generated |
| 420 // directly from ui::Event with the viewport coordinates. See | 424 // directly from ui::Event with the viewport coordinates. See |
| 421 // crbug.com/563730. | 425 // crbug.com/563730. |
| 422 scoped_ptr<blink::WebInputEvent> event_in_viewport = | 426 scoped_ptr<blink::WebInputEvent> event_in_viewport = |
| 423 ui::ScaleWebInputEvent(input_event, device_scale_factor_); | 427 ui::ScaleWebInputEvent(input_event, device_scale_factor_); |
| 424 const WebInputEvent* event_to_send = | 428 const WebInputEvent* event_to_send = |
| 425 event_in_viewport ? event_in_viewport.get() : &input_event; | 429 event_in_viewport ? event_in_viewport.get() : &input_event; |
| 426 | 430 |
| 427 if (Send(new InputMsg_HandleInputEvent( | 431 if (Send(new InputMsg_HandleInputEvent(routing_id(), event_to_send, |
| 428 routing_id(), event_to_send, latency_info, | 432 latency_info, dispatch_type))) { |
| 429 InputEventDispatchType::DISPATCH_TYPE_NORMAL))) { | |
| 430 // Ack messages for ignored ack event types should never be sent by the | 433 // Ack messages for ignored ack event types should never be sent by the |
| 431 // renderer. Consequently, such event types should not affect event time | 434 // renderer. Consequently, such event types should not affect event time |
| 432 // or in-flight event count metrics. | 435 // or in-flight event count metrics. |
| 433 if (WebInputEventTraits::WillReceiveAckFromRenderer(*event_to_send)) { | 436 if (dispatch_type == InputEventDispatchType::DISPATCH_TYPE_BLOCKING) { |
| 434 input_event_start_time_ = TimeTicks::Now(); | 437 input_event_start_time_ = TimeTicks::Now(); |
| 435 client_->IncrementInFlightEventCount(); | 438 client_->IncrementInFlightEventCount(); |
| 436 } | 439 } |
| 437 return true; | 440 return true; |
| 438 } | 441 } |
| 439 return false; | 442 return false; |
| 440 } | 443 } |
| 441 | 444 |
| 442 void InputRouterImpl::OnInputEventAck(const InputEventAck& ack) { | 445 void InputRouterImpl::OnInputEventAck(const InputEventAck& ack) { |
| 443 client_->DecrementInFlightEventCount(); | 446 client_->DecrementInFlightEventCount(); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 636 | 639 |
| 637 flush_requested_ = false; | 640 flush_requested_ = false; |
| 638 client_->DidFlush(); | 641 client_->DidFlush(); |
| 639 } | 642 } |
| 640 | 643 |
| 641 void InputRouterImpl::SetFrameTreeNodeId(int frameTreeNodeId) { | 644 void InputRouterImpl::SetFrameTreeNodeId(int frameTreeNodeId) { |
| 642 frame_tree_node_id_ = frameTreeNodeId; | 645 frame_tree_node_id_ = frameTreeNodeId; |
| 643 } | 646 } |
| 644 | 647 |
| 645 } // namespace content | 648 } // namespace content |
| OLD | NEW |