[iOS] Use new class name from UIKit when checking UITextSuggestion type
authorcpugh@apple.com <cpugh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Oct 2017 01:39:14 +0000 (01:39 +0000)
committercpugh@apple.com <cpugh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Oct 2017 01:39:14 +0000 (01:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=178416
Source/WebKit:

<rdar://problem/35010840>

Reviewed by Tim Horton.

Here we start using UITextAutofillSuggestion instead of the old name that was being used for
AutoFill text suggestions.

* Platform/spi/ios/UIKitSPI.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView insertTextSuggestion:]): Use UITextAutofillSuggestion when checking the class
and when casting instead of UIKeyboardLoginCredentialsSuggestion.

Tools:

Reviewed by Tim Horton.

This updates our test using/mocking out UITextAutofillSuggestion instead of UIKeyboardLoginCredentialsSuggestion.

* TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm:
(-[UITextAutofillSuggestion initWithUsername:password:]): Copied from UIKit's implementation. This will serve as
a mock of this method for builds not containingit.
(+[UITextAutofillSuggestion autofillSuggestionWithUsername:password:]): Ditto.
(TestWebKitAPI::TEST): Use +[UITextAutofillSuggestion autofillSuggestionWithUsername:password:] inline instead of
helper function for creating a new suggestion.
(newUIKeyboardLoginCredentialsSuggestion): Deleted.

* TestWebKitAPI/ios/UIKitSPI.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223647 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/Platform/spi/ios/UIKitSPI.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm
Tools/TestWebKitAPI/ios/UIKitSPI.h

index 29f2a28..59ebda7 100644 (file)
@@ -1,3 +1,19 @@
+2017-10-18  Chelsea Pugh  <cpugh@apple.com>
+
+        [iOS] Use new class name from UIKit when checking UITextSuggestion type
+        https://bugs.webkit.org/show_bug.cgi?id=178416
+        <rdar://problem/35010840>
+
+        Reviewed by Tim Horton.
+
+        Here we start using UITextAutofillSuggestion instead of the old name that was being used for
+        AutoFill text suggestions.
+
+        * Platform/spi/ios/UIKitSPI.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView insertTextSuggestion:]): Use UITextAutofillSuggestion when checking the class
+        and when casting instead of UIKeyboardLoginCredentialsSuggestion.
+
 2017-10-17  Jiewen Tan  <jiewen_tan@apple.com>
 
         Replace some stack raw pointers with RefPtrs within WebCore/html
index 74c0407..58237c9 100644 (file)
@@ -954,10 +954,10 @@ typedef NS_OPTIONS(NSUInteger, UIDragOperation)
 - (UIResponder *)firstResponder;
 @end
 
-#if __has_include(<UIKit/UIKeyboardLoginCredentialsSuggestion.h>)
-#import <UIKit/UIKeyboardLoginCredentialsSuggestion.h>
+#if __has_include(<UIKit/UITextAutofillSuggestion.h>)
+#import <UIKit/UITextAutofillSuggestion.h>
 #else
-@interface UIKeyboardLoginCredentialsSuggestion : UITextSuggestion
+@interface UITextAutofillSuggestion : UITextSuggestion
 @property (nonatomic, assign) NSString *username;
 @property (nonatomic, assign) NSString *password;
 @end
index c5b283f..b4cc0ae 100644 (file)
@@ -2985,8 +2985,8 @@ static void selectionChangedWithTouch(WKContentView *view, const WebCore::IntPoi
 - (void)insertTextSuggestion:(UITextSuggestion *)textSuggestion
 {
     // FIXME: Replace NSClassFromString with actual class as soon as UIKit submitted the new class into the iOS SDK.
-    if ([textSuggestion isKindOfClass:NSClassFromString(@"UIKeyboardLoginCredentialsSuggestion")]) {
-        _page->autofillLoginCredentials([(UIKeyboardLoginCredentialsSuggestion *)textSuggestion username], [(UIKeyboardLoginCredentialsSuggestion *)textSuggestion password]);
+    if ([textSuggestion isKindOfClass:NSClassFromString(@"UITextAutofillSuggestion")]) {
+        _page->autofillLoginCredentials([(UITextAutofillSuggestion *)textSuggestion username], [(UITextAutofillSuggestion *)textSuggestion password]);
         return;
     }
     id <_WKInputDelegate> inputDelegate = [_webView _inputDelegate];
index f0f3393..7a1a9b7 100644 (file)
@@ -1,3 +1,22 @@
+2017-10-18  Chelsea Pugh  <cpugh@apple.com>
+
+        [iOS] Use new class name from UIKit when checking UITextSuggestion type
+        https://bugs.webkit.org/show_bug.cgi?id=178416
+
+        Reviewed by Tim Horton.
+
+        This updates our test using/mocking out UITextAutofillSuggestion instead of UIKeyboardLoginCredentialsSuggestion.
+
+        * TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm:
+        (-[UITextAutofillSuggestion initWithUsername:password:]): Copied from UIKit's implementation. This will serve as
+        a mock of this method for builds not containingit.
+        (+[UITextAutofillSuggestion autofillSuggestionWithUsername:password:]): Ditto.
+        (TestWebKitAPI::TEST): Use +[UITextAutofillSuggestion autofillSuggestionWithUsername:password:] inline instead of
+        helper function for creating a new suggestion.
+        (newUIKeyboardLoginCredentialsSuggestion): Deleted.
+
+        * TestWebKitAPI/ios/UIKitSPI.h:
+
 2017-10-18  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         update-webkit-auxiliary-libs can't download WebKitAuxiliaryLibrary.zip due to 403 Forbidden
index 0ed03a0..a991c0e 100644 (file)
 #import <WebKit/_WKInputDelegate.h>
 #import <wtf/BlockPtr.h>
 
-#if !__has_include(<UIKit/UIKeyboardLoginCredentialsSuggestion.h>)
+#if !__has_include(<UIKit/UITextAutofillSuggestion.h>)
 // FIXME: This can be safely removed once <rdar://problem/34583628> lands in the SDK.
-@implementation UIKeyboardLoginCredentialsSuggestion
-@end
-#endif
+@implementation UITextAutofillSuggestion
+- (instancetype)initWithUsername:(NSString *)username password:(NSString *)password
+{
+    self = [super init];
+    if (self) {
+        _username = username;
+        _password = password;
+    }
+    return self;
+}
 
-static UIKeyboardLoginCredentialsSuggestion *newUIKeyboardLoginCredentialsSuggestion(NSString *username, NSString *password)
++ (instancetype)autofillSuggestionWithUsername:(NSString *)username password:(NSString *)password
 {
-    UIKeyboardLoginCredentialsSuggestion *suggestion = [UIKeyboardLoginCredentialsSuggestion new];
-    suggestion.username = username;
-    suggestion.password = password;
-    return suggestion;
+    return [[self alloc] initWithUsername:username password:password];
 }
+@end
+#endif
 
 typedef UIView <UITextInputTraits_Private_Proposed_SPI_34583628> AutofillInputView;
 
@@ -119,8 +125,8 @@ TEST(WKWebViewAutofillTests, UsernameAndPasswordField)
     [webView stringByEvaluatingJavaScript:@"password.focus()"];
     EXPECT_TRUE([webView textInputHasAutofillContext]);
 
-    auto credentialSuggestion = adoptNS(newUIKeyboardLoginCredentialsSuggestion(@"frederik", @"famos"));
-    [[webView _autofillInputView] insertTextSuggestion:credentialSuggestion.get()];
+    auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"];
+    [[webView _autofillInputView] insertTextSuggestion:credentialSuggestion];
 
     EXPECT_WK_STREQ("famos", [webView stringByEvaluatingJavaScript:@"password.value"]);
 
@@ -138,8 +144,8 @@ TEST(WKWebViewAutofillTests, UsernameAndPasswordFieldSeparatedByRadioButton)
     [webView stringByEvaluatingJavaScript:@"password.focus()"];
     EXPECT_TRUE([webView textInputHasAutofillContext]);
 
-    auto credentialSuggestion = adoptNS(newUIKeyboardLoginCredentialsSuggestion(@"frederik", @"famos"));
-    [[webView _autofillInputView] insertTextSuggestion:credentialSuggestion.get()];
+    auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"];
+    [[webView _autofillInputView] insertTextSuggestion:credentialSuggestion];
 
     EXPECT_WK_STREQ("frederik", [webView stringByEvaluatingJavaScript:@"user.value"]);
     EXPECT_WK_STREQ("famos", [webView stringByEvaluatingJavaScript:@"password.value"]);
@@ -166,8 +172,8 @@ TEST(WKWebViewAutofillTests, StandalonePasswordField)
     [webView stringByEvaluatingJavaScript:@"password.focus()"];
     EXPECT_TRUE([webView textInputHasAutofillContext]);
 
-    auto credentialSuggestion = adoptNS(newUIKeyboardLoginCredentialsSuggestion(@"frederik", @"famos"));
-    [[webView _autofillInputView] insertTextSuggestion:credentialSuggestion.get()];
+    auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"];
+    [[webView _autofillInputView] insertTextSuggestion:credentialSuggestion];
 
     EXPECT_WK_STREQ("famos", [webView stringByEvaluatingJavaScript:@"password.value"]);
 
index 81e5674..36a2fae 100644 (file)
@@ -73,13 +73,17 @@ WTF_EXTERN_C_END
 - (void)_dragInteraction:(UIDragInteraction *)interaction itemsForAddingToSession:(id <UIDragSession>)session withTouchAtPoint:(CGPoint)point completion:(void(^)(NSArray<UIDragItem *> *))completion;
 @end
 
-#if __has_include(<UIKit/UIKeyboardLoginCredentialsSuggestion.h>)
+#if __has_include(<UIKit/UITextAutofillSuggestion.h>)
 // FIXME: Move this import under USE(APPLE_INTERNAL_SDK) once <rdar://problem/34583628> lands in the SDK.
-#import <UIKit/UIKeyboardLoginCredentialsSuggestion.h>
+#import <UIKit/UITextAutofillSuggestion.h>
+@interface UITextAutofillSuggestion ()
++ (instancetype)autofillSuggestionWithUsername:(NSString *)username password:(NSString *)password;
+@end
 #else
-@interface UIKeyboardLoginCredentialsSuggestion : UITextSuggestion
+@interface UITextAutofillSuggestion : UITextSuggestion
 @property (nonatomic, assign) NSString *username;
 @property (nonatomic, assign) NSString *password;
++ (instancetype)autofillSuggestionWithUsername:(NSString *)username password:(NSString *)password;
 @end
 #endif