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

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: Cleanup and simplify 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, WebTouchPoint::State state)
745 { 745 {
746 unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned> (WebTouchEvent::touchesLengthCap)); 746 WebTouchPoint point;
747 for (unsigned i = 0; i < numberOfTouches; ++i) { 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 = state;
755 return point;
756 }
757
758 static bool hasTouchPointWithId(const WebTouchPoint* touchPoints, unsigned touch PointsLength, unsigned id)
759 {
760 for (unsigned i = 0; i < touchPointsLength; ++i) {
761 if (touchPoints[i].id == static_cast<int>(id))
762 return true;
763 }
764 return false;
765 }
766
767 static void addTouchPointsIfNotYetAdded(const Widget* widget, WebTouchPoint::Sta te state, TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsL ength, const RenderObject* renderObject)
768 {
769 unsigned initialTouchPointsLength = *touchPointsLength;
770 for (unsigned i = 0; i < touches->length(); ++i) {
771 const unsigned pointIndex = *touchPointsLength;
772 if (pointIndex >= static_cast<unsigned>(WebTouchEvent::touchesLengthCap) )
773 return;
774
748 const Touch* touch = touches->item(i); 775 const Touch* touch = touches->item(i);
776 if (hasTouchPointWithId(touchPoints, initialTouchPointsLength, touch->id entifier()))
777 continue;
749 778
750 WebTouchPoint point; 779 touchPoints[pointIndex] = toWebTouchPoint(touch, renderObject, state);
751 point.id = touch->identifier(); 780 ++(*touchPointsLength);
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 } 781 }
762 *touchPointsLength = numberOfTouches;
763 } 782 }
764 783
765 WebTouchEventBuilder::WebTouchEventBuilder(const Widget* widget, const RenderObj ect* renderObject, const TouchEvent& event) 784 WebTouchEventBuilder::WebTouchEventBuilder(const Widget* widget, const RenderObj ect* renderObject, const TouchEvent& event)
766 { 785 {
767 if (event.type() == EventTypeNames::touchstart) 786 if (event.type() == EventTypeNames::touchstart)
768 type = TouchStart; 787 type = TouchStart;
769 else if (event.type() == EventTypeNames::touchmove) 788 else if (event.type() == EventTypeNames::touchmove)
770 type = TouchMove; 789 type = TouchMove;
771 else if (event.type() == EventTypeNames::touchend) 790 else if (event.type() == EventTypeNames::touchend)
772 type = TouchEnd; 791 type = TouchEnd;
773 else if (event.type() == EventTypeNames::touchcancel) 792 else if (event.type() == EventTypeNames::touchcancel)
774 type = TouchCancel; 793 type = TouchCancel;
775 else { 794 else {
776 ASSERT_NOT_REACHED(); 795 ASSERT_NOT_REACHED();
777 type = Undefined; 796 type = Undefined;
778 return; 797 return;
779 } 798 }
780 799
781 modifiers = getWebInputModifiers(event); 800 modifiers = getWebInputModifiers(event);
782 timeStampSeconds = event.timeStamp() / millisPerSecond; 801 timeStampSeconds = event.timeStamp() / millisPerSecond;
783 cancelable = event.cancelable(); 802 cancelable = event.cancelable();
784 803
785 addTouchPoints(widget, event.type(), event.touches(), touches, &touchesLengt h, renderObject); 804 addTouchPointsIfNotYetAdded(widget, toWebTouchPointState(event.type()), even t.changedTouches(), touches, &touchesLength, renderObject);
786 addTouchPoints(widget, event.type(), event.changedTouches(), changedTouches, &changedTouchesLength, renderObject); 805 addTouchPointsIfNotYetAdded(widget, WebTouchPoint::StateStationary, event.to uches(), touches, &touchesLength, renderObject);
787 addTouchPoints(widget, event.type(), event.targetTouches(), targetTouches, & targetTouchesLength, renderObject);
788 } 806 }
789 807
790 WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const Rende rObject* renderObject, const GestureEvent& event) 808 WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const Rende rObject* renderObject, const GestureEvent& event)
791 { 809 {
792 if (event.type() == EventTypeNames::gestureshowpress) 810 if (event.type() == EventTypeNames::gestureshowpress)
793 type = GestureShowPress; 811 type = GestureShowPress;
794 else if (event.type() == EventTypeNames::gesturetapdown) 812 else if (event.type() == EventTypeNames::gesturetapdown)
795 type = GestureTapDown; 813 type = GestureTapDown;
796 else if (event.type() == EventTypeNames::gesturescrollstart) 814 else if (event.type() == EventTypeNames::gesturescrollstart)
797 type = GestureScrollBegin; 815 type = GestureScrollBegin;
(...skipping 12 matching lines...) Expand all
810 modifiers = getWebInputModifiers(event); 828 modifiers = getWebInputModifiers(event);
811 829
812 globalX = event.screenX(); 830 globalX = event.screenX();
813 globalY = event.screenY(); 831 globalY = event.screenY();
814 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL ocation(), *renderObject); 832 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL ocation(), *renderObject);
815 x = localPoint.x(); 833 x = localPoint.x();
816 y = localPoint.y(); 834 y = localPoint.y();
817 } 835 }
818 836
819 } // namespace blink 837 } // 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