OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/glue/plugins/pepper_event_conversion.h" | 5 #include "webkit/glue/plugins/pepper_event_conversion.h" |
6 | 6 |
7 #include "base/i18n/char_iterator.h" | 7 #include "base/i18n/char_iterator.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "base/utf_string_conversion_utils.h" | 12 #include "base/utf_string_conversion_utils.h" |
13 #include "ppapi/c/pp_input_event.h" | 13 #include "ppapi/c/pp_input_event.h" |
14 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" | 14 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" |
| 15 #include "webkit/glue/plugins/pepper_common.h" |
15 | 16 |
16 using WebKit::WebInputEvent; | 17 using WebKit::WebInputEvent; |
17 using WebKit::WebKeyboardEvent; | 18 using WebKit::WebKeyboardEvent; |
18 using WebKit::WebMouseEvent; | 19 using WebKit::WebMouseEvent; |
19 using WebKit::WebMouseWheelEvent; | 20 using WebKit::WebMouseWheelEvent; |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 PP_InputEvent_Type ConvertEventTypes(WebInputEvent::Type wetype) { | 24 PP_InputEvent_Type ConvertEventTypes(WebInputEvent::Type wetype) { |
24 switch (wetype) { | 25 switch (wetype) { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 void AppendMouseWheelEvent(const WebInputEvent& event, | 136 void AppendMouseWheelEvent(const WebInputEvent& event, |
136 std::vector<PP_InputEvent>* pp_events) { | 137 std::vector<PP_InputEvent>* pp_events) { |
137 const WebMouseWheelEvent& mouse_wheel_event = | 138 const WebMouseWheelEvent& mouse_wheel_event = |
138 reinterpret_cast<const WebMouseWheelEvent&>(event); | 139 reinterpret_cast<const WebMouseWheelEvent&>(event); |
139 PP_InputEvent result = GetPPEventWithCommonFieldsAndType(event); | 140 PP_InputEvent result = GetPPEventWithCommonFieldsAndType(event); |
140 result.u.wheel.modifier = mouse_wheel_event.modifiers; | 141 result.u.wheel.modifier = mouse_wheel_event.modifiers; |
141 result.u.wheel.delta_x = mouse_wheel_event.deltaX; | 142 result.u.wheel.delta_x = mouse_wheel_event.deltaX; |
142 result.u.wheel.delta_y = mouse_wheel_event.deltaY; | 143 result.u.wheel.delta_y = mouse_wheel_event.deltaY; |
143 result.u.wheel.wheel_ticks_x = mouse_wheel_event.wheelTicksX; | 144 result.u.wheel.wheel_ticks_x = mouse_wheel_event.wheelTicksX; |
144 result.u.wheel.wheel_ticks_y = mouse_wheel_event.wheelTicksY; | 145 result.u.wheel.wheel_ticks_y = mouse_wheel_event.wheelTicksY; |
145 result.u.wheel.scroll_by_page = !!mouse_wheel_event.scrollByPage; | 146 result.u.wheel.scroll_by_page = |
| 147 pepper::BoolToPPBool(!!mouse_wheel_event.scrollByPage); |
146 pp_events->push_back(result); | 148 pp_events->push_back(result); |
147 } | 149 } |
148 | 150 |
149 | 151 |
150 WebKeyboardEvent* BuildKeyEvent(const PP_InputEvent& event) { | 152 WebKeyboardEvent* BuildKeyEvent(const PP_InputEvent& event) { |
151 WebKeyboardEvent* key_event = new WebKeyboardEvent(); | 153 WebKeyboardEvent* key_event = new WebKeyboardEvent(); |
152 switch (event.type) { | 154 switch (event.type) { |
153 case PP_INPUTEVENT_TYPE_RAWKEYDOWN: | 155 case PP_INPUTEVENT_TYPE_RAWKEYDOWN: |
154 key_event->type = WebInputEvent::RawKeyDown; | 156 key_event->type = WebInputEvent::RawKeyDown; |
155 break; | 157 break; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 break; | 292 break; |
291 case PP_INPUTEVENT_TYPE_CHAR: | 293 case PP_INPUTEVENT_TYPE_CHAR: |
292 web_input_event.reset(BuildCharEvent(event)); | 294 web_input_event.reset(BuildCharEvent(event)); |
293 break; | 295 break; |
294 } | 296 } |
295 | 297 |
296 return web_input_event.release(); | 298 return web_input_event.release(); |
297 } | 299 } |
298 | 300 |
299 } // namespace pepper | 301 } // namespace pepper |
OLD | NEW |