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" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "base/strings/utf_string_conversion_utils.h" | 13 #include "base/strings/utf_string_conversion_utils.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "content/common/input/web_touch_event_traits.h" | 15 #include "content/common/input/web_touch_event_traits.h" |
16 #include "content/renderer/pepper/usb_key_code_conversion.h" | |
17 #include "ppapi/c/pp_input_event.h" | 16 #include "ppapi/c/pp_input_event.h" |
18 #include "ppapi/shared_impl/ppb_input_event_shared.h" | 17 #include "ppapi/shared_impl/ppb_input_event_shared.h" |
19 #include "ppapi/shared_impl/time_conversion.h" | 18 #include "ppapi/shared_impl/time_conversion.h" |
20 #include "third_party/WebKit/public/platform/WebGamepads.h" | 19 #include "third_party/WebKit/public/platform/WebGamepads.h" |
21 #include "third_party/WebKit/public/platform/WebString.h" | 20 #include "third_party/WebKit/public/platform/WebString.h" |
22 #include "third_party/WebKit/public/web/WebInputEvent.h" | 21 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 22 #include "ui/events/keycodes/dom/keycode_converter.h" |
23 | 23 |
24 using ppapi::EventTimeToPPTimeTicks; | 24 using ppapi::EventTimeToPPTimeTicks; |
25 using ppapi::InputEventData; | 25 using ppapi::InputEventData; |
26 using ppapi::PPTimeTicksToEventTime; | 26 using ppapi::PPTimeTicksToEventTime; |
27 using blink::WebInputEvent; | 27 using blink::WebInputEvent; |
28 using blink::WebKeyboardEvent; | 28 using blink::WebKeyboardEvent; |
29 using blink::WebMouseEvent; | 29 using blink::WebMouseEvent; |
30 using blink::WebMouseWheelEvent; | 30 using blink::WebMouseWheelEvent; |
31 using blink::WebString; | 31 using blink::WebString; |
32 using blink::WebTouchEvent; | 32 using blink::WebTouchEvent; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 return result; | 128 return result; |
129 } | 129 } |
130 | 130 |
131 void AppendKeyEvent(const WebInputEvent& event, | 131 void AppendKeyEvent(const WebInputEvent& event, |
132 std::vector<InputEventData>* result_events) { | 132 std::vector<InputEventData>* result_events) { |
133 const WebKeyboardEvent& key_event = | 133 const WebKeyboardEvent& key_event = |
134 static_cast<const WebKeyboardEvent&>(event); | 134 static_cast<const WebKeyboardEvent&>(event); |
135 InputEventData result = GetEventWithCommonFieldsAndType(event); | 135 InputEventData result = GetEventWithCommonFieldsAndType(event); |
136 result.event_modifiers = key_event.modifiers; | 136 result.event_modifiers = key_event.modifiers; |
137 result.key_code = key_event.windowsKeyCode; | 137 result.key_code = key_event.windowsKeyCode; |
138 result.code = CodeForKeyboardEvent(key_event); | 138 result.code = ui::KeycodeConverter::DomCodeToCodeString( |
| 139 static_cast<ui::DomCode>(key_event.domCode)); |
139 result_events->push_back(result); | 140 result_events->push_back(result); |
140 } | 141 } |
141 | 142 |
142 void AppendCharEvent(const WebInputEvent& event, | 143 void AppendCharEvent(const WebInputEvent& event, |
143 std::vector<InputEventData>* result_events) { | 144 std::vector<InputEventData>* result_events) { |
144 const WebKeyboardEvent& key_event = | 145 const WebKeyboardEvent& key_event = |
145 static_cast<const WebKeyboardEvent&>(event); | 146 static_cast<const WebKeyboardEvent&>(event); |
146 | 147 |
147 // This is a bit complex, the input event will normally just have one 16-bit | 148 // This is a bit complex, the input event will normally just have one 16-bit |
148 // character in it, but may be zero or more than one. The text array is | 149 // character in it, but may be zero or more than one. The text array is |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 case WebInputEvent::TouchStart: | 743 case WebInputEvent::TouchStart: |
743 return PP_INPUTEVENT_CLASS_TOUCH; | 744 return PP_INPUTEVENT_CLASS_TOUCH; |
744 case WebInputEvent::Undefined: | 745 case WebInputEvent::Undefined: |
745 default: | 746 default: |
746 CHECK(WebInputEvent::isGestureEventType(type)); | 747 CHECK(WebInputEvent::isGestureEventType(type)); |
747 return PP_InputEvent_Class(0); | 748 return PP_InputEvent_Class(0); |
748 } | 749 } |
749 } | 750 } |
750 | 751 |
751 } // namespace content | 752 } // namespace content |
OLD | NEW |