haikuwebkit/Source/WebCore/platform/DataListSuggestionPicker.h

49 lines
1.9 KiB
C
Raw Permalink Normal View History

[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): Canonical link: https://commits.webkit.org/201804@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232640 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-06-08 21:08:58 +00:00
/*
* Copyright (C) 2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#if ENABLE(DATALIST_ELEMENT)
Crash when attempting to change input type while dismissing datalist suggestions https://bugs.webkit.org/show_bug.cgi?id=195384 <rdar://problem/48563718> Reviewed by Brent Fulgham. Source/WebCore: When closing a datalist suggestion menu, WebPageProxy sends a message to WebPage instructing it to tell its active datalist suggestions picker to close. However, for a myriad of reasons, the suggestions picker (kept alive by its text input type) may have already gone away by this point. To mitigate this, make WebPage weakly reference its active datalist suggestions picker. Test: fast/forms/datalist/change-input-type-after-closing-datalist-suggestions.html * platform/DataListSuggestionPicker.h: Make DataListSuggestionPicker capable of being weakly referenced. Additionally, fix some minor preexisting issues in this header (#imports instead of #includes, as well as an unnecessary include of IntRect.h). Source/WebKit: See WebCore ChangeLog for more details. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::setActiveDataListSuggestionPicker): (WebKit::WebPage::didSelectDataListOption): (WebKit::WebPage::didCloseSuggestions): * WebProcess/WebPage/WebPage.h: Turn m_activeDataListSuggestionPicker from a raw pointer into a WeakPtr. LayoutTests: Add a new layout test to exercise this scenario. * fast/forms/datalist/change-input-type-after-closing-datalist-suggestions-expected.txt: Added. * fast/forms/datalist/change-input-type-after-closing-datalist-suggestions.html: Added. Canonical link: https://commits.webkit.org/209728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242587 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-03-07 03:11:38 +00:00
#include "DataListSuggestionInformation.h"
#include <wtf/WeakPtr.h>
#include <wtf/text/WTFString.h>
[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): Canonical link: https://commits.webkit.org/201804@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232640 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-06-08 21:08:58 +00:00
namespace WebCore {
Crash when attempting to change input type while dismissing datalist suggestions https://bugs.webkit.org/show_bug.cgi?id=195384 <rdar://problem/48563718> Reviewed by Brent Fulgham. Source/WebCore: When closing a datalist suggestion menu, WebPageProxy sends a message to WebPage instructing it to tell its active datalist suggestions picker to close. However, for a myriad of reasons, the suggestions picker (kept alive by its text input type) may have already gone away by this point. To mitigate this, make WebPage weakly reference its active datalist suggestions picker. Test: fast/forms/datalist/change-input-type-after-closing-datalist-suggestions.html * platform/DataListSuggestionPicker.h: Make DataListSuggestionPicker capable of being weakly referenced. Additionally, fix some minor preexisting issues in this header (#imports instead of #includes, as well as an unnecessary include of IntRect.h). Source/WebKit: See WebCore ChangeLog for more details. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::setActiveDataListSuggestionPicker): (WebKit::WebPage::didSelectDataListOption): (WebKit::WebPage::didCloseSuggestions): * WebProcess/WebPage/WebPage.h: Turn m_activeDataListSuggestionPicker from a raw pointer into a WeakPtr. LayoutTests: Add a new layout test to exercise this scenario. * fast/forms/datalist/change-input-type-after-closing-datalist-suggestions-expected.txt: Added. * fast/forms/datalist/change-input-type-after-closing-datalist-suggestions.html: Added. Canonical link: https://commits.webkit.org/209728@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242587 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-03-07 03:11:38 +00:00
class DataListSuggestionPicker : public CanMakeWeakPtr<DataListSuggestionPicker> {
Mark more heap-allocated classes as fast allocated https://bugs.webkit.org/show_bug.cgi?id=194422 Reviewed by Ryosuke Niwa. Source/WebCore: * Modules/applepay/PaymentCoordinator.h: * Modules/beacon/NavigatorBeacon.h: * Modules/cache/DOMWindowCaches.h: * Modules/cache/WorkerGlobalScopeCaches.h: * Modules/credentialmanagement/NavigatorCredentials.h: * Modules/encryptedmedia/legacy/LegacyCDMPrivateClearKey.h: * Modules/gamepad/NavigatorGamepad.h: * Modules/indexeddb/IDBGetAllResult.h: * Modules/indexeddb/IDBGetResult.h: * Modules/indexeddb/IDBKeyData.h: * Modules/indexeddb/IDBValue.h: * Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.h: * Modules/indexeddb/server/IndexValueEntry.h: * Modules/indexeddb/server/IndexValueStore.h: * Modules/indexeddb/server/MemoryBackingStoreTransaction.h: * Modules/indexeddb/server/MemoryCursor.h: * Modules/indexeddb/server/MemoryIDBBackingStore.h: * Modules/indexeddb/server/SQLiteIDBBackingStore.h: * Modules/indexeddb/server/SQLiteIDBCursor.h: * Modules/indexeddb/server/SQLiteIDBTransaction.h: * Modules/indexeddb/server/UniqueIDBDatabase.h: * Modules/indexeddb/shared/IDBDatabaseInfo.h: * Modules/indexeddb/shared/IDBResourceIdentifier.h: * Modules/indexeddb/shared/IDBTransactionInfo.h: * Modules/mediacapabilities/NavigatorMediaCapabilities.h: * Modules/mediasession/WebMediaSessionManager.cpp: * Modules/mediastream/NavigatorMediaDevices.h: * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h: * Modules/mediastream/libwebrtc/LibWebRTCRtpReceiverBackend.h: * Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.h: * Modules/mediastream/libwebrtc/LibWebRTCRtpTransceiverBackend.h: * Modules/navigatorcontentutils/NavigatorContentUtils.h: * Modules/quota/DOMWindowQuota.h: * Modules/quota/NavigatorStorageQuota.h: * Modules/quota/WorkerNavigatorStorageQuota.h: * Modules/speech/DOMWindowSpeechSynthesis.h: * Modules/webaudio/BiquadProcessor.h: * Modules/webaudio/DelayProcessor.h: * Modules/webauthn/fido/FidoHidPacket.h: * Modules/webdriver/NavigatorWebDriver.h: * Modules/webgpu/DOMWindowWebGPU.h: * Modules/websockets/WebSocketChannel.h: * Modules/webvr/NavigatorWebVR.h: * accessibility/AXObjectCache.h: * bindings/js/DOMGCOutputConstraint.h: * bindings/js/DOMPromiseProxy.h: * bridge/c/c_runtime.h: * contentextensions/CombinedURLFilters.cpp: * crypto/CryptoAlgorithmParameters.h: * css/CSSComputedStyleDeclaration.h: * css/CSSRegisteredCustomProperty.h: * css/DOMCSSPaintWorklet.h: * css/DOMCSSRegisterCustomProperty.h: * css/StyleRule.h: * dom/ConstantPropertyMap.h: * dom/CustomElementReactionQueue.h: * dom/Document.h: * dom/GenericEventQueue.h: * dom/RejectedPromiseTracker.h: * dom/UserGestureIndicator.h: * editing/ReplaceSelectionCommand.cpp: * editing/SelectionRectGatherer.h: * editing/TextIterator.h: * editing/cocoa/HTMLConverter.mm: * fileapi/AsyncFileStream.cpp: * fileapi/AsyncFileStream.h: * html/forms/FileIconLoader.h: * html/parser/HTMLTreeBuilder.h: * html/track/WebVTTParser.h: * inspector/DOMPatchSupport.cpp: * loader/FrameLoaderClient.h: * loader/WorkerThreadableLoader.cpp: * page/IntersectionObserver.h: * page/PerformanceMonitor.h: * page/PerformanceUserTiming.h: * page/PrintContext.h: * page/ValidationMessageClient.h: * platform/ColorChooser.h: * platform/ControlStates.h: * platform/DataListSuggestionPicker.h: * platform/FileStream.h: * platform/KeyedCoding.h: * platform/LowPowerModeNotifier.h: * platform/PlatformSpeechSynthesizer.h: * platform/WebGLStateTracker.h: * platform/audio/AudioArray.h: * platform/audio/AudioDestination.h: * platform/audio/DownSampler.h: * platform/audio/DynamicsCompressor.h: * platform/audio/FFTFrame.h: * platform/audio/HRTFDatabase.h: * platform/audio/MultiChannelResampler.h: * platform/audio/Panner.h: * platform/audio/Reverb.h: * platform/audio/ReverbConvolver.h: * platform/audio/ReverbConvolverStage.h: * platform/audio/UpSampler.h: * platform/audio/mac/AudioSessionMac.cpp: * platform/audio/mac/CAAudioStreamDescription.h: * platform/audio/mac/CARingBuffer.h: * platform/cocoa/ScrollSnapAnimatorState.h: * platform/gamepad/PlatformGamepad.h: * platform/graphics/GraphicsLayer.cpp: * platform/graphics/GraphicsLayerFactory.h: * platform/graphics/PlatformTimeRanges.h: * platform/graphics/TextTrackRepresentation.h: * platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.h: * platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h: * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.h: * platform/graphics/displaylists/DisplayListRecorder.h: * platform/network/cocoa/WebCoreNSURLSession.mm: * platform/sql/SQLiteDatabase.h: * platform/text/TextCodecICU.h: * rendering/GridBaselineAlignment.h: * rendering/GridTrackSizingAlgorithm.h: * rendering/RenderObject.h: * rendering/style/GridArea.h: * workers/service/context/SWContextManager.h: Source/WebCore/PAL: * pal/crypto/openssl/CryptoDigestOpenSSL.cpp: * pal/system/Clock.h: Source/WebKit: * NetworkProcess/NetworkLoad.cpp: * NetworkProcess/NetworkLoadChecker.h: * NetworkProcess/NetworkResourceLoader.cpp: * Platform/IPC/Connection.h: * Platform/IPC/mac/ImportanceAssertion.h: * PluginProcess/PluginCreationParameters.h: * Shared/API/Cocoa/RemoteObjectRegistry.h: * Shared/WebEvent.h: * UIProcess/API/APIHTTPCookieStore.cpp: * UIProcess/API/APINotificationProvider.h: * UIProcess/API/Cocoa/PageLoadStateObserver.h: * UIProcess/API/Cocoa/WKHTTPCookieStore.mm: * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _setInputDelegate:]): * UIProcess/API/gtk/PageClientImpl.h: * UIProcess/BackingStore.h: * UIProcess/Cocoa/AutomationClient.h: * UIProcess/Cocoa/DiagnosticLoggingClient.h: * UIProcess/Cocoa/DownloadClient.h: * UIProcess/Cocoa/FindClient.h: * UIProcess/Cocoa/NavigationState.h: * UIProcess/Cocoa/UIDelegate.h: * UIProcess/Cocoa/ViewGestureController.h: * UIProcess/DeviceIdHashSaltStorage.h: * UIProcess/Downloads/DownloadProxyMap.h: * UIProcess/Gamepad/UIGamepad.h: * UIProcess/Notifications/WebNotificationProvider.h: * UIProcess/ProcessAssertion.h: * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h: * UIProcess/WebContextInjectedBundleClient.h: * UIProcess/WebFormClient.h: * UIProcess/WebGeolocationProvider.h: * UIProcess/WebPageProxy.h: * WebProcess/Automation/WebAutomationSessionProxy.h: * WebProcess/InjectedBundle/API/APIInjectedBundleBundleClient.h: * WebProcess/InjectedBundle/API/APIInjectedBundleEditorClient.h: * WebProcess/InjectedBundle/API/APIInjectedBundlePageContextMenuClient.h: * WebProcess/InjectedBundle/API/APIInjectedBundlePageLoaderClient.h: * WebProcess/InjectedBundle/API/APIInjectedBundlePageResourceLoadClient.h: * WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h: * WebProcess/InjectedBundle/APIInjectedBundleFormClient.h: * WebProcess/Network/webrtc/LibWebRTCNetwork.h: * WebProcess/Network/webrtc/LibWebRTCSocket.h: * WebProcess/Network/webrtc/WebRTCResolver.h: * WebProcess/WebCoreSupport/WebInspectorClient.cpp: * WebProcess/WebPage/DrawingArea.h: Source/WTF: * wtf/Function.h: (WTF::Function<Out): * wtf/RefCounter.h: * wtf/URL.h: * wtf/text/StringView.cpp: Canonical link: https://commits.webkit.org/208851@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241183 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-02-08 02:38:46 +00:00
WTF_MAKE_FAST_ALLOCATED;
[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): Canonical link: https://commits.webkit.org/201804@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232640 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-06-08 21:08:58 +00:00
public:
virtual ~DataListSuggestionPicker() = default;
virtual void close() { }
virtual void handleKeydownWithIdentifier(const String&) { }
virtual void displayWithActivationType(DataListSuggestionActivationType) { }
};
} // namespace WebCore
#endif