Add AssistedNodeInformation plumbing for form control placeholder text and label...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Mar 2018 02:28:29 +0000 (02:28 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Mar 2018 02:28:29 +0000 (02:28 +0000)
commit10d1cdcbaab684e8f954a3c55652baec463494ff
treea1d2c68d7bb71b3dd65ae19781f058bf64f38a43
parentf6ddcfbe2ff7d40976121294dc081a2c0827a86f
Add AssistedNodeInformation plumbing for form control placeholder text and label text
https://bugs.webkit.org/show_bug.cgi?id=183802
<rdar://problem/38686273>

Reviewed by Tim Horton.

Source/WebKit:

Surfaces some additional information about the currently focused element to the input delegate in the UI process.
See comments below for more details.

Test: WebKit.FocusedElementInfo

* Shared/AssistedNodeInformation.cpp:
(WebKit::AssistedNodeInformation::encode const):
(WebKit::AssistedNodeInformation::decode):
* Shared/AssistedNodeInformation.h:

Add `placeholder` and `label` to AssistedNodeInformation, which capture the value of the placeholder attribute
and the text of the first associated label element for the focused form control. Also add boilerplate encoder/
decoder support for these members.

* UIProcess/API/Cocoa/_WKFocusedElementInfo.h:

Augment _WKFocusedElementInfo to include placeholder and label.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKFocusedElementInfo initWithAssistedNodeInformation:isUserInitiated:userObject:]):
(-[WKFocusedElementInfo label]):
(-[WKFocusedElementInfo placeholder]):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getAssistedNodeInformation):

For input elements and textareas, set the placeholder to the value of the placeholder attribute. For all
elements with associated labels, grab the inner text of the first label that is not empty, ignoring all labels
that are `display: none` (i.e. not being rendered).

Tools:

Adds a new API test to exercise new placeholder and label SPI on _WKFocusedFormElement.

* TestWebKitAPI/Tests/WebKitCocoa/_WKInputDelegate.mm:
(-[InputDelegate _webView:focusShouldStartInputSession:]):
(-[InputDelegate shouldStartInputSessionHandler]):
(-[InputDelegate setShouldStartInputSessionHandler:]):
(TEST):
(-[FormSubmissionDelegate webView:startURLSchemeTask:]): Deleted.
(-[FormSubmissionDelegate webView:stopURLSchemeTask:]): Deleted.
(-[FormSubmissionDelegate _webView:willSubmitFormValues:userObject:submissionHandler:]): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229783 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit/ChangeLog
Source/WebKit/Shared/AssistedNodeInformation.cpp
Source/WebKit/Shared/AssistedNodeInformation.h
Source/WebKit/UIProcess/API/Cocoa/_WKFocusedElementInfo.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKInputDelegate.mm