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

Side by Side Diff: third_party/WebKit/Source/web/WebInputEventConversion.cpp

Issue 2542693002: Use WTF::TimeTicks to represent timestamp in Platform/Core event types (Closed)
Patch Set: rebase Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 const WebMouseEvent& e) { 196 const WebMouseEvent& e) {
197 // FIXME: Widget is always toplevel, unless it's a popup. We may be able 197 // FIXME: Widget is always toplevel, unless it's a popup. We may be able
198 // to get rid of this once we abstract popups into a WebKit API. 198 // to get rid of this once we abstract popups into a WebKit API.
199 m_position = widget->convertFromRootFrame( 199 m_position = widget->convertFromRootFrame(
200 flooredIntPoint(convertHitPointToRootFrame(widget, IntPoint(e.x, e.y)))); 200 flooredIntPoint(convertHitPointToRootFrame(widget, IntPoint(e.x, e.y))));
201 m_globalPosition = IntPoint(e.globalX, e.globalY); 201 m_globalPosition = IntPoint(e.globalX, e.globalY);
202 m_movementDelta = IntPoint(scaleDeltaToWindow(widget, e.movementX), 202 m_movementDelta = IntPoint(scaleDeltaToWindow(widget, e.movementX),
203 scaleDeltaToWindow(widget, e.movementY)); 203 scaleDeltaToWindow(widget, e.movementY));
204 m_modifiers = e.modifiers; 204 m_modifiers = e.modifiers;
205 205
206 m_timestamp = e.timeStampSeconds; 206 m_timestamp = TimeTicks::FromSeconds(e.timeStampSeconds);
207 m_clickCount = e.clickCount; 207 m_clickCount = e.clickCount;
208 208
209 m_pointerProperties = static_cast<WebPointerProperties>(e); 209 m_pointerProperties = static_cast<WebPointerProperties>(e);
210 210
211 switch (e.type) { 211 switch (e.type) {
212 case WebInputEvent::MouseMove: 212 case WebInputEvent::MouseMove:
213 case WebInputEvent::MouseEnter: // synthesize a move event 213 case WebInputEvent::MouseEnter: // synthesize a move event
214 case WebInputEvent::MouseLeave: // synthesize a move event 214 case WebInputEvent::MouseLeave: // synthesize a move event
215 m_type = PlatformEvent::MouseMoved; 215 m_type = PlatformEvent::MouseMoved;
216 break; 216 break;
(...skipping 27 matching lines...) Expand all
244 m_globalPosition = IntPoint(e.globalX, e.globalY); 244 m_globalPosition = IntPoint(e.globalX, e.globalY);
245 m_deltaX = scaleDeltaToWindow(widget, e.deltaX); 245 m_deltaX = scaleDeltaToWindow(widget, e.deltaX);
246 m_deltaY = scaleDeltaToWindow(widget, e.deltaY); 246 m_deltaY = scaleDeltaToWindow(widget, e.deltaY);
247 m_wheelTicksX = e.wheelTicksX; 247 m_wheelTicksX = e.wheelTicksX;
248 m_wheelTicksY = e.wheelTicksY; 248 m_wheelTicksY = e.wheelTicksY;
249 m_granularity = 249 m_granularity =
250 e.scrollByPage ? ScrollByPageWheelEvent : ScrollByPixelWheelEvent; 250 e.scrollByPage ? ScrollByPageWheelEvent : ScrollByPixelWheelEvent;
251 251
252 m_type = PlatformEvent::Wheel; 252 m_type = PlatformEvent::Wheel;
253 253
254 m_timestamp = e.timeStampSeconds; 254 m_timestamp = TimeTicks::FromSeconds(e.timeStampSeconds);
255 m_modifiers = e.modifiers; 255 m_modifiers = e.modifiers;
256 m_dispatchType = toPlatformDispatchType(e.dispatchType); 256 m_dispatchType = toPlatformDispatchType(e.dispatchType);
257 257
258 m_hasPreciseScrollingDeltas = e.hasPreciseScrollingDeltas; 258 m_hasPreciseScrollingDeltas = e.hasPreciseScrollingDeltas;
259 m_resendingPluginId = e.resendingPluginId; 259 m_resendingPluginId = e.resendingPluginId;
260 m_railsMode = static_cast<PlatformEvent::RailsMode>(e.railsMode); 260 m_railsMode = static_cast<PlatformEvent::RailsMode>(e.railsMode);
261 #if OS(MACOSX) 261 #if OS(MACOSX)
262 m_phase = static_cast<PlatformWheelEventPhase>(e.phase); 262 m_phase = static_cast<PlatformWheelEventPhase>(e.phase);
263 m_momentumPhase = static_cast<PlatformWheelEventPhase>(e.momentumPhase); 263 m_momentumPhase = static_cast<PlatformWheelEventPhase>(e.momentumPhase);
264 #endif 264 #endif
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 case WebInputEvent::GesturePinchUpdate: 368 case WebInputEvent::GesturePinchUpdate:
369 m_type = PlatformEvent::GesturePinchUpdate; 369 m_type = PlatformEvent::GesturePinchUpdate;
370 m_data.m_pinchUpdate.m_scale = e.data.pinchUpdate.scale; 370 m_data.m_pinchUpdate.m_scale = e.data.pinchUpdate.scale;
371 break; 371 break;
372 default: 372 default:
373 NOTREACHED(); 373 NOTREACHED();
374 } 374 }
375 m_position = widget->convertFromRootFrame(flooredIntPoint( 375 m_position = widget->convertFromRootFrame(flooredIntPoint(
376 convertHitPointToRootFrame(widget, FloatPoint(e.x, e.y)))); 376 convertHitPointToRootFrame(widget, FloatPoint(e.x, e.y))));
377 m_globalPosition = IntPoint(e.globalX, e.globalY); 377 m_globalPosition = IntPoint(e.globalX, e.globalY);
378 m_timestamp = e.timeStampSeconds; 378 m_timestamp = TimeTicks::FromSeconds(e.timeStampSeconds);
379 m_modifiers = e.modifiers; 379 m_modifiers = e.modifiers;
380 switch (e.sourceDevice) { 380 switch (e.sourceDevice) {
381 case WebGestureDeviceTouchpad: 381 case WebGestureDeviceTouchpad:
382 m_source = PlatformGestureSourceTouchpad; 382 m_source = PlatformGestureSourceTouchpad;
383 break; 383 break;
384 case WebGestureDeviceTouchscreen: 384 case WebGestureDeviceTouchscreen:
385 m_source = PlatformGestureSourceTouchscreen; 385 m_source = PlatformGestureSourceTouchscreen;
386 break; 386 break;
387 case WebGestureDeviceUninitialized: 387 case WebGestureDeviceUninitialized:
388 NOTREACHED(); 388 NOTREACHED();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 m_screenPos = FloatPoint(point.screenPosition.x, point.screenPosition.y); 456 m_screenPos = FloatPoint(point.screenPosition.x, point.screenPosition.y);
457 m_radius = scaleSizeToWindow(widget, FloatSize(point.radiusX, point.radiusY)); 457 m_radius = scaleSizeToWindow(widget, FloatSize(point.radiusX, point.radiusY));
458 m_rotationAngle = point.rotationAngle; 458 m_rotationAngle = point.rotationAngle;
459 } 459 }
460 460
461 PlatformTouchEventBuilder::PlatformTouchEventBuilder( 461 PlatformTouchEventBuilder::PlatformTouchEventBuilder(
462 Widget* widget, 462 Widget* widget,
463 const WebTouchEvent& event) { 463 const WebTouchEvent& event) {
464 m_type = toPlatformTouchEventType(event.type); 464 m_type = toPlatformTouchEventType(event.type);
465 m_modifiers = event.modifiers; 465 m_modifiers = event.modifiers;
466 m_timestamp = event.timeStampSeconds; 466 m_timestamp = TimeTicks::FromSeconds(event.timeStampSeconds);
467 m_causesScrollingIfUncanceled = event.movedBeyondSlopRegion; 467 m_causesScrollingIfUncanceled = event.movedBeyondSlopRegion;
468 m_touchStartOrFirstTouchMove = event.touchStartOrFirstTouchMove; 468 m_touchStartOrFirstTouchMove = event.touchStartOrFirstTouchMove;
469 469
470 for (unsigned i = 0; i < event.touchesLength; ++i) 470 for (unsigned i = 0; i < event.touchesLength; ++i)
471 m_touchPoints.append(PlatformTouchPointBuilder(widget, event.touches[i])); 471 m_touchPoints.append(PlatformTouchPointBuilder(widget, event.touches[i]));
472 472
473 m_dispatchType = toPlatformDispatchType(event.dispatchType); 473 m_dispatchType = toPlatformDispatchType(event.dispatchType);
474 m_uniqueTouchEventId = event.uniqueTouchEventId; 474 m_uniqueTouchEventId = event.uniqueTouchEventId;
475 } 475 }
476 476
(...skipping 10 matching lines...) Expand all
487 convertAbsoluteLocationForLayoutObjectFloat(location, layoutItem)); 487 convertAbsoluteLocationForLayoutObjectFloat(location, layoutItem));
488 } 488 }
489 489
490 // FIXME: Change |widget| to const Widget& after RemoteFrames get 490 // FIXME: Change |widget| to const Widget& after RemoteFrames get
491 // RemoteFrameViews. 491 // RemoteFrameViews.
492 static void updateWebMouseEventFromCoreMouseEvent( 492 static void updateWebMouseEventFromCoreMouseEvent(
493 const MouseRelatedEvent& event, 493 const MouseRelatedEvent& event,
494 const Widget* widget, 494 const Widget* widget,
495 const LayoutItem layoutItem, 495 const LayoutItem layoutItem,
496 WebMouseEvent& webEvent) { 496 WebMouseEvent& webEvent) {
497 webEvent.timeStampSeconds = event.platformTimeStamp(); 497 webEvent.timeStampSeconds = event.platformTimeStamp().InSeconds();
498 webEvent.modifiers = event.modifiers(); 498 webEvent.modifiers = event.modifiers();
499 499
500 FrameView* view = widget ? toFrameView(widget->parent()) : 0; 500 FrameView* view = widget ? toFrameView(widget->parent()) : 0;
501 // TODO(bokan): If view == nullptr, pointInRootFrame will really be 501 // TODO(bokan): If view == nullptr, pointInRootFrame will really be
502 // pointInRootContent. 502 // pointInRootContent.
503 IntPoint pointInRootFrame(event.absoluteLocation().x(), 503 IntPoint pointInRootFrame(event.absoluteLocation().x(),
504 event.absoluteLocation().y()); 504 event.absoluteLocation().y());
505 if (view) 505 if (view)
506 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); 506 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame);
507 webEvent.globalX = event.screenX(); 507 webEvent.globalX = event.screenX();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 590
591 if (event.type() == EventTypeNames::touchstart) 591 if (event.type() == EventTypeNames::touchstart)
592 type = MouseDown; 592 type = MouseDown;
593 else if (event.type() == EventTypeNames::touchmove) 593 else if (event.type() == EventTypeNames::touchmove)
594 type = MouseMove; 594 type = MouseMove;
595 else if (event.type() == EventTypeNames::touchend) 595 else if (event.type() == EventTypeNames::touchend)
596 type = MouseUp; 596 type = MouseUp;
597 else 597 else
598 return; 598 return;
599 599
600 timeStampSeconds = event.platformTimeStamp(); 600 timeStampSeconds = event.platformTimeStamp().InSeconds();
601 modifiers = event.modifiers(); 601 modifiers = event.modifiers();
602 602
603 // The mouse event co-ordinates should be generated from the co-ordinates of 603 // The mouse event co-ordinates should be generated from the co-ordinates of
604 // the touch point. 604 // the touch point.
605 FrameView* view = toFrameView(widget->parent()); 605 FrameView* view = toFrameView(widget->parent());
606 // FIXME: if view == nullptr, pointInRootFrame will really be 606 // FIXME: if view == nullptr, pointInRootFrame will really be
607 // pointInRootContent. 607 // pointInRootContent.
608 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation()); 608 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation());
609 if (view) 609 if (view)
610 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); 610 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 if (event.type() == EventTypeNames::keydown) 665 if (event.type() == EventTypeNames::keydown)
666 type = KeyDown; 666 type = KeyDown;
667 else if (event.type() == EventTypeNames::keyup) 667 else if (event.type() == EventTypeNames::keyup)
668 type = WebInputEvent::KeyUp; 668 type = WebInputEvent::KeyUp;
669 else if (event.type() == EventTypeNames::keypress) 669 else if (event.type() == EventTypeNames::keypress)
670 type = WebInputEvent::Char; 670 type = WebInputEvent::Char;
671 else 671 else
672 return; // Skip all other keyboard events. 672 return; // Skip all other keyboard events.
673 673
674 modifiers = event.modifiers(); 674 modifiers = event.modifiers();
675 timeStampSeconds = event.platformTimeStamp(); 675 timeStampSeconds = event.platformTimeStamp().InSeconds();
676 windowsKeyCode = event.keyCode(); 676 windowsKeyCode = event.keyCode();
677 } 677 }
678 678
679 static WebTouchPoint toWebTouchPoint(const Touch* touch, 679 static WebTouchPoint toWebTouchPoint(const Touch* touch,
680 const LayoutItem layoutItem, 680 const LayoutItem layoutItem,
681 WebTouchPoint::State state, 681 WebTouchPoint::State state,
682 WebPointerProperties::PointerType type) { 682 WebPointerProperties::PointerType type) {
683 WebTouchPoint point; 683 WebTouchPoint point;
684 point.pointerType = type; 684 point.pointerType = type;
685 point.id = touch->identifier(); 685 point.id = touch->identifier();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 else if (event.type() == EventTypeNames::touchend) 739 else if (event.type() == EventTypeNames::touchend)
740 type = TouchEnd; 740 type = TouchEnd;
741 else if (event.type() == EventTypeNames::touchcancel) 741 else if (event.type() == EventTypeNames::touchcancel)
742 type = TouchCancel; 742 type = TouchCancel;
743 else { 743 else {
744 NOTREACHED(); 744 NOTREACHED();
745 type = Undefined; 745 type = Undefined;
746 return; 746 return;
747 } 747 }
748 748
749 timeStampSeconds = event.platformTimeStamp(); 749 timeStampSeconds = event.platformTimeStamp().InSeconds();
750 modifiers = event.modifiers(); 750 modifiers = event.modifiers();
751 dispatchType = event.cancelable() ? WebInputEvent::Blocking 751 dispatchType = event.cancelable() ? WebInputEvent::Blocking
752 : WebInputEvent::EventNonBlocking; 752 : WebInputEvent::EventNonBlocking;
753 movedBeyondSlopRegion = event.causesScrollingIfUncanceled(); 753 movedBeyondSlopRegion = event.causesScrollingIfUncanceled();
754 754
755 // Currently touches[] is empty, add stationary points as-is. 755 // Currently touches[] is empty, add stationary points as-is.
756 for (unsigned i = 0; 756 for (unsigned i = 0;
757 i < event.touches()->length() && 757 i < event.touches()->length() &&
758 i < static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap); 758 i < static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap);
759 ++i) { 759 ++i) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 resendingPluginId = event.resendingPluginId(); 804 resendingPluginId = event.resendingPluginId();
805 } else if (event.type() == EventTypeNames::gestureflingstart) { 805 } else if (event.type() == EventTypeNames::gestureflingstart) {
806 type = GestureFlingStart; 806 type = GestureFlingStart;
807 data.flingStart.velocityX = event.velocityX(); 807 data.flingStart.velocityX = event.velocityX();
808 data.flingStart.velocityY = event.velocityY(); 808 data.flingStart.velocityY = event.velocityY();
809 } else if (event.type() == EventTypeNames::gesturetap) { 809 } else if (event.type() == EventTypeNames::gesturetap) {
810 type = GestureTap; 810 type = GestureTap;
811 data.tap.tapCount = 1; 811 data.tap.tapCount = 1;
812 } 812 }
813 813
814 timeStampSeconds = event.platformTimeStamp(); 814 timeStampSeconds = event.platformTimeStamp().InSeconds();
815 modifiers = event.modifiers(); 815 modifiers = event.modifiers();
816 816
817 globalX = event.screenX(); 817 globalX = event.screenX();
818 globalY = event.screenY(); 818 globalY = event.screenY();
819 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt( 819 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt(
820 event.absoluteLocation(), layoutItem); 820 event.absoluteLocation(), layoutItem);
821 x = localPoint.x(); 821 x = localPoint.x();
822 y = localPoint.y(); 822 y = localPoint.y();
823 823
824 switch (event.source()) { 824 switch (event.source()) {
(...skipping 26 matching lines...) Expand all
851 Vector<PlatformTouchEvent> result; 851 Vector<PlatformTouchEvent> result;
852 for (const auto& event : coalescedEvents) { 852 for (const auto& event : coalescedEvents) {
853 DCHECK(WebInputEvent::isTouchEventType(event->type)); 853 DCHECK(WebInputEvent::isTouchEventType(event->type));
854 result.append(PlatformTouchEventBuilder( 854 result.append(PlatformTouchEventBuilder(
855 widget, static_cast<const WebTouchEvent&>(*event))); 855 widget, static_cast<const WebTouchEvent&>(*event)));
856 } 856 }
857 return result; 857 return result;
858 } 858 }
859 859
860 } // namespace blink 860 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebFrameWidgetBase.cpp ('k') | third_party/WebKit/Source/web/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698