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

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

Issue 558773002: Remove WebTouchEvent.targetTouches (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updates Created 6 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 | « Source/web/WebInputEvent.cpp ('k') | Source/web/tests/WebInputEventConversionTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 nativeKeyCode = event.nativeVirtualKeyCode(); 734 nativeKeyCode = event.nativeVirtualKeyCode();
735 735
736 windowsKeyCode = windowsKeyCodeWithoutLocation(event.windowsVirtualKeyCode() ); 736 windowsKeyCode = windowsKeyCodeWithoutLocation(event.windowsVirtualKeyCode() );
737 modifiers |= locationModifiersFromWindowsKeyCode(event.windowsVirtualKeyCode ()); 737 modifiers |= locationModifiersFromWindowsKeyCode(event.windowsVirtualKeyCode ());
738 738
739 event.text().copyTo(text, 0, textLengthCap); 739 event.text().copyTo(text, 0, textLengthCap);
740 event.unmodifiedText().copyTo(unmodifiedText, 0, textLengthCap); 740 event.unmodifiedText().copyTo(unmodifiedText, 0, textLengthCap);
741 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), std::min(static_ cast<unsigned>(keyIdentifierLengthCap), event.keyIdentifier().length())); 741 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), std::min(static_ cast<unsigned>(keyIdentifierLengthCap), event.keyIdentifier().length()));
742 } 742 }
743 743
744 static void addTouchPoints(const Widget* widget, const AtomicString& touchType, TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, con st RenderObject* renderObject) 744 static WebTouchPoint toWebTouchPoint(const Touch* touch, const RenderObject* ren derObject)
745 {
746 WebTouchPoint point;
747 point.id = touch->identifier();
748 point.screenPosition = touch->screenLocation();
749 point.position = convertAbsoluteLocationForRenderObjectFloat(touch->absolute Location(), *renderObject);
750 point.radiusX = touch->radiusX();
751 point.radiusY = touch->radiusY();
752 point.rotationAngle = touch->webkitRotationAngle();
753 point.force = touch->force();
754 point.state = WebTouchPoint::StateStationary;
755 return point;
756 }
757
758 static void addActiveTouchPoints(const Widget* widget, TouchList* touches, WebTo uchPoint* touchPoints, unsigned* touchPointsLength, const RenderObject* renderOb ject)
745 { 759 {
746 unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned> (WebTouchEvent::touchesLengthCap)); 760 unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned> (WebTouchEvent::touchesLengthCap));
747 for (unsigned i = 0; i < numberOfTouches; ++i) { 761 for (unsigned i = 0; i < numberOfTouches; ++i)
748 const Touch* touch = touches->item(i); 762 touchPoints[i] = toWebTouchPoint(touches->item(i), renderObject);
749
750 WebTouchPoint point;
751 point.id = touch->identifier();
752 point.screenPosition = touch->screenLocation();
753 point.position = convertAbsoluteLocationForRenderObjectFloat(touch->abso luteLocation(), *renderObject);
754 point.radiusX = touch->radiusX();
755 point.radiusY = touch->radiusY();
756 point.rotationAngle = touch->webkitRotationAngle();
757 point.force = touch->force();
758 point.state = toWebTouchPointState(touchType);
759
760 touchPoints[i] = point;
761 }
762 *touchPointsLength = numberOfTouches; 763 *touchPointsLength = numberOfTouches;
763 } 764 }
764 765
766 static void addOrUpdateChangedTouchPoints(const Widget* widget, const AtomicStri ng& touchType, TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPo intsLength, const RenderObject* renderObject)
767 {
768 unsigned initialTouchPointsLength = *touchPointsLength;
769 for (unsigned i = 0; i < touches->length(); ++i) {
770 const Touch* touch = touches->item(i);
771
772 unsigned pointIndex = *touchPointsLength;
773 for (unsigned j = 0; j < initialTouchPointsLength; ++j) {
774 if (touchPoints[j].id == static_cast<int>(touch->identifier())) {
775 pointIndex = j;
aelias_OOO_until_Jul13 2014/09/10 01:14:05 Would it have correct semantics to first add the c
jdduke (slow) 2014/09/10 01:53:36 Yeah, that also works, will update in the morning.
776 break;
777 }
778 }
779
780 if (pointIndex >= static_cast<unsigned>(WebTouchEvent::touchesLengthCap) )
781 continue;
782
783 if (pointIndex == *touchPointsLength) {
784 ++(*touchPointsLength);
785 touchPoints[pointIndex] = toWebTouchPoint(touch, renderObject);
786 }
787 touchPoints[pointIndex].state = toWebTouchPointState(touchType);
788 }
789 }
790
765 WebTouchEventBuilder::WebTouchEventBuilder(const Widget* widget, const RenderObj ect* renderObject, const TouchEvent& event) 791 WebTouchEventBuilder::WebTouchEventBuilder(const Widget* widget, const RenderObj ect* renderObject, const TouchEvent& event)
766 { 792 {
767 if (event.type() == EventTypeNames::touchstart) 793 if (event.type() == EventTypeNames::touchstart)
768 type = TouchStart; 794 type = TouchStart;
769 else if (event.type() == EventTypeNames::touchmove) 795 else if (event.type() == EventTypeNames::touchmove)
770 type = TouchMove; 796 type = TouchMove;
771 else if (event.type() == EventTypeNames::touchend) 797 else if (event.type() == EventTypeNames::touchend)
772 type = TouchEnd; 798 type = TouchEnd;
773 else if (event.type() == EventTypeNames::touchcancel) 799 else if (event.type() == EventTypeNames::touchcancel)
774 type = TouchCancel; 800 type = TouchCancel;
775 else { 801 else {
776 ASSERT_NOT_REACHED(); 802 ASSERT_NOT_REACHED();
777 type = Undefined; 803 type = Undefined;
778 return; 804 return;
779 } 805 }
780 806
781 modifiers = getWebInputModifiers(event); 807 modifiers = getWebInputModifiers(event);
782 timeStampSeconds = event.timeStamp() / millisPerSecond; 808 timeStampSeconds = event.timeStamp() / millisPerSecond;
783 cancelable = event.cancelable(); 809 cancelable = event.cancelable();
784 810
785 addTouchPoints(widget, event.type(), event.touches(), touches, &touchesLengt h, renderObject); 811 addActiveTouchPoints(widget, event.touches(), touches, &touchesLength, rende rObject);
786 addTouchPoints(widget, event.type(), event.changedTouches(), changedTouches, &changedTouchesLength, renderObject); 812 addOrUpdateChangedTouchPoints(widget, event.type(), event.changedTouches(), touches, &touchesLength, renderObject);
787 addTouchPoints(widget, event.type(), event.targetTouches(), targetTouches, & targetTouchesLength, renderObject);
788 } 813 }
789 814
790 WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const Rende rObject* renderObject, const GestureEvent& event) 815 WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const Rende rObject* renderObject, const GestureEvent& event)
791 { 816 {
792 if (event.type() == EventTypeNames::gestureshowpress) 817 if (event.type() == EventTypeNames::gestureshowpress)
793 type = GestureShowPress; 818 type = GestureShowPress;
794 else if (event.type() == EventTypeNames::gesturetapdown) 819 else if (event.type() == EventTypeNames::gesturetapdown)
795 type = GestureTapDown; 820 type = GestureTapDown;
796 else if (event.type() == EventTypeNames::gesturescrollstart) 821 else if (event.type() == EventTypeNames::gesturescrollstart)
797 type = GestureScrollBegin; 822 type = GestureScrollBegin;
(...skipping 12 matching lines...) Expand all
810 modifiers = getWebInputModifiers(event); 835 modifiers = getWebInputModifiers(event);
811 836
812 globalX = event.screenX(); 837 globalX = event.screenX();
813 globalY = event.screenY(); 838 globalY = event.screenY();
814 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL ocation(), *renderObject); 839 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL ocation(), *renderObject);
815 x = localPoint.x(); 840 x = localPoint.x();
816 y = localPoint.y(); 841 y = localPoint.y();
817 } 842 }
818 843
819 } // namespace blink 844 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebInputEvent.cpp ('k') | Source/web/tests/WebInputEventConversionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698