OLD | NEW |
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 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(); |
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 WebTouchPoint point; | 683 WebTouchPoint point; |
683 point.pointerType = WebPointerProperties::PointerType::Touch; | 684 point.pointerType = type; |
684 point.id = touch->identifier(); | 685 point.id = touch->identifier(); |
685 point.screenPosition = touch->screenLocation(); | 686 point.screenPosition = touch->screenLocation(); |
686 point.position = convertAbsoluteLocationForLayoutObjectFloat( | 687 point.position = convertAbsoluteLocationForLayoutObjectFloat( |
687 DoublePoint(touch->absoluteLocation()), layoutItem); | 688 DoublePoint(touch->absoluteLocation()), layoutItem); |
688 point.radiusX = touch->radiusX(); | 689 point.radiusX = touch->radiusX(); |
689 point.radiusY = touch->radiusY(); | 690 point.radiusY = touch->radiusY(); |
690 point.rotationAngle = touch->rotationAngle(); | 691 point.rotationAngle = touch->rotationAngle(); |
691 point.force = touch->force(); | 692 point.force = touch->force(); |
692 point.state = state; | 693 point.state = state; |
693 return point; | 694 return point; |
694 } | 695 } |
695 | 696 |
696 static unsigned indexOfTouchPointWithId(const WebTouchPoint* touchPoints, | 697 static unsigned indexOfTouchPointWithId(const WebTouchPoint* touchPoints, |
697 unsigned touchPointsLength, | 698 unsigned touchPointsLength, |
698 unsigned id) { | 699 unsigned id) { |
699 for (unsigned i = 0; i < touchPointsLength; ++i) { | 700 for (unsigned i = 0; i < touchPointsLength; ++i) { |
700 if (touchPoints[i].id == static_cast<int>(id)) | 701 if (touchPoints[i].id == static_cast<int>(id)) |
701 return i; | 702 return i; |
702 } | 703 } |
703 return std::numeric_limits<unsigned>::max(); | 704 return std::numeric_limits<unsigned>::max(); |
704 } | 705 } |
705 | 706 |
706 static void addTouchPointsUpdateStateIfNecessary(WebTouchPoint::State state, | 707 static void addTouchPointsUpdateStateIfNecessary( |
707 TouchList* touches, | 708 WebTouchPoint::State state, |
708 WebTouchPoint* touchPoints, | 709 TouchList* touches, |
709 unsigned* touchPointsLength, | 710 WebTouchPoint* touchPoints, |
710 const LayoutItem layoutItem) { | 711 unsigned* touchPointsLength, |
| 712 const LayoutItem layoutItem, |
| 713 WebPointerProperties::PointerType pointerType) { |
711 unsigned initialTouchPointsLength = *touchPointsLength; | 714 unsigned initialTouchPointsLength = *touchPointsLength; |
712 for (unsigned i = 0; i < touches->length(); ++i) { | 715 for (unsigned i = 0; i < touches->length(); ++i) { |
713 const unsigned pointIndex = *touchPointsLength; | 716 const unsigned pointIndex = *touchPointsLength; |
714 if (pointIndex >= static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap)) | 717 if (pointIndex >= static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap)) |
715 return; | 718 return; |
716 | 719 |
717 const Touch* touch = touches->item(i); | 720 const Touch* touch = touches->item(i); |
718 unsigned existingPointIndex = indexOfTouchPointWithId( | 721 unsigned existingPointIndex = indexOfTouchPointWithId( |
719 touchPoints, initialTouchPointsLength, touch->identifier()); | 722 touchPoints, initialTouchPointsLength, touch->identifier()); |
720 if (existingPointIndex != std::numeric_limits<unsigned>::max()) { | 723 if (existingPointIndex != std::numeric_limits<unsigned>::max()) { |
721 touchPoints[existingPointIndex].state = state; | 724 touchPoints[existingPointIndex].state = state; |
722 } else { | 725 } else { |
723 touchPoints[pointIndex] = toWebTouchPoint(touch, layoutItem, state); | 726 touchPoints[pointIndex] = |
| 727 toWebTouchPoint(touch, layoutItem, state, pointerType); |
724 ++(*touchPointsLength); | 728 ++(*touchPointsLength); |
725 } | 729 } |
726 } | 730 } |
727 } | 731 } |
728 | 732 |
729 WebTouchEventBuilder::WebTouchEventBuilder(const LayoutItem layoutItem, | 733 WebTouchEventBuilder::WebTouchEventBuilder(const LayoutItem layoutItem, |
730 const TouchEvent& event) { | 734 const TouchEvent& event) { |
731 if (event.type() == EventTypeNames::touchstart) | 735 if (event.type() == EventTypeNames::touchstart) |
732 type = TouchStart; | 736 type = TouchStart; |
733 else if (event.type() == EventTypeNames::touchmove) | 737 else if (event.type() == EventTypeNames::touchmove) |
(...skipping 12 matching lines...) Expand all Loading... |
746 modifiers = event.modifiers(); | 750 modifiers = event.modifiers(); |
747 dispatchType = event.cancelable() ? WebInputEvent::Blocking | 751 dispatchType = event.cancelable() ? WebInputEvent::Blocking |
748 : WebInputEvent::EventNonBlocking; | 752 : WebInputEvent::EventNonBlocking; |
749 movedBeyondSlopRegion = event.causesScrollingIfUncanceled(); | 753 movedBeyondSlopRegion = event.causesScrollingIfUncanceled(); |
750 | 754 |
751 // Currently touches[] is empty, add stationary points as-is. | 755 // Currently touches[] is empty, add stationary points as-is. |
752 for (unsigned i = 0; | 756 for (unsigned i = 0; |
753 i < event.touches()->length() && | 757 i < event.touches()->length() && |
754 i < static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap); | 758 i < static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap); |
755 ++i) { | 759 ++i) { |
756 touches[i] = toWebTouchPoint(event.touches()->item(i), layoutItem, | 760 touches[i] = |
757 WebTouchPoint::StateStationary); | 761 toWebTouchPoint(event.touches()->item(i), layoutItem, |
| 762 WebTouchPoint::StateStationary, event.pointerType()); |
758 ++touchesLength; | 763 ++touchesLength; |
759 } | 764 } |
760 // If any existing points are also in the change list, we should update | 765 // If any existing points are also in the change list, we should update |
761 // their state, otherwise just add the new points. | 766 // their state, otherwise just add the new points. |
762 addTouchPointsUpdateStateIfNecessary(toWebTouchPointState(event.type()), | 767 addTouchPointsUpdateStateIfNecessary( |
763 event.changedTouches(), touches, | 768 toWebTouchPointState(event.type()), event.changedTouches(), touches, |
764 &touchesLength, layoutItem); | 769 &touchesLength, layoutItem, event.pointerType()); |
765 } | 770 } |
766 | 771 |
767 WebGestureEventBuilder::WebGestureEventBuilder(const LayoutItem layoutItem, | 772 WebGestureEventBuilder::WebGestureEventBuilder(const LayoutItem layoutItem, |
768 const GestureEvent& event) { | 773 const GestureEvent& event) { |
769 if (event.type() == EventTypeNames::gestureshowpress) { | 774 if (event.type() == EventTypeNames::gestureshowpress) { |
770 type = GestureShowPress; | 775 type = GestureShowPress; |
771 } else if (event.type() == EventTypeNames::gesturelongpress) { | 776 } else if (event.type() == EventTypeNames::gesturelongpress) { |
772 type = GestureLongPress; | 777 type = GestureLongPress; |
773 } else if (event.type() == EventTypeNames::gesturetapdown) { | 778 } else if (event.type() == EventTypeNames::gesturetapdown) { |
774 type = GestureTapDown; | 779 type = GestureTapDown; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 Vector<PlatformTouchEvent> result; | 851 Vector<PlatformTouchEvent> result; |
847 for (const auto& event : coalescedEvents) { | 852 for (const auto& event : coalescedEvents) { |
848 DCHECK(WebInputEvent::isTouchEventType(event->type)); | 853 DCHECK(WebInputEvent::isTouchEventType(event->type)); |
849 result.append(PlatformTouchEventBuilder( | 854 result.append(PlatformTouchEventBuilder( |
850 widget, static_cast<const WebTouchEvent&>(*event))); | 855 widget, static_cast<const WebTouchEvent&>(*event))); |
851 } | 856 } |
852 return result; | 857 return result; |
853 } | 858 } |
854 | 859 |
855 } // namespace blink | 860 } // namespace blink |
OLD | NEW |