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

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

Issue 8907005: Add support for new scroll valuators coming from CMT (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review nits Created 9 years 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) 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 #include "ui/aura/window.h" 8 #include "ui/aura/window.h"
9 9
10 namespace content { 10 namespace content {
11 11
12 #if defined(OS_WIN) 12 #if defined(OS_WIN)
13 WebKit::WebMouseEvent MakeUntranslatedWebMouseEventFromNativeEvent( 13 WebKit::WebMouseEvent MakeUntranslatedWebMouseEventFromNativeEvent(
14 base::NativeEvent native_event); 14 base::NativeEvent native_event);
15 WebKit::WebMouseWheelEvent MakeUntranslatedWebMouseWheelEventFromNativeEvent( 15 WebKit::WebMouseWheelEvent MakeUntranslatedWebMouseWheelEventFromNativeEvent(
16 base::NativeEvent native_event); 16 base::NativeEvent native_event);
17 WebKit::WebKeyboardEvent MakeWebKeyboardEventFromNativeEvent( 17 WebKit::WebKeyboardEvent MakeWebKeyboardEventFromNativeEvent(
18 base::NativeEvent native_event); 18 base::NativeEvent native_event);
19 WebKit::WebTouchPoint* UpdateWebTouchEventFromNativeEvent( 19 WebKit::WebTouchPoint* UpdateWebTouchEventFromNativeEvent(
20 base::NativeEvent native_event, WebKit::WebTouchEvent* web_event); 20 base::NativeEvent native_event, WebKit::WebTouchEvent* web_event);
21 #else 21 #else
22 WebKit::WebMouseEvent MakeWebMouseEventFromAuraEvent(aura::MouseEvent* event); 22 WebKit::WebMouseEvent MakeWebMouseEventFromAuraEvent(aura::MouseEvent* event);
23 WebKit::WebMouseWheelEvent MakeWebMouseWheelEventFromAuraEvent( 23 WebKit::WebMouseWheelEvent MakeWebMouseWheelEventFromAuraEvent(
24 aura::MouseEvent* event); 24 aura::MouseEvent* event);
25 WebKit::WebMouseWheelEvent MakeWebMouseWheelEventFromAuraEvent(
26 aura::ScrollEvent* event);
25 WebKit::WebKeyboardEvent MakeWebKeyboardEventFromAuraEvent( 27 WebKit::WebKeyboardEvent MakeWebKeyboardEventFromAuraEvent(
26 aura::KeyEvent* event); 28 aura::KeyEvent* event);
27 WebKit::WebTouchPoint* UpdateWebTouchEventFromAuraEvent( 29 WebKit::WebTouchPoint* UpdateWebTouchEventFromAuraEvent(
28 aura::TouchEvent* event, WebKit::WebTouchEvent* web_event); 30 aura::TouchEvent* event, WebKit::WebTouchEvent* web_event);
29 #endif 31 #endif
30 32
31 // General approach: 33 // General approach:
32 // 34 //
33 // aura::Event only carries a subset of possible event data provided to Aura by 35 // aura::Event only carries a subset of possible event data provided to Aura by
34 // the host platform. WebKit utilizes a larger subset of that information than 36 // the host platform. WebKit utilizes a larger subset of that information than
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 webkit_event.windowY = webkit_event.y = event->y(); 91 webkit_event.windowY = webkit_event.y = event->y();
90 92
91 const gfx::Point host_point = 93 const gfx::Point host_point =
92 ui::EventLocationFromNative(event->native_event()); 94 ui::EventLocationFromNative(event->native_event());
93 webkit_event.globalX = host_point.x(); 95 webkit_event.globalX = host_point.x();
94 webkit_event.globalY = host_point.y(); 96 webkit_event.globalY = host_point.y();
95 97
96 return webkit_event; 98 return webkit_event;
97 } 99 }
98 100
101 WebKit::WebMouseWheelEvent MakeWebMouseWheelEvent(aura::ScrollEvent* event) {
102 #if defined(OS_WIN)
103 // Construct an untranslated event from the platform event data.
104 WebKit::WebMouseWheelEvent webkit_event =
105 MakeUntranslatedWebMouseWheelEventFromNativeEvent(event->native_event());
106 #else
107 WebKit::WebMouseWheelEvent webkit_event =
108 MakeWebMouseWheelEventFromAuraEvent(event);
109 #endif
110
111 // Replace the event's coordinate fields with translated position data from
112 // |event|.
113 webkit_event.windowX = webkit_event.x = event->x();
114 webkit_event.windowY = webkit_event.y = event->y();
115
116 const gfx::Point host_point =
117 ui::EventLocationFromNative(event->native_event());
118 webkit_event.globalX = host_point.x();
119 webkit_event.globalY = host_point.y();
120
121 return webkit_event;
122 }
123
99 WebKit::WebKeyboardEvent MakeWebKeyboardEvent(aura::KeyEvent* event) { 124 WebKit::WebKeyboardEvent MakeWebKeyboardEvent(aura::KeyEvent* event) {
100 // Windows can figure out whether or not to construct a RawKeyDown or a Char 125 // Windows can figure out whether or not to construct a RawKeyDown or a Char
101 // WebInputEvent based on the type of message carried in 126 // WebInputEvent based on the type of message carried in
102 // event->native_event(). X11 is not so fortunate, there is no separate 127 // event->native_event(). X11 is not so fortunate, there is no separate
103 // translated event type, so DesktopHostLinux sends an extra KeyEvent with 128 // translated event type, so DesktopHostLinux sends an extra KeyEvent with
104 // is_char() == true. We need to pass the aura::KeyEvent to the X11 function 129 // is_char() == true. We need to pass the aura::KeyEvent to the X11 function
105 // to detect this case so the right event type can be constructed. 130 // to detect this case so the right event type can be constructed.
106 #if defined(OS_WIN) 131 #if defined(OS_WIN)
107 // Key events require no translation by the aura system. 132 // Key events require no translation by the aura system.
108 return MakeWebKeyboardEventFromNativeEvent(event->native_event()); 133 return MakeWebKeyboardEventFromNativeEvent(event->native_event());
109 #else 134 #else
110 return MakeWebKeyboardEventFromAuraEvent(event); 135 return MakeWebKeyboardEventFromAuraEvent(event);
111 #endif 136 #endif
112 } 137 }
113 138
114 WebKit::WebTouchPoint* UpdateWebTouchEvent(aura::TouchEvent* event, 139 WebKit::WebTouchPoint* UpdateWebTouchEvent(aura::TouchEvent* event,
115 WebKit::WebTouchEvent* web_event) { 140 WebKit::WebTouchEvent* web_event) {
116 #if defined(OS_WIN) 141 #if defined(OS_WIN)
117 return UpdateWebTouchEventFromNativeEvent(event->native_event(), web_event); 142 return UpdateWebTouchEventFromNativeEvent(event->native_event(), web_event);
118 #else 143 #else
119 return UpdateWebTouchEventFromAuraEvent(event, web_event); 144 return UpdateWebTouchEventFromAuraEvent(event, web_event);
120 #endif 145 #endif
121 } 146 }
122 147
123 } // namespace content 148 } // 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