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

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

Issue 8377001: aura: Add touch-event support for RWHVA. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: windows Created 9 years, 2 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) 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 // Portions based heavily on: 5 // Portions based heavily on:
6 // third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFactory.cpp 6 // third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFactory.cpp
7 // 7 //
8 /* 8 /*
9 * Copyright (C) 2006-2011 Google Inc. All rights reserved. 9 * Copyright (C) 2006-2011 Google Inc. All rights reserved.
10 * 10 *
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 192 }
193 193
194 void ResetClickCountState() { 194 void ResetClickCountState() {
195 g_num_clicks = 0; 195 g_num_clicks = 0;
196 g_last_click_time = 0.0; 196 g_last_click_time = 0.0;
197 g_last_click_x = 0; 197 g_last_click_x = 0;
198 g_last_click_y = 0; 198 g_last_click_y = 0;
199 g_last_click_button = WebKit::WebMouseEvent::ButtonNone; 199 g_last_click_button = WebKit::WebMouseEvent::ButtonNone;
200 } 200 }
201 201
202 WebKit::WebTouchPoint::State TouchPointStateFromEvent(
203 const aura::TouchEvent* event) {
204 switch (event->type()) {
205 case ui::ET_TOUCH_PRESSED:
206 return WebKit::WebTouchPoint::StatePressed;
207 case ui::ET_TOUCH_RELEASED:
208 return WebKit::WebTouchPoint::StateReleased;
209 case ui::ET_TOUCH_MOVED:
210 return WebKit::WebTouchPoint::StateMoved;
211 case ui::ET_TOUCH_CANCELLED:
212 return WebKit::WebTouchPoint::StateCancelled;
213 default:
214 return WebKit::WebTouchPoint::StateUndefined;
215 }
216 }
217
218 WebKit::WebInputEvent::Type TouchEventTypeFromEvent(
219 const aura::TouchEvent* event) {
220 switch (event->type()) {
221 case ui::ET_TOUCH_PRESSED:
222 return WebKit::WebInputEvent::TouchStart;
223 case ui::ET_TOUCH_RELEASED:
224 return WebKit::WebInputEvent::TouchEnd;
225 case ui::ET_TOUCH_MOVED:
226 return WebKit::WebInputEvent::TouchMove;
227 case ui::ET_TOUCH_CANCELLED:
228 return WebKit::WebInputEvent::TouchCancel;
229 default:
230 return WebKit::WebInputEvent::Undefined;
231 }
232 }
233
202 } // namespace 234 } // namespace
203 235
204 WebKit::WebMouseEvent MakeWebMouseEventFromAuraEvent(aura::MouseEvent* event) { 236 WebKit::WebMouseEvent MakeWebMouseEventFromAuraEvent(aura::MouseEvent* event) {
205 WebKit::WebMouseEvent webkit_event; 237 WebKit::WebMouseEvent webkit_event;
206 238
207 webkit_event.modifiers = EventFlagsToWebEventModifiers(event->flags()); 239 webkit_event.modifiers = EventFlagsToWebEventModifiers(event->flags());
208 webkit_event.timeStampSeconds = event->time_stamp().ToDoubleT(); 240 webkit_event.timeStampSeconds = event->time_stamp().ToDoubleT();
209 241
210 webkit_event.button = WebKit::WebMouseEvent::ButtonNone; 242 webkit_event.button = WebKit::WebMouseEvent::ButtonNone;
211 if (event->flags() & ui::EF_LEFT_BUTTON_DOWN) 243 if (event->flags() & ui::EF_LEFT_BUTTON_DOWN)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 webkit_event.text[0] = webkit_event.unmodifiedText[0]; 344 webkit_event.text[0] = webkit_event.unmodifiedText[0];
313 } 345 }
314 346
315 webkit_event.setKeyIdentifierFromWindowsKeyCode(); 347 webkit_event.setKeyIdentifierFromWindowsKeyCode();
316 348
317 // TODO: IsAutoRepeat/IsKeyPad? 349 // TODO: IsAutoRepeat/IsKeyPad?
318 350
319 return webkit_event; 351 return webkit_event;
320 } 352 }
321 353
354 WebKit::WebTouchPoint* UpdateWebTouchEventFromAuraEvent(
355 aura::TouchEvent* event, WebKit::WebTouchEvent* web_event) {
356 WebKit::WebTouchPoint* point = NULL;
357 switch (event->type()) {
358 case ui::ET_TOUCH_PRESSED:
359 // Add a new touch point.
360 if (web_event->touchesLength < WebKit::WebTouchEvent::touchesLengthCap) {
361 point = &web_event->touches[web_event->touchesLength++];
362 point->id = event->touch_id();
363 }
364 break;
365 case ui::ET_TOUCH_RELEASED:
366 case ui::ET_TOUCH_CANCELLED:
367 case ui::ET_TOUCH_MOVED: {
368 // The touch point should have been added to the event from an earlier
369 // _PRESSED event. So find that.
370 // At the moment, only a maximum of 4 touch-points are allowed. So a
371 // simple loop should be sufficient.
372 for (unsigned i = 0; i < web_event->touchesLength; ++i) {
373 point = web_event->touches + i;
374 if (point->id == event->touch_id())
375 break;
376 point = NULL;
377 }
378 break;
379 }
380 default:
381 DLOG(WARNING) << "Unknown touch event " << event->type();
382 break;
383 }
384
385 if (!point)
386 return NULL;
387
388 point->radiusX = event->radius_x();
389 point->radiusY = event->radius_y();
390 point->rotationAngle = event->rotation_angle();
391 point->force = event->force();
392
393 // Update the location and state of the point.
394 point->state = TouchPointStateFromEvent(event);
395 if (point->state == WebKit::WebTouchPoint::StateMoved) {
396 // It is possible for badly written touch drivers to emit Move events even
397 // when the touch location hasn't changed. In such cases, consume the event
398 // and pretend nothing happened.
399 if (point->position.x == event->x() && point->position.y == event->y())
400 return NULL;
401 }
402 point->position.x = event->x();
403 point->position.y = event->y();
404
405 // TODO(sad): Convert to screen coordinates.
406 point->screenPosition.x = point->position.x;
407 point->screenPosition.y = point->position.y;
408
409 // Mark the rest of the points as stationary.
410 for (unsigned i = 0; i < web_event->touchesLength; ++i) {
411 WebKit::WebTouchPoint* iter = web_event->touches + i;
412 if (iter != point)
413 iter->state = WebKit::WebTouchPoint::StateStationary;
414 }
415
416 // Update the type of the touch event.
417 web_event->type = TouchEventTypeFromEvent(event);
418 web_event->timeStampSeconds = event->time_stamp().ToDoubleT();
419
420 return point;
421 }
422
322 } // namespace content 423 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698