WebDataListSuggestionPicker.cpp [plain text]
#include "config.h"
#include "WebDataListSuggestionPicker.h"
#if ENABLE(DATALIST_ELEMENT)
#include "WebCoreArgumentCoders.h"
#include "WebPage.h"
#include "WebPageProxyMessages.h"
#include "WebProcess.h"
#include <WebCore/DataListSuggestionsClient.h>
namespace WebKit {
WebDataListSuggestionPicker::WebDataListSuggestionPicker(WebPage& page, WebCore::DataListSuggestionsClient& client)
: m_client(client)
, m_page(page)
{
}
void WebDataListSuggestionPicker::handleKeydownWithIdentifier(const String& key)
{
WebProcess::singleton().parentProcessConnection()->send(Messages::WebPageProxy::HandleKeydownInDataList(key), m_page.identifier());
}
void WebDataListSuggestionPicker::didSelectOption(const String& selectedOption)
{
m_client.didSelectDataListOption(selectedOption);
}
void WebDataListSuggestionPicker::didCloseSuggestions()
{
m_client.didCloseSuggestions();
}
void WebDataListSuggestionPicker::close()
{
WebProcess::singleton().parentProcessConnection()->send(Messages::WebPageProxy::EndDataListSuggestions(), m_page.identifier());
}
void WebDataListSuggestionPicker::displayWithActivationType(WebCore::DataListSuggestionActivationType type)
{
auto suggestions = m_client.suggestions();
if (suggestions.isEmpty()) {
close();
return;
}
m_page.setActiveDataListSuggestionPicker(*this);
WebCore::DataListSuggestionInformation info { type, WTFMove(suggestions), m_client.elementRectInRootViewCoordinates() };
WebProcess::singleton().parentProcessConnection()->send(Messages::WebPageProxy::ShowDataListSuggestions(info), m_page.identifier());
}
}
#endif