WebKit Bugzilla
Attachment 356254 Details for
Bug 191608
: [iOS] Do not handle key events that are key commands
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch and layout tests
bug-191608-20181130155142.patch (text/plain), 16.81 KB, created by
Daniel Bates
on 2018-11-30 15:51:43 PST
(
hide
)
Description:
Patch and layout tests
Filename:
MIME Type:
Creator:
Daniel Bates
Created:
2018-11-30 15:51:43 PST
Size:
16.81 KB
patch
obsolete
>Subversion Revision: 238758 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index ee0d98386d590f58971923265de2d6798a66f110..a3daa3ee761084b6994913c5558c4f87a5940e10 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,19 @@ >+2018-11-30 Daniel Bates <dabates@apple.com> >+ >+ [iOS] Do not handle key events that are key commands >+ https://bugs.webkit.org/show_bug.cgi?id=191608 >+ <rdar://problem/46046013> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ A key down event may be associated with a key command. If it is then we want to execute the >+ key command instead of inserting or deleting text. We need to ask UIKit to handle the current >+ event as a key command to find out. >+ >+ * UIProcess/ios/WKContentViewInteraction.mm: >+ (-[WKContentView _interpretKeyEvent:isCharEvent:]): Ask UIKit to handle the current event >+ as a key command. If it handles it then we're done. Otherwise, do what we do now. >+ > 2018-11-30 Don Olmstead <don.olmstead@sony.com> > > Rename ENABLE_SUBTLE_CRYPTO to ENABLE_WEB_CRYPTO >diff --git a/Source/WebKitLegacy/ios/ChangeLog b/Source/WebKitLegacy/ios/ChangeLog >index 45226fd4d494d579f563ce2d0afe7be6b0b3527b..d20b975f3a8015cd20a3fcc9a7439eae892175ae 100644 >--- a/Source/WebKitLegacy/ios/ChangeLog >+++ b/Source/WebKitLegacy/ios/ChangeLog >@@ -1,3 +1,18 @@ >+2018-11-30 Daniel Bates <dabates@apple.com> >+ >+ [iOS] Do not handle key events that are key commands >+ https://bugs.webkit.org/show_bug.cgi?id=191608 >+ <rdar://problem/46046013> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add default implementation of -handleKeyCommandForCurrentEvent that returns NO - the current >+ event was not handled as a key command. >+ >+ * DefaultDelegates/WebDefaultUIKitDelegate.m: >+ (-[WebDefaultUIKitDelegate handleKeyCommandForCurrentEvent]): >+ * WebView/WebUIKitDelegate.h: >+ > 2018-11-29 Zalan Bujtas <zalan@apple.com> > > Rename *ObservedContentModifier(s) to *ObservedDOMTimer(s) >diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog >index bee238d1f52cb97f59b78eb70e82d2e47693de33..9ab17287ff86486d24ee9dcf32f96f46dc936d51 100644 >--- a/Source/WebKitLegacy/mac/ChangeLog >+++ b/Source/WebKitLegacy/mac/ChangeLog >@@ -1,3 +1,18 @@ >+2018-11-30 Daniel Bates <dabates@apple.com> >+ >+ [iOS] Do not handle key events that are key commands >+ https://bugs.webkit.org/show_bug.cgi?id=191608 >+ <rdar://problem/46046013> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ A key down event may be associated with a key command. If it is then we want to execute the >+ key command instead of inserting or deleting text. We need to ask UIKit to handle the current >+ event as a key command to find out. >+ >+ * WebView/WebHTMLView.mm: >+ (-[WebHTMLView _handleEditingKeyEvent:]): >+ > 2018-11-30 Don Olmstead <don.olmstead@sony.com> > > Rename ENABLE_SUBTLE_CRYPTO to ENABLE_WEB_CRYPTO >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index 12d6717760c49332134f64b389f6553a5783ca3e..d921790d01ef7cfeaa34443445b52995d4c8e497 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -133,6 +133,14 @@ @end > > #endif > >+#if PLATFORM(IOS_FAMILY) >+ >+@interface UIKeyboardImpl (Staging) >+- (BOOL)handleKeyCommandForCurrentEvent; >+@end >+ >+#endif >+ > using namespace WebCore; > using namespace WebKit; > >@@ -3963,8 +3971,13 @@ - (BOOL)_interpretKeyEvent:(::WebEvent *)event isCharEvent:(BOOL)isCharEvent > return YES; > > UIKeyboardImpl *keyboard = [UIKeyboardImpl sharedInstance]; >+ >+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000 >+ if (event.type == WebEventKeyDown && [keyboard respondsToSelector:@selector(handleKeyCommandForCurrentEvent)] && [keyboard handleKeyCommandForCurrentEvent]) >+ return YES; >+#endif >+ > NSString *characters = event.characters; >- > if (!characters.length) > return NO; > >diff --git a/Source/WebKitLegacy/ios/DefaultDelegates/WebDefaultUIKitDelegate.m b/Source/WebKitLegacy/ios/DefaultDelegates/WebDefaultUIKitDelegate.m >index dd3c835af763e60192dc44b0042cb1d1004b0c2f..aaee826c3339110583a1da60024f34e217233f9f 100644 >--- a/Source/WebKitLegacy/ios/DefaultDelegates/WebDefaultUIKitDelegate.m >+++ b/Source/WebKitLegacy/ios/DefaultDelegates/WebDefaultUIKitDelegate.m >@@ -162,6 +162,11 @@ - (void)webView:(WebView *)aWebView didReceiveMessage:(NSDictionary *)aMessage > { > } > >+- (BOOL)handleKeyCommandForCurrentEvent >+{ >+ return NO; >+} >+ > - (void)addInputString:(NSString *)str withFlags:(NSUInteger)flags > { > } >diff --git a/Source/WebKitLegacy/ios/WebView/WebUIKitDelegate.h b/Source/WebKitLegacy/ios/WebView/WebUIKitDelegate.h >index 3a4462e43889ec7b836fc276fbe7748bb193cd67..b85547b8fe6e2362c306df33f7c46eb51f8a9dd8 100644 >--- a/Source/WebKitLegacy/ios/WebView/WebUIKitDelegate.h >+++ b/Source/WebKitLegacy/ios/WebView/WebUIKitDelegate.h >@@ -90,6 +90,7 @@ typedef NS_ENUM(NSInteger, WebMediaCaptureType) { > - (void)webView:(WebView *)webView didHideFullScreenForPlugInView:(id)plugInView; > - (void)webView:(WebView *)aWebView didReceiveMessage:(NSDictionary *)aMessage; > - (void)addInputString:(NSString *)str withFlags:(NSUInteger)flags; >+- (BOOL)handleKeyCommandForCurrentEvent; > // FIXME: remove deleteFromInput when UIKit implements deleteFromInputWithFlags. > - (void)deleteFromInput; > - (void)deleteFromInputWithFlags:(NSUInteger)flags; >diff --git a/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm b/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm >index 88a9e4b175e2d9d02f6741b746c62f18f58278ab..e023353522dbdfda71a9f584ff13a766957c3ba2 100644 >--- a/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm >+++ b/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm >@@ -6082,13 +6082,20 @@ - (BOOL)_handleEditingKeyEvent:(KeyboardEvent *)wcEvent > WebEvent *event = platformEvent->event(); > if (event.keyboardFlags & WebEventKeyboardInputModifierFlagsChanged) > return NO; >- if (![[self _webView] isEditable] && event.isTabKey) >+ >+ if (![[self _webView] isEditable] && event.isTabKey) > return NO; >- >+ >+ WebView *webView = [self _webView]; >+ >+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000 >+ if (event.type == WebEventKeyDown && [webView._UIKitDelegateForwarder handleKeyCommandForCurrentEvent]) >+ return YES; >+#endif >+ > NSString *s = [event characters]; > if (!s.length) > return NO; >- WebView* webView = [self _webView]; > switch ([s characterAtIndex:0]) { > case kWebBackspaceKey: > case kWebDeleteKey: >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 7a5e9cfcf98747386d951a3cb32b7c7787ca6884..fd61ba562544c0c533692f8a6d1420c1d657af13 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,21 @@ >+2018-11-30 Daniel Bates <dabates@apple.com> >+ >+ [iOS] Do not handle key events that are key commands >+ https://bugs.webkit.org/show_bug.cgi?id=191608 >+ <rdar://problem/46046013> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add tests to ensure that we process key commands correctly. >+ >+ * fast/events/ios/key-command-italic-dispatches-keydown-expected.txt: Added. >+ * fast/events/ios/key-command-italic-dispatches-keydown.html: Added. >+ * fast/events/ios/key-command-italic-expected.txt: Added. >+ * fast/events/ios/key-command-italic.html: Added. >+ * fast/events/ios/type-digits-holding-control-key-expected.txt: Added. >+ * fast/events/ios/type-digits-holding-control-key.html: Added. >+ * platform/ios-wk1/TestExpectations: >+ > 2018-11-30 Ryosuke Niwa <rniwa@webkit.org> > > ShadowRoot should have styleSheets property >diff --git a/LayoutTests/fast/events/ios/key-command-italic-dispatches-keydown-expected.txt b/LayoutTests/fast/events/ios/key-command-italic-dispatches-keydown-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..2508e6bb5a0c2a85d7821b8d87ee3761960de499 >--- /dev/null >+++ b/LayoutTests/fast/events/ios/key-command-italic-dispatches-keydown-expected.txt >@@ -0,0 +1,11 @@ >+Tests that pressing Command + I in a rich editing field dispatches a key down event. To run this test by hand, select all the text below and press Command + I. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS event.key is "i" >+PASS event.metaKey is true >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/events/ios/key-command-italic-dispatches-keydown.html b/LayoutTests/fast/events/ios/key-command-italic-dispatches-keydown.html >new file mode 100644 >index 0000000000000000000000000000000000000000..55a3b32e3a96996c11a44f89f31b249262cadfdf >--- /dev/null >+++ b/LayoutTests/fast/events/ios/key-command-italic-dispatches-keydown.html >@@ -0,0 +1,82 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<meta name="viewport" content="width=device-width"> >+<script src="../../../resources/js-test.js"></script> >+<script src="../../../resources/ui-helper.js"></script> >+<style> >+#test { >+ border: 1px solid black; >+ height: 500px; >+ width: 500px; >+ user-modify: read-write; >+ -webkit-user-modify: read-write; >+} >+ >+.hidden { >+ display: none; >+} >+</style> >+</head> >+<body> >+<p id="description"></p> >+<div id="test" contenteditable="true">This text should be italicized.</div> >+<div id="console"></div> >+<script> >+window.jsTestIsAsync = true; >+ >+let testElement; >+let event; >+let ignoredFirstKeyDownEvent = false; >+ >+function shouldIgnoreKeyDownEvent(event) >+{ >+ // When performing the test manually a person is not fast enough to press Command + I simultaneously. >+ // We receive a key down for Command followed by a key down for Command + I. So, we ignore the first >+ // event to normalize the test result. >+ if (window.testRunner || ignoredFirstKeyDownEvent) >+ return false; >+ ignoredFirstKeyDownEvent = true; >+ console.assert(event.key == "Meta"); >+ return true; >+} >+ >+function handleKeyDownEvent(event) >+{ >+ window.event = event; >+ >+ if (shouldIgnoreKeyDownEvent(event)) >+ return; >+ >+ testElement.removeEventListener("keydown", handleKeyDownEvent, true); >+ >+ shouldBeEqualToString("event.key", "i"); >+ shouldBeTrue("event.metaKey"); >+ >+ // Remove the test element to make the output pretty. >+ document.body.removeChild(document.getElementById("test")); >+ >+ finishJSTest(); >+} >+ >+function runTest() >+{ >+ if (!window.testRunner) >+ return; >+ function handleFocus() { >+ window.getSelection().selectAllChildren(testElement); >+ UIHelper.keyDown("i", ["metaKey"]); >+ } >+ testElement.addEventListener("focus", handleFocus, { once: true }); >+ UIHelper.activateElement(testElement); >+} >+ >+description("Tests that pressing Command + I in a rich editing field dispatches a key down event. To run this test by hand, select all the text below and press Command + I."); >+ >+testElement = document.getElementById("test"); >+testElement.addEventListener("keydown", handleKeyDownEvent, true); >+ >+runTest(); >+</script> >+</body> >+</html> >diff --git a/LayoutTests/fast/events/ios/key-command-italic-expected.txt b/LayoutTests/fast/events/ios/key-command-italic-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..805ce51cdf28ff6367684ff51e5b7e6ac1bc512d >--- /dev/null >+++ b/LayoutTests/fast/events/ios/key-command-italic-expected.txt >@@ -0,0 +1,3 @@ >+Tests that pressing Command + I in a rich editing field italizes the selection. >+| <i> >+| "<#selection-anchor>This text should be italicized.<#selection-focus>" >diff --git a/LayoutTests/fast/events/ios/key-command-italic.html b/LayoutTests/fast/events/ios/key-command-italic.html >new file mode 100644 >index 0000000000000000000000000000000000000000..daf3df2a2407682a6c7a1c77ddee43d072c684aa >--- /dev/null >+++ b/LayoutTests/fast/events/ios/key-command-italic.html >@@ -0,0 +1,62 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<meta name="viewport" content="width=device-width"> >+<script src="../../../resources/ui-helper.js"></script> >+<script src="../../../resources/dump-as-markup.js"></script> >+<script> >+Markup.waitUntilDone(); >+</script> >+<style> >+#test { >+ border: 1px solid black; >+ height: 500px; >+ width: 500px; >+ user-modify: read-write; >+ -webkit-user-modify: read-write; >+} >+ >+.hidden { >+ display: none; >+} >+</style> >+</head> >+<body> >+<p id="description">Tests that pressing Command + I in a rich editing field italizes the selection.</p> >+<p id="manual-instructions" class="hide">To run this test by hand, select all the text below and press Command + I. This test PASSED if the text becomes italic. Otherwise, it FAILED.</p> >+<div id="test" contenteditable="true">This text should be italicized.</div> >+<script> >+let testElement = document.getElementById("test"); >+let mutationObserver = null; >+ >+function handleChildListModified() >+{ >+ mutationObserver.disconnect(); >+ Markup.dump(testElement); >+ Markup.notifyDone(); >+} >+ >+function runTest() >+{ >+ if (!window.testRunner) { >+ document.getElementById("manual-instructions").classList.remove("hidden"); >+ return; >+ } >+ >+ Markup.description(document.getElementById("description").textContent); >+ >+ mutationObserver = new MutationObserver(handleChildListModified); >+ mutationObserver.observe(testElement, { childList: true }); >+ >+ function handleFocus() { >+ window.getSelection().selectAllChildren(testElement); >+ UIHelper.keyDown("i", ["metaKey"]); >+ } >+ testElement.addEventListener("focus", handleFocus, { once: true }); >+ UIHelper.activateElement(testElement); >+} >+ >+runTest(); >+</script> >+</body> >+</html> >diff --git a/LayoutTests/fast/events/ios/type-digits-holding-control-key-expected.txt b/LayoutTests/fast/events/ios/type-digits-holding-control-key-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..56f7e4b041a2c68ded85cc72f1150714c90ffb70 >--- /dev/null >+++ b/LayoutTests/fast/events/ios/type-digits-holding-control-key-expected.txt >@@ -0,0 +1,3 @@ >+Tests that decimal numbers typed while holding down the Control key are inserted. >+ >+PASS >diff --git a/LayoutTests/fast/events/ios/type-digits-holding-control-key.html b/LayoutTests/fast/events/ios/type-digits-holding-control-key.html >new file mode 100644 >index 0000000000000000000000000000000000000000..ec1e666859db7ec110622cea2ae5a4de3a341795 >--- /dev/null >+++ b/LayoutTests/fast/events/ios/type-digits-holding-control-key.html >@@ -0,0 +1,53 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<meta charset="utf-8"> >+<script src="../../../resources/ui-helper.js"></script> >+<script type="text/plain" id="ui-script"> >+let charactersToType = "1234567890".split(""); >+for (let c of charactersToType) >+ uiController.keyDown(c, ["ctrlKey"]); >+</script> >+<script> >+if (window.testRunner) { >+ testRunner.dumpAsText(); >+ testRunner.waitUntilDone(); >+} >+ >+const expectedCharacters = "1234567890"; >+ >+function checkDone() >+{ >+ let input = document.getElementById("input"); >+ if (input.value === expectedCharacters) { >+ document.getElementById("result").textContent = "PASS"; >+ document.body.removeChild(input); >+ if (window.testRunner) >+ testRunner.notifyDone(); >+ } >+} >+ >+function runTest() >+{ >+ if (!window.testRunner) >+ return; >+ >+ function handleFocus() { >+ testRunner.runUIScript(document.getElementById("ui-script").text, () => { /* Do nothing */ }); >+ } >+ let input = document.getElementById("input"); >+ input.addEventListener("focus", handleFocus, { once: true }); >+ UIHelper.activateFormControl(input); >+} >+</script> >+</head> >+<body onload="runTest()"> >+<p>Tests that decimal numbers typed while holding down the <key>Control</key> key are inserted.</p> >+<!-- >+Note that when running this test by hande this test assumes that iOS maps Control + k to k for some non-numpad numeral. This >+is a non-issue when running the test in WebKitTestRunner because uiController.keyDown() generates "after key mapping" events. >+--> >+<input type="text" id="input" size="100" oninput="checkDone()"> >+<div id="result">FAIL</div> >+</body> >+</html> >diff --git a/LayoutTests/platform/ios-wk1/TestExpectations b/LayoutTests/platform/ios-wk1/TestExpectations >index 6cf9f283ec3c0853f85f74332f6d4117bd76a219..8c6bc5df332c501683da1714157daf9433726a32 100644 >--- a/LayoutTests/platform/ios-wk1/TestExpectations >+++ b/LayoutTests/platform/ios-wk1/TestExpectations >@@ -33,6 +33,9 @@ imported/w3c/web-platform-tests/html/semantics/forms/the-datalist-element [ Wont > > # No support for testing key commands with modifiers in WK1 > fast/events/ios/focus-tab-previous-field.html [ Skip ] >+fast/events/ios/key-command-italic-dispatches-keydown.html [ Skip ] >+fast/events/ios/key-command-italic.html [ Skip ] >+fast/events/ios/type-digits-holding-control-key.html [ Skip ] > > # <input type=color> is not supported in WebKit1 on iOS. > fast/forms/color/input-color-onchange-event.html [ Failure ]
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 191608
:
354971
|
354992
|
356254
|
356326
|
356394