OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/pepper/event_conversion.h" | 5 #include "content/renderer/pepper/event_conversion.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/i18n/char_iterator.h" | 8 #include "base/i18n/char_iterator.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 case PP_INPUTEVENT_TYPE_TOUCHCANCEL: | 626 case PP_INPUTEVENT_TYPE_TOUCHCANCEL: |
627 web_input_event.reset(BuildTouchEvent(event)); | 627 web_input_event.reset(BuildTouchEvent(event)); |
628 break; | 628 break; |
629 } | 629 } |
630 | 630 |
631 return web_input_event.release(); | 631 return web_input_event.release(); |
632 } | 632 } |
633 | 633 |
634 // Generate a coherent sequence of input events to simulate a user event. | 634 // Generate a coherent sequence of input events to simulate a user event. |
635 // From src/components/test_runner/event_sender.cc. | 635 // From src/components/test_runner/event_sender.cc. |
636 std::vector<linked_ptr<WebInputEvent> > CreateSimulatedWebInputEvents( | 636 std::vector<scoped_ptr<WebInputEvent>> CreateSimulatedWebInputEvents( |
637 const ppapi::InputEventData& event, | 637 const ppapi::InputEventData& event, |
638 int plugin_x, | 638 int plugin_x, |
639 int plugin_y) { | 639 int plugin_y) { |
640 std::vector<linked_ptr<WebInputEvent> > events; | 640 std::vector<scoped_ptr<WebInputEvent>> events; |
641 linked_ptr<WebInputEvent> original_event(CreateWebInputEvent(event)); | 641 scoped_ptr<WebInputEvent> original_event(CreateWebInputEvent(event)); |
642 | 642 |
643 switch (event.event_type) { | 643 switch (event.event_type) { |
644 case PP_INPUTEVENT_TYPE_MOUSEDOWN: | 644 case PP_INPUTEVENT_TYPE_MOUSEDOWN: |
645 case PP_INPUTEVENT_TYPE_MOUSEUP: | 645 case PP_INPUTEVENT_TYPE_MOUSEUP: |
646 case PP_INPUTEVENT_TYPE_MOUSEMOVE: | 646 case PP_INPUTEVENT_TYPE_MOUSEMOVE: |
647 case PP_INPUTEVENT_TYPE_MOUSEENTER: | 647 case PP_INPUTEVENT_TYPE_MOUSEENTER: |
648 case PP_INPUTEVENT_TYPE_MOUSELEAVE: | 648 case PP_INPUTEVENT_TYPE_MOUSELEAVE: |
649 case PP_INPUTEVENT_TYPE_TOUCHSTART: | 649 case PP_INPUTEVENT_TYPE_TOUCHSTART: |
650 case PP_INPUTEVENT_TYPE_TOUCHMOVE: | 650 case PP_INPUTEVENT_TYPE_TOUCHMOVE: |
651 case PP_INPUTEVENT_TYPE_TOUCHEND: | 651 case PP_INPUTEVENT_TYPE_TOUCHEND: |
652 case PP_INPUTEVENT_TYPE_TOUCHCANCEL: | 652 case PP_INPUTEVENT_TYPE_TOUCHCANCEL: |
653 events.push_back(original_event); | 653 events.push_back(std::move(original_event)); |
654 break; | 654 break; |
655 | 655 |
656 case PP_INPUTEVENT_TYPE_WHEEL: { | 656 case PP_INPUTEVENT_TYPE_WHEEL: { |
657 WebMouseWheelEvent* web_mouse_wheel_event = | 657 WebMouseWheelEvent* web_mouse_wheel_event = |
658 static_cast<WebMouseWheelEvent*>(original_event.get()); | 658 static_cast<WebMouseWheelEvent*>(original_event.get()); |
659 web_mouse_wheel_event->x = plugin_x; | 659 web_mouse_wheel_event->x = plugin_x; |
660 web_mouse_wheel_event->y = plugin_y; | 660 web_mouse_wheel_event->y = plugin_y; |
661 events.push_back(original_event); | 661 events.push_back(std::move(original_event)); |
662 break; | 662 break; |
663 } | 663 } |
664 | 664 |
665 case PP_INPUTEVENT_TYPE_RAWKEYDOWN: | 665 case PP_INPUTEVENT_TYPE_RAWKEYDOWN: |
666 case PP_INPUTEVENT_TYPE_KEYDOWN: | 666 case PP_INPUTEVENT_TYPE_KEYDOWN: |
667 case PP_INPUTEVENT_TYPE_KEYUP: { | 667 case PP_INPUTEVENT_TYPE_KEYUP: { |
668 // Windows key down events should always be "raw" to avoid an ASSERT. | 668 // Windows key down events should always be "raw" to avoid an ASSERT. |
669 #if defined(OS_WIN) | 669 #if defined(OS_WIN) |
670 WebKeyboardEvent* web_keyboard_event = | 670 WebKeyboardEvent* web_keyboard_event = |
671 static_cast<WebKeyboardEvent*>(original_event.get()); | 671 static_cast<WebKeyboardEvent*>(original_event.get()); |
672 if (web_keyboard_event->type == WebInputEvent::KeyDown) | 672 if (web_keyboard_event->type == WebInputEvent::KeyDown) |
673 web_keyboard_event->type = WebInputEvent::RawKeyDown; | 673 web_keyboard_event->type = WebInputEvent::RawKeyDown; |
674 #endif | 674 #endif |
675 events.push_back(original_event); | 675 events.push_back(std::move(original_event)); |
676 break; | 676 break; |
677 } | 677 } |
678 | 678 |
679 case PP_INPUTEVENT_TYPE_CHAR: { | 679 case PP_INPUTEVENT_TYPE_CHAR: { |
680 WebKeyboardEvent* web_char_event = | 680 WebKeyboardEvent* web_char_event = |
681 static_cast<WebKeyboardEvent*>(original_event.get()); | 681 static_cast<WebKeyboardEvent*>(original_event.get()); |
682 | 682 |
683 WebUChar code = 0, text = 0; | 683 WebUChar code = 0, text = 0; |
684 bool needs_shift_modifier = false, generate_char = false; | 684 bool needs_shift_modifier = false, generate_char = false; |
685 GetKeyCode(event.character_text, | 685 GetKeyCode(event.character_text, |
(...skipping 15 matching lines...) Expand all Loading... |
701 // If a char event is needed, set the text fields. | 701 // If a char event is needed, set the text fields. |
702 if (generate_char) { | 702 if (generate_char) { |
703 key_down_event->text[0] = text; | 703 key_down_event->text[0] = text; |
704 key_down_event->unmodifiedText[0] = text; | 704 key_down_event->unmodifiedText[0] = text; |
705 } | 705 } |
706 // Convert the key code to a string identifier. | 706 // Convert the key code to a string identifier. |
707 key_down_event->setKeyIdentifierFromWindowsKeyCode(); | 707 key_down_event->setKeyIdentifierFromWindowsKeyCode(); |
708 | 708 |
709 *key_up_event = *web_char_event = *key_down_event; | 709 *key_up_event = *web_char_event = *key_down_event; |
710 | 710 |
711 events.push_back(linked_ptr<WebInputEvent>(key_down_event.release())); | 711 events.push_back(std::move(key_down_event)); |
712 | 712 |
713 if (generate_char) { | 713 if (generate_char) { |
714 web_char_event->type = WebInputEvent::Char; | 714 web_char_event->type = WebInputEvent::Char; |
715 web_char_event->keyIdentifier[0] = '\0'; | 715 web_char_event->keyIdentifier[0] = '\0'; |
716 events.push_back(original_event); | 716 events.push_back(std::move(original_event)); |
717 } | 717 } |
718 | 718 |
719 key_up_event->type = WebInputEvent::KeyUp; | 719 key_up_event->type = WebInputEvent::KeyUp; |
720 events.push_back(linked_ptr<WebInputEvent>(key_up_event.release())); | 720 events.push_back(std::move(key_up_event)); |
721 break; | 721 break; |
722 } | 722 } |
723 | 723 |
724 default: | 724 default: |
725 break; | 725 break; |
726 } | 726 } |
727 return events; | 727 return events; |
728 } | 728 } |
729 | 729 |
730 PP_InputEvent_Class ClassifyInputEvent(WebInputEvent::Type type) { | 730 PP_InputEvent_Class ClassifyInputEvent(WebInputEvent::Type type) { |
(...skipping 18 matching lines...) Expand all Loading... |
749 case WebInputEvent::TouchStart: | 749 case WebInputEvent::TouchStart: |
750 return PP_INPUTEVENT_CLASS_TOUCH; | 750 return PP_INPUTEVENT_CLASS_TOUCH; |
751 case WebInputEvent::Undefined: | 751 case WebInputEvent::Undefined: |
752 default: | 752 default: |
753 CHECK(WebInputEvent::isGestureEventType(type)); | 753 CHECK(WebInputEvent::isGestureEventType(type)); |
754 return PP_InputEvent_Class(0); | 754 return PP_InputEvent_Class(0); |
755 } | 755 } |
756 } | 756 } |
757 | 757 |
758 } // namespace content | 758 } // namespace content |
OLD | NEW |