| 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 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 206 |
| 207 const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event); | 207 const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event); |
| 208 InputEventData result = GetEventWithCommonFieldsAndType(event); | 208 InputEventData result = GetEventWithCommonFieldsAndType(event); |
| 209 result.event_modifiers = ConvertEventModifiers(mouse_event.modifiers()); | 209 result.event_modifiers = ConvertEventModifiers(mouse_event.modifiers()); |
| 210 if (mouse_event.type() == WebInputEvent::MouseDown || | 210 if (mouse_event.type() == WebInputEvent::MouseDown || |
| 211 mouse_event.type() == WebInputEvent::MouseMove || | 211 mouse_event.type() == WebInputEvent::MouseMove || |
| 212 mouse_event.type() == WebInputEvent::MouseUp) { | 212 mouse_event.type() == WebInputEvent::MouseUp) { |
| 213 result.mouse_button = | 213 result.mouse_button = |
| 214 static_cast<PP_InputEvent_MouseButton>(mouse_event.button); | 214 static_cast<PP_InputEvent_MouseButton>(mouse_event.button); |
| 215 } | 215 } |
| 216 result.mouse_position.x = mouse_event.x; | 216 result.mouse_position.x = mouse_event.positionInWidget().x; |
| 217 result.mouse_position.y = mouse_event.y; | 217 result.mouse_position.y = mouse_event.positionInWidget().y; |
| 218 result.mouse_click_count = mouse_event.clickCount; | 218 result.mouse_click_count = mouse_event.clickCount; |
| 219 result.mouse_movement.x = mouse_event.movementX; | 219 result.mouse_movement.x = mouse_event.movementX; |
| 220 result.mouse_movement.y = mouse_event.movementY; | 220 result.mouse_movement.y = mouse_event.movementY; |
| 221 result_events->push_back(result); | 221 result_events->push_back(result); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void AppendMouseWheelEvent(const WebInputEvent& event, | 224 void AppendMouseWheelEvent(const WebInputEvent& event, |
| 225 std::vector<InputEventData>* result_events) { | 225 std::vector<InputEventData>* result_events) { |
| 226 const WebMouseWheelEvent& mouse_wheel_event = | 226 const WebMouseWheelEvent& mouse_wheel_event = |
| 227 static_cast<const WebMouseWheelEvent&>(event); | 227 static_cast<const WebMouseWheelEvent&>(event); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 mouse_event->pointerType = blink::WebPointerProperties::PointerType::Mouse; | 459 mouse_event->pointerType = blink::WebPointerProperties::PointerType::Mouse; |
| 460 mouse_event->button = static_cast<WebMouseEvent::Button>(event.mouse_button); | 460 mouse_event->button = static_cast<WebMouseEvent::Button>(event.mouse_button); |
| 461 if (mouse_event->type() == WebInputEvent::MouseMove) { | 461 if (mouse_event->type() == WebInputEvent::MouseMove) { |
| 462 if (mouse_event->modifiers() & WebInputEvent::LeftButtonDown) | 462 if (mouse_event->modifiers() & WebInputEvent::LeftButtonDown) |
| 463 mouse_event->button = WebMouseEvent::Button::Left; | 463 mouse_event->button = WebMouseEvent::Button::Left; |
| 464 else if (mouse_event->modifiers() & WebInputEvent::MiddleButtonDown) | 464 else if (mouse_event->modifiers() & WebInputEvent::MiddleButtonDown) |
| 465 mouse_event->button = WebMouseEvent::Button::Middle; | 465 mouse_event->button = WebMouseEvent::Button::Middle; |
| 466 else if (mouse_event->modifiers() & WebInputEvent::RightButtonDown) | 466 else if (mouse_event->modifiers() & WebInputEvent::RightButtonDown) |
| 467 mouse_event->button = WebMouseEvent::Button::Right; | 467 mouse_event->button = WebMouseEvent::Button::Right; |
| 468 } | 468 } |
| 469 mouse_event->x = event.mouse_position.x; | 469 mouse_event->setPositionInWidget(event.mouse_position.x, |
| 470 mouse_event->y = event.mouse_position.y; | 470 event.mouse_position.y); |
| 471 mouse_event->clickCount = event.mouse_click_count; | 471 mouse_event->clickCount = event.mouse_click_count; |
| 472 mouse_event->movementX = event.mouse_movement.x; | 472 mouse_event->movementX = event.mouse_movement.x; |
| 473 mouse_event->movementY = event.mouse_movement.y; | 473 mouse_event->movementY = event.mouse_movement.y; |
| 474 return mouse_event; | 474 return mouse_event; |
| 475 } | 475 } |
| 476 | 476 |
| 477 WebMouseWheelEvent* BuildMouseWheelEvent(const InputEventData& event) { | 477 WebMouseWheelEvent* BuildMouseWheelEvent(const InputEventData& event) { |
| 478 WebMouseWheelEvent* mouse_wheel_event = new WebMouseWheelEvent( | 478 WebMouseWheelEvent* mouse_wheel_event = new WebMouseWheelEvent( |
| 479 WebInputEvent::MouseWheel, event.event_modifiers, event.event_time_stamp); | 479 WebInputEvent::MouseWheel, event.event_modifiers, event.event_time_stamp); |
| 480 mouse_wheel_event->deltaX = event.wheel_delta.x; | 480 mouse_wheel_event->deltaX = event.wheel_delta.x; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 case PP_INPUTEVENT_TYPE_TOUCHSTART: | 668 case PP_INPUTEVENT_TYPE_TOUCHSTART: |
| 669 case PP_INPUTEVENT_TYPE_TOUCHMOVE: | 669 case PP_INPUTEVENT_TYPE_TOUCHMOVE: |
| 670 case PP_INPUTEVENT_TYPE_TOUCHEND: | 670 case PP_INPUTEVENT_TYPE_TOUCHEND: |
| 671 case PP_INPUTEVENT_TYPE_TOUCHCANCEL: | 671 case PP_INPUTEVENT_TYPE_TOUCHCANCEL: |
| 672 events.push_back(std::move(original_event)); | 672 events.push_back(std::move(original_event)); |
| 673 break; | 673 break; |
| 674 | 674 |
| 675 case PP_INPUTEVENT_TYPE_WHEEL: { | 675 case PP_INPUTEVENT_TYPE_WHEEL: { |
| 676 WebMouseWheelEvent* web_mouse_wheel_event = | 676 WebMouseWheelEvent* web_mouse_wheel_event = |
| 677 static_cast<WebMouseWheelEvent*>(original_event.get()); | 677 static_cast<WebMouseWheelEvent*>(original_event.get()); |
| 678 web_mouse_wheel_event->x = plugin_x; | 678 web_mouse_wheel_event->setPositionInWidget(plugin_x, plugin_y); |
| 679 web_mouse_wheel_event->y = plugin_y; | |
| 680 events.push_back(std::move(original_event)); | 679 events.push_back(std::move(original_event)); |
| 681 break; | 680 break; |
| 682 } | 681 } |
| 683 | 682 |
| 684 case PP_INPUTEVENT_TYPE_RAWKEYDOWN: | 683 case PP_INPUTEVENT_TYPE_RAWKEYDOWN: |
| 685 case PP_INPUTEVENT_TYPE_KEYDOWN: | 684 case PP_INPUTEVENT_TYPE_KEYDOWN: |
| 686 case PP_INPUTEVENT_TYPE_KEYUP: { | 685 case PP_INPUTEVENT_TYPE_KEYUP: { |
| 687 // Windows key down events should always be "raw" to avoid an ASSERT. | 686 // Windows key down events should always be "raw" to avoid an ASSERT. |
| 688 #if defined(OS_WIN) | 687 #if defined(OS_WIN) |
| 689 WebKeyboardEvent* web_keyboard_event = | 688 WebKeyboardEvent* web_keyboard_event = |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 return PP_INPUTEVENT_CLASS_TOUCH; | 766 return PP_INPUTEVENT_CLASS_TOUCH; |
| 768 case WebInputEvent::TouchScrollStarted: | 767 case WebInputEvent::TouchScrollStarted: |
| 769 return PP_InputEvent_Class(0); | 768 return PP_InputEvent_Class(0); |
| 770 default: | 769 default: |
| 771 CHECK(WebInputEvent::isGestureEventType(event.type())); | 770 CHECK(WebInputEvent::isGestureEventType(event.type())); |
| 772 return PP_InputEvent_Class(0); | 771 return PP_InputEvent_Class(0); |
| 773 } | 772 } |
| 774 } | 773 } |
| 775 | 774 |
| 776 } // namespace content | 775 } // namespace content |
| OLD | NEW |