Skip to content

Commit 0417e04

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: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@223647 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 0e052df commit 0417e04

File tree

6 files changed

+68
-23
lines changed

6 files changed

+68
-23
lines changed

Source/WebKit/ChangeLog

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
2017-10-18 Chelsea Pugh <[email protected]>
2+
3+
[iOS] Use new class name from UIKit when checking UITextSuggestion type
4+
https://bugs.webkit.org/show_bug.cgi?id=178416
5+
<rdar://problem/35010840>
6+
7+
Reviewed by Tim Horton.
8+
9+
Here we start using UITextAutofillSuggestion instead of the old name that was being used for
10+
AutoFill text suggestions.
11+
12+
* Platform/spi/ios/UIKitSPI.h:
13+
* UIProcess/ios/WKContentViewInteraction.mm:
14+
(-[WKContentView insertTextSuggestion:]): Use UITextAutofillSuggestion when checking the class
15+
and when casting instead of UIKeyboardLoginCredentialsSuggestion.
16+
117
2017-10-17 Jiewen Tan <[email protected]>
218

319
Replace some stack raw pointers with RefPtrs within WebCore/html

Source/WebKit/Platform/spi/ios/UIKitSPI.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -954,10 +954,10 @@ typedef NS_OPTIONS(NSUInteger, UIDragOperation)
954954
- (UIResponder *)firstResponder;
955955
@end
956956

957-
#if __has_include(<UIKit/UIKeyboardLoginCredentialsSuggestion.h>)
958-
#import <UIKit/UIKeyboardLoginCredentialsSuggestion.h>
957+
#if __has_include(<UIKit/UITextAutofillSuggestion.h>)
958+
#import <UIKit/UITextAutofillSuggestion.h>
959959
#else
960-
@interface UIKeyboardLoginCredentialsSuggestion : UITextSuggestion
960+
@interface UITextAutofillSuggestion : UITextSuggestion
961961
@property (nonatomic, assign) NSString *username;
962962
@property (nonatomic, assign) NSString *password;
963963
@end

Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -2985,8 +2985,8 @@ - (void)endSelectionChange
29852985
- (void)insertTextSuggestion:(UITextSuggestion *)textSuggestion
29862986
{
29872987
// FIXME: Replace NSClassFromString with actual class as soon as UIKit submitted the new class into the iOS SDK.
2988-
if ([textSuggestion isKindOfClass:NSClassFromString(@"UIKeyboardLoginCredentialsSuggestion")]) {
2989-
_page->autofillLoginCredentials([(UIKeyboardLoginCredentialsSuggestion *)textSuggestion username], [(UIKeyboardLoginCredentialsSuggestion *)textSuggestion password]);
2988+
if ([textSuggestion isKindOfClass:NSClassFromString(@"UITextAutofillSuggestion")]) {
2989+
_page->autofillLoginCredentials([(UITextAutofillSuggestion *)textSuggestion username], [(UITextAutofillSuggestion *)textSuggestion password]);
29902990
return;
29912991
}
29922992
id <_WKInputDelegate> inputDelegate = [_webView _inputDelegate];

Tools/ChangeLog

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
2017-10-18 Chelsea Pugh <[email protected]>
2+
3+
[iOS] Use new class name from UIKit when checking UITextSuggestion type
4+
https://bugs.webkit.org/show_bug.cgi?id=178416
5+
6+
Reviewed by Tim Horton.
7+
8+
This updates our test using/mocking out UITextAutofillSuggestion instead of UIKeyboardLoginCredentialsSuggestion.
9+
10+
* TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm:
11+
(-[UITextAutofillSuggestion initWithUsername:password:]): Copied from UIKit's implementation. This will serve as
12+
a mock of this method for builds not containingit.
13+
(+[UITextAutofillSuggestion autofillSuggestionWithUsername:password:]): Ditto.
14+
(TestWebKitAPI::TEST): Use +[UITextAutofillSuggestion autofillSuggestionWithUsername:password:] inline instead of
15+
helper function for creating a new suggestion.
16+
(newUIKeyboardLoginCredentialsSuggestion): Deleted.
17+
18+
* TestWebKitAPI/ios/UIKitSPI.h:
19+
120
2017-10-18 Fujii Hironori <[email protected]>
221

322
update-webkit-auxiliary-libs can't download WebKitAuxiliaryLibrary.zip due to 403 Forbidden

Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm

+21-15
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,25 @@
3535
#import <WebKit/_WKInputDelegate.h>
3636
#import <wtf/BlockPtr.h>
3737

38-
#if !__has_include(<UIKit/UIKeyboardLoginCredentialsSuggestion.h>)
38+
#if !__has_include(<UIKit/UITextAutofillSuggestion.h>)
3939
// FIXME: This can be safely removed once <rdar://problem/34583628> lands in the SDK.
40-
@implementation UIKeyboardLoginCredentialsSuggestion
41-
@end
42-
#endif
40+
@implementation UITextAutofillSuggestion
41+
- (instancetype)initWithUsername:(NSString *)username password:(NSString *)password
42+
{
43+
self = [super init];
44+
if (self) {
45+
_username = username;
46+
_password = password;
47+
}
48+
return self;
49+
}
4350

44-
static UIKeyboardLoginCredentialsSuggestion *newUIKeyboardLoginCredentialsSuggestion(NSString *username, NSString *password)
51+
+ (instancetype)autofillSuggestionWithUsername:(NSString *)username password:(NSString *)password
4552
{
46-
UIKeyboardLoginCredentialsSuggestion *suggestion = [UIKeyboardLoginCredentialsSuggestion new];
47-
suggestion.username = username;
48-
suggestion.password = password;
49-
return suggestion;
53+
return [[self alloc] initWithUsername:username password:password];
5054
}
55+
@end
56+
#endif
5157

5258
typedef UIView <UITextInputTraits_Private_Proposed_SPI_34583628> AutofillInputView;
5359

@@ -119,8 +125,8 @@ - (BOOL)textInputHasAutofillContext
119125
[webView stringByEvaluatingJavaScript:@"password.focus()"];
120126
EXPECT_TRUE([webView textInputHasAutofillContext]);
121127

122-
auto credentialSuggestion = adoptNS(newUIKeyboardLoginCredentialsSuggestion(@"frederik", @"famos"));
123-
[[webView _autofillInputView] insertTextSuggestion:credentialSuggestion.get()];
128+
auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"];
129+
[[webView _autofillInputView] insertTextSuggestion:credentialSuggestion];
124130

125131
EXPECT_WK_STREQ("famos", [webView stringByEvaluatingJavaScript:@"password.value"]);
126132

@@ -138,8 +144,8 @@ - (BOOL)textInputHasAutofillContext
138144
[webView stringByEvaluatingJavaScript:@"password.focus()"];
139145
EXPECT_TRUE([webView textInputHasAutofillContext]);
140146

141-
auto credentialSuggestion = adoptNS(newUIKeyboardLoginCredentialsSuggestion(@"frederik", @"famos"));
142-
[[webView _autofillInputView] insertTextSuggestion:credentialSuggestion.get()];
147+
auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"];
148+
[[webView _autofillInputView] insertTextSuggestion:credentialSuggestion];
143149

144150
EXPECT_WK_STREQ("frederik", [webView stringByEvaluatingJavaScript:@"user.value"]);
145151
EXPECT_WK_STREQ("famos", [webView stringByEvaluatingJavaScript:@"password.value"]);
@@ -166,8 +172,8 @@ - (BOOL)textInputHasAutofillContext
166172
[webView stringByEvaluatingJavaScript:@"password.focus()"];
167173
EXPECT_TRUE([webView textInputHasAutofillContext]);
168174

169-
auto credentialSuggestion = adoptNS(newUIKeyboardLoginCredentialsSuggestion(@"frederik", @"famos"));
170-
[[webView _autofillInputView] insertTextSuggestion:credentialSuggestion.get()];
175+
auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"];
176+
[[webView _autofillInputView] insertTextSuggestion:credentialSuggestion];
171177

172178
EXPECT_WK_STREQ("famos", [webView stringByEvaluatingJavaScript:@"password.value"]);
173179

Tools/TestWebKitAPI/ios/UIKitSPI.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,17 @@ WTF_EXTERN_C_END
7373
- (void)_dragInteraction:(UIDragInteraction *)interaction itemsForAddingToSession:(id <UIDragSession>)session withTouchAtPoint:(CGPoint)point completion:(void(^)(NSArray<UIDragItem *> *))completion;
7474
@end
7575

76-
#if __has_include(<UIKit/UIKeyboardLoginCredentialsSuggestion.h>)
76+
#if __has_include(<UIKit/UITextAutofillSuggestion.h>)
7777
// FIXME: Move this import under USE(APPLE_INTERNAL_SDK) once <rdar://problem/34583628> lands in the SDK.
78-
#import <UIKit/UIKeyboardLoginCredentialsSuggestion.h>
78+
#import <UIKit/UITextAutofillSuggestion.h>
79+
@interface UITextAutofillSuggestion ()
80+
+ (instancetype)autofillSuggestionWithUsername:(NSString *)username password:(NSString *)password;
81+
@end
7982
#else
80-
@interface UIKeyboardLoginCredentialsSuggestion : UITextSuggestion
83+
@interface UITextAutofillSuggestion : UITextSuggestion
8184
@property (nonatomic, assign) NSString *username;
8285
@property (nonatomic, assign) NSString *password;
86+
+ (instancetype)autofillSuggestionWithUsername:(NSString *)username password:(NSString *)password;
8387
@end
8488
#endif
8589

0 commit comments

Comments
 (0)