Skip to content
Permalink
Browse files
[iOS] Use new class name from UIKit when checking UITextSuggestion type
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:


Canonical link: https://commits.webkit.org/194692@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223647 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Chelsea Pugh committed Oct 19, 2017
1 parent ff64ffe commit 92379de55274c3b245977767f2916701aed9b37c
@@ -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
@@ -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
@@ -2985,8 +2985,8 @@ - (void)endSelectionChange
- (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];
@@ -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
@@ -35,19 +35,25 @@
#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 @@ - (BOOL)textInputHasAutofillContext
[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 @@ - (BOOL)textInputHasAutofillContext
[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 @@ - (BOOL)textInputHasAutofillContext
[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"]);

@@ -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

0 comments on commit 92379de

Please sign in to comment.