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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
| 11 #include <memory> |
| 12 |
11 #include "base/i18n/char_iterator.h" | 13 #include "base/i18n/char_iterator.h" |
12 #include "base/logging.h" | 14 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
17 #include "base/strings/utf_string_conversion_utils.h" | 18 #include "base/strings/utf_string_conversion_utils.h" |
18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
19 #include "build/build_config.h" | 20 #include "build/build_config.h" |
20 #include "content/common/input/web_touch_event_traits.h" | 21 #include "content/common/input/web_touch_event_traits.h" |
21 #include "ppapi/c/pp_input_event.h" | 22 #include "ppapi/c/pp_input_event.h" |
22 #include "ppapi/shared_impl/ppb_input_event_shared.h" | 23 #include "ppapi/shared_impl/ppb_input_event_shared.h" |
23 #include "third_party/WebKit/public/platform/WebGamepads.h" | 24 #include "third_party/WebKit/public/platform/WebGamepads.h" |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 case WebInputEvent::TouchCancel: | 577 case WebInputEvent::TouchCancel: |
577 AppendTouchEvent(event, result); | 578 AppendTouchEvent(event, result); |
578 break; | 579 break; |
579 case WebInputEvent::Undefined: | 580 case WebInputEvent::Undefined: |
580 default: | 581 default: |
581 break; | 582 break; |
582 } | 583 } |
583 } | 584 } |
584 | 585 |
585 WebInputEvent* CreateWebInputEvent(const InputEventData& event) { | 586 WebInputEvent* CreateWebInputEvent(const InputEventData& event) { |
586 scoped_ptr<WebInputEvent> web_input_event; | 587 std::unique_ptr<WebInputEvent> web_input_event; |
587 switch (event.event_type) { | 588 switch (event.event_type) { |
588 case PP_INPUTEVENT_TYPE_UNDEFINED: | 589 case PP_INPUTEVENT_TYPE_UNDEFINED: |
589 return NULL; | 590 return NULL; |
590 case PP_INPUTEVENT_TYPE_MOUSEDOWN: | 591 case PP_INPUTEVENT_TYPE_MOUSEDOWN: |
591 case PP_INPUTEVENT_TYPE_MOUSEUP: | 592 case PP_INPUTEVENT_TYPE_MOUSEUP: |
592 case PP_INPUTEVENT_TYPE_MOUSEMOVE: | 593 case PP_INPUTEVENT_TYPE_MOUSEMOVE: |
593 case PP_INPUTEVENT_TYPE_MOUSEENTER: | 594 case PP_INPUTEVENT_TYPE_MOUSEENTER: |
594 case PP_INPUTEVENT_TYPE_MOUSELEAVE: | 595 case PP_INPUTEVENT_TYPE_MOUSELEAVE: |
595 case PP_INPUTEVENT_TYPE_CONTEXTMENU: | 596 case PP_INPUTEVENT_TYPE_CONTEXTMENU: |
596 web_input_event.reset(BuildMouseEvent(event)); | 597 web_input_event.reset(BuildMouseEvent(event)); |
(...skipping 23 matching lines...) Expand all Loading... |
620 case PP_INPUTEVENT_TYPE_TOUCHCANCEL: | 621 case PP_INPUTEVENT_TYPE_TOUCHCANCEL: |
621 web_input_event.reset(BuildTouchEvent(event)); | 622 web_input_event.reset(BuildTouchEvent(event)); |
622 break; | 623 break; |
623 } | 624 } |
624 | 625 |
625 return web_input_event.release(); | 626 return web_input_event.release(); |
626 } | 627 } |
627 | 628 |
628 // Generate a coherent sequence of input events to simulate a user event. | 629 // Generate a coherent sequence of input events to simulate a user event. |
629 // From src/components/test_runner/event_sender.cc. | 630 // From src/components/test_runner/event_sender.cc. |
630 std::vector<scoped_ptr<WebInputEvent>> CreateSimulatedWebInputEvents( | 631 std::vector<std::unique_ptr<WebInputEvent>> CreateSimulatedWebInputEvents( |
631 const ppapi::InputEventData& event, | 632 const ppapi::InputEventData& event, |
632 int plugin_x, | 633 int plugin_x, |
633 int plugin_y) { | 634 int plugin_y) { |
634 std::vector<scoped_ptr<WebInputEvent>> events; | 635 std::vector<std::unique_ptr<WebInputEvent>> events; |
635 scoped_ptr<WebInputEvent> original_event(CreateWebInputEvent(event)); | 636 std::unique_ptr<WebInputEvent> original_event(CreateWebInputEvent(event)); |
636 | 637 |
637 switch (event.event_type) { | 638 switch (event.event_type) { |
638 case PP_INPUTEVENT_TYPE_MOUSEDOWN: | 639 case PP_INPUTEVENT_TYPE_MOUSEDOWN: |
639 case PP_INPUTEVENT_TYPE_MOUSEUP: | 640 case PP_INPUTEVENT_TYPE_MOUSEUP: |
640 case PP_INPUTEVENT_TYPE_MOUSEMOVE: | 641 case PP_INPUTEVENT_TYPE_MOUSEMOVE: |
641 case PP_INPUTEVENT_TYPE_MOUSEENTER: | 642 case PP_INPUTEVENT_TYPE_MOUSEENTER: |
642 case PP_INPUTEVENT_TYPE_MOUSELEAVE: | 643 case PP_INPUTEVENT_TYPE_MOUSELEAVE: |
643 case PP_INPUTEVENT_TYPE_TOUCHSTART: | 644 case PP_INPUTEVENT_TYPE_TOUCHSTART: |
644 case PP_INPUTEVENT_TYPE_TOUCHMOVE: | 645 case PP_INPUTEVENT_TYPE_TOUCHMOVE: |
645 case PP_INPUTEVENT_TYPE_TOUCHEND: | 646 case PP_INPUTEVENT_TYPE_TOUCHEND: |
(...skipping 30 matching lines...) Expand all Loading... |
676 | 677 |
677 WebUChar code = 0, text = 0; | 678 WebUChar code = 0, text = 0; |
678 bool needs_shift_modifier = false, generate_char = false; | 679 bool needs_shift_modifier = false, generate_char = false; |
679 GetKeyCode(event.character_text, | 680 GetKeyCode(event.character_text, |
680 &code, | 681 &code, |
681 &text, | 682 &text, |
682 &needs_shift_modifier, | 683 &needs_shift_modifier, |
683 &generate_char); | 684 &generate_char); |
684 | 685 |
685 // Synthesize key down and key up events in all cases. | 686 // Synthesize key down and key up events in all cases. |
686 scoped_ptr<WebKeyboardEvent> key_down_event(new WebKeyboardEvent()); | 687 std::unique_ptr<WebKeyboardEvent> key_down_event(new WebKeyboardEvent()); |
687 scoped_ptr<WebKeyboardEvent> key_up_event(new WebKeyboardEvent()); | 688 std::unique_ptr<WebKeyboardEvent> key_up_event(new WebKeyboardEvent()); |
688 | 689 |
689 key_down_event->type = WebInputEvent::RawKeyDown; | 690 key_down_event->type = WebInputEvent::RawKeyDown; |
690 key_down_event->windowsKeyCode = code; | 691 key_down_event->windowsKeyCode = code; |
691 key_down_event->nativeKeyCode = code; | 692 key_down_event->nativeKeyCode = code; |
692 if (needs_shift_modifier) | 693 if (needs_shift_modifier) |
693 key_down_event->modifiers |= WebInputEvent::ShiftKey; | 694 key_down_event->modifiers |= WebInputEvent::ShiftKey; |
694 | 695 |
695 // If a char event is needed, set the text fields. | 696 // If a char event is needed, set the text fields. |
696 if (generate_char) { | 697 if (generate_char) { |
697 key_down_event->text[0] = text; | 698 key_down_event->text[0] = text; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 case WebInputEvent::TouchStart: | 744 case WebInputEvent::TouchStart: |
744 return PP_INPUTEVENT_CLASS_TOUCH; | 745 return PP_INPUTEVENT_CLASS_TOUCH; |
745 case WebInputEvent::Undefined: | 746 case WebInputEvent::Undefined: |
746 default: | 747 default: |
747 CHECK(WebInputEvent::isGestureEventType(type)); | 748 CHECK(WebInputEvent::isGestureEventType(type)); |
748 return PP_InputEvent_Class(0); | 749 return PP_InputEvent_Class(0); |
749 } | 750 } |
750 } | 751 } |
751 | 752 |
752 } // namespace content | 753 } // namespace content |
OLD | NEW |