Changeset 238235 in webkit
- Timestamp:
- Nov 15, 2018 11:15:28 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r238230 r238235 1 2018-11-15 Daniel Bates <dabates@apple.com> 2 3 [iOS] Shift + Tab does not focus previous field 4 https://bugs.webkit.org/show_bug.cgi?id=191596 5 <rdar://problem/45892053> 6 7 Reviewed by Wenson Hsieh. 8 9 Add tests to ensure that we do not regress the tab and shift + tab key commands. 10 11 * fast/events/ios/focus-tab-next-field-expected.txt: Added. 12 * fast/events/ios/focus-tab-next-field.html: Added. 13 * fast/events/ios/focus-tab-previous-field-expected.txt: Added. 14 * fast/events/ios/focus-tab-previous-field.html: Added. 15 * platform/ios-wk1/TestExpectations: Skip test focus-tab-previous-field.html in Legacy WebKit as 16 we do not support testing key commands with modifier keys. 17 * resources/ui-helper.js: 18 (window.UIHelper.keyDown): Updated to support taking an optional array of modifiers (defaults: []) 19 and use the new infrastructure to generate a key down event for the specified character. 20 1 21 2018-11-15 Youenn Fablet <youenn@apple.com> 2 22 -
trunk/LayoutTests/platform/ios-wk1/TestExpectations
r238038 r238235 31 31 fast/forms/datalist [ WontFix ] 32 32 imported/w3c/web-platform-tests/html/semantics/forms/the-datalist-element [ WontFix ] 33 34 # No support for testing key commands with modifiers in WK1 35 fast/events/ios/focus-tab-previous-field.html [ Skip ] 33 36 34 37 # <input type=color> is not supported in WebKit1 on iOS. -
trunk/LayoutTests/resources/ui-helper.js
r238146 r238235 55 55 } 56 56 57 static keyDown(key )57 static keyDown(key, modifiers=[]) 58 58 { 59 59 if (!this.isWebKit2() || !this.isIOS()) { … … 63 63 64 64 return new Promise((resolve) => { 65 testRunner.runUIScript(` 66 uiController.keyDownUsingHardwareKeyboard("downArrow", function() { 67 uiController.uiScriptComplete("Done"); 68 });`, resolve); 65 testRunner.runUIScript(`uiController.keyDown("${key}", ${JSON.stringify(modifiers)});`, resolve); 69 66 }); 70 67 } -
trunk/Source/WebKit/ChangeLog
r238231 r238235 1 2018-11-15 Daniel Bates <dabates@apple.com> 2 3 [iOS] Shift + Tab does not focus previous field 4 https://bugs.webkit.org/show_bug.cgi?id=191596 5 <rdar://problem/45892053> 6 7 Reviewed by Wenson Hsieh. 8 9 Wire up the the tab and shift + tab key commands to the WKWebView/WKContentView's 10 action forwarding mechanism. Also rename -_prevAccessoryTab to -_previousAccessoryTab. 11 12 * Platform/spi/ios/UIKitSPI.h: Add more SPI. 13 * UIProcess/API/Cocoa/WKWebViewInternal.h: 14 * UIProcess/ios/WKContentViewInteraction.h: 15 * UIProcess/ios/WKContentViewInteraction.mm: 16 (-[WKContentView canPerformActionForWebView:withSender:]): 17 (-[WKContentView keyCommands]): 18 (-[WKContentView _nextAccessoryTabForWebView:]): Added. 19 (-[WKContentView _previousAccessoryTabForWebView:]): Added. 20 (-[WKContentView _nextAccessoryTab:]): Deleted. 21 (-[WKContentView _prevAccessoryTab:]): Deleted. 22 1 23 2018-11-15 Keith Rollin <krollin@apple.com> 2 24 -
trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h
r238186 r238235 159 159 160 160 WTF_EXTERN_C_BEGIN 161 typedef struct __IOHIDEvent * IOHIDEventRef; 161 typedef struct __IOHIDEvent* IOHIDEventRef; 162 typedef struct __GSKeyboard* GSKeyboardRef; 162 163 WTF_EXTERN_C_END 163 164 … … 169 170 - (void)_enqueueHIDEvent:(IOHIDEventRef)event; 170 171 - (void)_handleHIDEvent:(IOHIDEventRef)event; 172 - (void)handleKeyUIEvent:(UIEvent *)event; 171 173 @end 172 174 … … 1024 1026 1025 1027 @interface UIPhysicalKeyboardEvent () 1028 + (UIPhysicalKeyboardEvent *)_eventWithInput:(NSString *)input inputFlags:(UIKeyboardInputFlags)flags; 1029 - (void)_setHIDEvent:(IOHIDEventRef)event keyboard:(GSKeyboardRef)gsKeyboard; 1030 - (UIPhysicalKeyboardEvent *)_cloneEvent NS_RETURNS_RETAINED; 1026 1031 @property (nonatomic, readonly) UIKeyboardInputFlags _inputFlags; 1027 - (UIPhysicalKeyboardEvent *)_cloneEvent NS_RETURNS_RETAINED;1028 1032 @property (nonatomic, readonly) CFIndex _keyCode; 1029 1033 @end -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h
r238190 r238235 152 152 - (void)replace:(id)sender; 153 153 154 - (void)_nextAccessoryTab:(id)sender; 155 - (void)_previousAccessoryTab:(id)sender; 156 154 157 - (void)_incrementFocusPreservationCount; 155 158 - (void)_decrementFocusPreservationCount; -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
r238188 r238235 1 1 /* 2 * Copyright (C) 2012-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2012-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 115 115 M(_showTextStyleOptions) \ 116 116 M(_transliterateChinese) \ 117 M(_nextAccessoryTab) \ 118 M(_previousAccessoryTab) \ 117 119 M(copy) \ 118 120 M(cut) \ -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r238188 r238235 1 1 /* 2 * Copyright (C) 2012-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2012-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 2441 2441 2442 2442 - (BOOL)canPerformActionForWebView:(SEL)action withSender:(id)sender 2443 { 2443 { 2444 if (action == @selector(_nextAccessoryTab:)) 2445 return hasAssistedNode(_assistedNodeInformation) && _assistedNodeInformation.hasNextNode; 2446 if (action == @selector(_previousAccessoryTab:)) 2447 return hasAssistedNode(_assistedNodeInformation) && _assistedNodeInformation.hasPreviousNode; 2448 2444 2449 auto editorState = _page->editorState(); 2445 2450 if (action == @selector(_showTextStyleOptions:)) … … 3219 3224 3220 3225 static NSArray* editableKeyCommands = [@[ 3221 [UIKeyCommand keyCommandWithInput:@"\t" modifierFlags:0 action:@selector(_nextAccessoryTab:)],3222 [UIKeyCommand keyCommandWithInput:@"\t" modifierFlags:UIKeyModifierShift action:@selector(_prevAccessoryTab:)]3226 [UIKeyCommand keyCommandWithInput:@"\t" modifierFlags:0 action:@selector(_nextAccessoryTab:)], 3227 [UIKeyCommand keyCommandWithInput:@"\t" modifierFlags:UIKeyModifierShift action:@selector(_previousAccessoryTab:)] 3223 3228 ] retain]; 3224 3229 return editableKeyCommands; 3225 3230 } 3226 3231 3227 - (void)_nextAccessoryTab :(id)sender3232 - (void)_nextAccessoryTabForWebView:(id)sender 3228 3233 { 3229 3234 [self accessoryTab:YES]; 3230 3235 } 3231 3236 3232 - (void)_prev AccessoryTab:(id)sender3237 - (void)_previousAccessoryTabForWebView:(id)sender 3233 3238 { 3234 3239 [self accessoryTab:NO]; -
trunk/Tools/ChangeLog
r238231 r238235 1 2018-11-15 Daniel Bates <dabates@apple.com> 2 3 [iOS] Shift + Tab does not focus previous field 4 https://bugs.webkit.org/show_bug.cgi?id=191596 5 <rdar://problem/45892053> 6 7 Reviewed by Wenson Hsieh. 8 9 Add infrastructure to support testing a key down event with modifiers by creating 10 and dispatching a UIEvent. This infrastructure replaces the previous mechanism in 11 Tools/WebKitTestRunner/ios/HIDEventGenerator.mm to generate a IOHIDEvent for a 12 keydown as it did not support creating an event with modifier key state that would 13 be recognized by UIKit. 14 15 * DumpRenderTree/ios/UIScriptControllerIOS.mm: 16 (WTR::UIScriptController::keyDown): 17 (WTR::UIScriptController::keyDownUsingHardwareKeyboard): Deleted. 18 (WTR::UIScriptController::keyUpUsingHardwareKeyboard): Deleted. 19 * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: 20 Add function uiController.keyDown() that takes a character that represents a keyboard key 21 and an array of modifier keys. The behavior of this function is analogous to eventSender.keyDown(). 22 Remove functions uiController.keyDownUsingHardwareKeyboard() and uiController.keyUpUsingHardwareKeyboard() 23 as the former is replaced by uiController.keyDown() and the latter was never used. 24 25 * TestRunnerShared/UIScriptContext/UIScriptController.cpp: 26 (WTR::UIScriptController::keyDown): Added. 27 (WTR::UIScriptController::keyUpUsingHardwareKeyboard): Deleted. 28 (WTR::UIScriptController::keyDownUsingHardwareKeyboard): Deleted. 29 * TestRunnerShared/UIScriptContext/UIScriptController.h: 30 * WebKitTestRunner/ios/HIDEventGenerator.h: 31 * WebKitTestRunner/ios/HIDEventGenerator.mm: 32 (createHIDKeyDownEvent): Added. 33 (-[HIDEventGenerator keyDown:completionBlock:]): Deleted. 34 (-[HIDEventGenerator keyUp:completionBlock:]): Deleted. 35 * WebKitTestRunner/ios/UIScriptControllerIOS.mm: 36 (WTR::arrayLength): Added. 37 (WTR::parseModifier): Added. 38 (WTR::parseModifierArray): Added. 39 (WTR::UIScriptController::keyDown): 40 (WTR::UIScriptController::keyDownUsingHardwareKeyboard): Deleted. 41 (WTR::UIScriptController::keyUpUsingHardwareKeyboard): Deleted. 42 1 43 2018-11-15 Keith Rollin <krollin@apple.com> 2 44 -
trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm
r238146 r238235 152 152 } 153 153 154 void UIScriptController::keyDownUsingHardwareKeyboard(JSStringRef character, JSValueRef callback) 155 { 156 } 157 158 void UIScriptController::keyUpUsingHardwareKeyboard(JSStringRef character, JSValueRef callback) 154 void UIScriptController::keyDown(JSStringRef, JSValueRef) 159 155 { 160 156 } -
trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
r238146 r238235 1 1 /* 2 * Copyright (C) 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2015-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 31 31 }; 32 32 33 enum ModifierKey { 34 "alt", 35 "capsLock", 36 "ctrl", 37 "meta", // Command key on Mac and iOS 38 "shift" 39 }; 40 33 41 interface UIScriptController { 34 42 … … 61 69 void enterText(DOMString text); 62 70 void typeCharacterUsingHardwareKeyboard(DOMString character, object callback); 63 void keyDownUsingHardwareKeyboard(DOMString character, object callback); 64 void key UpUsingHardwareKeyboard(DOMString character, object callback);71 72 void keyDown(DOMString character, object modifierArray); 65 73 66 74 // eventsJSON describes a series of user events in JSON form. For the keys, see HIDEventGenerator.mm. -
trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp
r238146 r238235 297 297 } 298 298 299 void UIScriptController::keyUpUsingHardwareKeyboard(JSStringRef, JSValueRef) 300 { 301 } 302 303 void UIScriptController::keyDownUsingHardwareKeyboard(JSStringRef, JSValueRef) 299 void UIScriptController::keyDown(JSStringRef, JSValueRef) 304 300 { 305 301 } -
trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
r238146 r238235 90 90 void enterText(JSStringRef); 91 91 void typeCharacterUsingHardwareKeyboard(JSStringRef character, JSValueRef callback); 92 void keyDownUsingHardwareKeyboard(JSStringRef character, JSValueRef callback); 93 void key UpUsingHardwareKeyboard(JSStringRef character, JSValueRef callback);92 93 void keyDown(JSStringRef character, JSValueRef modifierArray); 94 94 95 95 void keyboardAccessoryBarNext(); -
trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.h
r238134 r238235 27 27 28 28 #import <CoreGraphics/CGGeometry.h> 29 #import <wtf/RetainPtr.h> 29 30 30 31 // Keys for sendEventStream:completionBlock:. … … 69 70 extern NSUInteger const HIDMaxTouchCount; 70 71 72 RetainPtr<IOHIDEventRef> createHIDKeyDownEvent(NSString *, uint64_t timestamp); 73 71 74 @interface HIDEventGenerator : NSObject 72 75 … … 106 109 // Keyboard 107 110 - (void)keyPress:(NSString *)character completionBlock:(void (^)(void))completionBlock; 108 - (void)keyDown:(NSString *)character completionBlock:(void (^)(void))completionBlock;109 - (void)keyUp:(NSString *)character completionBlock:(void (^)(void))completionBlock;110 111 111 112 @end -
trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm
r238134 r238235 34 34 #import <wtf/BlockPtr.h> 35 35 #import <wtf/Optional.h> 36 #import <wtf/RetainPtr.h>37 36 #import <wtf/SoftLinking.h> 38 37 … … 199 198 [super dealloc]; 200 199 } 201 202 203 200 204 201 - (void)_sendIOHIDKeyboardEvent:(uint64_t)timestamp usage:(uint32_t)usage isKeyDown:(bool)isKeyDown … … 977 974 } 978 975 976 RetainPtr<IOHIDEventRef> createHIDKeyDownEvent(NSString *character, uint64_t timestamp) 977 { 978 return adoptCF(IOHIDEventCreateKeyboardEvent(kCFAllocatorDefault, timestamp, kHIDPage_KeyboardOrKeypad, hidUsageCodeForCharacter(character), true /* key down */, kIOHIDEventOptionNone)); 979 } 980 979 981 - (void)keyPress:(NSString *)character completionBlock:(void (^)(void))completionBlock 980 982 { … … 987 989 988 990 [self _sendIOHIDKeyboardEvent:absoluteMachTime usage:usage isKeyDown:true]; 989 [self _sendIOHIDKeyboardEvent:absoluteMachTime usage:usage isKeyDown:false];990 991 if (shouldWrapWithShift)992 [self _sendIOHIDKeyboardEvent:absoluteMachTime usage:kHIDUsage_KeyboardLeftShift isKeyDown:false];993 994 [self _sendMarkerHIDEventWithCompletionBlock:completionBlock];995 }996 997 - (void)keyDown:(NSString *)character completionBlock:(void (^)(void))completionBlock998 {999 bool shouldWrapWithShift = shouldWrapWithShiftKeyEventForCharacter(character);1000 uint32_t usage = hidUsageCodeForCharacter(character);1001 uint64_t absoluteMachTime = mach_absolute_time();1002 1003 if (shouldWrapWithShift)1004 [self _sendIOHIDKeyboardEvent:absoluteMachTime usage:kHIDUsage_KeyboardLeftShift isKeyDown:true];1005 1006 [self _sendIOHIDKeyboardEvent:absoluteMachTime usage:usage isKeyDown:true];1007 1008 [self _sendMarkerHIDEventWithCompletionBlock:completionBlock];1009 }1010 1011 - (void)keyUp:(NSString *)character completionBlock:(void (^)(void))completionBlock1012 {1013 bool shouldWrapWithShift = shouldWrapWithShiftKeyEventForCharacter(character);1014 uint32_t usage = hidUsageCodeForCharacter(character);1015 uint64_t absoluteMachTime = mach_absolute_time();1016 1017 991 [self _sendIOHIDKeyboardEvent:absoluteMachTime usage:usage isKeyDown:false]; 1018 992 -
trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm
r238146 r238235 43 43 #import <WebKit/WKWebViewPrivate.h> 44 44 #import <WebKit/WebKit.h> 45 #import <wtf/SoftLinking.h> 46 47 SOFT_LINK_FRAMEWORK(UIKit) 48 SOFT_LINK_CLASS(UIKit, UIPhysicalKeyboardEvent) 49 50 @interface UIPhysicalKeyboardEvent (UIPhysicalKeyboardEventHack) 51 @property (nonatomic, assign) NSInteger _modifierFlags; 52 @end 45 53 46 54 namespace WTR { … … 341 349 } 342 350 343 void UIScriptController::keyDownUsingHardwareKeyboard(JSStringRef character, JSValueRef callback) 344 { 345 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 346 347 // Assumes that the keyboard is already shown. 348 [[HIDEventGenerator sharedHIDEventGenerator] keyDown:toWTFString(toWK(character)) completionBlock:^{ 349 if (!m_context) 350 return; 351 m_context->asyncTaskComplete(callbackID); 352 }]; 353 } 354 355 void UIScriptController::keyUpUsingHardwareKeyboard(JSStringRef character, JSValueRef callback) 356 { 357 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); 358 359 // Assumes that the keyboard is already shown. 360 [[HIDEventGenerator sharedHIDEventGenerator] keyUp:toWTFString(toWK(character)) completionBlock:^{ 361 if (!m_context) 362 return; 363 m_context->asyncTaskComplete(callbackID); 364 }]; 351 static unsigned arrayLength(JSContextRef context, JSObjectRef array) 352 { 353 auto lengthString = adopt(JSStringCreateWithUTF8CString("length")); 354 if (auto lengthValue = JSObjectGetProperty(context, array, lengthString.get(), nullptr)) 355 return static_cast<unsigned>(JSValueToNumber(context, lengthValue, nullptr)); 356 return 0; 357 } 358 359 static UIKeyModifierFlags parseModifier(JSStringRef modifier) 360 { 361 if (JSStringIsEqualToUTF8CString(modifier, "altKey")) 362 return UIKeyModifierAlternate; 363 if (JSStringIsEqualToUTF8CString(modifier, "capsLockKey")) 364 return UIKeyModifierAlphaShift; 365 if (JSStringIsEqualToUTF8CString(modifier, "ctrlKey")) 366 return UIKeyModifierControl; 367 if (JSStringIsEqualToUTF8CString(modifier, "metaKey")) 368 return UIKeyModifierCommand; 369 if (JSStringIsEqualToUTF8CString(modifier, "shiftKey")) 370 return UIKeyModifierShift; 371 return 0; 372 } 373 374 static UIKeyModifierFlags parseModifierArray(JSContextRef context, JSValueRef arrayValue) 375 { 376 if (!arrayValue) 377 return 0; 378 379 // The value may either be a string with a single modifier or an array of modifiers. 380 if (JSValueIsString(context, arrayValue)) { 381 auto string = adopt(JSValueToStringCopy(context, arrayValue, nullptr)); 382 return parseModifier(string.get()); 383 } 384 385 if (!JSValueIsObject(context, arrayValue)) 386 return 0; 387 JSObjectRef array = const_cast<JSObjectRef>(arrayValue); 388 unsigned length = arrayLength(context, array); 389 UIKeyModifierFlags modifiers = 0; 390 for (unsigned i = 0; i < length; ++i) { 391 JSValueRef exception = nullptr; 392 JSValueRef value = JSObjectGetPropertyAtIndex(context, array, i, &exception); 393 if (exception) 394 continue; 395 auto string = adopt(JSValueToStringCopy(context, value, &exception)); 396 if (exception) 397 continue; 398 modifiers |= parseModifier(string.get()); 399 } 400 return modifiers; 401 } 402 403 void UIScriptController::keyDown(JSStringRef character, JSValueRef modifierArray) 404 { 405 // Character can be either a single Unicode code point or the name of a special key (e.g. "downArrow"). 406 // createHIDKeyEvent() knows how to map these special keys to the appropriate keycode. 407 // 408 // FIXME: The UIEvent input string for special keys (e.g. "downArrow") should either be a UIKeyInput* 409 // string constant or an ASCII control character. In practice the input string for a special key is 410 // ambiguious (e.g. F5 and F6 have the same string - the ASCII DLE character) and hence it is effectively 411 // ignored in favor of key identification by keycode. So, we just take the empty string as the input string 412 // for a special key. 413 String inputString = toWTFString(toWK(character)); 414 String uiEventInputString = inputString.length() > 1 ? emptyString() : inputString; 415 auto *keyboardEvent = [getUIPhysicalKeyboardEventClass() _eventWithInput:uiEventInputString inputFlags:(UIKeyboardInputFlags)0]; 416 keyboardEvent._modifierFlags = parseModifierArray(m_context->jsContext(), modifierArray); 417 auto hidEvent = createHIDKeyDownEvent(inputString, keyboardEvent.timestamp); 418 [keyboardEvent _setHIDEvent:hidEvent.get() keyboard:nullptr]; 419 [[UIApplication sharedApplication] handleKeyUIEvent:keyboardEvent]; 365 420 } 366 421
Note: See TracChangeset
for help on using the changeset viewer.