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

Unified Diff: third_party/WebKit/Source/platform/WebGestureEvent.cpp

Issue 2539283002: Remove PlatformGestureEvent in favour of using WebGestureEvent (Closed)
Patch Set: Rebase and fix comments Created 4 years 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
Index: third_party/WebKit/Source/platform/WebGestureEvent.cpp
diff --git a/third_party/WebKit/Source/platform/WebGestureEvent.cpp b/third_party/WebKit/Source/platform/WebGestureEvent.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5f961b0163264de6389803328b83d75ded2d4ad9
--- /dev/null
+++ b/third_party/WebKit/Source/platform/WebGestureEvent.cpp
@@ -0,0 +1,147 @@
+#include "public/platform/WebGestureEvent.h"
+
+namespace blink {
+
+float WebGestureEvent::deltaXInRootFrame() const {
+ if (type == WebInputEvent::GestureScrollBegin)
+ return data.scrollBegin.deltaXHint / frameScale;
+ DCHECK(type == WebInputEvent::GestureScrollUpdate);
+ return data.scrollUpdate.deltaX / frameScale;
+}
+
+float WebGestureEvent::deltaYInRootFrame() const {
+ if (type == WebInputEvent::GestureScrollBegin)
+ return data.scrollBegin.deltaYHint / frameScale;
+ DCHECK(type == WebInputEvent::GestureScrollUpdate);
+ return data.scrollUpdate.deltaY / frameScale;
+}
+
+WebGestureEvent::ScrollUnits WebGestureEvent::deltaUnits() const {
+ if (type == WebInputEvent::GestureScrollBegin)
+ return data.scrollBegin.deltaHintUnits;
+ if (type == WebInputEvent::GestureScrollUpdate)
+ return data.scrollUpdate.deltaUnits;
+ DCHECK(type == WebInputEvent::GestureScrollEnd);
+ return data.scrollEnd.deltaUnits;
+}
+
+float WebGestureEvent::pinchScale() const {
+ DCHECK(type == WebInputEvent::GesturePinchUpdate);
+ return data.pinchUpdate.scale;
+}
+
+WebGestureEvent::InertialPhaseState WebGestureEvent::inertialPhase() const {
+ if (type == WebInputEvent::GestureScrollBegin)
+ return data.scrollBegin.inertialPhase;
+ if (type == WebInputEvent::GestureScrollUpdate)
+ return data.scrollUpdate.inertialPhase;
+ DCHECK(type == WebInputEvent::GestureScrollEnd);
+ return data.scrollEnd.inertialPhase;
+}
+
+bool WebGestureEvent::synthetic() const {
+ if (type == WebInputEvent::GestureScrollBegin)
+ return data.scrollBegin.synthetic;
+ DCHECK(type == WebInputEvent::GestureScrollEnd);
+ return data.scrollEnd.synthetic;
+}
+
+float WebGestureEvent::velocityX() const {
+ if (type == WebInputEvent::GestureScrollUpdate)
+ return data.scrollUpdate.velocityX;
+ DCHECK(type == WebInputEvent::GestureFlingStart);
+ return data.flingStart.velocityX;
+}
+
+float WebGestureEvent::velocityY() const {
+ if (type == WebInputEvent::GestureScrollUpdate)
+ return data.scrollUpdate.velocityY;
+ DCHECK(type == WebInputEvent::GestureFlingStart);
+ return data.flingStart.velocityY;
+}
+
+WebFloatSize WebGestureEvent::tapAreaInRootFrame() const {
+ if (type == WebInputEvent::GestureTwoFingerTap) {
+ return WebFloatSize(data.twoFingerTap.firstFingerWidth / frameScale,
+ data.twoFingerTap.firstFingerHeight / frameScale);
+ } else if (type == WebInputEvent::GestureLongPress ||
+ type == WebInputEvent::GestureLongTap) {
+ return WebFloatSize(data.longPress.width / frameScale,
+ data.longPress.height / frameScale);
+ } else if (type == WebInputEvent::GestureTap ||
+ type == WebInputEvent::GestureTapUnconfirmed) {
+ return WebFloatSize(data.tap.width / frameScale,
+ data.tap.height / frameScale);
+ } else if (type == WebInputEvent::GestureTapDown) {
+ return WebFloatSize(data.tapDown.width / frameScale,
+ data.tapDown.height / frameScale);
+ } else if (type == WebInputEvent::GestureShowPress) {
+ return WebFloatSize(data.showPress.width / frameScale,
+ data.showPress.height / frameScale);
+ }
+ // This function is called for all gestures and determined if the tap
+ // area is empty or not; so return an empty rect here.
+ return WebFloatSize();
+}
+
+WebFloatPoint WebGestureEvent::positionInRootFrame() const {
+ return WebFloatPoint((x / frameScale) + frameTranslate.x,
+ (y / frameScale) + frameTranslate.y);
+}
+
+int WebGestureEvent::tapCount() const {
+ DCHECK(type == WebInputEvent::GestureTap);
+ return data.tap.tapCount;
+}
+
+void WebGestureEvent::applyTouchAdjustment(WebFloatPoint rootFrameCoords) {
+ frameTranslate.x = rootFrameCoords.x - (x / frameScale);
majidvp 2016/12/15 17:40:46 nit: the original method had a comment which was i
dtapuska 2016/12/15 21:29:39 Done.
+ frameTranslate.y = rootFrameCoords.y - (y / frameScale);
+}
+
+void WebGestureEvent::flattenTransform() {
+ if (frameScale != 1.0) {
+ switch (type) {
+ case WebInputEvent::GestureScrollBegin:
+ data.scrollBegin.deltaXHint /= frameScale;
+ data.scrollBegin.deltaYHint /= frameScale;
+ break;
+ case WebInputEvent::GestureScrollUpdate:
+ data.scrollUpdate.deltaX /= frameScale;
+ data.scrollUpdate.deltaY /= frameScale;
+ break;
+ case WebInputEvent::GestureTwoFingerTap:
+ data.twoFingerTap.firstFingerWidth /= frameScale;
+ data.twoFingerTap.firstFingerHeight /= frameScale;
+ break;
+ case WebInputEvent::GestureLongPress:
+ case WebInputEvent::GestureLongTap:
+ data.longPress.width /= frameScale;
+ data.longPress.height /= frameScale;
+ break;
+ case WebInputEvent::GestureTap:
+ case WebInputEvent::GestureTapUnconfirmed:
+ data.tap.width /= frameScale;
+ data.tap.height /= frameScale;
+ break;
+ case WebInputEvent::GestureTapDown:
+ data.tapDown.width /= frameScale;
+ data.tapDown.height /= frameScale;
+ break;
+ case WebInputEvent::GestureShowPress:
+ data.showPress.width /= frameScale;
+ data.showPress.height /= frameScale;
+ break;
+ default:
+ break;
+ }
+ }
+
+ x = (x / frameScale) + frameTranslate.x;
mustaq 2016/12/15 19:25:46 Any way we can do these transforms in a common pla
dtapuska 2016/12/15 21:29:39 I think that adding inline for div operators will
mustaq 2016/12/15 22:16:13 I didn't mean operator overload, sorry for being t
+ y = (y / frameScale) + frameTranslate.y;
+ frameTranslate.x = 0;
+ frameTranslate.y = 0;
+ frameScale = 1;
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698