Skip to content

Commit ec29cf1

Browse files
committed
Unreviewed, reverting r273115.
Breaks autocorrect without the accompanying change in rdar://problem/74211293 Reverted changeset: "Unconditionally return information in _autofillContext SPI when a field is focused" https://bugs.webkit.org/show_bug.cgi?id=221828 https://commits.webkit.org/r273115 Canonical link: https://commits.webkit.org/234388@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273202 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 3b79a52 commit ec29cf1

5 files changed

Lines changed: 53 additions & 33 deletions

File tree

Source/WebKit/ChangeLog

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
2021-02-20 Wenson Hsieh <wenson_hsieh@apple.com>
2+
3+
Unreviewed, reverting r273115.
4+
5+
Breaks autocorrect without the accompanying change in
6+
rdar://problem/74211293
7+
8+
Reverted changeset:
9+
10+
"Unconditionally return information in _autofillContext SPI
11+
when a field is focused"
12+
https://bugs.webkit.org/show_bug.cgi?id=221828
13+
https://commits.webkit.org/r273115
14+
115
2021-02-20 Chris Dumez <cdumez@apple.com>
216

317
Unreviewed, fix regression from r273194 that was spotted by Darin Adler after landing.

Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8117,23 +8117,18 @@ - (UIView *)textEffectsWindow
81178117

81188118
- (NSDictionary *)_autofillContext
81198119
{
8120-
if (!self._hasFocusedElement)
8120+
BOOL provideStrongPasswordAssistance = _focusRequiresStrongPasswordAssistance && _focusedElementInformation.elementType == WebKit::InputType::Password;
8121+
if (!self._hasFocusedElement || (!_focusedElementInformation.acceptsAutofilledLoginCredentials && !provideStrongPasswordAssistance))
81218122
return nil;
81228123

8123-
auto context = adoptNS([[NSMutableDictionary alloc] init]);
8124-
context.get()[@"_WKAutofillContextVersion"] = @(2);
8125-
8126-
if (_focusRequiresStrongPasswordAssistance && _focusedElementInformation.elementType == WebKit::InputType::Password) {
8127-
context.get()[@"_automaticPasswordKeyboard"] = @YES;
8128-
context.get()[@"strongPasswordAdditionalContext"] = _additionalContextForStrongPasswordAssistance.get();
8129-
} else if (_focusedElementInformation.acceptsAutofilledLoginCredentials)
8130-
context.get()[@"_acceptsLoginCredentials"] = @YES;
8124+
if (provideStrongPasswordAssistance)
8125+
return @{ @"_automaticPasswordKeyboard" : @YES, @"strongPasswordAdditionalContext" : _additionalContextForStrongPasswordAssistance.get() };
81318126

81328127
NSURL *platformURL = _focusedElementInformation.representingPageURL;
81338128
if (platformURL)
8134-
context.get()[@"_WebViewURL"] = platformURL;
8129+
return @{ @"_WebViewURL" : platformURL };
81358130

8136-
return context.autorelease();
8131+
return nil;
81378132
}
81388133

81398134
- (BOOL)supportsImagePaste

Tools/ChangeLog

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
2021-02-20 Wenson Hsieh <wenson_hsieh@apple.com>
2+
3+
Unreviewed, reverting r273115.
4+
5+
Breaks autocorrect without the accompanying change in
6+
rdar://problem/74211293
7+
8+
Reverted changeset:
9+
10+
"Unconditionally return information in _autofillContext SPI
11+
when a field is focused"
12+
https://bugs.webkit.org/show_bug.cgi?id=221828
13+
https://commits.webkit.org/r273115
14+
115
2021-02-20 Aakash Jain <aakash_jain@apple.com>
216

317
Revert r272384 [Python-3] Change shebang in git-webkit

Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,6 @@ - (UIView *)inputAccessoryView
689689

690690
NSDictionary *actual = [[webView textInputContentView] _autofillContext];
691691
EXPECT_TRUE([[actual allValues] containsObject:expected]);
692-
EXPECT_TRUE([actual[@"_automaticPasswordKeyboard"] boolValue]);
693692
}
694693

695694
TEST(KeyboardInputTests, TestWebViewAccessoryDoneDuringStrongPasswordAssistance)

Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,14 @@ - (AutoFillInputView *)_autofillInputView
6666
return (AutoFillInputView *)self.textInputContentView;
6767
}
6868

69-
- (BOOL)acceptsAutoFillLoginCredentials
69+
- (BOOL)textInputHasAutoFillContext
7070
{
71-
auto context = self._autofillInputView._autofillContext;
72-
if (!context)
71+
NSURL *url = [self._autofillInputView._autofillContext objectForKey:@"_WebViewURL"];
72+
if (![url isKindOfClass:[NSURL class]])
7373
return NO;
7474

75-
NSURL *url = context[@"_WebViewURL"];
76-
EXPECT_TRUE([url isKindOfClass:NSURL.class]);
7775
EXPECT_WK_STREQ([self stringByEvaluatingJavaScript:@"document.URL"], url.absoluteString);
78-
return [context[@"_acceptsLoginCredentials"] boolValue];
76+
return YES;
7977
}
8078

8179
@end
@@ -87,29 +85,29 @@ - (BOOL)acceptsAutoFillLoginCredentials
8785
auto webView = adoptNS([[AutoFillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
8886
[webView synchronouslyLoadHTMLString:@"<input id='user' type='email'><input id='password' type='password'>"];
8987
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"user.focus()"];
90-
EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
88+
EXPECT_TRUE([webView textInputHasAutoFillContext]);
9189

9290
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"];
93-
EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
91+
EXPECT_TRUE([webView textInputHasAutoFillContext]);
9492

9593
auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"];
9694
[[webView _autofillInputView] insertTextSuggestion:credentialSuggestion];
9795

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

10098
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.activeElement.blur()"];
101-
EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
99+
EXPECT_FALSE([webView textInputHasAutoFillContext]);
102100
}
103101

104102
TEST(WKWebViewAutoFillTests, UsernameAndPasswordFieldSeparatedByRadioButton)
105103
{
106104
auto webView = adoptNS([[AutoFillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
107105
[webView synchronouslyLoadHTMLString:@"<input id='user' type='email'><input type='radio' name='radio_button' value='radio'><input id='password' type='password'>"];
108106
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"user.focus()"];
109-
EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
107+
EXPECT_TRUE([webView textInputHasAutoFillContext]);
110108

111109
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"];
112-
EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
110+
EXPECT_TRUE([webView textInputHasAutoFillContext]);
113111

114112
auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"];
115113
[[webView _autofillInputView] insertTextSuggestion:credentialSuggestion];
@@ -118,56 +116,56 @@ - (BOOL)acceptsAutoFillLoginCredentials
118116
EXPECT_WK_STREQ("famos", [webView stringByEvaluatingJavaScript:@"password.value"]);
119117

120118
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.activeElement.blur()"];
121-
EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
119+
EXPECT_FALSE([webView textInputHasAutoFillContext]);
122120
}
123121

124122
TEST(WKWebViewAutoFillTests, TwoTextFields)
125123
{
126124
auto webView = adoptNS([[AutoFillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
127125
[webView synchronouslyLoadHTMLString:@"<input id='text1' type='email'><input id='text2' type='text'>"];
128126
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"text1.focus()"];
129-
EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
127+
EXPECT_FALSE([webView textInputHasAutoFillContext]);
130128

131129
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"text2.focus()"];
132-
EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
130+
EXPECT_FALSE([webView textInputHasAutoFillContext]);
133131
}
134132

135133
TEST(WKWebViewAutoFillTests, StandalonePasswordField)
136134
{
137135
auto webView = adoptNS([[AutoFillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
138136
[webView synchronouslyLoadHTMLString:@"<input id='password' type='password'>"];
139137
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"];
140-
EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
138+
EXPECT_TRUE([webView textInputHasAutoFillContext]);
141139

142140
auto credentialSuggestion = [UITextAutofillSuggestion autofillSuggestionWithUsername:@"frederik" password:@"famos"];
143141
[[webView _autofillInputView] insertTextSuggestion:credentialSuggestion];
144142

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

147145
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.activeElement.blur()"];
148-
EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
146+
EXPECT_FALSE([webView textInputHasAutoFillContext]);
149147
}
150148

151149
TEST(WKWebViewAutoFillTests, StandaloneTextField)
152150
{
153151
auto webView = adoptNS([[AutoFillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
154152
[webView synchronouslyLoadHTMLString:@"<input id='textfield' type='text'>"];
155153
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"textfield.focus()"];
156-
EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
154+
EXPECT_FALSE([webView textInputHasAutoFillContext]);
157155
}
158156

159157
TEST(WKWebViewAutoFillTests, AccountCreationPage)
160158
{
161159
auto webView = adoptNS([[AutoFillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
162160
[webView synchronouslyLoadHTMLString:@"<input id='user' type='email'><input id='password' type='password'><input id='confirm_password' type='password'>"];
163161
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"user.focus()"];
164-
EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
162+
EXPECT_TRUE([webView textInputHasAutoFillContext]);
165163

166164
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"password.focus()"];
167-
EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
165+
EXPECT_TRUE([webView textInputHasAutoFillContext]);
168166

169167
[webView evaluateJavaScriptAndWaitForInputSessionToChange:@"confirm_password.focus()"];
170-
EXPECT_TRUE([webView acceptsAutoFillLoginCredentials]);
168+
EXPECT_TRUE([webView textInputHasAutoFillContext]);
171169
}
172170

173171
static BOOL overrideIsInHardwareKeyboardMode()
@@ -189,7 +187,7 @@ static BOOL overrideIsInHardwareKeyboardMode()
189187
[webView stringByEvaluatingJavaScript:@"user.focus()"];
190188
Util::run(&done);
191189

192-
EXPECT_FALSE([webView acceptsAutoFillLoginCredentials]);
190+
EXPECT_FALSE([webView textInputHasAutoFillContext]);
193191
}
194192

195193
#if PLATFORM(WATCHOS)

0 commit comments

Comments
 (0)