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..166bc9d43fb9452e6480f5a5f2cfd993fe1f9d6f |
--- /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) + frameTranslateX, |
+ (y / frameScale) + frameTranslateY); |
+} |
+ |
+int WebGestureEvent::tapCount() const { |
+ DCHECK(type == WebInputEvent::GestureTap); |
+ return data.tap.tapCount; |
+} |
+ |
+void WebGestureEvent::applyTouchAdjustment(WebFloatPoint rootFrameCoords) { |
+ frameTranslateX = rootFrameCoords.x - (x / frameScale); |
+ frameTranslateY = rootFrameCoords.y - (y / frameScale); |
+} |
+ |
+void WebGestureEvent::flattenScale() { |
+ 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) + frameTranslateX; |
+ y = (y / frameScale) + frameTranslateY; |
+ frameTranslateX = 0; |
+ frameTranslateY = 0; |
+ frameScale = 1; |
+} |
+ |
+} // namespace blink |