Consolidate touch event code dealing with force.
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Sep 2015 22:25:36 +0000 (22:25 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Sep 2015 22:25:36 +0000 (22:25 +0000)
Reviewed by Beth Dakin.

* Shared/WebEvent.h:
(WebKit::WebPlatformTouchPoint::state):
(WebKit::WebPlatformTouchPoint::setForce):
(WebKit::WebPlatformTouchPoint::force):
* Shared/ios/NativeWebTouchEventIOS.mm:
(WebKit::positionForCGPoint):
(WebKit::NativeWebTouchEvent::extractWebTouchPoint):
(WebKit::NativeWebTouchEvent::NativeWebTouchEvent):
* Shared/ios/WebPlatformTouchPointIOS.cpp:
(WebKit::WebPlatformTouchPoint::encode):
(WebKit::WebPlatformTouchPoint::decode):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189753 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebEvent.h
Source/WebKit2/Shared/ios/NativeWebTouchEventIOS.mm
Source/WebKit2/Shared/ios/WebPlatformTouchPointIOS.cpp

index 0f5b796..a4d388e 100644 (file)
@@ -1,3 +1,21 @@
+2015-09-14  Dan Bernstein  <mitz@apple.com>
+
+        Consolidate touch event code dealing with force.
+
+        Reviewed by Beth Dakin.
+
+        * Shared/WebEvent.h:
+        (WebKit::WebPlatformTouchPoint::state):
+        (WebKit::WebPlatformTouchPoint::setForce):
+        (WebKit::WebPlatformTouchPoint::force):
+        * Shared/ios/NativeWebTouchEventIOS.mm:
+        (WebKit::positionForCGPoint):
+        (WebKit::NativeWebTouchEvent::extractWebTouchPoint):
+        (WebKit::NativeWebTouchEvent::NativeWebTouchEvent):
+        * Shared/ios/WebPlatformTouchPointIOS.cpp:
+        (WebKit::WebPlatformTouchPoint::encode):
+        (WebKit::WebPlatformTouchPoint::decode):
+
 2015-09-14  Alex Christensen  <achristensen@webkit.org>
 
         Progress towards CMake on Mac.
index c42aeef..c15d4df 100644 (file)
@@ -310,7 +310,8 @@ public:
     TouchPointState state() const { return phase(); }
 
 #if ENABLE(IOS_TOUCH_EVENTS)
-#include <WebKitAdditions/WebEventIOS.h>
+    void setForce(double force) { m_force = force; }
+    double force() const { return m_force; }
 #endif
 
     void encode(IPC::ArgumentEncoder&) const;
@@ -320,6 +321,9 @@ private:
     unsigned m_identifier;
     WebCore::IntPoint m_location;
     uint32_t m_phase;
+#if ENABLE(IOS_TOUCH_EVENTS)
+    double m_force { 0 };
+#endif
 };
 
 class WebTouchEvent : public WebEvent {
index 15e9980..00e7193 100644 (file)
@@ -75,9 +75,6 @@ static inline WebCore::IntPoint positionForCGPoint(CGPoint position)
     return WebCore::IntPoint(position);
 }
 
-#if ENABLE(IOS_TOUCH_EVENTS)
-#import <WebKitAdditions/NativeWebTouchEventIOS.mm>
-#else
 Vector<WebPlatformTouchPoint> NativeWebTouchEvent::extractWebTouchPoint(const _UIWebTouchEvent* event)
 {
     unsigned touchCount = event->touchPointCount;
@@ -89,11 +86,14 @@ Vector<WebPlatformTouchPoint> NativeWebTouchEvent::extractWebTouchPoint(const _U
         unsigned identifier = touchPoint.identifier;
         WebCore::IntPoint location = positionForCGPoint(touchPoint.locationInDocumentCoordinates);
         WebPlatformTouchPoint::TouchPointState phase = convertTouchPhase(touchPoint.phase);
-        touchPointList.uncheckedAppend(WebPlatformTouchPoint(identifier, location, phase));
+        WebPlatformTouchPoint platformTouchPoint = WebPlatformTouchPoint(identifier, location, phase);
+#if ENABLE(IOS_TOUCH_EVENTS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000
+        platformTouchPoint.setForce(touchPoint.force);
+#endif
+        touchPointList.uncheckedAppend(platformTouchPoint);
     }
     return touchPointList;
 }
-#endif
 
 NativeWebTouchEvent::NativeWebTouchEvent(const _UIWebTouchEvent* event)
     : WebTouchEvent(
index 6af9c48..a241c9e 100644 (file)
@@ -35,14 +35,14 @@ using namespace WebCore;
 
 namespace WebKit {
 
-#if ENABLE(IOS_TOUCH_EVENTS)
-#import <WebKitAdditions/WebPlatformTouchPointIOS.cpp>
-#else
 void WebPlatformTouchPoint::encode(IPC::ArgumentEncoder& encoder) const
 {
     encoder << m_identifier;
     encoder << m_location;
     encoder << m_phase;
+#if ENABLE(IOS_TOUCH_EVENTS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000
+    encoder << m_force;
+#endif
 }
 
 bool WebPlatformTouchPoint::decode(IPC::ArgumentDecoder& decoder, WebPlatformTouchPoint& result)
@@ -53,9 +53,12 @@ bool WebPlatformTouchPoint::decode(IPC::ArgumentDecoder& decoder, WebPlatformTou
         return false;
     if (!decoder.decode(result.m_phase))
         return false;
+#if ENABLE(IOS_TOUCH_EVENTS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000
+    if (!decoder.decode(result.m_force))
+        return false;
+#endif
     return true;
 }
-#endif // ENABLE(IOS_TOUCH_EVENTS)
 
 } // namespace WebKit