Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: content/browser/renderer_host/input/web_input_event_util.cc

Issue 2234023002: Refactor WebInputEventAura to ui/events/blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698