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

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

Issue 1266643002: content: Populate WebPointerProperties with stylus details from ui::MouseEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@experimental-pointer-events
Patch Set: Test MakeWebMouseEvent and MakeWebMouseWheelEvent instead Created 5 years, 3 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
« no previous file with comments | « no previous file | content/browser/renderer_host/web_input_event_aura_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/input/web_input_event_util.h" 7 #include "content/browser/renderer_host/input/web_input_event_util.h"
8 #include "content/browser/renderer_host/ui_events_helper.h" 8 #include "content/browser/renderer_host/ui_events_helper.h"
9 #include "ui/aura/client/screen_position_client.h" 9 #include "ui/aura/client/screen_position_client.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
(...skipping 30 matching lines...) Expand all
41 case ui::DomKeyLocation::RIGHT: 41 case ui::DomKeyLocation::RIGHT:
42 return blink::WebInputEvent::IsRight; 42 return blink::WebInputEvent::IsRight;
43 case ui::DomKeyLocation::NUMPAD: 43 case ui::DomKeyLocation::NUMPAD:
44 return blink::WebInputEvent::IsKeyPad; 44 return blink::WebInputEvent::IsKeyPad;
45 case ui::DomKeyLocation::STANDARD: 45 case ui::DomKeyLocation::STANDARD:
46 break; 46 break;
47 } 47 }
48 return static_cast<blink::WebInputEvent::Modifiers>(0); 48 return static_cast<blink::WebInputEvent::Modifiers>(0);
49 } 49 }
50 50
51 blink::WebPointerProperties::PointerType EventPointerTypeToWebPointerType(
52 ui::EventPointerType pointer_type) {
53 switch (pointer_type) {
54 case ui::EventPointerType::POINTER_TYPE_UNKNOWN:
55 return blink::WebPointerProperties::PointerType::PointerTypeUnknown;
56 case ui::EventPointerType::POINTER_TYPE_MOUSE:
57 return blink::WebPointerProperties::PointerType::PointerTypeMouse;
58 case ui::EventPointerType::POINTER_TYPE_PEN:
59 return blink::WebPointerProperties::PointerType::PointerTypePen;
60 case ui::EventPointerType::POINTER_TYPE_TOUCH:
61 return blink::WebPointerProperties::PointerType::PointerTypeTouch;
62 }
63 NOTREACHED() << "Unexpected EventPointerType";
64 return blink::WebPointerProperties::PointerType::PointerTypeUnknown;
65 }
66
51 } // namespace 67 } // namespace
52 68
53 #if defined(OS_WIN) 69 #if defined(OS_WIN)
54 blink::WebMouseEvent MakeUntranslatedWebMouseEventFromNativeEvent( 70 blink::WebMouseEvent MakeUntranslatedWebMouseEventFromNativeEvent(
55 const base::NativeEvent& native_event); 71 const base::NativeEvent& native_event);
56 blink::WebMouseWheelEvent MakeUntranslatedWebMouseWheelEventFromNativeEvent( 72 blink::WebMouseWheelEvent MakeUntranslatedWebMouseWheelEventFromNativeEvent(
57 const base::NativeEvent& native_event); 73 const base::NativeEvent& native_event);
58 blink::WebKeyboardEvent MakeWebKeyboardEventFromNativeEvent( 74 blink::WebKeyboardEvent MakeWebKeyboardEventFromNativeEvent(
59 const base::NativeEvent& native_event); 75 const base::NativeEvent& native_event);
60 blink::WebGestureEvent MakeWebGestureEventFromNativeEvent( 76 blink::WebGestureEvent MakeWebGestureEventFromNativeEvent(
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 case ui::ET_MOUSE_EXITED: 388 case ui::ET_MOUSE_EXITED:
373 case ui::ET_MOUSE_MOVED: 389 case ui::ET_MOUSE_MOVED:
374 case ui::ET_MOUSE_DRAGGED: 390 case ui::ET_MOUSE_DRAGGED:
375 webkit_event.type = blink::WebInputEvent::MouseMove; 391 webkit_event.type = blink::WebInputEvent::MouseMove;
376 break; 392 break;
377 default: 393 default:
378 NOTIMPLEMENTED() << "Received unexpected event: " << event.type(); 394 NOTIMPLEMENTED() << "Received unexpected event: " << event.type();
379 break; 395 break;
380 } 396 }
381 397
398 webkit_event.tiltX = roundf(event.pointer_details().tilt_x());
399 webkit_event.tiltY = roundf(event.pointer_details().tilt_y());
400 webkit_event.force = event.pointer_details().force();
401 webkit_event.pointerType =
402 EventPointerTypeToWebPointerType(event.pointer_details().pointer_type());
403
382 return webkit_event; 404 return webkit_event;
383 } 405 }
384 406
385 blink::WebMouseWheelEvent MakeWebMouseWheelEventFromAuraEvent( 407 blink::WebMouseWheelEvent MakeWebMouseWheelEventFromAuraEvent(
386 const ui::MouseWheelEvent& event) { 408 const ui::MouseWheelEvent& event) {
387 blink::WebMouseWheelEvent webkit_event; 409 blink::WebMouseWheelEvent webkit_event;
388 410
389 webkit_event.type = blink::WebInputEvent::MouseWheel; 411 webkit_event.type = blink::WebInputEvent::MouseWheel;
390 webkit_event.button = blink::WebMouseEvent::ButtonNone; 412 webkit_event.button = blink::WebMouseEvent::ButtonNone;
391 webkit_event.modifiers = ui::EventFlagsToWebEventModifiers(event.flags()); 413 webkit_event.modifiers = ui::EventFlagsToWebEventModifiers(event.flags());
392 webkit_event.timeStampSeconds = event.time_stamp().InSecondsF(); 414 webkit_event.timeStampSeconds = event.time_stamp().InSecondsF();
393 415
394 if ((event.flags() & ui::EF_SHIFT_DOWN) != 0 && event.x_offset() == 0) { 416 if ((event.flags() & ui::EF_SHIFT_DOWN) != 0 && event.x_offset() == 0) {
395 webkit_event.deltaX = event.y_offset(); 417 webkit_event.deltaX = event.y_offset();
396 webkit_event.deltaY = 0; 418 webkit_event.deltaY = 0;
397 } else { 419 } else {
398 webkit_event.deltaX = event.x_offset(); 420 webkit_event.deltaX = event.x_offset();
399 webkit_event.deltaY = event.y_offset(); 421 webkit_event.deltaY = event.y_offset();
400 } 422 }
401 423
402 webkit_event.wheelTicksX = webkit_event.deltaX / kPixelsPerTick; 424 webkit_event.wheelTicksX = webkit_event.deltaX / kPixelsPerTick;
403 webkit_event.wheelTicksY = webkit_event.deltaY / kPixelsPerTick; 425 webkit_event.wheelTicksY = webkit_event.deltaY / kPixelsPerTick;
404 426
427 webkit_event.tiltX = roundf(event.pointer_details().tilt_x());
428 webkit_event.tiltY = roundf(event.pointer_details().tilt_y());
429 webkit_event.force = event.pointer_details().force();
430 webkit_event.pointerType =
431 EventPointerTypeToWebPointerType(event.pointer_details().pointer_type());
432
405 return webkit_event; 433 return webkit_event;
406 } 434 }
407 435
408 } // namespace content 436 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/web_input_event_aura_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698