WebKit Bugzilla
Attachment 369497 Details for
Bug 197632
: [iOS] Unable to commit search on MSN.com, qq.com, or sina.com.cn using enter key (hardware or software keyboard)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-197632-20190509103603.patch (text/plain), 15.01 KB, created by
Daniel Bates
on 2019-05-09 10:36:04 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Daniel Bates
Created:
2019-05-09 10:36:04 PDT
Size:
15.01 KB
patch
obsolete
>Subversion Revision: 245143 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 6aff2f494543e2c69a47658fc587dd2393b7c72b..8e056e6bb57702068e8d6bdc4d594f18d7cbbffd 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,45 @@ >+2019-05-09 Daniel Bates <dabates@apple.com> >+ >+ [iOS] Unable to commit search on MSN.com, qq.com, or sina.com.cn using enter key (hardware or software keyboard) >+ https://bugs.webkit.org/show_bug.cgi?id=197632 >+ <rdar://problem/47902054> >+ >+ Reviewed by Brent Fulgham. >+ >+ Fixes an issue where it is not possible to submit a <form> with target = "_blank": a form that >+ opens a new window. >+ >+ By default we only allow popups to open if they were user initiated (like when a person clicks >+ on a link). We achieve this by putting a token on the stack, called the UserGestureToken when >+ WebCore processes an event from WebKit. So long as this token is on the stack we consider >+ all requests to open a popup to be user initiated. And we implicitly submit a form when pressing >+ the Return key in an HTML input element during the processing of a TextInputEvent dispatched as >+ part of inserting a '\n' into the field. On Mac, the keydown dispatches a TextInputEvent synchronously. >+ However on iOS text insertion, and hence a dispatch of a TextInputEvent event, occurs asynchronously >+ with respect to the keydown event. So, by the time the UI process calls back to the WebProcess >+ to perform the text insertion of '\n' we have long since popped the UserGestureToken off the stack >+ and hence we disallow opening a popup. To fix this, when -insertText is called we query the keyboard >+ to determine if it's being called by the keyboard. If it is then we can assume that this is >+ part of key event handling and hence was initiated by the user. We can pass along this detail >+ to the WebProcess for it to push a new UserGestureToken onto the stack. >+ >+ For now we only track whether text inserted by the keyboard was user initiated or not. In >+ <https://bugs.webkit.org/show_bug.cgi?id=197721> we will fix this up for all editing commands. >+ >+ * Platform/spi/ios/UIKitSPI.h: Expose SPI. >+ * Shared/Cocoa/InsertTextOptions.cpp: >+ (IPC::ArgumentCoder<WebKit::InsertTextOptions>::encode): >+ (IPC::ArgumentCoder<WebKit::InsertTextOptions>::decode): >+ Encode and decode whether we are processing a user gesture. >+ >+ * Shared/Cocoa/InsertTextOptions.h: >+ * UIProcess/ios/WKContentViewInteraction.mm: >+ (-[WKContentView insertText:]): Query the keyboard to determine whether it called us or >+ the embedding client did. We only want to privilege user initiated actions (the keyboard). >+ * WebProcess/WebPage/WebPage.cpp: >+ (WebKit::WebPage::insertTextAsync): Push a UserGestureToken onto the stack that is initialized >+ depending on whether we are or are not processing a user gesture. >+ > 2019-05-09 Antoine Quint <graouts@apple.com> > > pointerevents/ios/touch-action-none-in-overflow-scrolling-touch.html is a timeout >diff --git a/Source/WebKit/Platform/spi/ios/UIKitSPI.h b/Source/WebKit/Platform/spi/ios/UIKitSPI.h >index c262b37ff81d23eed22b46b2cd2129a16eed2c71..fabe18a70ce9bd47853234c76aeec593e09ef092 100644 >--- a/Source/WebKit/Platform/spi/ios/UIKitSPI.h >+++ b/Source/WebKit/Platform/spi/ios/UIKitSPI.h >@@ -1126,6 +1126,7 @@ typedef NS_OPTIONS(NSInteger, UIWKDocumentRequestFlags) { > - (BOOL)handleKeyTextCommandForCurrentEvent; > - (BOOL)handleKeyAppCommandForCurrentEvent; > - (BOOL)handleKeyInputMethodCommandForCurrentEvent; >+- (BOOL)isCallingInputDelegate; > @property (nonatomic, readonly) UIKeyboardInputMode *currentInputModeInPreference; > @end > >diff --git a/Source/WebKit/Shared/Cocoa/InsertTextOptions.cpp b/Source/WebKit/Shared/Cocoa/InsertTextOptions.cpp >index 4000efdc73baf6279bfa42e3c5e85c5efb437962..816442612a2279a8c33bd5cf3a8e2403746750be 100644 >--- a/Source/WebKit/Shared/Cocoa/InsertTextOptions.cpp >+++ b/Source/WebKit/Shared/Cocoa/InsertTextOptions.cpp >@@ -32,6 +32,7 @@ void ArgumentCoder<WebKit::InsertTextOptions>::encode(Encoder& encoder, const We > { > encoder << options.registerUndoGroup; > encoder << options.suppressSelectionUpdate; >+ encoder << options.processingUserGesture; > encoder << options.editingRangeIsRelativeTo; > } > >@@ -42,6 +43,8 @@ Optional<WebKit::InsertTextOptions> ArgumentCoder<WebKit::InsertTextOptions>::de > return WTF::nullopt; > if (!decoder.decode(options.suppressSelectionUpdate)) > return WTF::nullopt; >+ if (!decoder.decode(options.processingUserGesture)) >+ return WTF::nullopt; > if (!decoder.decode(options.editingRangeIsRelativeTo)) > return WTF::nullopt; > return options; >diff --git a/Source/WebKit/Shared/Cocoa/InsertTextOptions.h b/Source/WebKit/Shared/Cocoa/InsertTextOptions.h >index b169520ae305fb679a7b8e31af57bbf1418e3f97..cd201ab2bad3d293df8b3ea0387e341ad4b70b51 100644 >--- a/Source/WebKit/Shared/Cocoa/InsertTextOptions.h >+++ b/Source/WebKit/Shared/Cocoa/InsertTextOptions.h >@@ -33,6 +33,7 @@ namespace WebKit { > struct InsertTextOptions { > bool registerUndoGroup { false }; > bool suppressSelectionUpdate { false }; >+ bool processingUserGesture { false }; > EditingRangeIsRelativeTo editingRangeIsRelativeTo { EditingRangeIsRelativeTo::EditableRoot }; > }; > >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index 953ebf90643610c526bf82eea9e7960e453d781a..d8d027741528cc51db3186233f4063794d0991cc 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -4179,7 +4179,12 @@ - (void)deleteBackward > // Inserts the given string, replacing any selected or marked text. > - (void)insertText:(NSString *)aStringValue > { >- _page->insertTextAsync(aStringValue, WebKit::EditingRange(), { }); >+ auto* keyboard = [UIKeyboardImpl sharedInstance]; >+ >+ WebKit::InsertTextOptions options; >+ options.processingUserGesture = [keyboard respondsToSelector:@selector(isCallingInputDelegate)] && keyboard.isCallingInputDelegate; >+ >+ _page->insertTextAsync(aStringValue, WebKit::EditingRange(), WTFMove(options)); > } > > - (BOOL)hasText >@@ -4671,6 +4676,9 @@ - (void)keyboardScrollViewAnimatorDidFinishScrolling:(WKKeyboardScrollViewAnimat > > - (void)executeEditCommandWithCallback:(NSString *)commandName > { >+ // FIXME: Editing commands are not considered by WebKit as user initiated even if they are the result >+ // of keydown or keyup. We need to query the keyboard to determine if this was called from the keyboard >+ // or not to know whether to tell WebKit to treat this command as user initiated or not. > [self beginSelectionChange]; > RetainPtr<WKContentView> view = self; > _page->executeEditCommand(commandName, { }, [view](WebKit::CallbackBase::Error) { >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >index d2d7a0e506c86714c5ab2762abc3c0b22a3b7d5c..944bea5404669dbbed857dae48de789eaf0c0107 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >@@ -5135,6 +5135,8 @@ void WebPage::insertTextAsync(const String& text, const EditingRange& replacemen > > Ref<Frame> protector(frame); > >+ UserGestureIndicator gestureIndicator { options.processingUserGesture ? ProcessingUserGesture : NotProcessingUserGesture, frame.document() }; >+ > bool replacesText = false; > if (replacementEditingRange.location != notFound) { > if (auto replacementRange = EditingRange::toRange(frame, replacementEditingRange, options.editingRangeIsRelativeTo)) { >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 61441c3c3871cf3cdb6e56cd6e344bf9869353aa..b303f73a11f4e5e0b4c7ac4d5298ffd22fbcd855 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,21 @@ >+2019-05-09 Daniel Bates <dabates@apple.com> >+ >+ [iOS] Unable to commit search on MSN.com, qq.com, or sina.com.cn using enter key (hardware or software keyboard) >+ https://bugs.webkit.org/show_bug.cgi?id=197632 >+ <rdar://problem/47902054> >+ >+ Reviewed by Brent Fulgham. >+ >+ Add tests to ensure we fire input and keypress events in the correct order and that we can >+ submit a <form> with target = "_blank" using the Return key. >+ >+ * fast/events/ios/fire-input-and-keypress-on-return-key-expected.txt: Added. >+ * fast/events/ios/fire-input-and-keypress-on-return-key.html: Added. >+ * fast/events/ios/submit-form-target-blank-using-return-key-expected.txt: Added. >+ * fast/events/ios/submit-form-target-blank-using-return-key.html: Added. >+ * platform/ios/TestExpectations: Skip the test until we have the UIKit SPI added >+ in <rdar://problem/50596032>. >+ > 2019-05-09 Per Arne Vollan <pvollan@apple.com> > > [Win10] Some tests are failing only on specific machines >diff --git a/LayoutTests/fast/events/ios/fire-input-and-keypress-on-return-key-expected.txt b/LayoutTests/fast/events/ios/fire-input-and-keypress-on-return-key-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..163ae61cdd0682b41a62c34bc793967109d69c54 >--- /dev/null >+++ b/LayoutTests/fast/events/ios/fire-input-and-keypress-on-return-key-expected.txt >@@ -0,0 +1,11 @@ >+Tests that pressing the Return key in a content editable elemnent dispatches a DOM input event and DOM keypress event (in that order). To run this test by hand, focus the content editable element below and press the Return key. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS event.key is "Enter" >+PASS event.inputType is "insertParagraph" >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/events/ios/fire-input-and-keypress-on-return-key.html b/LayoutTests/fast/events/ios/fire-input-and-keypress-on-return-key.html >new file mode 100644 >index 0000000000000000000000000000000000000000..892291ce542f1b3b3bff1e868fe6a7141e90961e >--- /dev/null >+++ b/LayoutTests/fast/events/ios/fire-input-and-keypress-on-return-key.html >@@ -0,0 +1,49 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../../resources/js-test.js"></script> >+<script src="../../../resources/ui-helper.js"></script> >+</head> >+<body> >+<p id="description"></p> >+<div id="test" contenteditable="true" style="width:256px; height: 256px; border: 1px solid black"></div> >+<div id="console"></div> >+<script> >+window.jsTestIsAsync = true; >+ >+function done() >+{ >+ document.body.removeChild(document.getElementById("test")); >+ finishJSTest(); >+} >+ >+function checkInputEvent() >+{ >+ shouldBeEqualToString("event.inputType", "insertParagraph"); >+ done(); >+} >+ >+function checkKeypressAndDone() >+{ >+ shouldBeEqualToString("event.key", "Enter"); >+} >+ >+function runTest() >+{ >+ function handleFocus(event) { >+ event.target.addEventListener("input", checkInputEvent, { once: true }); >+ event.target.addEventListener("keypress", checkKeypressAndDone, { once: true }); >+ if (window.testRunner) >+ UIHelper.keyDown("return"); >+ } >+ let test = document.getElementById("test"); >+ test.addEventListener("focus", handleFocus, { once: true }); >+ if (window.testRunner) >+ UIHelper.activateElement(test); >+} >+ >+description("Tests that pressing the Return key in a content editable elemnent dispatches a DOM input event and DOM keypress event (in that order). To run this test by hand, focus the content editable element below and press the <key>Return<key> key."); >+runTest(); >+</script> >+</body> >+</html> >diff --git a/LayoutTests/fast/events/ios/submit-form-target-blank-using-return-key-expected.txt b/LayoutTests/fast/events/ios/submit-form-target-blank-using-return-key-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..18183b82100ee3f88c30a7beebec9e3eb1be31e7 >--- /dev/null >+++ b/LayoutTests/fast/events/ios/submit-form-target-blank-using-return-key-expected.txt >@@ -0,0 +1,10 @@ >+Tests that pressing the Return key in a text field with an associated form implicitly submits the form. To run this test by hand, focus the text field below and press the Return key. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS event.key is "Enter" >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/events/ios/submit-form-target-blank-using-return-key.html b/LayoutTests/fast/events/ios/submit-form-target-blank-using-return-key.html >new file mode 100644 >index 0000000000000000000000000000000000000000..f918dc4417caa588fad78e5a811ed6bddb98d3c9 >--- /dev/null >+++ b/LayoutTests/fast/events/ios/submit-form-target-blank-using-return-key.html >@@ -0,0 +1,57 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../../resources/js-test.js"></script> >+<script src="../../../resources/ui-helper.js"></script> >+</head> >+<body> >+<p id="description"></p> >+<form action="resources/submit-form-target-blank-using-return-key.html" target="_blank"> >+ <input type="text" id="test"> >+</form> >+<div id="console"></div> >+<script> >+window.jsTestIsAsync = true; >+ >+if (window.testRunner) { >+ testRunner.setCanOpenWindows(true); >+ testRunner.setCloseRemainingWindowsWhenComplete(true); >+ testRunner.setPopupBlockingEnabled(true); >+} >+ >+function done() >+{ >+ document.body.removeChild(document.querySelector("form")); >+ finishJSTest(); >+} >+ >+function checkInputEvent() >+{ >+ testFailed("Should not have dispatched input event."); >+ done(); >+} >+ >+function checkKeypressAndDone() >+{ >+ shouldBeEqualToString("event.key", "Enter"); >+} >+ >+function runTest() >+{ >+ function handleFocus(event) { >+ event.target.addEventListener("input", checkInputEvent, { once: true }); >+ event.target.addEventListener("keypress", checkKeypressAndDone, { once: true }); >+ if (window.testRunner) >+ UIHelper.keyDown("return"); >+ } >+ let test = document.getElementById("test"); >+ test.addEventListener("focus", handleFocus, { once: true }); >+ if (window.testRunner) >+ UIHelper.activateElement(test); >+} >+ >+description("Tests that pressing the Return key in a text field with an associated form implicitly submits the form. To run this test by hand, focus the text field below and press the <key>Return<key> key."); >+runTest(); >+</script> >+</body> >+</html> >diff --git a/LayoutTests/platform/ios/TestExpectations b/LayoutTests/platform/ios/TestExpectations >index 85ff7dfc7468abd0dd3d4f6c1323f5e69d6f5d20..1670cd62f5a7b87bc1918053b6bfbe5b6d825b29 100644 >--- a/LayoutTests/platform/ios/TestExpectations >+++ b/LayoutTests/platform/ios/TestExpectations >@@ -3261,3 +3261,6 @@ webkit.org/b/191711 quicklook/numbers.html [ ImageOnlyFailure ] > webkit.org/b/197473 imported/w3c/web-platform-tests/resource-timing/resource-timing-level1.sub.html [ Pass Failure ] > > webkit.org/b/175678 media/W3C/video/events/event_progress.html [ Pass Failure ] >+ >+# FIXME: Unskip the following test once we have the fix for <rdar://problem/50596032>. >+fast/events/ios/submit-form-target-blank-using-return-key.html
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 197632
:
369189
|
369277
|
369428
|
369441
|
369446
|
369464
| 369497