| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // MSVC++ requires this to be set before any other includes to get M_PI. | |
| 6 #define _USE_MATH_DEFINES | |
| 7 | |
| 8 #include "content/browser/renderer_host/input/web_input_event_util.h" | |
| 9 | |
| 10 #include <cmath> | |
| 11 | |
| 12 #include "base/strings/string_util.h" | |
| 13 #include "content/common/input/web_touch_event_traits.h" | |
| 14 #include "ui/events/blink/blink_event_util.h" | |
| 15 #include "ui/events/event_constants.h" | |
| 16 #include "ui/events/gesture_detection/gesture_event_data.h" | |
| 17 #include "ui/events/keycodes/dom/keycode_converter.h" | |
| 18 #include "ui/gfx/geometry/safe_integer_conversions.h" | |
| 19 | |
| 20 using blink::WebGestureEvent; | |
| 21 using blink::WebInputEvent; | |
| 22 using blink::WebTouchEvent; | |
| 23 using blink::WebTouchPoint; | |
| 24 | |
| 25 namespace content { | |
| 26 | |
| 27 int WebEventModifiersToEventFlags(int modifiers) { | |
| 28 int flags = 0; | |
| 29 | |
| 30 if (modifiers & blink::WebInputEvent::ShiftKey) | |
| 31 flags |= ui::EF_SHIFT_DOWN; | |
| 32 if (modifiers & blink::WebInputEvent::ControlKey) | |
| 33 flags |= ui::EF_CONTROL_DOWN; | |
| 34 if (modifiers & blink::WebInputEvent::AltKey) | |
| 35 flags |= ui::EF_ALT_DOWN; | |
| 36 if (modifiers & blink::WebInputEvent::MetaKey) | |
| 37 flags |= ui::EF_COMMAND_DOWN; | |
| 38 if (modifiers & blink::WebInputEvent::CapsLockOn) | |
| 39 flags |= ui::EF_CAPS_LOCK_ON; | |
| 40 if (modifiers & blink::WebInputEvent::NumLockOn) | |
| 41 flags |= ui::EF_NUM_LOCK_ON; | |
| 42 if (modifiers & blink::WebInputEvent::ScrollLockOn) | |
| 43 flags |= ui::EF_SCROLL_LOCK_ON; | |
| 44 if (modifiers & blink::WebInputEvent::LeftButtonDown) | |
| 45 flags |= ui::EF_LEFT_MOUSE_BUTTON; | |
| 46 if (modifiers & blink::WebInputEvent::MiddleButtonDown) | |
| 47 flags |= ui::EF_MIDDLE_MOUSE_BUTTON; | |
| 48 if (modifiers & blink::WebInputEvent::RightButtonDown) | |
| 49 flags |= ui::EF_RIGHT_MOUSE_BUTTON; | |
| 50 if (modifiers & blink::WebInputEvent::IsAutoRepeat) | |
| 51 flags |= ui::EF_IS_REPEAT; | |
| 52 | |
| 53 return flags; | |
| 54 } | |
| 55 | |
| 56 blink::WebInputEvent::Modifiers DomCodeToWebInputEventModifiers( | |
| 57 ui::DomCode code) { | |
| 58 switch (ui::KeycodeConverter::DomCodeToLocation(code)) { | |
| 59 case ui::DomKeyLocation::LEFT: | |
| 60 return blink::WebInputEvent::IsLeft; | |
| 61 case ui::DomKeyLocation::RIGHT: | |
| 62 return blink::WebInputEvent::IsRight; | |
| 63 case ui::DomKeyLocation::NUMPAD: | |
| 64 return blink::WebInputEvent::IsKeyPad; | |
| 65 case ui::DomKeyLocation::STANDARD: | |
| 66 break; | |
| 67 } | |
| 68 return static_cast<blink::WebInputEvent::Modifiers>(0); | |
| 69 } | |
| 70 | |
| 71 } // namespace content | |
| OLD | NEW |