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

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

Issue 2406263003: Make PointerEvent coordinates fractional for touch (Closed)
Patch Set: Rebased. Created 4 years, 1 month 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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
477 static FloatPoint convertAbsoluteLocationForLayoutObjectFloat( 477 static FloatPoint convertAbsoluteLocationForLayoutObjectFloat(
478 const LayoutPoint& location, 478 const DoublePoint& location,
479 const LayoutItem layoutItem) { 479 const LayoutItem layoutItem) {
480 return layoutItem.absoluteToLocal(FloatPoint(location), UseTransforms); 480 return layoutItem.absoluteToLocal(FloatPoint(location), UseTransforms);
481 } 481 }
482 482
483 static IntPoint convertAbsoluteLocationForLayoutObject( 483 static IntPoint convertAbsoluteLocationForLayoutObjectInt(
484 const LayoutPoint& location, 484 const DoublePoint& location,
485 const LayoutItem layoutItem) { 485 const LayoutItem layoutItem) {
486 return roundedIntPoint( 486 return roundedIntPoint(
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();
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 = IntPoint(event.absoluteLocation().x().toInt(), 503 IntPoint pointInRootFrame(event.absoluteLocation().x(),
504 event.absoluteLocation().y().toInt()); 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();
508 webEvent.globalY = event.screenY(); 508 webEvent.globalY = event.screenY();
509 webEvent.windowX = pointInRootFrame.x(); 509 webEvent.windowX = pointInRootFrame.x();
510 webEvent.windowY = pointInRootFrame.y(); 510 webEvent.windowY = pointInRootFrame.y();
511 IntPoint localPoint = convertAbsoluteLocationForLayoutObject( 511 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt(
512 event.absoluteLocation(), layoutItem); 512 event.absoluteLocation(), layoutItem);
513 webEvent.x = localPoint.x(); 513 webEvent.x = localPoint.x();
514 webEvent.y = localPoint.y(); 514 webEvent.y = localPoint.y();
515 } 515 }
516 516
517 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, 517 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget,
518 const LayoutItem layoutItem, 518 const LayoutItem layoutItem,
519 const MouseEvent& event) { 519 const MouseEvent& event) {
520 if (event.type() == EventTypeNames::mousemove) 520 if (event.type() == EventTypeNames::mousemove)
521 type = WebInputEvent::MouseMove; 521 type = WebInputEvent::MouseMove;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 IntPoint screenPoint = roundedIntPoint(touch->screenLocation()); 611 IntPoint screenPoint = roundedIntPoint(touch->screenLocation());
612 globalX = screenPoint.x(); 612 globalX = screenPoint.x();
613 globalY = screenPoint.y(); 613 globalY = screenPoint.y();
614 windowX = pointInRootFrame.x(); 614 windowX = pointInRootFrame.x();
615 windowY = pointInRootFrame.y(); 615 windowY = pointInRootFrame.y();
616 616
617 button = WebMouseEvent::Button::Left; 617 button = WebMouseEvent::Button::Left;
618 modifiers |= WebInputEvent::LeftButtonDown; 618 modifiers |= WebInputEvent::LeftButtonDown;
619 clickCount = (type == MouseDown || type == MouseUp); 619 clickCount = (type == MouseDown || type == MouseUp);
620 620
621 IntPoint localPoint = convertAbsoluteLocationForLayoutObject( 621 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt(
622 touch->absoluteLocation(), layoutItem); 622 DoublePoint(touch->absoluteLocation()), layoutItem);
623 x = localPoint.x(); 623 x = localPoint.x();
624 y = localPoint.y(); 624 y = localPoint.y();
625 625
626 pointerType = WebPointerProperties::PointerType::Touch; 626 pointerType = WebPointerProperties::PointerType::Touch;
627 } 627 }
628 628
629 WebMouseWheelEventBuilder::WebMouseWheelEventBuilder( 629 WebMouseWheelEventBuilder::WebMouseWheelEventBuilder(
630 const Widget* widget, 630 const Widget* widget,
631 const LayoutItem layoutItem, 631 const LayoutItem layoutItem,
632 const WheelEvent& event) { 632 const WheelEvent& event) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 WebTouchPoint point; 682 WebTouchPoint point;
683 point.pointerType = WebPointerProperties::PointerType::Touch; 683 point.pointerType = WebPointerProperties::PointerType::Touch;
684 point.id = touch->identifier(); 684 point.id = touch->identifier();
685 point.screenPosition = touch->screenLocation(); 685 point.screenPosition = touch->screenLocation();
686 point.position = convertAbsoluteLocationForLayoutObjectFloat( 686 point.position = convertAbsoluteLocationForLayoutObjectFloat(
687 touch->absoluteLocation(), layoutItem); 687 DoublePoint(touch->absoluteLocation()), layoutItem);
688 point.radiusX = touch->radiusX(); 688 point.radiusX = touch->radiusX();
689 point.radiusY = touch->radiusY(); 689 point.radiusY = touch->radiusY();
690 point.rotationAngle = touch->rotationAngle(); 690 point.rotationAngle = touch->rotationAngle();
691 point.force = touch->force(); 691 point.force = touch->force();
692 point.state = state; 692 point.state = state;
693 return point; 693 return point;
694 } 694 }
695 695
696 static unsigned indexOfTouchPointWithId(const WebTouchPoint* touchPoints, 696 static unsigned indexOfTouchPointWithId(const WebTouchPoint* touchPoints,
697 unsigned touchPointsLength, 697 unsigned touchPointsLength,
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 } else if (event.type() == EventTypeNames::gesturetap) { 804 } else if (event.type() == EventTypeNames::gesturetap) {
805 type = GestureTap; 805 type = GestureTap;
806 data.tap.tapCount = 1; 806 data.tap.tapCount = 1;
807 } 807 }
808 808
809 timeStampSeconds = event.platformTimeStamp(); 809 timeStampSeconds = event.platformTimeStamp();
810 modifiers = event.modifiers(); 810 modifiers = event.modifiers();
811 811
812 globalX = event.screenX(); 812 globalX = event.screenX();
813 globalY = event.screenY(); 813 globalY = event.screenY();
814 IntPoint localPoint = convertAbsoluteLocationForLayoutObject( 814 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt(
815 event.absoluteLocation(), layoutItem); 815 event.absoluteLocation(), layoutItem);
816 x = localPoint.x(); 816 x = localPoint.x();
817 y = localPoint.y(); 817 y = localPoint.y();
818 818
819 switch (event.source()) { 819 switch (event.source()) {
820 case GestureSourceTouchpad: 820 case GestureSourceTouchpad:
821 sourceDevice = WebGestureDeviceTouchpad; 821 sourceDevice = WebGestureDeviceTouchpad;
822 break; 822 break;
823 case GestureSourceTouchscreen: 823 case GestureSourceTouchscreen:
824 sourceDevice = WebGestureDeviceTouchscreen; 824 sourceDevice = WebGestureDeviceTouchscreen;
825 break; 825 break;
826 case GestureSourceUninitialized: 826 case GestureSourceUninitialized:
827 NOTREACHED(); 827 NOTREACHED();
828 } 828 }
829 } 829 }
830 830
831 } // namespace blink 831 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698