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/common/input/web_input_event_traits.h" | 5 #include "content/common/input/web_input_event_traits.h" |
6 | 6 |
7 #include <bitset> | 7 #include <bitset> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "content/common/input_messages.h" | |
12 | 13 |
13 using base::StringAppendF; | 14 using base::StringAppendF; |
14 using base::SStringPrintf; | 15 using base::SStringPrintf; |
15 using blink::WebGestureEvent; | 16 using blink::WebGestureEvent; |
16 using blink::WebInputEvent; | 17 using blink::WebInputEvent; |
17 using blink::WebKeyboardEvent; | 18 using blink::WebKeyboardEvent; |
18 using blink::WebMouseEvent; | 19 using blink::WebMouseEvent; |
19 using blink::WebMouseWheelEvent; | 20 using blink::WebMouseWheelEvent; |
20 using blink::WebTouchEvent; | 21 using blink::WebTouchEvent; |
21 using blink::WebTouchPoint; | 22 using blink::WebTouchPoint; |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
454 event_to_coalesce, | 455 event_to_coalesce, |
455 &event); | 456 &event); |
456 } | 457 } |
457 | 458 |
458 void WebInputEventTraits::Coalesce(const WebInputEvent& event_to_coalesce, | 459 void WebInputEventTraits::Coalesce(const WebInputEvent& event_to_coalesce, |
459 WebInputEvent* event) { | 460 WebInputEvent* event) { |
460 DCHECK(event); | 461 DCHECK(event); |
461 Apply(WebInputEventCoalesce(), event->type, event_to_coalesce, event); | 462 Apply(WebInputEventCoalesce(), event->type, event_to_coalesce, event); |
462 } | 463 } |
463 | 464 |
464 bool WebInputEventTraits::IgnoresAckDisposition(const WebInputEvent& event) { | 465 bool WebInputEventTraits::WillReceiveAckFromRenderer( |
466 const WebInputEvent& event) { | |
465 switch (event.type) { | 467 switch (event.type) { |
466 case WebInputEvent::MouseDown: | 468 case WebInputEvent::MouseDown: |
467 case WebInputEvent::MouseUp: | 469 case WebInputEvent::MouseUp: |
468 case WebInputEvent::MouseEnter: | 470 case WebInputEvent::MouseEnter: |
469 case WebInputEvent::MouseLeave: | 471 case WebInputEvent::MouseLeave: |
470 case WebInputEvent::ContextMenu: | 472 case WebInputEvent::ContextMenu: |
471 case WebInputEvent::GestureScrollBegin: | 473 case WebInputEvent::GestureScrollBegin: |
472 case WebInputEvent::GestureScrollEnd: | 474 case WebInputEvent::GestureScrollEnd: |
473 case WebInputEvent::GestureShowPress: | 475 case WebInputEvent::GestureShowPress: |
474 case WebInputEvent::GestureTapUnconfirmed: | 476 case WebInputEvent::GestureTapUnconfirmed: |
475 case WebInputEvent::GestureTapDown: | 477 case WebInputEvent::GestureTapDown: |
476 case WebInputEvent::GestureTapCancel: | 478 case WebInputEvent::GestureTapCancel: |
477 case WebInputEvent::GesturePinchBegin: | 479 case WebInputEvent::GesturePinchBegin: |
478 case WebInputEvent::GesturePinchEnd: | 480 case WebInputEvent::GesturePinchEnd: |
479 case WebInputEvent::TouchCancel: | 481 case WebInputEvent::TouchCancel: |
482 return false; | |
483 case WebInputEvent::TouchStart: | |
484 case WebInputEvent::TouchEnd: | |
485 return static_cast<const WebTouchEvent&>(event).cancelable; | |
486 default: | |
480 return true; | 487 return true; |
481 case WebInputEvent::TouchStart: | |
482 case WebInputEvent::TouchMove: | |
483 case WebInputEvent::TouchEnd: | |
484 return !static_cast<const WebTouchEvent&>(event).cancelable; | |
485 default: | |
486 return false; | |
487 } | 488 } |
488 } | 489 } |
489 | 490 |
491 scoped_ptr<IPC::Message> WebInputEventTraits::CreateAckIfNecessary( | |
492 const blink::WebInputEvent& event, | |
493 const content::InputEventAckState ack_state, | |
494 const ui::LatencyInfo& latency_info, | |
495 scoped_ptr<DidOverscrollParams> overscroll_params, | |
496 int routing_id) { | |
497 scoped_ptr<IPC::Message> response; | |
498 if (event.type == WebInputEvent::TouchMove) { | |
499 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(event); | |
500 if (!touch.cancelable) { | |
501 response = scoped_ptr<IPC::Message>( | |
jdduke (slow)
2015/04/15 17:14:53
I think we can just do:
return make_scoped_ptr(ne
lanwei
2015/04/17 20:49:00
Done.
| |
502 new InputHostMsg_HandleUncancelableTouchMoveEvent_ACK(routing_id)); | |
503 return response.Pass(); | |
504 } | |
505 } | |
506 | |
507 const bool send_ack = WebInputEventTraits::WillReceiveAckFromRenderer(event); | |
508 if (send_ack) { | |
509 DCHECK(!response); | |
510 InputHostMsg_HandleInputEvent_ACK_Params ack; | |
511 ack.type = event.type; | |
512 ack.state = ack_state; | |
513 ack.latency = latency_info; | |
514 ack.overscroll = overscroll_params.Pass(); | |
515 response = scoped_ptr<IPC::Message>( | |
jdduke (slow)
2015/04/15 17:14:53
Same here, |return make_scoped_ptr(new ...)|.
lanwei
2015/04/17 20:49:00
Done.
| |
516 new InputHostMsg_HandleInputEvent_ACK(routing_id, ack)); | |
517 } | |
518 return response.Pass(); | |
jdduke (slow)
2015/04/15 17:14:53
Then this just becomes |return nullptr;|
lanwei
2015/04/17 20:49:00
Done.
| |
519 } | |
520 | |
490 } // namespace content | 521 } // namespace content |
OLD | NEW |