Changeset 205572 in webkit
- Timestamp:
- Sep 7, 2016 4:32:08 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r205568 r205572 1 2016-09-06 Dean Jackson <dino@apple.com> 2 3 Expose Apple Pencil input to testing system 4 https://bugs.webkit.org/show_bug.cgi?id=161670 5 <rdar://problem/28183327> 6 7 Reviewed by Simon Fraser. 8 9 Four new tests that make sure Apple Pencil's register the correct 10 touch* style events. 11 12 * fast/events/touch/ios/pencil-down-gives-touchstart-expected.txt: Added. 13 * fast/events/touch/ios/pencil-down-gives-touchstart.html: Added. 14 * fast/events/touch/ios/pencil-move-gives-touchmove-expected.txt: Added. 15 * fast/events/touch/ios/pencil-move-gives-touchmove.html: Added. 16 * fast/events/touch/ios/pencil-tap-gives-touchstart-and-touchend-expected.txt: Added. 17 * fast/events/touch/ios/pencil-tap-gives-touchstart-and-touchend.html: Added. 18 * fast/events/touch/ios/pencil-up-gives-touchend-expected.txt: Added. 19 * fast/events/touch/ios/pencil-up-gives-touchend.html: Added. 20 1 21 2016-09-07 Andy VanWagoner <thetalecrafter@gmail.com> 2 22 -
trunk/Tools/ChangeLog
r205560 r205572 1 2016-09-06 Dean Jackson <dino@apple.com> 2 3 Expose Apple Pencil input to testing system 4 https://bugs.webkit.org/show_bug.cgi?id=161670 5 <rdar://problem/28183327> 6 7 Reviewed by Simon Fraser. 8 9 Add API to UIScriptController that allows a test to emulate 10 stylus input, such as from the Apple Pencil. 11 12 The code is only implemented for WebKitTestRunner. 13 14 There are also four new tests that ensure an Apple Pencil 15 operates similarly to a regular touch. The main difference 16 is that you can't have multiple touches when using an Apple Pencil. 17 18 * DumpRenderTree/ios/UIScriptControllerIOS.mm: New methods. Empty implementations. 19 (WTR::UIScriptController::stylusDownAtPoint): 20 (WTR::UIScriptController::stylusMoveToPoint): 21 (WTR::UIScriptController::stylusUpAtPoint): 22 (WTR::UIScriptController::stylusTapAtPoint): 23 * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: New methods. 24 * TestRunnerShared/UIScriptContext/UIScriptController.cpp: Empty implementations. 25 (WTR::UIScriptController::stylusDownAtPoint): 26 (WTR::UIScriptController::stylusMoveToPoint): 27 (WTR::UIScriptController::stylusUpAtPoint): 28 (WTR::UIScriptController::stylusTapAtPoint): 29 * TestRunnerShared/UIScriptContext/UIScriptController.h: 30 31 * WebKitTestRunner/ios/HIDEventGenerator.h: 32 * WebKitTestRunner/ios/HIDEventGenerator.mm: New StylusEvent types. Add some properties 33 to SyntheticEventDigitizerInfo. 34 (-[HIDEventGenerator _createIOHIDEventType:]): Add support for StylusEvent types. 35 (-[HIDEventGenerator touchDownAtPoints:touchCount:]): Clear any old stylus info. 36 (-[HIDEventGenerator stylusDownAtPoint:azimuthAngle:altitudeAngle:pressure:]): 37 (-[HIDEventGenerator stylusMoveToPoint:azimuthAngle:altitudeAngle:pressure:]): 38 (-[HIDEventGenerator stylusUpAtPoint:]): 39 (-[HIDEventGenerator stylusDownAtPoint:azimuthAngle:altitudeAngle:pressure:completionBlock:]): 40 (-[HIDEventGenerator stylusMoveToPoint:azimuthAngle:altitudeAngle:pressure:completionBlock:]): 41 (-[HIDEventGenerator stylusUpAtPoint:completionBlock:]): 42 (-[HIDEventGenerator stylusTapAtPoint:azimuthAngle:altitudeAngle:pressure:completionBlock:]): 43 * WebKitTestRunner/ios/IOKitSPI.h: Add new include, and new SPI. 44 * WebKitTestRunner/ios/UIScriptControllerIOS.mm: Calls into the HIDEventGenerator for the new API. 45 (WTR::UIScriptController::stylusDownAtPoint): 46 (WTR::UIScriptController::stylusMoveToPoint): 47 (WTR::UIScriptController::stylusUpAtPoint): 48 (WTR::UIScriptController::stylusTapAtPoint): 49 1 50 2016-09-07 Daniel Bates <dabates@apple.com> 2 51 -
trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm
r204955 r205572 89 89 } 90 90 91 void UIScriptController::stylusDownAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback) 92 { 93 } 94 95 void UIScriptController::stylusMoveToPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback) 96 { 97 } 98 99 void UIScriptController::stylusUpAtPoint(long x, long y, JSValueRef callback) 100 { 101 } 102 103 void UIScriptController::stylusTapAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback) 104 { 105 } 106 91 107 void UIScriptController::typeCharacterUsingHardwareKeyboard(JSStringRef character, JSValueRef callback) 92 108 { -
trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
r204877 r205572 39 39 void dragFromPointToPoint(long startX, long startY, long endX, long endY, double durationSeconds, object callback); 40 40 41 void stylusDownAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, object callback); 42 void stylusMoveToPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, object callback); 43 void stylusUpAtPoint(long x, long y, object callback); 44 void stylusTapAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, object callback); 45 41 46 void typeCharacterUsingHardwareKeyboard(DOMString character, object callback); 42 47 void keyDownUsingHardwareKeyboard(DOMString character, object callback); -
trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp
r204877 r205572 161 161 } 162 162 163 void UIScriptController::stylusDownAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback) 164 { 165 } 166 167 void UIScriptController::stylusMoveToPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback) 168 { 169 } 170 171 void UIScriptController::stylusUpAtPoint(long x, long y, JSValueRef callback) 172 { 173 } 174 175 void UIScriptController::stylusTapAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback) 176 { 177 } 178 163 179 void UIScriptController::typeCharacterUsingHardwareKeyboard(JSStringRef, JSValueRef) 164 180 { -
trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
r204945 r205572 57 57 void doubleTapAtPoint(long x, long y, JSValueRef callback); 58 58 void dragFromPointToPoint(long startX, long startY, long endX, long endY, double durationSeconds, JSValueRef callback); 59 59 60 void stylusDownAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback); 61 void stylusMoveToPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback); 62 void stylusUpAtPoint(long x, long y, JSValueRef callback); 63 void stylusTapAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback); 64 60 65 void typeCharacterUsingHardwareKeyboard(JSStringRef character, JSValueRef callback); 61 66 void keyDownUsingHardwareKeyboard(JSStringRef character, JSValueRef callback); -
trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.h
r200602 r205572 36 36 - (void)liftUp:(CGPoint)location touchCount:(NSUInteger)count completionBlock:(void (^)(void))completionBlock; 37 37 38 // Stylus 39 - (void)stylusDownAtPoint:(CGPoint)location azimuthAngle:(CGFloat)azimuthAngle altitudeAngle:(CGFloat)altitudeAngle pressure:(CGFloat)pressure completionBlock:(void (^)(void))completionBlock; 40 - (void)stylusMoveToPoint:(CGPoint)location azimuthAngle:(CGFloat)azimuthAngle altitudeAngle:(CGFloat)altitudeAngle pressure:(CGFloat)pressure completionBlock:(void (^)(void))completionBlock; 41 - (void)stylusUpAtPoint:(CGPoint)location completionBlock:(void (^)(void))completionBlock; 42 - (void)stylusTapAtPoint:(CGPoint)location azimuthAngle:(CGFloat)azimuthAngle altitudeAngle:(CGFloat)altitudeAngle pressure:(CGFloat)pressure completionBlock:(void (^)(void))completionBlock; 43 38 44 // Taps 39 45 - (void)tap:(CGPoint)location completionBlock:(void (^)(void))completionBlock; -
trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm
r200602 r205572 56 56 HandEventInRange, 57 57 HandEventInRangeLift, 58 StylusEventTouched, 59 StylusEventMoved, 60 StylusEventLifted, 58 61 } HandEventType; 59 62 … … 64 67 IOHIDFloat pathPressure; 65 68 UInt8 pathProximity; 69 BOOL isStylus; 70 IOHIDFloat azimuthAngle; 71 IOHIDFloat altitudeAngle; 66 72 } SyntheticEventDigitizerInfo; 67 73 … … 143 149 - (IOHIDEventRef)_createIOHIDEventType:(HandEventType)eventType 144 150 { 145 BOOL isTouching = (eventType == HandEventTouched || eventType == HandEventMoved || eventType == HandEventChordChanged );151 BOOL isTouching = (eventType == HandEventTouched || eventType == HandEventMoved || eventType == HandEventChordChanged || eventType == StylusEventTouched || eventType == StylusEventMoved); 146 152 147 153 IOHIDDigitizerEventMask eventMask = kIOHIDDigitizerEventTouch; … … 183 189 if (!pointInfo->pathProximity) 184 190 pointInfo->pathProximity = kGSEventPathInfoInTouch | kGSEventPathInfoInRange; 185 } else if (eventType == HandEventLifted || eventType == HandEventCanceled ) {191 } else if (eventType == HandEventLifted || eventType == HandEventCanceled || eventType == StylusEventLifted) { 186 192 pointInfo->pathMajorRadius = 0; 187 193 pointInfo->pathPressure = 0; … … 191 197 CGPoint point = pointInfo->point; 192 198 point = CGPointMake(roundf(point.x), roundf(point.y)); 193 RetainPtr<IOHIDEventRef> subEvent = adoptCF(IOHIDEventCreateDigitizerFingerEvent(kCFAllocatorDefault, machTime, 194 pointInfo->identifier, 195 pointInfo->identifier, 196 eventMask, 197 point.x, point.y, 0, 198 pointInfo->pathPressure, 199 0, 200 pointInfo->pathProximity & kGSEventPathInfoInRange, 201 pointInfo->pathProximity & kGSEventPathInfoInTouch, 202 kIOHIDEventOptionNone)); 199 RetainPtr<IOHIDEventRef> subEvent; 200 if (pointInfo->isStylus) { 201 if (eventType == StylusEventTouched) { 202 eventMask |= kIOHIDDigitizerEventEstimatedAltitude; 203 eventMask |= kIOHIDDigitizerEventEstimatedAzimuth; 204 eventMask |= kIOHIDDigitizerEventEstimatedPressure; 205 } else if (eventType == StylusEventMoved) 206 eventMask = kIOHIDDigitizerEventPosition; 207 208 subEvent = adoptCF(IOHIDEventCreateDigitizerStylusEventWithPolarOrientation(kCFAllocatorDefault, machTime, 209 pointInfo->identifier, 210 pointInfo->identifier, 211 eventMask, 212 0, 213 point.x, point.y, 0, 214 pointInfo->pathPressure, 215 pointInfo->pathPressure, 216 0, 217 pointInfo->altitudeAngle, 218 pointInfo->azimuthAngle, 219 1, 220 0, 221 isTouching ? kIOHIDTransducerTouch : 0)); 222 223 if (eventType == StylusEventTouched) 224 IOHIDEventSetIntegerValue(subEvent.get(), kIOHIDEventFieldDigitizerWillUpdateMask, 0x0400); 225 else if (eventType == StylusEventMoved) 226 IOHIDEventSetIntegerValue(subEvent.get(), kIOHIDEventFieldDigitizerDidUpdateMask, 0x0400); 227 228 } else { 229 subEvent = adoptCF(IOHIDEventCreateDigitizerFingerEvent(kCFAllocatorDefault, machTime, 230 pointInfo->identifier, 231 pointInfo->identifier, 232 eventMask, 233 point.x, point.y, 0, 234 pointInfo->pathPressure, 235 0, 236 pointInfo->pathProximity & kGSEventPathInfoInRange, 237 pointInfo->pathProximity & kGSEventPathInfoInTouch, 238 kIOHIDEventOptionNone)); 239 } 240 203 241 IOHIDEventSetFloatValue(subEvent.get(), kIOHIDEventFieldDigitizerMajorRadius, pointInfo->pathMajorRadius); 204 242 IOHIDEventSetFloatValue(subEvent.get(), kIOHIDEventFieldDigitizerMinorRadius, pointInfo->pathMajorRadius); 243 205 244 IOHIDEventAppendEvent(eventRef.get(), subEvent.get(), 0); 206 245 } … … 285 324 _activePointCount = touchCount; 286 325 287 for (NSUInteger index = 0; index < touchCount; ++index) 326 for (NSUInteger index = 0; index < touchCount; ++index) { 288 327 _activePoints[index].point = locations[index]; 328 _activePoints[index].isStylus = NO; 329 } 289 330 290 331 RetainPtr<IOHIDEventRef> eventRef = adoptCF([self _createIOHIDEventType:HandEventTouched]); … … 380 421 { 381 422 [self liftUp:location touchCount:count]; 423 [self _sendMarkerHIDEventWithCompletionBlock:completionBlock]; 424 } 425 426 - (void)stylusDownAtPoint:(CGPoint)location azimuthAngle:(CGFloat)azimuthAngle altitudeAngle:(CGFloat)altitudeAngle pressure:(CGFloat)pressure 427 { 428 _activePointCount = 1; 429 _activePoints[0].point = location; 430 _activePoints[0].isStylus = YES; 431 _activePoints[0].pathPressure = pressure; 432 _activePoints[0].azimuthAngle = azimuthAngle; 433 _activePoints[0].altitudeAngle = altitudeAngle; 434 435 RetainPtr<IOHIDEventRef> eventRef = adoptCF([self _createIOHIDEventType:StylusEventTouched]); 436 [self _sendHIDEvent:eventRef.get()]; 437 } 438 439 - (void)stylusMoveToPoint:(CGPoint)location azimuthAngle:(CGFloat)azimuthAngle altitudeAngle:(CGFloat)altitudeAngle pressure:(CGFloat)pressure 440 { 441 _activePointCount = 1; 442 _activePoints[0].point = location; 443 _activePoints[0].isStylus = YES; 444 _activePoints[0].pathPressure = pressure; 445 _activePoints[0].azimuthAngle = azimuthAngle; 446 _activePoints[0].altitudeAngle = altitudeAngle; 447 448 RetainPtr<IOHIDEventRef> eventRef = adoptCF([self _createIOHIDEventType:StylusEventMoved]); 449 [self _sendHIDEvent:eventRef.get()]; 450 } 451 452 - (void)stylusUpAtPoint:(CGPoint)location 453 { 454 _activePointCount = 1; 455 _activePoints[0].point = location; 456 _activePoints[0].isStylus = YES; 457 _activePoints[0].pathPressure = 0; 458 _activePoints[0].azimuthAngle = 0; 459 _activePoints[0].altitudeAngle = 0; 460 461 RetainPtr<IOHIDEventRef> eventRef = adoptCF([self _createIOHIDEventType:StylusEventLifted]); 462 [self _sendHIDEvent:eventRef.get()]; 463 } 464 465 - (void)stylusDownAtPoint:(CGPoint)location azimuthAngle:(CGFloat)azimuthAngle altitudeAngle:(CGFloat)altitudeAngle pressure:(CGFloat)pressure completionBlock:(void (^)(void))completionBlock 466 { 467 [self stylusDownAtPoint:location azimuthAngle:azimuthAngle altitudeAngle:altitudeAngle pressure:pressure]; 468 [self _sendMarkerHIDEventWithCompletionBlock:completionBlock]; 469 } 470 471 - (void)stylusMoveToPoint:(CGPoint)location azimuthAngle:(CGFloat)azimuthAngle altitudeAngle:(CGFloat)altitudeAngle pressure:(CGFloat)pressure completionBlock:(void (^)(void))completionBlock 472 { 473 [self stylusMoveToPoint:location azimuthAngle:azimuthAngle altitudeAngle:altitudeAngle pressure:pressure]; 474 [self _sendMarkerHIDEventWithCompletionBlock:completionBlock]; 475 } 476 477 - (void)stylusUpAtPoint:(CGPoint)location completionBlock:(void (^)(void))completionBlock 478 { 479 [self stylusUpAtPoint:location]; 480 [self _sendMarkerHIDEventWithCompletionBlock:completionBlock]; 481 } 482 483 - (void)stylusTapAtPoint:(CGPoint)location azimuthAngle:(CGFloat)azimuthAngle altitudeAngle:(CGFloat)altitudeAngle pressure:(CGFloat)pressure completionBlock:(void (^)(void))completionBlock 484 { 485 struct timespec pressDelay = { 0, static_cast<long>(fingerLiftDelay) }; 486 487 [self stylusDownAtPoint:location azimuthAngle:azimuthAngle altitudeAngle:altitudeAngle pressure:pressure]; 488 nanosleep(&pressDelay, 0); 489 [self stylusUpAtPoint:location]; 490 382 491 [self _sendMarkerHIDEventWithCompletionBlock:completionBlock]; 383 492 } -
trunk/Tools/WebKitTestRunner/ios/IOKitSPI.h
r190408 r205572 34 34 35 35 #import <IOKit/hid/IOHIDEvent.h> 36 #import <IOKit/hid/IOHIDEventData.h> 36 37 #import <IOKit/hid/IOHIDEventSystemClient.h> 37 38 #import <IOKit/hid/IOHIDUsageTables.h> … … 73 74 kIOHIDDigitizerEventCancel = 1<<7, 74 75 kIOHIDDigitizerEventStart = 1<<8, 76 kIOHIDDigitizerEventEstimatedAltitude = 1<<28, 77 kIOHIDDigitizerEventEstimatedAzimuth = 1<<29, 78 kIOHIDDigitizerEventEstimatedPressure = 1<<30, 75 79 }; 76 80 typedef uint32_t IOHIDDigitizerEventMask; … … 101 105 102 106 enum { 107 kIOHIDTransducerRange = 0x00010000, 108 kIOHIDTransducerTouch = 0x00020000, 109 kIOHIDTransducerInvert = 0x00040000, 110 kIOHIDTransducerDisplayIntegrated = 0x00080000 111 }; 112 113 enum { 103 114 kIOHIDDigitizerTransducerTypeHand = 3 104 115 }; 105 116 typedef uint32_t IOHIDDigitizerTransducerType; 117 118 enum { 119 kIOHIDEventFieldDigitizerWillUpdateMask = 720924, 120 kIOHIDEventFieldDigitizerDidUpdateMask = 720925 121 }; 106 122 107 123 IOHIDEventRef IOHIDEventCreateDigitizerEvent(CFAllocatorRef, uint64_t, IOHIDDigitizerTransducerType, uint32_t, uint32_t, IOHIDDigitizerEventMask, uint32_t, IOHIDFloat, IOHIDFloat, IOHIDFloat, IOHIDFloat, IOHIDFloat, boolean_t, boolean_t, IOOptionBits); … … 114 130 115 131 IOHIDEventRef IOHIDEventCreateVendorDefinedEvent(CFAllocatorRef, uint64_t, uint32_t, uint32_t, uint32_t, uint8_t*, CFIndex, IOHIDEventOptionBits); 132 133 IOHIDEventRef IOHIDEventCreateDigitizerStylusEventWithPolarOrientation(CFAllocatorRef, uint64_t, uint32_t, uint32_t, IOHIDDigitizerEventMask, uint32_t, IOHIDFloat, IOHIDFloat, IOHIDFloat, IOHIDFloat, IOHIDFloat, IOHIDFloat, IOHIDFloat, IOHIDFloat, boolean_t, boolean_t, IOHIDEventOptionBits); 116 134 117 135 IOHIDEventType IOHIDEventGetType(IOHIDEventRef); -
trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm
r204877 r205572 127 127 } 128 128 129 void UIScriptController::stylusDownAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback) 130 { 131 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 132 133 auto location = globalToContentCoordinates(TestController::singleton().mainWebView()->platformView(), x, y); 134 [[HIDEventGenerator sharedHIDEventGenerator] stylusDownAtPoint:location azimuthAngle:azimuthAngle altitudeAngle:altitudeAngle pressure:pressure completionBlock:^{ 135 if (!m_context) 136 return; 137 m_context->asyncTaskComplete(callbackID); 138 }]; 139 } 140 141 void UIScriptController::stylusMoveToPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback) 142 { 143 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 144 145 auto location = globalToContentCoordinates(TestController::singleton().mainWebView()->platformView(), x, y); 146 [[HIDEventGenerator sharedHIDEventGenerator] stylusMoveToPoint:location azimuthAngle:azimuthAngle altitudeAngle:altitudeAngle pressure:pressure completionBlock:^{ 147 if (!m_context) 148 return; 149 m_context->asyncTaskComplete(callbackID); 150 }]; 151 } 152 153 void UIScriptController::stylusUpAtPoint(long x, long y, JSValueRef callback) 154 { 155 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 156 157 auto location = globalToContentCoordinates(TestController::singleton().mainWebView()->platformView(), x, y); 158 [[HIDEventGenerator sharedHIDEventGenerator] stylusUpAtPoint:location completionBlock:^{ 159 if (!m_context) 160 return; 161 m_context->asyncTaskComplete(callbackID); 162 }]; 163 } 164 165 void UIScriptController::stylusTapAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback) 166 { 167 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 168 169 auto location = globalToContentCoordinates(TestController::singleton().mainWebView()->platformView(), x, y); 170 [[HIDEventGenerator sharedHIDEventGenerator] stylusTapAtPoint:location azimuthAngle:azimuthAngle altitudeAngle:altitudeAngle pressure:pressure completionBlock:^{ 171 if (!m_context) 172 return; 173 m_context->asyncTaskComplete(callbackID); 174 }]; 175 } 176 129 177 void UIScriptController::dragFromPointToPoint(long startX, long startY, long endX, long endY, double durationSeconds, JSValueRef callback) 130 178 {
Note: See TracChangeset
for help on using the changeset viewer.