WebKit Bugzilla
Attachment 346380 Details for
Bug 188251
: [iOS] Keyboard becomes unresponsive after pressing delete while pressing down on a character key with accents
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188251-20180802080206.patch (text/plain), 22.91 KB, created by
Wenson Hsieh
on 2018-08-02 08:02:07 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2018-08-02 08:02:07 PDT
Size:
22.91 KB
patch
obsolete
>Subversion Revision: 234457 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index a838cb3dded9a3c794b03ed63a880b9fe9c38ea2..855b30fd1efca216e44d5e001dc45b76a267cb19 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,23 @@ >+2018-08-01 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [iOS] Keyboard becomes unresponsive after pressing delete while pressing down on a character key with accents >+ https://bugs.webkit.org/show_bug.cgi?id=188251 >+ <rdar://problem/37842108> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Fixes a bug in key event handling where invoking -handleKeyWebEvent:withCompletionHandler: from within the >+ completion callback of a previous call to -handleKeyWebEvent:withCompletionHandler: would cause the completion >+ callback to be cleared out prematurely. In some cases (as described in the title of this bug), UIKit exercises >+ this codepath and subsequently hangs due to their completion block never getting invoked by WebKit. >+ >+ Test: KeyboardInputTests.CanHandleKeyEventInCompletionHandler >+ >+ * UIProcess/ios/WKContentViewInteraction.h: >+ * UIProcess/ios/WKContentViewInteraction.mm: >+ (-[WKContentView handleKeyWebEvent:withCompletionHandler:]): >+ (-[WKContentView _didHandleKeyEvent:eventWasHandled:]): >+ > 2018-08-01 Zan Dobersek <zdobersek@igalia.com> > > [CoordGraphics] Move CoordinatedBackingStore to WebCore >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >index f8e4584ebefc8d8b8e7262eb8fc400b61dcd1457..5501fa36014a591774964724ad06fb4a763c6197 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >@@ -92,7 +92,6 @@ typedef void (^UIWKAutocorrectionContextHandler)(UIWKAutocorrectionContext *auto > typedef void (^UIWKDictationContextHandler)(NSString *selectedText, NSString *beforeText, NSString *afterText); > typedef void (^UIWKSelectionCompletionHandler)(void); > typedef void (^UIWKSelectionWithDirectionCompletionHandler)(BOOL selectionEndIsMoving); >-typedef void (^UIWKKeyWebEventCompletionHandler)(::WebEvent *theEvent, BOOL wasHandled); > > typedef BlockPtr<void(WebKit::InteractionInformationAtPosition)> InteractionInformationCallback; > typedef std::pair<WebKit::InteractionInformationRequest, InteractionInformationCallback> InteractionInformationRequestAndCallback; >@@ -201,7 +200,7 @@ struct WKAutoCorrectionData { > WebKit::AssistedNodeInformation _assistedNodeInformation; > RetainPtr<NSObject<WKFormPeripheral>> _inputPeripheral; > RetainPtr<UIEvent> _uiEventBeingResent; >- UIWKKeyWebEventCompletionHandler _keyWebEventHandler; >+ BlockPtr<void(::WebEvent *, BOOL)> _keyWebEventHandler; > > CGPoint _lastInteractionLocation; > uint64_t _layerTreeTransactionIdAtLastTouchStart; >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index a1a4dc8b6056a8fe6d69430d0d4669e1ce670082..4c08fa588a16cdfb42aca2f4129ee76dcc5548d8 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -3643,16 +3643,14 @@ static NSString *contentTypeFromFieldName(WebCore::AutofillFieldName fieldName) > > - (void)handleKeyWebEvent:(::WebEvent *)theEvent withCompletionHandler:(void (^)(::WebEvent *theEvent, BOOL wasHandled))completionHandler > { >- _keyWebEventHandler = [completionHandler copy]; >+ _keyWebEventHandler = makeBlockPtr(completionHandler); > _page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent)); > } > > - (void)_didHandleKeyEvent:(::WebEvent *)event eventWasHandled:(BOOL)eventWasHandled > { >- if (_keyWebEventHandler) { >- _keyWebEventHandler(event, eventWasHandled); >- [_keyWebEventHandler release]; >- _keyWebEventHandler = nil; >+ if (auto handler = WTFMove(_keyWebEventHandler)) { >+ handler(event, eventWasHandled); > return; > } > >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 5f732e2befd59c77e816f5a0bb58623459502dd3..424ad5f8ffc5f53aff53b5a430744c4cd492fa66 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,32 @@ >+2018-08-01 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [iOS] Keyboard becomes unresponsive after pressing delete while pressing down on a character key with accents >+ https://bugs.webkit.org/show_bug.cgi?id=188251 >+ <rdar://problem/37842108> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Adds a new API test to verify that clients (in this case, UIKit) is allowed to invoke >+ -handleKeyWebEvent:withCompletionHandler: within the completion block of a prior invocation. >+ >+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: >+ * TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm: Added. >+ (TestWebKitAPI::TEST): >+ * TestWebKitAPI/Tests/ios/TestInputDelegate.h: Added. >+ >+ Pull some logic used to force an input session to start out from an existing API test file >+ (WKWebViewAutofillTests) and into a separate helper class that is used by both the existing API tests and the >+ new keyboard input test. >+ >+ * TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm: >+ (-[AutofillTestView initWithFrame:]): >+ (TestWebKitAPI::TEST): >+ (-[TestInputDelegate init]): Deleted. >+ (-[TestInputDelegate _webView:focusShouldStartInputSession:]): Deleted. >+ * TestWebKitAPI/ios/UIKitSPI.h: >+ >+ Add some UIKit SPI utilized by the new API test. >+ > 2018-07-31 Ben Richards <benton_richards@apple.com> > > Add configuration for automatic process pre-warming >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index 02ae00c303071a02032d9d9000d2cb5a9c78529c..5d8d2cd4157da1a7b2635b9817da74d67a6617de 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -803,6 +803,8 @@ > F457A9D6202D68AF00F7E9D5 /* DataTransfer.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F457A9B3202D535300F7E9D5 /* DataTransfer.html */; }; > F45B63FB1F197F4A009D38B9 /* image-map.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F45B63FA1F197F33009D38B9 /* image-map.html */; }; > F45B63FE1F19D410009D38B9 /* ActionSheetTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F45B63FC1F19D410009D38B9 /* ActionSheetTests.mm */; }; >+ F45E15732112CE2900307E82 /* KeyboardInputTestsIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = F45E15722112CE2900307E82 /* KeyboardInputTestsIOS.mm */; }; >+ F45E15762112CE6200307E82 /* TestInputDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = F45E15752112CE6200307E82 /* TestInputDelegate.mm */; }; > F464AF9220BB66EA007F9B18 /* RenderingProgressTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F464AF9120BB66EA007F9B18 /* RenderingProgressTests.mm */; }; > F46849BE1EEF58E400B937FE /* UIPasteboardTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F46849BD1EEF58E400B937FE /* UIPasteboardTests.mm */; }; > F46849C01EEF5EF300B937FE /* rich-and-plain-text.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F46849BF1EEF5EDC00B937FE /* rich-and-plain-text.html */; }; >@@ -2020,6 +2022,9 @@ > F457A9B6202D5CDC00F7E9D5 /* PasteMixedContent.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PasteMixedContent.mm; sourceTree = "<group>"; }; > F45B63FA1F197F33009D38B9 /* image-map.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "image-map.html"; sourceTree = "<group>"; }; > F45B63FC1F19D410009D38B9 /* ActionSheetTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ActionSheetTests.mm; sourceTree = "<group>"; }; >+ F45E15722112CE2900307E82 /* KeyboardInputTestsIOS.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = KeyboardInputTestsIOS.mm; sourceTree = "<group>"; }; >+ F45E15742112CE6200307E82 /* TestInputDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TestInputDelegate.h; sourceTree = "<group>"; }; >+ F45E15752112CE6200307E82 /* TestInputDelegate.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TestInputDelegate.mm; sourceTree = "<group>"; }; > F464AF9120BB66EA007F9B18 /* RenderingProgressTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RenderingProgressTests.mm; sourceTree = "<group>"; }; > F46849BD1EEF58E400B937FE /* UIPasteboardTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = UIPasteboardTests.mm; sourceTree = "<group>"; }; > F46849BF1EEF5EDC00B937FE /* rich-and-plain-text.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "rich-and-plain-text.html"; sourceTree = "<group>"; }; >@@ -2483,12 +2488,15 @@ > 2E205BA31F527746005952DD /* AccessibilityTestsIOS.mm */, > F45B63FC1F19D410009D38B9 /* ActionSheetTests.mm */, > F4D4F3B71E4E36E400BB2767 /* DataInteractionTests.mm */, >+ F45E15722112CE2900307E82 /* KeyboardInputTestsIOS.mm */, > 574F55CE204D3763002948C6 /* LocalAuthenticator.mm */, > 7560917719259C59009EF06E /* MemoryCacheAddImageToCacheIOS.mm */, > F464AF9120BB66EA007F9B18 /* RenderingProgressTests.mm */, > F4C8797E2059D8D3009CD00B /* ScrollViewInsetTests.mm */, > CE6E819F20A6935F00E2C80F /* SetTimeoutFunction.mm */, > 4433A395208044130091ED57 /* SynchronousTimeoutTests.mm */, >+ F45E15742112CE6200307E82 /* TestInputDelegate.h */, >+ F45E15752112CE6200307E82 /* TestInputDelegate.mm */, > F45033F4206BEC95009351CE /* TextAutosizingBoost.mm */, > F46849BD1EEF58E400B937FE /* UIPasteboardTests.mm */, > F43E3BBE20DADA1E00A4E7ED /* WKScrollViewTests.mm */, >@@ -3757,6 +3765,7 @@ > 7CCE7EAD1A411A3400447C4C /* JavaScriptTest.cpp in Sources */, > 7CCE7EA51A411A0800447C4C /* JavaScriptTestMac.mm in Sources */, > 7CCE7EC41A411A7E00447C4C /* JSWrapperForNodeInWebFrame.mm in Sources */, >+ F45E15732112CE2900307E82 /* KeyboardInputTestsIOS.mm in Sources */, > 7CCE7F061A411AE600447C4C /* LayoutMilestonesWithAllContentInFrame.cpp in Sources */, > 7CCE7EDF1A411A9200447C4C /* LayoutUnit.cpp in Sources */, > 7A66BDB61EAF14EF00CCC924 /* LimitTitleSize.cpp in Sources */, >@@ -3895,6 +3904,7 @@ > 1C734B5320788C4800F430EA /* SystemColors.mm in Sources */, > 7CCE7F161A411AE600447C4C /* TerminateTwice.cpp in Sources */, > 7CCE7EA91A411A1D00447C4C /* TestBrowsingContextLoadDelegate.mm in Sources */, >+ F45E15762112CE6200307E82 /* TestInputDelegate.mm in Sources */, > 2D1C04A71D76298B000A6816 /* TestNavigationDelegate.mm in Sources */, > A14FC5901B8AE36F00D107EB /* TestProtocol.mm in Sources */, > 7CCE7EAE1A411A3400447C4C /* TestsController.cpp in Sources */, >diff --git a/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm b/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..209db0881aee62a38e76cf4abd3f8d2108d49db5 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm >@@ -0,0 +1,73 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#if WK_API_ENABLED && PLATFORM(IOS) >+ >+#import "PlatformUtilities.h" >+#import "TestInputDelegate.h" >+#import "TestWKWebView.h" >+#import "UIKitSPI.h" >+#import <WebKit/WKWebViewPrivate.h> >+#import <WebKitLegacy/WebEvent.h> >+ >+namespace TestWebKitAPI { >+ >+TEST(KeyboardInputTests, CanHandleKeyEventInCompletionHandler) >+{ >+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); >+ auto inputDelegate = adoptNS([[TestInputDelegate alloc] init]); >+ >+ bool doneWaiting = false; >+ [inputDelegate setFocusStartsInputSessionPolicyHandler:[&] (WKWebView *, id <_WKFocusedElementInfo>) -> _WKFocusStartsInputSessionPolicy { >+ doneWaiting = true; >+ return _WKFocusStartsInputSessionPolicyAllow; >+ }]; >+ [webView _setInputDelegate:inputDelegate.get()]; >+ [webView synchronouslyLoadHTMLString:@"<input autofocus>"]; >+ >+ TestWebKitAPI::Util::run(&doneWaiting); >+ doneWaiting = false; >+ >+ id <UITextInputPrivate> contentView = (id <UITextInputPrivate>)[webView firstResponder]; >+ auto firstWebEvent = adoptNS([[WebEvent alloc] initWithKeyEventType:WebEventKeyDown timeStamp:CFAbsoluteTimeGetCurrent() characters:@"a" charactersIgnoringModifiers:@"a" modifiers:0 isRepeating:NO withFlags:0 withInputManagerHint:nil keyCode:0 isTabKey:NO]); >+ auto secondWebEvent = adoptNS([[WebEvent alloc] initWithKeyEventType:WebEventKeyUp timeStamp:CFAbsoluteTimeGetCurrent() characters:@"a" charactersIgnoringModifiers:@"a" modifiers:0 isRepeating:NO withFlags:0 withInputManagerHint:nil keyCode:0 isTabKey:NO]); >+ [contentView handleKeyWebEvent:firstWebEvent.get() withCompletionHandler:[&] (WebEvent *event, BOOL) { >+ EXPECT_TRUE([event isEqual:firstWebEvent.get()]); >+ [contentView handleKeyWebEvent:secondWebEvent.get() withCompletionHandler:[&] (WebEvent *event, BOOL) { >+ EXPECT_TRUE([event isEqual:secondWebEvent.get()]); >+ [contentView insertText:@"a"]; >+ doneWaiting = true; >+ }]; >+ }]; >+ >+ TestWebKitAPI::Util::run(&doneWaiting); >+ EXPECT_WK_STREQ("a", [webView stringByEvaluatingJavaScript:@"document.querySelector('input').value"]); >+} >+ >+} // namespace TestWebKitAPI >+ >+#endif // WK_API_ENABLED && PLATFORM(IOS) >diff --git a/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.h b/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.h >new file mode 100644 >index 0000000000000000000000000000000000000000..ff28be6894efd601340419bccd1f5d0dcc1abeda >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.h >@@ -0,0 +1,39 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if WK_API_ENABLED && PLATFORM(IOS) >+ >+#import <WebKit/_WKFocusedElementInfo.h> >+#import <WebKit/_WKInputDelegate.h> >+ >+@class WKWebView; >+ >+@interface TestInputDelegate : NSObject <_WKInputDelegate> >+@property (nonatomic, copy) _WKFocusStartsInputSessionPolicy (^focusStartsInputSessionPolicyHandler)(WKWebView *, id <_WKFocusedElementInfo>); >+@end >+ >+#endif >diff --git a/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.mm b/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..f0d1d24242993f7089e39c9d50327c0840c707cd >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.mm >@@ -0,0 +1,54 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "TestInputDelegate.h" >+ >+#if WK_API_ENABLED && PLATFORM(IOS) >+ >+#import <wtf/BlockPtr.h> >+ >+@implementation TestInputDelegate { >+ BlockPtr<_WKFocusStartsInputSessionPolicy(WKWebView *, id <_WKFocusedElementInfo>)> _focusStartsInputSessionPolicyHandler; >+} >+ >+- (void)setFocusStartsInputSessionPolicyHandler:(_WKFocusStartsInputSessionPolicy (^)(WKWebView *, id <_WKFocusedElementInfo>))handler >+{ >+ _focusStartsInputSessionPolicyHandler = makeBlockPtr(handler); >+} >+ >+- (_WKFocusStartsInputSessionPolicy (^)(WKWebView *, id <_WKFocusedElementInfo>))focusStartsInputSessionPolicyHandler >+{ >+ return _focusStartsInputSessionPolicyHandler.get(); >+} >+ >+- (_WKFocusStartsInputSessionPolicy)_webView:(WKWebView *)webView decidePolicyForFocusedElement:(id <_WKFocusedElementInfo>)info >+{ >+ return self.focusStartsInputSessionPolicyHandler ? self.focusStartsInputSessionPolicyHandler(webView, info) : _WKFocusStartsInputSessionPolicyAuto; >+} >+ >+@end >+ >+#endif // WK_API_ENABLED && PLATFORM(IOS) >diff --git a/Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm b/Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm >index ba375a7f3b5345a70d8a4a62abf8917b76e69cc5..fa6b1cdbdd9e53185075973676d67263b09fd524 100644 >--- a/Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm >+++ b/Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm >@@ -28,36 +28,14 @@ > #if WK_API_ENABLED && PLATFORM(IOS) > > #import "PlatformUtilities.h" >+#import "TestInputDelegate.h" > #import "TestWKWebView.h" > #import "UIKitSPI.h" > #import <WebKit/WKWebViewPrivate.h> >-#import <WebKit/_WKFocusedElementInfo.h> >-#import <WebKit/_WKInputDelegate.h> > #import <wtf/BlockPtr.h> > > typedef UIView <UITextInputTraits_Private_Proposed_SPI_34583628> AutofillInputView; > >-@interface TestInputDelegate : NSObject <_WKInputDelegate> >-@property (nonatomic) BOOL inputSessionRequiresUserInteraction; >-@end >- >-@implementation TestInputDelegate >- >-- (instancetype)init >-{ >- if (self = [super init]) >- _inputSessionRequiresUserInteraction = NO; >- >- return self; >-} >- >-- (BOOL)_webView:(WKWebView *)webView focusShouldStartInputSession:(id <_WKFocusedElementInfo>)info >-{ >- return !self.inputSessionRequiresUserInteraction || info.userInitiated; >-} >- >-@end >- > @interface AutofillTestView : TestWKWebView > @end > >@@ -71,6 +49,9 @@ typedef UIView <UITextInputTraits_Private_Proposed_SPI_34583628> AutofillInputVi > return nil; > > _testDelegate = adoptNS([[TestInputDelegate alloc] init]); >+ [_testDelegate setFocusStartsInputSessionPolicyHandler:[] (WKWebView *, id <_WKFocusedElementInfo>) -> _WKFocusStartsInputSessionPolicy { >+ return _WKFocusStartsInputSessionPolicyAllow; >+ }]; > self._inputDelegate = _testDelegate.get(); > return self; > } >@@ -186,7 +167,9 @@ TEST(WKWebViewAutofillTests, AccountCreationPage) > TEST(WKWebViewAutofillTests, AutofillRequiresInputSession) > { > auto webView = adoptNS([[AutofillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); >- [(TestInputDelegate *)[webView _inputDelegate] setInputSessionRequiresUserInteraction:YES]; >+ [(TestInputDelegate *)[webView _inputDelegate] setFocusStartsInputSessionPolicyHandler:[] (WKWebView *, id <_WKFocusedElementInfo>) -> _WKFocusStartsInputSessionPolicy { >+ return _WKFocusStartsInputSessionPolicyAuto; >+ }]; > [webView synchronouslyLoadHTMLString:@"<input id='user' type='email'><input id='password' type='password'>"]; > [webView stringByEvaluatingJavaScript:@"user.focus()"]; > >diff --git a/Tools/TestWebKitAPI/ios/UIKitSPI.h b/Tools/TestWebKitAPI/ios/UIKitSPI.h >index c4b7277b60e8c9c54fdb378970f2af7076435404..8edd052a0384b0c794f99ed707bf45a1e7290ff2 100644 >--- a/Tools/TestWebKitAPI/ios/UIKitSPI.h >+++ b/Tools/TestWebKitAPI/ios/UIKitSPI.h >@@ -30,6 +30,7 @@ > #if USE(APPLE_INTERNAL_SDK) > > #import <UIKit/UIApplication_Private.h> >+#import <UIKit/UIResponder_Private.h> > #import <UIKit/UITextInputTraits_Private.h> > #import <UIKit/UITextInput_Private.h> > #import <UIKit/UIViewController_Private.h> >@@ -62,8 +63,11 @@ WTF_EXTERN_C_END > @property (nonatomic, readonly) UIColor *insertionPointColor; > @end > >+@class WebEvent; >+ > @protocol UITextInputPrivate <UITextInput, UITextInputTraits_Private> > - (void)insertTextSuggestion:(UITextSuggestion *)textSuggestion; >+- (void)handleKeyWebEvent:(WebEvent *)theEvent withCompletionHandler:(void (^)(WebEvent *, BOOL))completionHandler; > @end > > #endif >@@ -100,4 +104,8 @@ WTF_EXTERN_C_END > + (UIViewController *)_viewControllerForFullScreenPresentationFromView:(UIView *)view; > @end > >+@interface UIResponder (UIKitSPI) >+- (UIResponder *)firstResponder; >+@end >+ > #endif // PLATFORM(IOS)
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 188251
:
346360
| 346380