Fix the WebKitTestRunner build
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 May 2019 06:30:51 +0000 (06:30 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 May 2019 06:30:51 +0000 (06:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197449
<rdar://problem/50334169>

Reviewed by Alexey Proskuryakov.

* WebKitTestRunner/mac/EventSenderProxy.mm:
(-[EventSenderSyntheticEvent initPressureEventAtLocation:globalLocation:stage:pressure:stageTransition:phase:time:eventNumber:window:]):
(WTR::EventSenderProxy::mouseForceChanged):
Use some SPI instead of IPI.

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

Tools/ChangeLog
Tools/TestRunnerShared/spi/CoreGraphicsTestSPI.h
Tools/WebKitTestRunner/mac/EventSenderProxy.mm

index d068d7d..72f9b10 100644 (file)
@@ -1,3 +1,16 @@
+2019-04-30  Tim Horton  <timothy_horton@apple.com>
+
+        Fix the WebKitTestRunner build
+        https://bugs.webkit.org/show_bug.cgi?id=197449
+        <rdar://problem/50334169>
+
+        Reviewed by Alexey Proskuryakov.
+
+        * WebKitTestRunner/mac/EventSenderProxy.mm:
+        (-[EventSenderSyntheticEvent initPressureEventAtLocation:globalLocation:stage:pressure:stageTransition:phase:time:eventNumber:window:]):
+        (WTR::EventSenderProxy::mouseForceChanged):
+        Use some SPI instead of IPI.
+
 2019-04-30  Chris Dumez  <cdumez@apple.com>
 
         Regression(PSON) URL scheme handlers can no longer respond asynchronously
index e75be07..029a9d8 100644 (file)
@@ -84,6 +84,21 @@ enum {
 };
 typedef uint32_t CGSHIDEventType;
 
+typedef CF_ENUM(uint8_t, CGSGesturePhase)
+{
+    kCGSGesturePhaseNone = 0,
+    kCGSGesturePhaseBegan = 1,
+    kCGSGesturePhaseChanged = 2,
+    kCGSGesturePhaseEnded = 4,
+    kCGSGesturePhaseCancelled = 8,
+    kCGSGesturePhaseMayBegin = 128
+};
+
+typedef CF_ENUM(uint8_t, CGSGestureBehavior)
+{
+    kCGSGestureBehaviorDeepPress = 5,
+};
+
 CGPoint CGEventGetWindowLocation(CGEventRef);
 void CGEventSetWindowLocation(CGEventRef, CGPoint);
 
index 3985e14..75537f1 100644 (file)
@@ -27,6 +27,7 @@
 #import "config.h"
 #import "EventSenderProxy.h"
 
+#import "CoreGraphicsTestSPI.h"
 #import "PlatformWebView.h"
 #import "StringFunctions.h"
 #import "TestController.h"
@@ -45,6 +46,7 @@
 
 @interface NSEvent (ForTestRunner)
 - (void)_postDelayed;
+- (instancetype)_initWithCGEvent:(CGEventRef)event eventRef:(void *)eventRef;
 @end
 
 @interface EventSenderSyntheticEvent : NSEvent {
 
 @implementation EventSenderSyntheticEvent
 
-- (id)initPressureEventAtLocation:(NSPoint)location globalLocation:(NSPoint)globalLocation stage:(NSInteger)stage pressure:(float)pressure stageTransition:(float)stageTransition phase:(NSEventPhase)phase time:(NSTimeInterval)time eventNumber:(NSInteger)eventNumber window:(NSWindow *)window
-{
-    self = [super init];
+- (instancetype)initPressureEventAtLocation:(NSPoint)location globalLocation:(NSPoint)globalLocation stage:(NSInteger)stage pressure:(float)pressure stageTransition:(float)stageTransition phase:(NSEventPhase)phase time:(NSTimeInterval)time eventNumber:(NSInteger)eventNumber window:(NSWindow *)window
+{
+    CGSGesturePhase gesturePhase;
+    switch (phase) {
+    case NSEventPhaseMayBegin:
+        gesturePhase = kCGSGesturePhaseMayBegin;
+        break;
+    case NSEventPhaseBegan:
+        gesturePhase = kCGSGesturePhaseBegan;
+        break;
+    case NSEventPhaseChanged:
+        gesturePhase = kCGSGesturePhaseChanged;
+        break;
+    case NSEventPhaseCancelled:
+        gesturePhase = kCGSGesturePhaseCancelled;
+        break;
+    case NSEventPhaseEnded:
+        gesturePhase = kCGSGesturePhaseEnded;
+        break;
+    case NSEventPhaseNone:
+    default:
+        gesturePhase = kCGSGesturePhaseNone;
+        break;
+    }
+
+    CGEventRef cgEvent = CGEventCreate(nullptr);
+    CGEventSetType(cgEvent, (CGEventType)kCGSEventGesture);
+    CGEventSetIntegerValueField(cgEvent, kCGEventGestureHIDType, 32);
+    CGEventSetIntegerValueField(cgEvent, kCGEventGesturePhase, gesturePhase);
+    CGEventSetDoubleValueField(cgEvent, kCGEventStagePressure, pressure);
+    CGEventSetDoubleValueField(cgEvent, kCGEventTransitionProgress, pressure);
+    CGEventSetIntegerValueField(cgEvent, kCGEventGestureStage, stageTransition);
+    CGEventSetIntegerValueField(cgEvent, kCGEventGestureBehavior, kCGSGestureBehaviorDeepPress);
+
+    self = [super _initWithCGEvent:cgEvent eventRef:nullptr];
 
     if (!self)
         return nil;
     _eventSender_timestamp = time;
     _eventSender_eventNumber = eventNumber;
     _eventSender_window = window;
-#if defined(__LP64__)
-    self->_type = NSEventTypePressure;
     _eventSender_type = NSEventTypePressure;
-#endif
 
     return self;
 }
@@ -325,7 +356,6 @@ void EventSenderProxy::mouseUp(unsigned buttonNumber, WKEventModifiers modifiers
     m_clickPosition = m_position;
 }
 
-#if defined(__LP64__)
 void EventSenderProxy::sendMouseDownToStartPressureEvents()
 {
     updateClickCountForButton(0);
@@ -525,49 +555,6 @@ void EventSenderProxy::mouseForceChanged(float force)
     [targetView pressureChangeWithEvent:nil];
     IGNORE_NULL_CHECK_WARNINGS_END
 }
-#else
-
-#if PLATFORM(COCOA)
-RetainPtr<NSEvent> EventSenderProxy::beginPressureEvent(int)
-{
-    return nil;
-}
-
-RetainPtr<NSEvent> EventSenderProxy::pressureChangeEvent(int, PressureChangeDirection)
-{
-    return nil;
-}
-
-RetainPtr<NSEvent> EventSenderProxy::pressureChangeEvent(int, float, PressureChangeDirection)
-{
-    return nil;
-}
-#endif // PLATFORM(COCOA)
-
-void EventSenderProxy::sendMouseDownToStartPressureEvents()
-{
-}
-
-void EventSenderProxy::mouseForceDown()
-{
-}
-
-void EventSenderProxy::mouseForceUp()
-{
-}
-
-void EventSenderProxy::mouseForceChanged(float)
-{
-}
-
-void EventSenderProxy::mouseForceClick()
-{
-}
-
-void EventSenderProxy::startAndCancelMouseForceClick()
-{
-}
-#endif // defined(__LP64__)
 
 void EventSenderProxy::mouseMoveTo(double x, double y)
 {