Changeset 222487 in webkit


Ignore:
Timestamp:
Sep 25, 2017, 7:33:43 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

Expose way to set values of classified form controls as {Legacy WebKit, WebKit} SPI
https://bugs.webkit.org/show_bug.cgi?id=174394
<rdar://problem/33183504>

Patch by Frederik Riedel <riedel@apple.com> on 2017-09-25
Reviewed by Ryosuke Niwa.

Source/WebCore:

  • WebCore.xcodeproj/project.pbxproj:
  • editing/ios/AutofillElements.cpp: Added.

(WebCore::isAutofillableElement): Returns true if the element is of type text or email.
(WebCore::nextAutofillableElement): Returns the next focusable element that is autofillable.
(WebCore::previousAutofillableElement): Returns the previous focusable element that is autofillable.
(WebCore::AutofillElements::computeAutofillElements): Computes the autofill elements (username & password)
for a given input element.
(WebCore::AutofillElements::autofill): Fills the credentials into the pair of username/password elements.

  • editing/ios/AutofillElements.h: Added.

Source/WebKit:

  • Platform/spi/ios/UIKitSPI.h:
  • Shared/AssistedNodeInformation.cpp:

(WebKit::AssistedNodeInformation::encode const):
Encodes additional node information, including if the node is part of a login screen.
(WebKit::AssistedNodeInformation::decode):
Decodes the additional assisted node information.

  • Shared/AssistedNodeInformation.h:
  • UIProcess/WebPageProxy.h:
  • UIProcess/ios/WKContentView.mm:

(-[WKContentView acceptsAutofilledLoginCredentials]):
Determines if the WKContentView shows a login screen.
(-[WKContentView representingPageUrl]):
Returns the URL of the currently displayed web page.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView insertTextSuggestion:]):
Inserts the login credentials into the Web View.

  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::WebPageProxy::startAssistingNode):
Transfer the additional assistednode information (acceptsAutofilledLoginCredentials and representingPageUrl).
(WebKit::WebPageProxy::acceptsAutofilledLoginCredentials):
Returns if the Web View shows a login screen.
(WebKit::WebPageProxy::representingPageUrl):
Returns the Web View's URL.
(WebKit::WebPageProxy::autofillLoginCredentials):
Insert the credentials into the Web View.

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:
  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::getAssistedNodeInformation): Transports the information if the currently
highlighted node accepts autofilled login credentials.
(WebKit::WebPage::autofillLoginCredentials): Fills the login credentials into the
WebPage.

Source/WebKitLegacy/mac:

  • DOM/DOMHTMLInputElement.h:
  • DOM/DOMHTMLInputElement.mm:

(-[DOMHTMLInputElement acceptsAutofilledLoginCredentials]):
Determines if this HTMLInputElement is part of a login screen.
(-[DOMHTMLInputElement representingPageUrl]):
Returns the webpage's URL that is currently displayed in the Web View.
(-[DOMHTMLInputElement insertTextSuggestion:]):
Inserts login credentials into the Web View.

Tools:

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm: Added.

(-[WKWebView _privateTextInput]): Testing helpers.
(TestWebKitAPI::TEST): Added test cases to test AutoFill for web views.

  • TestWebKitAPI/ios/UIKitSPI.h:
Location:
trunk
Files:
2 added
19 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r222486 r222487  
     12017-09-25  Frederik Riedel  <riedel@apple.com>
     2
     3        Expose way to set values of classified form controls as {Legacy WebKit, WebKit} SPI
     4        https://bugs.webkit.org/show_bug.cgi?id=174394
     5        <rdar://problem/33183504>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        * WebCore.xcodeproj/project.pbxproj:
     10        * editing/ios/AutofillElements.cpp: Added.
     11        (WebCore::isAutofillableElement): Returns true if the element is of type text or email.
     12        (WebCore::nextAutofillableElement): Returns the next focusable element that is autofillable.
     13        (WebCore::previousAutofillableElement): Returns the previous focusable element that is autofillable.
     14        (WebCore::AutofillElements::computeAutofillElements): Computes the autofill elements (username & password)
     15        for a given input element.
     16        (WebCore::AutofillElements::autofill): Fills the credentials into the pair of username/password elements.
     17        * editing/ios/AutofillElements.h: Added.
     18
    1192017-09-25  Devin Rousso  <webkit@devinrousso.com>
    220
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r222478 r222487  
    22982298                5162C7F511F77EFB00612EFE /* SchemeRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 5162C7F311F77EFB00612EFE /* SchemeRegistry.h */; settings = {ATTRIBUTES = (Private, ); }; };
    22992299                5166D3CD1E8ED48F00AD62E3 /* StorageType.h in Headers */ = {isa = PBXBuildFile; fileRef = 5166D3CC1E8ED41100AD62E3 /* StorageType.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2300                51699EE31F608CD500D57D06 /* AutofillElements.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51699EE11F608CD500D57D06 /* AutofillElements.cpp */; };
     2301                51699EE41F608CD500D57D06 /* AutofillElements.h in Headers */ = {isa = PBXBuildFile; fileRef = 51699EE21F608CD500D57D06 /* AutofillElements.h */; settings = {ATTRIBUTES = (Private, ); }; };
    23002302                516BB7940CE91E6800512F79 /* JSTreeWalkerCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 516BB7920CE91E6800512F79 /* JSTreeWalkerCustom.cpp */; };
    23012303                516C62201950D48700337E75 /* GamepadEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 516C621D1950D48700337E75 /* GamepadEvent.cpp */; };
     
    1019810200                51645B541B9F88E800F789CE /* IDBCursor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBCursor.cpp; sourceTree = "<group>"; };
    1019910201                5166D3CC1E8ED41100AD62E3 /* StorageType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageType.h; sourceTree = "<group>"; };
     10202                51699EE11F608CD500D57D06 /* AutofillElements.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AutofillElements.cpp; sourceTree = "<group>"; };
     10203                51699EE21F608CD500D57D06 /* AutofillElements.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AutofillElements.h; sourceTree = "<group>"; };
    1020010204                516BB7920CE91E6800512F79 /* JSTreeWalkerCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTreeWalkerCustom.cpp; sourceTree = "<group>"; };
    1020110205                516C621D1950D48700337E75 /* GamepadEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GamepadEvent.cpp; sourceTree = "<group>"; };
     
    1839018394                        isa = PBXGroup;
    1839118395                        children = (
     18396                                51699EE11F608CD500D57D06 /* AutofillElements.cpp */,
     18397                                51699EE21F608CD500D57D06 /* AutofillElements.h */,
    1839218398                                D0BD4F5A1408850F006839B6 /* DictationCommandIOS.cpp */,
    1839318399                                D0BD4F5B1408850F006839B6 /* DictationCommandIOS.h */,
     
    2716227168                                7C1843FE1C8B7283002EB973 /* Autofill.h in Headers */,
    2716327169                                7C1E97281A9F9834007BF0FB /* AutoFillButtonElement.h in Headers */,
     27170                                51699EE41F608CD500D57D06 /* AutofillElements.h in Headers */,
    2716427171                                C9D467051E60C465008195FB /* AutoplayEvent.h in Headers */,
    2716527172                                45830D4E1679B4F800ACF8C3 /* AutoscrollController.h in Headers */,
     
    2783127838                                4129C9971F59B963009D7403 /* FetchBodySource.h in Headers */,
    2783227839                                41D129DB1F3D143800D15E47 /* FetchHeaders.h in Headers */,
     27840                                416E6FE81BBD12DF000A6023 /* FetchInternalsBuiltins.h in Headers */,
    2783327841                                41AD753A1CEF6BD100A31486 /* FetchOptions.h in Headers */,
    2783427842                                7CE1914D1F2A9AFB00272F78 /* FetchReferrerPolicy.h in Headers */,
     
    3132631334                                7C1843FD1C8B7283002EB973 /* Autofill.cpp in Sources */,
    3132731335                                7C1E97271A9F9834007BF0FB /* AutoFillButtonElement.cpp in Sources */,
     31336                                51699EE31F608CD500D57D06 /* AutofillElements.cpp in Sources */,
    3132831337                                45830D4D1679B4F800ACF8C3 /* AutoscrollController.cpp in Sources */,
    3132931338                                A8CFF0500A154F09000A4234 /* AutoTableLayout.cpp in Sources */,
  • trunk/Source/WebCore/editing/ios/AutofillElements.h

    r222486 r222487  
    2424 */
    2525
    26 #if PLATFORM(IOS)
     26#include "HTMLInputElement.h"
    2727
    28 #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
    29 @protocol UIDragSession;
    30 @class UIDragInteraction;
    31 @class UIDragItem;
    32 #endif
     28namespace WebCore {
    3329
    34 #if USE(APPLE_INTERNAL_SDK) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
    35 
    36 #import <UIKit/UIApplication_Private.h>
    37 #import <UIKit/UIDragInteraction_Private.h>
    38 
    39 #else
    40 
    41 WTF_EXTERN_C_BEGIN
    42 
    43 void UIApplicationInitialize(void);
    44 
    45 WTF_EXTERN_C_END
    46 
    47 #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
    48 @protocol UIDragInteractionDelegate_ForWebKitOnly <UIDragInteractionDelegate>
    49 @optional
    50 - (void)_dragInteraction:(UIDragInteraction *)interaction prepareForSession:(id<UIDragSession>)session completion:(void(^)(void))completion;
    51 @end
    52 #endif // __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
    53 
    54 #endif
    55 
    56 #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
    57 @protocol UIDragInteractionDelegate_Proposed_SPI_33146803 <UIDragInteractionDelegate>
    58 - (void)_dragInteraction:(UIDragInteraction *)interaction itemsForAddingToSession:(id <UIDragSession>)session withTouchAtPoint:(CGPoint)point completion:(void(^)(NSArray<UIDragItem *> *))completion;
    59 @end
    60 #endif // __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
    61 
    62 #endif // PLATFORM(IOS)
     30class AutofillElements {
     31    WTF_MAKE_FAST_ALLOCATED;
     32public:
     33    WEBCORE_EXPORT static std::optional<AutofillElements> computeAutofillElements(Ref<HTMLInputElement>);
     34    WEBCORE_EXPORT void autofill(String, String);
     35private:
     36    AutofillElements(RefPtr<HTMLInputElement>&&, RefPtr<HTMLInputElement>&&);
     37    RefPtr<HTMLInputElement> m_username;
     38    RefPtr<HTMLInputElement> m_password;
     39};
     40} // namespace WebCore
  • trunk/Source/WebKit/ChangeLog

    r222478 r222487  
     12017-09-25  Frederik Riedel  <riedel@apple.com>
     2
     3        Expose way to set values of classified form controls as {Legacy WebKit, WebKit} SPI
     4        https://bugs.webkit.org/show_bug.cgi?id=174394
     5        <rdar://problem/33183504>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        * Platform/spi/ios/UIKitSPI.h:
     10        * Shared/AssistedNodeInformation.cpp:
     11        (WebKit::AssistedNodeInformation::encode const):
     12        Encodes additional node information, including if the node is part of a login screen.
     13        (WebKit::AssistedNodeInformation::decode):
     14        Decodes the additional assisted node information.
     15        * Shared/AssistedNodeInformation.h:
     16        * UIProcess/WebPageProxy.h:
     17        * UIProcess/ios/WKContentView.mm:
     18        (-[WKContentView acceptsAutofilledLoginCredentials]):
     19        Determines if the WKContentView shows a login screen.
     20        (-[WKContentView representingPageUrl]):
     21        Returns the URL of the currently displayed web page.
     22        * UIProcess/ios/WKContentViewInteraction.mm:
     23        (-[WKContentView insertTextSuggestion:]):
     24        Inserts the login credentials into the Web View.
     25        * UIProcess/ios/WebPageProxyIOS.mm:
     26        (WebKit::WebPageProxy::startAssistingNode):
     27        Transfer the additional assistednode information (acceptsAutofilledLoginCredentials and representingPageUrl).
     28        (WebKit::WebPageProxy::acceptsAutofilledLoginCredentials):
     29        Returns if the Web View shows a login screen.
     30        (WebKit::WebPageProxy::representingPageUrl):
     31        Returns the Web View's URL.
     32        (WebKit::WebPageProxy::autofillLoginCredentials):
     33        Insert the credentials into the Web View.
     34        * WebProcess/WebPage/WebPage.h:
     35        * WebProcess/WebPage/WebPage.messages.in:
     36        * WebProcess/WebPage/ios/WebPageIOS.mm:
     37        (WebKit::WebPage::getAssistedNodeInformation): Transports the information if the currently
     38        highlighted node accepts autofilled login credentials.
     39        (WebKit::WebPage::autofillLoginCredentials): Fills the login credentials into the
     40        WebPage.
     41
    1422017-09-25  Youenn Fablet  <youenn@apple.com>
    243
  • trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h

    r222265 r222487  
    4444#import <UIKit/UIKeyboardImpl.h>
    4545#import <UIKit/UIKeyboardIntl.h>
     46#if __has_include(<UIKit/UIKeyboardLoginCredentialsSuggestion.h>)
     47#import <UIKit/UIKeyboardLoginCredentialsSuggestion.h>
     48#else
     49#import <UIKit/UITextInput_Private.h>
     50@interface UIKeyboardLoginCredentialsSuggestion : UITextSuggestion
     51
     52@property (nonatomic, assign) NSString *username;
     53@property (nonatomic, assign) NSString *password;
     54
     55@end
     56#endif
    4657#import <UIKit/UIKeyboard_Private.h>
    4758#import <UIKit/UILongPressGestureRecognizer_Private.h>
  • trunk/Source/WebKit/Shared/AssistedNodeInformation.cpp

    r222233 r222487  
    8787    encoder << valueAsNumber;
    8888    encoder << title;
     89    encoder << acceptsAutofilledLoginCredentials;
     90    encoder << representingPageURL;
    8991    encoder.encodeEnum(autofillFieldName);
    9092}
     
    161163        return false;
    162164
     165    if (!decoder.decode(result.acceptsAutofilledLoginCredentials))
     166        return false;
     167
     168    if (!decoder.decode(result.representingPageURL))
     169        return false;
     170
    163171    if (!decoder.decodeEnum(result.autofillFieldName))
    164172        return false;
  • trunk/Source/WebKit/Shared/AssistedNodeInformation.h

    r222233 r222487  
    3030#include <WebCore/Autofill.h>
    3131#include <WebCore/IntRect.h>
     32#include <WebCore/URL.h>
    3233#include <wtf/text/WTFString.h>
    3334
     
    110111    double valueAsNumber { 0 };
    111112    String title;
     113    bool acceptsAutofilledLoginCredentials { false };
     114    WebCore::URL representingPageURL;
    112115    WebCore::AutofillFieldName autofillFieldName { WebCore::AutofillFieldName::None };
    113116
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r222468 r222487  
    8080#include <WebCore/TextChecking.h>
    8181#include <WebCore/TextGranularity.h>
     82#include <WebCore/URL.h>
    8283#include <WebCore/UserInterfaceLayoutDirection.h>
    8384#include <memory>
     
    560561    void requestRectsForGranularityWithSelectionOffset(WebCore::TextGranularity, uint32_t offset, WTF::Function<void(const Vector<WebCore::SelectionRect>&, CallbackBase::Error)>&&);
    561562    void requestRectsAtSelectionOffsetWithText(int32_t offset, const String&, WTF::Function<void(const Vector<WebCore::SelectionRect>&, CallbackBase::Error)>&&);
     563    bool acceptsAutofilledLoginCredentials();
     564    WebCore::URL representingPageURL();
     565    void autofillLoginCredentials(const String& username, const String& password);
    562566#if ENABLE(DATA_INTERACTION)
    563567    void didPerformDataInteractionControllerOperation(bool handled);
     
    19891993    std::unique_ptr<NodeAssistanceArguments> m_deferredNodeAssistanceArguments;
    19901994    bool m_forceAlwaysUserScalable { false };
     1995    bool m_acceptsAutofilledLoginCredentials { false };
     1996    WebCore::URL m_representingPageURL;
    19911997#endif
    19921998
  • trunk/Source/WebKit/UIProcess/ios/WKContentView.mm

    r220506 r222487  
    259259}
    260260
     261- (BOOL)acceptsAutofilledLoginCredentials
     262{
     263    return _page->acceptsAutofilledLoginCredentials();
     264}
     265
     266- (NSURL *)representingPageURL
     267{
     268    return _page->representingPageURL();
     269}
     270
    261271- (void)willMoveToWindow:(UIWindow *)newWindow
    262272{
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r221870 r222487  
    29772977    [self.inputDelegate selectionDidChange:self];
    29782978}
    2979    
     2979
     2980#if USE(APPLE_INTERNAL_SDK)
    29802981- (void)insertTextSuggestion:(UITextSuggestion *)textSuggestion
    29812982{
     2983    // FIXME: Replace NSClassFromString with actual class as soon as UIKit submitted the new class into the iOS SDK.
     2984    if ([textSuggestion isKindOfClass:NSClassFromString(@"UIKeyboardLoginCredentialsSuggestion")]) {
     2985        _page->autofillLoginCredentials([(UIKeyboardLoginCredentialsSuggestion *)textSuggestion username], [(UIKeyboardLoginCredentialsSuggestion *)textSuggestion password]);
     2986        return;
     2987    }
    29822988    id <_WKInputDelegate> inputDelegate = [_webView _inputDelegate];
    29832989    if ([inputDelegate respondsToSelector:@selector(_webView:insertTextSuggestion:inInputSession:)])
    29842990        [inputDelegate _webView:_webView insertTextSuggestion:textSuggestion inInputSession:_formInputSession.get()];
    29852991}
     2992#endif // USE(APPLE_INTERNAL_SDK)
    29862993
    29872994- (NSString *)textInRange:(UITextRange *)range
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r221660 r222487  
    892892void WebPageProxy::startAssistingNode(const AssistedNodeInformation& information, bool userIsInteracting, bool blurPreviousNode, const UserData& userData)
    893893{
     894    m_acceptsAutofilledLoginCredentials = information.acceptsAutofilledLoginCredentials;
     895    m_representingPageURL = information.representingPageURL;
    894896    API::Object* userDataObject = process().transformHandlesToObjects(userData.object()).get();
    895897    if (m_editorState.isMissingPostLayoutData) {
     
    909911    }
    910912    m_pageClient.stopAssistingNode();
     913}
     914
     915bool WebPageProxy::acceptsAutofilledLoginCredentials()
     916{
     917    return m_acceptsAutofilledLoginCredentials;
     918}
     919
     920WebCore::URL WebPageProxy::representingPageURL()
     921{
     922    return m_representingPageURL;
     923}
     924
     925void WebPageProxy::autofillLoginCredentials(const String& username, const String& password)
     926{
     927    m_process->send(Messages::WebPage::AutofillLoginCredentials(username, password), m_pageID);
    911928}
    912929
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r222456 r222487  
    577577    void performActionOnElement(uint32_t action);
    578578    void focusNextAssistedNode(bool isForward, CallbackID);
     579    void autofillLoginCredentials(const String&, const String&);
    579580    void setAssistedNodeValue(const String&);
    580581    void setAssistedNodeValueAsNumber(double);
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r222456 r222487  
    8585    FocusNextAssistedNode(bool isForward, WebKit::CallbackID callbackID)
    8686    SetAssistedNodeValue(String value)
     87    AutofillLoginCredentials(String username, String password)
    8788    SetAssistedNodeValueAsNumber(double value)
    8889    SetAssistedNodeSelectedIndex(uint32_t index, bool allowMultipleSelection)
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r222478 r222487  
    5454#import <CoreText/CTFont.h>
    5555#import <WebCore/Autofill.h>
     56#import <WebCore/AutofillElements.h>
    5657#import <WebCore/Chrome.h>
    5758#import <WebCore/DataDetection.h>
     
    27512752        if (form)
    27522753            information.formAction = form->getURLAttribute(WebCore::HTMLNames::actionAttr);
     2754        information.acceptsAutofilledLoginCredentials = !!WebCore::AutofillElements::computeAutofillElements(element);
     2755        information.representingPageURL = element.document().urlForBindings();
    27532756        information.autocapitalizeType = element.autocapitalizeType();
    27542757        information.isAutocorrect = element.shouldAutocorrect();
     
    28082811}
    28092812
     2813void WebPage::autofillLoginCredentials(const String& username, const String& password)
     2814{
     2815    if (is<HTMLInputElement>(*m_assistedNode)) {
     2816        if (auto autofillElements = AutofillElements::computeAutofillElements(downcast<HTMLInputElement>(*m_assistedNode)))
     2817            autofillElements->autofill(username, password);
     2818    }
     2819}
     2820
    28102821void WebPage::setViewportConfigurationMinimumLayoutSize(const FloatSize& size)
    28112822{
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r222477 r222487  
     12017-09-25  Frederik Riedel  <riedel@apple.com>
     2
     3        Expose way to set values of classified form controls as {Legacy WebKit, WebKit} SPI
     4        https://bugs.webkit.org/show_bug.cgi?id=174394
     5        <rdar://problem/33183504>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        * DOM/DOMHTMLInputElement.h:
     10        * DOM/DOMHTMLInputElement.mm:
     11        (-[DOMHTMLInputElement acceptsAutofilledLoginCredentials]):
     12        Determines if this HTMLInputElement is part of a login screen.
     13        (-[DOMHTMLInputElement representingPageUrl]):
     14        Returns the webpage's URL that is currently displayed in the Web View.
     15        (-[DOMHTMLInputElement insertTextSuggestion:]):
     16        Inserts login credentials into the Web View.
     17
    1182017-09-25  Sam Weinig  <sam@webkit.org>
    219
  • trunk/Source/WebKitLegacy/mac/DOM/DOMHTMLInputElement.h

    r204717 r222487  
    2525
    2626#import <WebKitLegacy/DOMHTMLElement.h>
     27#if TARGET_OS_IPHONE
     28#import <UIKit/UITextInputTraits.h>
     29#endif
    2730
    2831@class DOMFileList;
     
    3235
    3336WEBKIT_CLASS_AVAILABLE_MAC(10_4)
     37#if TARGET_OS_IPHONE
     38@interface DOMHTMLInputElement : DOMHTMLElement<UITextInputTraits>
     39#else
    3440@interface DOMHTMLInputElement : DOMHTMLElement
     41#endif
    3542@property (copy) NSString *accept;
    3643@property (copy) NSString *alt;
  • trunk/Source/WebKitLegacy/mac/DOM/DOMHTMLInputElement.mm

    r208624 r222487  
    3434#import "DOMPrivate.h"
    3535#import "ExceptionHandlers.h"
     36
     37// FIXME <radar:34583628>: Simplyfy this once the UIKit work is available in the build.
     38#if USE(APPLE_INTERNAL_SDK) && TARGET_OS_IPHONE
     39#if __has_include(<UIKit/UIKeyboardLoginCredentialsSuggestion.h>)
     40#import <UIKit/UIKeyboardLoginCredentialsSuggestion.h>
     41#else
     42#import <UIKit/UITextInput_Private.h>
     43@interface UIKeyboardLoginCredentialsSuggestion : UITextSuggestion
     44
     45@property (nonatomic, assign) NSString *username;
     46@property (nonatomic, assign) NSString *password;
     47
     48@end
     49#endif // __has_include(<UIKit/UIKeyboardLoginCredentialsSuggestion.h>)
     50#endif // USE(APPLE_INTERNAL_SDK) && TARGET_OS_IPHONE
     51
     52#import <WebCore/AutofillElements.h>
    3653#import <WebCore/FileList.h>
    3754#import <WebCore/HTMLElement.h>
     
    667684}
    668685
     686- (BOOL)acceptsAutofilledLoginCredentials
     687{
     688    WebCore::JSMainThreadNullState state;
     689    return !!WebCore::AutofillElements::computeAutofillElements(*IMPL);
     690}
     691
     692- (NSURL *)representingPageURL
     693{
     694    WebCore::JSMainThreadNullState state;
     695    return [NSURL URLWithString:self.ownerDocument.URL];
     696}
     697
     698#if USE(APPLE_INTERNAL_SDK) && TARGET_OS_IPHONE
     699- (void)insertTextSuggestion:(UIKeyboardLoginCredentialsSuggestion *)credentialsSuggestion
     700{
     701    WebCore::JSMainThreadNullState state;
     702    if (is<WebCore::HTMLInputElement>(IMPL)) {
     703        if (auto autofillElements = WebCore::AutofillElements::computeAutofillElements(*IMPL))
     704            autofillElements->autofill(credentialsSuggestion.username, credentialsSuggestion.password);
     705    }
     706}
     707#endif // USE(APPLE_INTERNAL_SDK) && TARGET_OS_IPHONE
     708
    669709@end
    670710
  • trunk/Tools/ChangeLog

    r222482 r222487  
     12017-09-25  Frederik Riedel  <riedel@apple.com>
     2
     3        Expose way to set values of classified form controls as {Legacy WebKit, WebKit} SPI
     4        https://bugs.webkit.org/show_bug.cgi?id=174394
     5        <rdar://problem/33183504>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     10        * TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm: Added.
     11        (-[WKWebView _privateTextInput]): Testing helpers.
     12        (TestWebKitAPI::TEST): Added test cases to test AutoFill for web views.
     13        * TestWebKitAPI/ios/UIKitSPI.h:
     14
    1152017-09-25  Frederic Wang  <fwang@igalia.com>
    216
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r222462 r222487  
    162162                51393E221523952D005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51393E1D1523944A005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp */; };
    163163                5142B2731517C8C800C32B19 /* ContextMenuCanCopyURL.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5142B2721517C89100C32B19 /* ContextMenuCanCopyURL.html */; };
     164                514958BE1F7427AC00E87BAD /* WKWebViewAutofillTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 514958BD1F7427AC00E87BAD /* WKWebViewAutofillTests.mm */; };
    164165                515BE16F1D428BB100DD7C68 /* StoreBlobToBeDeleted.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 515BE16E1D4288FF00DD7C68 /* StoreBlobToBeDeleted.html */; };
    165166                515BE1711D428E4B00DD7C68 /* StoreBlobThenDelete.mm in Sources */ = {isa = PBXBuildFile; fileRef = 515BE1701D428BD100DD7C68 /* StoreBlobThenDelete.mm */; };
     
    12431244                5142B2701517C88B00C32B19 /* ContextMenuCanCopyURL.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ContextMenuCanCopyURL.mm; sourceTree = "<group>"; };
    12441245                5142B2721517C89100C32B19 /* ContextMenuCanCopyURL.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ContextMenuCanCopyURL.html; sourceTree = "<group>"; };
     1246                514958BD1F7427AC00E87BAD /* WKWebViewAutofillTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewAutofillTests.mm; sourceTree = "<group>"; };
    12451247                515BE16E1D4288FF00DD7C68 /* StoreBlobToBeDeleted.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = StoreBlobToBeDeleted.html; sourceTree = "<group>"; };
    12461248                515BE1701D428BD100DD7C68 /* StoreBlobThenDelete.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StoreBlobThenDelete.mm; sourceTree = "<group>"; };
     
    21202122                                7560917719259C59009EF06E /* MemoryCacheAddImageToCacheIOS.mm */,
    21212123                                F46849BD1EEF58E400B937FE /* UIPasteboardTests.mm */,
     2124                                514958BD1F7427AC00E87BAD /* WKWebViewAutofillTests.mm */,
    21222125                        );
    21232126                        path = ios;
     
    34543457                                51C683DE1EA134E800650183 /* WKURLSchemeHandler-1.mm in Sources */,
    34553458                                5182C22E1F2BCE540059BA7C /* WKURLSchemeHandler-leaks.mm in Sources */,
     3459                                514958BE1F7427AC00E87BAD /* WKWebViewAutofillTests.mm in Sources */,
    34563460                                2EFF06D71D8AF34A0004BB30 /* WKWebViewCandidateTests.mm in Sources */,
    34573461                                A14FC5851B89739100D107EB /* WKWebViewConfigurationExtras.mm in Sources */,
  • trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h

    r221870 r222487  
    2626#if PLATFORM(IOS)
    2727
     28#import <UIKit/UITextInputTraits.h>
     29
    2830#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
    2931@protocol UIDragSession;
     
    3638#import <UIKit/UIApplication_Private.h>
    3739#import <UIKit/UIDragInteraction_Private.h>
     40#import <UIKit/UITextInputTraits_Private.h>
     41#import <UIKit/UITextSuggestion.h>
     42
     43
     44@protocol UITextInputTraits_Private_Staging_34583628 <NSObject, UITextInputTraits>
     45@property (nonatomic, readonly) BOOL acceptsAutofilledLoginCredentials;
     46@end
    3847
    3948#else
     
    5261#endif // __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
    5362
     63@protocol UITextInputTraits_Private <NSObject, UITextInputTraits>
     64@property (nonatomic, readonly) BOOL acceptsAutofilledLoginCredentials;
     65@end
     66
    5467#endif
    5568
Note: See TracChangeset for help on using the changeset viewer.