OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/aura/event.h" | 7 #include "ui/aura/event.h" |
8 | 8 |
9 namespace content { | 9 namespace content { |
10 | 10 |
| 11 #if defined(OS_WIN) |
11 WebKit::WebMouseEvent MakeUntranslatedWebMouseEventFromNativeEvent( | 12 WebKit::WebMouseEvent MakeUntranslatedWebMouseEventFromNativeEvent( |
12 base::NativeEvent native_event); | 13 base::NativeEvent native_event); |
13 WebKit::WebMouseEvent MakeWebMouseEventFromAuraEvent(aura::MouseEvent* event); | |
14 WebKit::WebKeyboardEvent MakeWebKeyboardEventFromNativeEvent( | 14 WebKit::WebKeyboardEvent MakeWebKeyboardEventFromNativeEvent( |
15 base::NativeEvent native_event); | 15 base::NativeEvent native_event); |
| 16 #else |
| 17 WebKit::WebMouseEvent MakeWebMouseEventFromAuraEvent(aura::MouseEvent* event); |
| 18 WebKit::WebKeyboardEvent MakeWebKeyboardEventFromAuraEvent( |
| 19 aura::KeyEvent* event); |
| 20 #endif |
16 | 21 |
17 // General approach: | 22 // General approach: |
18 // | 23 // |
19 // aura::Event only carries a subset of possible event data provided to Aura by | 24 // aura::Event only carries a subset of possible event data provided to Aura by |
20 // the host platform. WebKit utilizes a larger subset of that information than | 25 // the host platform. WebKit utilizes a larger subset of that information than |
21 // Aura itself. WebKit includes some built in cracking functionality that we | 26 // Aura itself. WebKit includes some built in cracking functionality that we |
22 // rely on to obtain this information cleanly and consistently. | 27 // rely on to obtain this information cleanly and consistently. |
23 // | 28 // |
24 // The only place where an aura::Event's data differs from what the underlying | 29 // The only place where an aura::Event's data differs from what the underlying |
25 // base::NativeEvent would provide is position data, since we would like to | 30 // base::NativeEvent would provide is position data, since we would like to |
(...skipping 26 matching lines...) Expand all Loading... |
52 webkit_event.windowY = webkit_event.y = event->y(); | 57 webkit_event.windowY = webkit_event.y = event->y(); |
53 | 58 |
54 // TODO(beng): map these to screen coordinates. | 59 // TODO(beng): map these to screen coordinates. |
55 webkit_event.globalX = event->x(); | 60 webkit_event.globalX = event->x(); |
56 webkit_event.globalY = event->y(); | 61 webkit_event.globalY = event->y(); |
57 | 62 |
58 return webkit_event; | 63 return webkit_event; |
59 } | 64 } |
60 | 65 |
61 WebKit::WebKeyboardEvent MakeWebKeyboardEvent(aura::KeyEvent* event) { | 66 WebKit::WebKeyboardEvent MakeWebKeyboardEvent(aura::KeyEvent* event) { |
| 67 // Windows can figure out whether or not to construct a RawKeyDown or a Char |
| 68 // WebInputEvent based on the type of message carried in |
| 69 // event->native_event(). X11 is not so fortunate, there is no separate |
| 70 // translated event type, so DesktopHostLinux sends an extra KeyEvent with |
| 71 // is_char() == true. We need to pass the aura::KeyEvent to the X11 function |
| 72 // to detect this case so the right event type can be constructed. |
| 73 #if defined(OS_WIN) |
62 // Key events require no translation by the aura system. | 74 // Key events require no translation by the aura system. |
63 return MakeWebKeyboardEventFromNativeEvent(event->native_event()); | 75 return MakeWebKeyboardEventFromNativeEvent(event->native_event()); |
| 76 #else |
| 77 return MakeWebKeyboardEventFromAuraEvent(event); |
| 78 #endif |
64 } | 79 } |
65 | 80 |
66 } // namespace content | 81 } // namespace content |
OLD | NEW |