[Datalist] Allow TextFieldInputType to show and hide suggestions
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jun 2018 21:08:58 +0000 (21:08 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jun 2018 21:08:58 +0000 (21:08 +0000)
commitaddc1dd057b1b50f8b532d5f32ef301c17a3f913
treeac561f205c4ba68d28330bcb76bef2eb57d71faf
parent4ff2d305a6c0ed00bcbc651592465cc4806a3ac5
[Datalist] Allow TextFieldInputType to show and hide suggestions
https://bugs.webkit.org/show_bug.cgi?id=186151

Patch by Aditya Keerthi <akeerthi@apple.com> on 2018-06-08
Reviewed by Tim Horton.

Source/WebCore:

TextFieldInputTypes with a list attribute should be able to display suggestions as the user
interacts with the input field. In order to display suggestions for an input field with a list
attribute, we need provide certain information - including the items to suggest and the location
to present the suggestions. TextFieldInputType can now provide this information by conforming to
the DataListSuggestionsClient interface.

In this initial patch, the suggestions can be shown in two ways. The first is by clicking on the
input field. The other is by typing text in the field. In a later patch, we will add a third way
to display suggestions, using a button. These ways to activate the suggestions are enumerated in
DataListSuggestionInformation.

We hide the suggestions if there are no more to show, or if the input has blurred.

Tests to be added once work has been done in the UIProcess.

* WebCore.xcodeproj/project.pbxproj:
* html/DataListSuggestionInformation.h: Added. Contains the information necessary to display suggestions.
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::~TextFieldInputType):
(WebCore::TextFieldInputType::handleClickEvent): Show suggestions when the element is clicked.
(WebCore::TextFieldInputType::handleKeydownEvent): Allow users to interact with the suggestions using the keyboard.
(WebCore::TextFieldInputType::elementDidBlur): Hide the suggestions.
(WebCore::TextFieldInputType::shouldRespectListAttribute):
(WebCore::TextFieldInputType::didSetValueByUserEdit): Update the suggestions if the text has changed.
(WebCore::TextFieldInputType::elementRectRelativeToRootView const): Provide the location where the suggestions should be shown.
(WebCore::TextFieldInputType::suggestions const): Provide the list of suggestions.
(WebCore::TextFieldInputType::didSelectDataListOption): Update the text once an suggestion has been selected.
(WebCore::TextFieldInputType::didCloseSuggestions):
(WebCore::TextFieldInputType::displaySuggestions):
(WebCore::TextFieldInputType::closeSuggestions):
* html/TextFieldInputType.h:
* loader/EmptyClients.cpp:
(WebCore::EmptyChromeClient::createDataListSuggestionPicker):
* loader/EmptyClients.h:
* page/Chrome.cpp:
(WebCore::Chrome::createDataListSuggestionPicker):
* page/Chrome.h:
* page/ChromeClient.h:
* platform/DataListSuggestionPicker.h: Added.
(WebCore::DataListSuggestionPicker::close):
(WebCore::DataListSuggestionPicker::handleKeydownWithIdentifier):
(WebCore::DataListSuggestionPicker::displayWithActivationType):
* platform/DataListSuggestionsClient.h: Added.

Source/WebKit:

Added WebDataListSuggestionPicker to send messages to the UIProcess in order to update the suggestions view.
This object is also responsible for forwarding messages from WebKit into the DataListSuggestionsClient, which
is the TextFieldInputType in this case. The client needs to know when the suggestions are hidden or if an
suggestion has been selected.

* WebKit.xcodeproj/project.pbxproj:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::createDataListSuggestionPicker): Responsible for creating WebDataListSuggestionPicker to send/receive messages.
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebCoreSupport/WebDataListSuggestionPicker.cpp: Added. Responsible for sending messages to UIProcess and updating the DataListSuggestionsClient.
(WebKit::WebDataListSuggestionPicker::WebDataListSuggestionPicker):
(WebKit::WebDataListSuggestionPicker::~WebDataListSuggestionPicker):
(WebKit::WebDataListSuggestionPicker::handleKeydownWithIdentifier):
(WebKit::WebDataListSuggestionPicker::didSelectOption):
(WebKit::WebDataListSuggestionPicker::didCloseSuggestions):
(WebKit::WebDataListSuggestionPicker::close):
(WebKit::WebDataListSuggestionPicker::displayWithActivationType):
* WebProcess/WebCoreSupport/WebDataListSuggestionPicker.h: Added.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setActiveDataListSuggestionPicker):
(WebKit::WebPage::didSelectDataListOption): Called by UIProcess when option selected.
(WebKit::WebPage::didCloseSuggestions): Called by UIProcess if the suggestions view is closed.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Source/WebKitLegacy/mac:

* WebCoreSupport/WebChromeClient.h:
* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::createDataListSuggestionPicker):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232640 268f45cc-cd09-0410-ab3c-d52691b4dbfc
24 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/html/DataListSuggestionInformation.h [new file with mode: 0644]
Source/WebCore/html/TextFieldInputType.cpp
Source/WebCore/html/TextFieldInputType.h
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/loader/EmptyClients.h
Source/WebCore/page/Chrome.cpp
Source/WebCore/page/Chrome.h
Source/WebCore/page/ChromeClient.h
Source/WebCore/platform/DataListSuggestionPicker.h [new file with mode: 0644]
Source/WebCore/platform/DataListSuggestionsClient.h [new file with mode: 0644]
Source/WebKit/ChangeLog
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h
Source/WebKit/WebProcess/WebCoreSupport/WebDataListSuggestionPicker.cpp [new file with mode: 0644]
Source/WebKit/WebProcess/WebCoreSupport/WebDataListSuggestionPicker.h [new file with mode: 0644]
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h
Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm