Changeset 223647 in webkit


Ignore:
Timestamp:
Oct 18, 2017 6:39:14 PM (7 years ago)
Author:
cpugh@apple.com
Message:

[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:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r223644 r223647  
     12017-10-18  Chelsea Pugh  <cpugh@apple.com>
     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
    1172017-10-17  Jiewen Tan  <jiewen_tan@apple.com>
    218
  • trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h

    r223017 r223647  
    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;
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r223261 r223647  
    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    }
  • trunk/Tools/ChangeLog

    r223643 r223647  
     12017-10-18  Chelsea Pugh  <cpugh@apple.com>
     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
    1202017-10-18  Fujii Hironori  <Hironori.Fujii@sony.com>
    221
  • trunk/Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm

    r222991 r223647  
    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
     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}
     50
     51+ (instancetype)autofillSuggestionWithUsername:(NSString *)username password:(NSString *)password
     52{
     53    return [[self alloc] initWithUsername:username password:password];
     54}
    4155@end
    4256#endif
    43 
    44 static UIKeyboardLoginCredentialsSuggestion *newUIKeyboardLoginCredentialsSuggestion(NSString *username, NSString *password)
    45 {
    46     UIKeyboardLoginCredentialsSuggestion *suggestion = [UIKeyboardLoginCredentialsSuggestion new];
    47     suggestion.username = username;
    48     suggestion.password = password;
    49     return suggestion;
    50 }
    5157
    5258typedef UIView <UITextInputTraits_Private_Proposed_SPI_34583628> AutofillInputView;
     
    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"]);
     
    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"]);
     
    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"]);
  • trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h

    r223012 r223647  
    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
Note: See TracChangeset for help on using the changeset viewer.