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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/web/WebInputEvent.cpp ('k') | Source/web/tests/WebInputEventConversionTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebInputEventConversion.cpp
diff --git a/Source/web/WebInputEventConversion.cpp b/Source/web/WebInputEventConversion.cpp
index 204429c7f6e95f54467d3efcde20d7732bcd39f3..657afcc80ed005cda00b6fb699593a157246b06e 100644
--- a/Source/web/WebInputEventConversion.cpp
+++ b/Source/web/WebInputEventConversion.cpp
@@ -741,25 +741,51 @@ WebKeyboardEventBuilder::WebKeyboardEventBuilder(const PlatformKeyboardEvent& ev
memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), std::min(static_cast<unsigned>(keyIdentifierLengthCap), event.keyIdentifier().length()));
}
-static void addTouchPoints(const Widget* widget, const AtomicString& touchType, TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, const RenderObject* renderObject)
+static WebTouchPoint toWebTouchPoint(const Touch* touch, const RenderObject* renderObject)
+{
+ WebTouchPoint point;
+ point.id = touch->identifier();
+ point.screenPosition = touch->screenLocation();
+ point.position = convertAbsoluteLocationForRenderObjectFloat(touch->absoluteLocation(), *renderObject);
+ point.radiusX = touch->radiusX();
+ point.radiusY = touch->radiusY();
+ point.rotationAngle = touch->webkitRotationAngle();
+ point.force = touch->force();
+ point.state = WebTouchPoint::StateStationary;
+ return point;
+}
+
+static void addActiveTouchPoints(const Widget* widget, TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, const RenderObject* renderObject)
{
unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned>(WebTouchEvent::touchesLengthCap));
- for (unsigned i = 0; i < numberOfTouches; ++i) {
+ for (unsigned i = 0; i < numberOfTouches; ++i)
+ touchPoints[i] = toWebTouchPoint(touches->item(i), renderObject);
+ *touchPointsLength = numberOfTouches;
+}
+
+static void addOrUpdateChangedTouchPoints(const Widget* widget, const AtomicString& touchType, TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, const RenderObject* renderObject)
+{
+ unsigned initialTouchPointsLength = *touchPointsLength;
+ for (unsigned i = 0; i < touches->length(); ++i) {
const Touch* touch = touches->item(i);
- WebTouchPoint point;
- point.id = touch->identifier();
- point.screenPosition = touch->screenLocation();
- point.position = convertAbsoluteLocationForRenderObjectFloat(touch->absoluteLocation(), *renderObject);
- point.radiusX = touch->radiusX();
- point.radiusY = touch->radiusY();
- point.rotationAngle = touch->webkitRotationAngle();
- point.force = touch->force();
- point.state = toWebTouchPointState(touchType);
-
- touchPoints[i] = point;
+ unsigned pointIndex = *touchPointsLength;
+ for (unsigned j = 0; j < initialTouchPointsLength; ++j) {
+ if (touchPoints[j].id == static_cast<int>(touch->identifier())) {
+ 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.
+ break;
+ }
+ }
+
+ if (pointIndex >= static_cast<unsigned>(WebTouchEvent::touchesLengthCap))
+ continue;
+
+ if (pointIndex == *touchPointsLength) {
+ ++(*touchPointsLength);
+ touchPoints[pointIndex] = toWebTouchPoint(touch, renderObject);
+ }
+ touchPoints[pointIndex].state = toWebTouchPointState(touchType);
}
- *touchPointsLength = numberOfTouches;
}
WebTouchEventBuilder::WebTouchEventBuilder(const Widget* widget, const RenderObject* renderObject, const TouchEvent& event)
@@ -782,9 +808,8 @@ WebTouchEventBuilder::WebTouchEventBuilder(const Widget* widget, const RenderObj
timeStampSeconds = event.timeStamp() / millisPerSecond;
cancelable = event.cancelable();
- addTouchPoints(widget, event.type(), event.touches(), touches, &touchesLength, renderObject);
- addTouchPoints(widget, event.type(), event.changedTouches(), changedTouches, &changedTouchesLength, renderObject);
- addTouchPoints(widget, event.type(), event.targetTouches(), targetTouches, &targetTouchesLength, renderObject);
+ addActiveTouchPoints(widget, event.touches(), touches, &touchesLength, renderObject);
+ addOrUpdateChangedTouchPoints(widget, event.type(), event.changedTouches(), touches, &touchesLength, renderObject);
}
WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const RenderObject* renderObject, const GestureEvent& event)
« 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