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

Side by Side Diff: content/browser/renderer_host/web_input_event_aura.cc

Issue 492863002: mojo: Plumb through sufficient context to make real blink::WebInputEvents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: final sky nits Created 6 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 | Annotate | Revision Log
OLDNEW
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/browser/renderer_host/web_input_event_aura.h" 5 #include "content/browser/renderer_host/web_input_event_aura.h"
6 6
7 #include "content/browser/renderer_host/ui_events_helper.h" 7 #include "content/browser/renderer_host/ui_events_helper.h"
8 #include "ui/aura/window.h" 8 #include "ui/aura/window.h"
9 #include "ui/events/event.h" 9 #include "ui/events/event.h"
10 #include "ui/events/event_utils.h" 10 #include "ui/events/event_utils.h"
11 11
12 #if defined(USE_OZONE) 12 #if defined(USE_OZONE)
13 #include "ui/events/keycodes/keyboard_code_conversion.h" 13 #include "ui/events/keycodes/keyboard_code_conversion.h"
14 #endif 14 #endif
15 15
16 namespace content { 16 namespace content {
17 17
18 #if defined(USE_X11) || defined(USE_OZONE)
19 // From third_party/WebKit/Source/web/gtk/WebInputEventFactory.cpp:
20 blink::WebUChar GetControlCharacter(int windows_key_code, bool shift) {
21 if (windows_key_code >= ui::VKEY_A &&
22 windows_key_code <= ui::VKEY_Z) {
23 // ctrl-A ~ ctrl-Z map to \x01 ~ \x1A
24 return windows_key_code - ui::VKEY_A + 1;
25 }
26 if (shift) {
27 // following graphics chars require shift key to input.
28 switch (windows_key_code) {
29 // ctrl-@ maps to \x00 (Null byte)
30 case ui::VKEY_2:
31 return 0;
32 // ctrl-^ maps to \x1E (Record separator, Information separator two)
33 case ui::VKEY_6:
34 return 0x1E;
35 // ctrl-_ maps to \x1F (Unit separator, Information separator one)
36 case ui::VKEY_OEM_MINUS:
37 return 0x1F;
38 // Returns 0 for all other keys to avoid inputting unexpected chars.
39 default:
40 break;
41 }
42 } else {
43 switch (windows_key_code) {
44 // ctrl-[ maps to \x1B (Escape)
45 case ui::VKEY_OEM_4:
46 return 0x1B;
47 // ctrl-\ maps to \x1C (File separator, Information separator four)
48 case ui::VKEY_OEM_5:
49 return 0x1C;
50 // ctrl-] maps to \x1D (Group separator, Information separator three)
51 case ui::VKEY_OEM_6:
52 return 0x1D;
53 // ctrl-Enter maps to \x0A (Line feed)
54 case ui::VKEY_RETURN:
55 return 0x0A;
56 // Returns 0 for all other keys to avoid inputting unexpected chars.
57 default:
58 break;
59 }
60 }
61 return 0;
62 }
63 #endif
64 #if defined(OS_WIN) 18 #if defined(OS_WIN)
65 blink::WebMouseEvent MakeUntranslatedWebMouseEventFromNativeEvent( 19 blink::WebMouseEvent MakeUntranslatedWebMouseEventFromNativeEvent(
66 const base::NativeEvent& native_event); 20 const base::NativeEvent& native_event);
67 blink::WebMouseWheelEvent MakeUntranslatedWebMouseWheelEventFromNativeEvent( 21 blink::WebMouseWheelEvent MakeUntranslatedWebMouseWheelEventFromNativeEvent(
68 const base::NativeEvent& native_event); 22 const base::NativeEvent& native_event);
69 blink::WebKeyboardEvent MakeWebKeyboardEventFromNativeEvent( 23 blink::WebKeyboardEvent MakeWebKeyboardEventFromNativeEvent(
70 const base::NativeEvent& native_event); 24 const base::NativeEvent& native_event);
71 blink::WebGestureEvent MakeWebGestureEventFromNativeEvent( 25 blink::WebGestureEvent MakeWebGestureEventFromNativeEvent(
72 const base::NativeEvent& native_event); 26 const base::NativeEvent& native_event);
73 #elif defined(USE_X11) 27 #elif defined(USE_X11)
(...skipping 29 matching lines...) Expand all
103 webkit_event.nativeKeyCode = character; 57 webkit_event.nativeKeyCode = character;
104 58
105 if (webkit_event.windowsKeyCode == ui::VKEY_RETURN) 59 if (webkit_event.windowsKeyCode == ui::VKEY_RETURN)
106 webkit_event.unmodifiedText[0] = '\r'; 60 webkit_event.unmodifiedText[0] = '\r';
107 else 61 else
108 webkit_event.unmodifiedText[0] = ui::GetCharacterFromKeyCode( 62 webkit_event.unmodifiedText[0] = ui::GetCharacterFromKeyCode(
109 ui::KeyboardCodeFromNative(native_event), 63 ui::KeyboardCodeFromNative(native_event),
110 ui::EventFlagsFromNative(native_event)); 64 ui::EventFlagsFromNative(native_event));
111 65
112 if (webkit_event.modifiers & blink::WebInputEvent::ControlKey) { 66 if (webkit_event.modifiers & blink::WebInputEvent::ControlKey) {
113 webkit_event.text[0] = 67 webkit_event.text[0] = ui::GetControlCharacterForKeycode(
114 GetControlCharacter( 68 webkit_event.windowsKeyCode,
115 webkit_event.windowsKeyCode, 69 webkit_event.modifiers & blink::WebInputEvent::ShiftKey);
116 webkit_event.modifiers & blink::WebInputEvent::ShiftKey);
117 } else { 70 } else {
118 webkit_event.text[0] = webkit_event.unmodifiedText[0]; 71 webkit_event.text[0] = webkit_event.unmodifiedText[0];
119 } 72 }
120 73
121 webkit_event.setKeyIdentifierFromWindowsKeyCode(); 74 webkit_event.setKeyIdentifierFromWindowsKeyCode();
122 75
123 return webkit_event; 76 return webkit_event;
124 } 77 }
125 #endif 78 #endif
126 #if defined(USE_X11) || defined(USE_OZONE) 79 #if defined(USE_X11) || defined(USE_OZONE)
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 webkit_event.deltaY = event->y_offset(); 360 webkit_event.deltaY = event->y_offset();
408 } 361 }
409 362
410 webkit_event.wheelTicksX = webkit_event.deltaX / kPixelsPerTick; 363 webkit_event.wheelTicksX = webkit_event.deltaX / kPixelsPerTick;
411 webkit_event.wheelTicksY = webkit_event.deltaY / kPixelsPerTick; 364 webkit_event.wheelTicksY = webkit_event.deltaY / kPixelsPerTick;
412 365
413 return webkit_event; 366 return webkit_event;
414 } 367 }
415 368
416 } // namespace content 369 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/web_input_event_aura.h ('k') | content/browser/renderer_host/web_input_event_aurax11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698