WebKit Bugzilla
Attachment 342714 Details for
Bug 186531
: [Datalist][macOS] Add suggestions UI for TextFieldInputTypes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186531-20180613174258.patch (text/plain), 61.56 KB, created by
Aditya Keerthi
on 2018-06-13 17:42:59 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Aditya Keerthi
Created:
2018-06-13 17:42:59 PDT
Size:
61.56 KB
patch
obsolete
>Subversion Revision: 232640 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 7ad212e7db2b05bab7176c977e82dc0e809cbeac..d5a6e160d61f9a06c9d14412116103d37f0ec7ea 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,17 @@ >+2018-06-11 Aditya Keerthi <akeerthi@apple.com> >+ >+ [Datalist][macOS] Add suggestions UI for TextFieldInputTypes >+ https://bugs.webkit.org/show_bug.cgi?id=186531 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Tests: fast/forms/datalist/datalist-show-hide.html >+ fast/forms/datalist/datalist-textinput-keydown.html >+ >+ * html/TextFieldInputType.cpp: >+ (WebCore::TextFieldInputType::handleKeydownEvent): >+ (WebCore::TextFieldInputType::handleKeydownEventForSpinButton): The suggestions view takes precedence when handling arrow key events. >+ > 2018-06-08 Aditya Keerthi <akeerthi@apple.com> > > [Datalist] Allow TextFieldInputType to show and hide suggestions >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 4563ec81fa891fe19293783a6fac247476f632bd..6702076cc531af84573048bd8e698bcd0f205262 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,105 @@ >+2018-06-11 Aditya Keerthi <akeerthi@apple.com> >+ >+ [Datalist][macOS] Add suggestions UI for TextFieldInputTypes >+ https://bugs.webkit.org/show_bug.cgi?id=186531 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Created WebDataListSuggestionsDropdownMac as a wrapper around the suggestions view. >+ The suggestions for TextFieldInputTypes are displayed using an NSTableView in it's own >+ child window. This is done so that suggestions can be presented outside of the page if >+ the parent window's size is too small. The maximum number of suggestions that are visible >+ at one time is 6, with additional suggestions made available by scrolling. >+ >+ Suggestions in the view can be selected via click or by using arrow keys. If the input >+ element associated with the suggestions is blurred, or the page is moved in any way, the >+ suggestions view is hidden. >+ >+ Added IPC messages to the UIProcess to enable the display of the suggestions view. This >+ required a new ArgumentCoder for DataListSuggestionInformation. >+ >+ * Shared/WebCoreArgumentCoders.cpp: >+ (IPC::ArgumentCoder<DataListSuggestionInformation>::encode): >+ (IPC::ArgumentCoder<DataListSuggestionInformation>::decode): >+ * Shared/WebCoreArgumentCoders.h: >+ * UIProcess/PageClient.h: >+ * UIProcess/WebDataListSuggestionsDropdown.h: Copied from Source/WebKit/WebProcess/WebCoreSupport/WebDataListSuggestionPicker.h. >+ (WebKit::WebDataListSuggestionsDropdown::Client::~Client): >+ (WebKit::WebDataListSuggestionsDropdown::create): >+ (WebKit::WebDataListSuggestionsDropdown::~WebDataListSuggestionsDropdown): >+ (WebKit::WebDataListSuggestionsDropdown::show): >+ (WebKit::WebDataListSuggestionsDropdown::close): >+ (WebKit::WebDataListSuggestionsDropdown::handleKeydownWithIdentifier): >+ (WebKit::WebDataListSuggestionsDropdown::WebDataListSuggestionsDropdown): >+ * UIProcess/WebPageProxy.cpp: >+ (WebKit::WebPageProxy::viewWillStartLiveResize): >+ (WebKit::WebPageProxy::viewDidLeaveWindow): >+ (WebKit::WebPageProxy::handleWheelEvent): >+ (WebKit::WebPageProxy::setPageZoomFactor): >+ (WebKit::WebPageProxy::setPageAndTextZoomFactors): >+ (WebKit::WebPageProxy::didStartProvisionalLoadForFrame): >+ (WebKit::WebPageProxy::pageDidScroll): >+ (WebKit::WebPageProxy::showDataListSuggestions): >+ (WebKit::WebPageProxy::handleKeydownInDataList): >+ (WebKit::WebPageProxy::endDataListSuggestions): >+ (WebKit::WebPageProxy::didCloseSuggestions): >+ (WebKit::WebPageProxy::didSelectOption): >+ (WebKit::WebPageProxy::resetState): >+ (WebKit::WebPageProxy::closeOverlayedViews): >+ * UIProcess/WebPageProxy.h: >+ * UIProcess/WebPageProxy.messages.in: >+ * UIProcess/ios/PageClientImplIOS.h: >+ * UIProcess/ios/PageClientImplIOS.mm: >+ (WebKit::PageClientImpl::createDataListSuggestionsDropdown): >+ * UIProcess/mac/PageClientImplMac.h: >+ * UIProcess/mac/PageClientImplMac.mm: >+ (WebKit::PageClientImpl::createDataListSuggestionsDropdown): >+ * UIProcess/mac/WebDataListSuggestionsDropdownMac.h: Copied from Source/WebKit/WebProcess/WebCoreSupport/WebDataListSuggestionPicker.h. >+ * UIProcess/mac/WebDataListSuggestionsDropdownMac.mm: Added. >+ (WebKit::WebDataListSuggestionsDropdownMac::create): >+ (WebKit::WebDataListSuggestionsDropdownMac::~WebDataListSuggestionsDropdownMac): >+ (WebKit::WebDataListSuggestionsDropdownMac::WebDataListSuggestionsDropdownMac): >+ (WebKit::WebDataListSuggestionsDropdownMac::show): >+ (WebKit::WebDataListSuggestionsDropdownMac::didSelectOption): >+ (WebKit::WebDataListSuggestionsDropdownMac::selectOption): >+ (WebKit::WebDataListSuggestionsDropdownMac::close): >+ (WebKit::WebDataListSuggestionsDropdownMac::handleKeydownWithIdentifier): >+ (-[WKDataListSuggestionCell initWithFrame:]): >+ (-[WKDataListSuggestionCell setText:]): >+ (-[WKDataListSuggestionCell activate:]): >+ (-[WKDataListSuggestionCell isActive]): >+ (-[WKDataListSuggestionCell drawRect:]): >+ (-[WKDataListSuggestionCell mouseEntered:]): >+ (-[WKDataListSuggestionCell mouseExited:]): >+ (-[WKDataListSuggestionCell acceptsFirstResponder]): >+ (-[WKDataListSuggestionTable initWithElementRect:]): >+ (-[WKDataListSuggestionTable setVisibleRect:]): >+ (-[WKDataListSuggestionTable currentActiveRow]): >+ (-[WKDataListSuggestionTable setActiveRow:]): >+ (-[WKDataListSuggestionTable reload]): >+ (-[WKDataListSuggestionTable acceptsFirstResponder]): >+ (-[WKDataListSuggestionTable enclosingScrollView]): >+ (-[WKDataListSuggestionTable removeFromSuperviewWithoutNeedingDisplay]): >+ (-[WKDataListSuggestionsView initWithInformation:inView:]): >+ (-[WKDataListSuggestionsView currentSelectedString]): >+ (-[WKDataListSuggestionsView updateWithInformation:]): >+ (-[WKDataListSuggestionsView moveSelectionByValue:]): >+ (-[WKDataListSuggestionsView invalidate]): >+ (-[WKDataListSuggestionsView dropdownRectForElementRect:]): >+ (-[WKDataListSuggestionsView showSuggestionsDropdown:]): >+ (-[WKDataListSuggestionsView selectedRow:]): >+ (-[WKDataListSuggestionsView numberOfRowsInTableView:]): >+ (-[WKDataListSuggestionsView tableView:heightOfRow:]): >+ (-[WKDataListSuggestionsView tableView:viewForTableColumn:row:]): >+ * WebKit.xcodeproj/project.pbxproj: >+ * WebProcess/WebCoreSupport/WebDataListSuggestionPicker.cpp: >+ (WebKit::WebDataListSuggestionPicker::handleKeydownWithIdentifier): >+ (WebKit::WebDataListSuggestionPicker::didSelectOption): >+ (WebKit::WebDataListSuggestionPicker::didCloseSuggestions): >+ (WebKit::WebDataListSuggestionPicker::close): >+ (WebKit::WebDataListSuggestionPicker::displayWithActivationType): >+ * WebProcess/WebCoreSupport/WebDataListSuggestionPicker.h: >+ > 2018-06-08 Aditya Keerthi <akeerthi@apple.com> > > [Datalist] Allow TextFieldInputType to show and hide suggestions >diff --git a/Source/WebCore/html/TextFieldInputType.cpp b/Source/WebCore/html/TextFieldInputType.cpp >index 4ab5b39fc2c69a6695be898c5f153cdafc855a43..1fdb17047985110267709abba0f7ce284de36bb8 100644 >--- a/Source/WebCore/html/TextFieldInputType.cpp >+++ b/Source/WebCore/html/TextFieldInputType.cpp >@@ -184,8 +184,10 @@ void TextFieldInputType::handleKeydownEvent(KeyboardEvent& event) > return; > #if ENABLE(DATALIST_ELEMENT) > const String& key = event.keyIdentifier(); >- if (m_suggestionPicker && (key == "Enter" || key == "Up" || key == "Down")) >+ if (m_suggestionPicker && (key == "Enter" || key == "Up" || key == "Down")) { > m_suggestionPicker->handleKeydownWithIdentifier(key); >+ event.setDefaultHandled(); >+ } > #endif > RefPtr<Frame> frame = element()->document().frame(); > if (!frame || !frame->editor().doTextFieldCommandFromEvent(element(), &event)) >@@ -198,6 +200,10 @@ void TextFieldInputType::handleKeydownEventForSpinButton(KeyboardEvent& event) > ASSERT(element()); > if (element()->isDisabledOrReadOnly()) > return; >+#if ENABLE(DATALIST_ELEMENT) >+ if (m_suggestionPicker) >+ return; >+#endif > const String& key = event.keyIdentifier(); > if (key == "Up") > spinButtonStepUp(); >diff --git a/Source/WebKit/Shared/WebCoreArgumentCoders.cpp b/Source/WebKit/Shared/WebCoreArgumentCoders.cpp >index 94d3591b7eb899d1a341fa3ef59f319c491fa6ea..37fe7ba0865ef0c08695b584a0eb7b232f72665d 100644 >--- a/Source/WebKit/Shared/WebCoreArgumentCoders.cpp >+++ b/Source/WebKit/Shared/WebCoreArgumentCoders.cpp >@@ -36,6 +36,7 @@ > #include <WebCore/CompositionUnderline.h> > #include <WebCore/Credential.h> > #include <WebCore/Cursor.h> >+#include <WebCore/DataListSuggestionPicker.h> > #include <WebCore/DatabaseDetails.h> > #include <WebCore/DictationAlternative.h> > #include <WebCore/DictionaryPopupInfo.h> >@@ -1623,6 +1624,29 @@ bool ArgumentCoder<DatabaseDetails>::decode(Decoder& decoder, DatabaseDetails& d > return true; > } > >+#if ENABLE(DATALIST_ELEMENT) >+void ArgumentCoder<DataListSuggestionInformation>::encode(Encoder& encoder, const WebCore::DataListSuggestionInformation& info) >+{ >+ encoder.encodeEnum(info.activationType); >+ encoder << info.suggestions; >+ encoder << info.elementRect; >+} >+ >+bool ArgumentCoder<DataListSuggestionInformation>::decode(Decoder& decoder, WebCore::DataListSuggestionInformation& info) >+{ >+ if (!decoder.decodeEnum(info.activationType)) >+ return false; >+ >+ if (!decoder.decode(info.suggestions)) >+ return false; >+ >+ if (!decoder.decode(info.elementRect)) >+ return false; >+ >+ return true; >+} >+#endif >+ > void ArgumentCoder<PasteboardCustomData>::encode(Encoder& encoder, const PasteboardCustomData& data) > { > encoder << data.origin; >diff --git a/Source/WebKit/Shared/WebCoreArgumentCoders.h b/Source/WebKit/Shared/WebCoreArgumentCoders.h >index edabab6625d0839dc13b3564868d33dbadf2e70c..885fad28acb33a807cd64749bb77be6b0d3121bd 100644 >--- a/Source/WebKit/Shared/WebCoreArgumentCoders.h >+++ b/Source/WebKit/Shared/WebCoreArgumentCoders.h >@@ -135,6 +135,10 @@ struct PasteboardWebContent; > struct ViewportArguments; > #endif > >+#if ENABLE(DATALIST_ELEMENT) >+struct DataListSuggestionInformation; >+#endif >+ > #if USE(SOUP) > struct SoupNetworkProxySettings; > #endif >@@ -452,6 +456,13 @@ template<> struct ArgumentCoder<WebCore::DatabaseDetails> { > static bool decode(Decoder&, WebCore::DatabaseDetails&); > }; > >+#if ENABLE(DATALIST_ELEMENT) >+template<> struct ArgumentCoder<WebCore::DataListSuggestionInformation> { >+ static void encode(Encoder&, const WebCore::DataListSuggestionInformation&); >+ static bool decode(Decoder&, WebCore::DataListSuggestionInformation&); >+}; >+#endif >+ > template<> struct ArgumentCoder<WebCore::DictationAlternative> { > static void encode(Encoder&, const WebCore::DictationAlternative&); > static std::optional<WebCore::DictationAlternative> decode(Decoder&); >diff --git a/Source/WebKit/UIProcess/PageClient.h b/Source/WebKit/UIProcess/PageClient.h >index b658fbb508d8543fe884c56b2f2aff6abdaf6535..a72a6a009f515e8a7e95530f34bff7cbad14eda8 100644 >--- a/Source/WebKit/UIProcess/PageClient.h >+++ b/Source/WebKit/UIProcess/PageClient.h >@@ -27,6 +27,7 @@ > > #include "ShareableBitmap.h" > #include "WebColorPicker.h" >+#include "WebDataListSuggestionsDropdown.h" > #include "WebPageProxy.h" > #include "WebPopupMenuProxy.h" > #include <WebCore/AlternativeTextClient.h> >@@ -81,6 +82,10 @@ class NativeWebTouchEvent; > class WebColorPicker; > #endif > >+#if ENABLE(DATALIST_ELEMENT) >+class WebDataListSuggestionsDropdown; >+#endif >+ > #if ENABLE(FULLSCREEN_API) > class WebFullScreenManagerProxyClient; > #endif >@@ -222,6 +227,10 @@ public: > virtual RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&) = 0; > #endif > >+#if ENABLE(DATALIST_ELEMENT) >+ virtual RefPtr<WebDataListSuggestionsDropdown> createDataListSuggestionsDropdown(WebPageProxy*) = 0; >+#endif >+ > #if PLATFORM(COCOA) > virtual Ref<WebCore::ValidationBubble> createValidationBubble(const String& message, const WebCore::ValidationBubble::Settings&) = 0; > #endif >diff --git a/Source/WebKit/UIProcess/WebDataListSuggestionsDropdown.h b/Source/WebKit/UIProcess/WebDataListSuggestionsDropdown.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0a7e07b16be2888c5961e73298d3d21aa05eb2e2 >--- /dev/null >+++ b/Source/WebKit/UIProcess/WebDataListSuggestionsDropdown.h >@@ -0,0 +1,72 @@ >+/* >+ * 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) >+ >+#include <WebCore/DataListSuggestionPicker.h> >+#include <wtf/RefCounted.h> >+#include <wtf/RefPtr.h> >+ >+namespace WebCore { >+class IntRect; >+} >+ >+namespace WebKit { >+ >+class WebPageProxy; >+ >+class WebDataListSuggestionsDropdown : public RefCounted<WebDataListSuggestionsDropdown> { >+public: >+ class Client { >+ protected: >+ virtual ~Client() { } >+ >+ public: >+ virtual void didSelectOption(String&) = 0; >+ virtual void didCloseSuggestions() = 0; >+ }; >+ >+ static Ref<WebDataListSuggestionsDropdown> create(Client* client) >+ { >+ return adoptRef(*new WebDataListSuggestionsDropdown(client)); >+ } >+ >+ virtual ~WebDataListSuggestionsDropdown() { }; >+ >+ virtual void show(const WebCore::DataListSuggestionInformation&) { }; >+ virtual void close() { }; >+ virtual void handleKeydownWithIdentifier(const String&) { }; >+ >+protected: >+ explicit WebDataListSuggestionsDropdown(Client* client) : m_client(client) { }; >+ >+ Client* m_client; >+}; >+ >+} // namespace WebKit >+ >+#endif // ENABLE(DATALIST_ELEMENT) >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index 4dd0aec8d8c6fe1f0cda377f2fe6c9d3632292d2..01d70f73a57553a946f0b67c37c4078a27e89624 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -1436,10 +1436,8 @@ void WebPageProxy::viewWillStartLiveResize() > { > if (!isValid()) > return; >-#if ENABLE(INPUT_TYPE_COLOR_POPOVER) && ENABLE(INPUT_TYPE_COLOR) >- if (m_colorPicker) >- endColorPicker(); >-#endif >+ >+ closeOverlayedViews(); > m_process->send(Messages::WebPage::ViewWillStartLiveResize(), m_pageID); > } > >@@ -1526,11 +1524,7 @@ void WebPageProxy::activityStateDidChange(ActivityState::Flags mayHaveChanged, b > > void WebPageProxy::viewDidLeaveWindow() > { >-#if ENABLE(INPUT_TYPE_COLOR_POPOVER) && ENABLE(INPUT_TYPE_COLOR) >- // When leaving the current page, close the popover color well. >- if (m_colorPicker) >- endColorPicker(); >-#endif >+ closeOverlayedViews(); > #if PLATFORM(IOS) && HAVE(AVKIT) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)) > // When leaving the current page, close the video fullscreen. > if (m_videoFullscreenManager) >@@ -2059,7 +2053,7 @@ void WebPageProxy::handleWheelEvent(const NativeWebWheelEvent& event) > if (!isValid()) > return; > >- hideValidationMessage(); >+ closeOverlayedViews(); > > if (!m_currentlyProcessedWheelEvents.isEmpty()) { > m_wheelEventQueue.append(event); >@@ -2689,7 +2683,7 @@ void WebPageProxy::setPageZoomFactor(double zoomFactor) > if (m_pageZoomFactor == zoomFactor) > return; > >- hideValidationMessage(); >+ closeOverlayedViews(); > > m_pageZoomFactor = zoomFactor; > m_process->send(Messages::WebPage::SetPageZoomFactor(m_pageZoomFactor), m_pageID); >@@ -2703,7 +2697,7 @@ void WebPageProxy::setPageAndTextZoomFactors(double pageZoomFactor, double textZ > if (m_pageZoomFactor == pageZoomFactor && m_textZoomFactor == textZoomFactor) > return; > >- hideValidationMessage(); >+ closeOverlayedViews(); > > m_pageZoomFactor = pageZoomFactor; > m_textZoomFactor = textZoomFactor; >@@ -3450,7 +3444,7 @@ void WebPageProxy::didStartProvisionalLoadForFrame(uint64_t frameID, uint64_t na > m_pageLoadStart = MonotonicTime::now(); > m_pageLoadState.didStartProvisionalLoad(transaction, url, unreachableURL); > m_pageClient.didStartProvisionalLoadForMainFrame(); >- hideValidationMessage(); >+ closeOverlayedViews(); > } > > frame->setUnreachableURL(unreachableURL); >@@ -4531,7 +4525,7 @@ void WebPageProxy::pageDidScroll() > if (m_isKeyboardAnimatingIn) > return; > #endif >- hideValidationMessage(); >+ closeOverlayedViews(); > } > > void WebPageProxy::runOpenPanel(uint64_t frameID, const SecurityOriginData& frameSecurityOrigin, const FileChooserSettings& settings) >@@ -4727,6 +4721,48 @@ void WebPageProxy::didEndColorPicker() > } > #endif > >+#if ENABLE(DATALIST_ELEMENT) >+ >+void WebPageProxy::showDataListSuggestions(const WebCore::DataListSuggestionInformation& info) >+{ >+ if (!m_dataListSuggestionsDropdown) >+ m_dataListSuggestionsDropdown = m_pageClient.createDataListSuggestionsDropdown(this); >+ >+ m_dataListSuggestionsDropdown->show(info); >+} >+ >+void WebPageProxy::handleKeydownInDataList(const String& key) >+{ >+ if (!m_dataListSuggestionsDropdown) >+ return; >+ >+ m_dataListSuggestionsDropdown->handleKeydownWithIdentifier(key); >+} >+ >+void WebPageProxy::endDataListSuggestions() >+{ >+ if (m_dataListSuggestionsDropdown) >+ m_dataListSuggestionsDropdown->close(); >+} >+ >+void WebPageProxy::didCloseSuggestions() >+{ >+ if (m_dataListSuggestionsDropdown) >+ m_dataListSuggestionsDropdown = nullptr; >+ >+ m_process->send(Messages::WebPage::DidCloseSuggestions(), m_pageID); >+} >+ >+void WebPageProxy::didSelectOption(String& selectedOption) >+{ >+ if (!isValid()) >+ return; >+ >+ m_process->send(Messages::WebPage::DidSelectDataListOption(selectedOption), m_pageID); >+} >+ >+#endif >+ > WebInspectorProxy* WebPageProxy::inspector() const > { > if (isClosed() || !isValid()) >@@ -5901,7 +5937,7 @@ void WebPageProxy::resetState(ResetStateReason resetStateReason) > m_scrollingPerformanceData = nullptr; > #endif > m_drawingArea = nullptr; >- hideValidationMessage(); >+ closeOverlayedViews(); > > if (m_inspector) { > m_inspector->invalidate(); >@@ -7451,7 +7487,21 @@ void WebPageProxy::hideValidationMessage() > m_validationBubble = nullptr; > #endif > } >- >+ >+void WebPageProxy::closeOverlayedViews() >+{ >+ hideValidationMessage(); >+ >+#if ENABLE(DATALIST_ELEMENT) >+ endDataListSuggestions(); >+#endif >+ >+#if ENABLE(INPUT_TYPE_COLOR_POPOVER) && ENABLE(INPUT_TYPE_COLOR) >+ if (m_colorPicker) >+ endColorPicker(); >+#endif >+} >+ > #if ENABLE(POINTER_LOCK) > void WebPageProxy::requestPointerLock() > { >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index 2b62a389c41375612391c93e8603322d112175f8..a099a8633dd68d09c3d650f4c5c992be3cc286bd 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -54,6 +54,7 @@ > #include "WebColorPicker.h" > #include "WebContextMenuItemData.h" > #include "WebCoreArgumentCoders.h" >+#include "WebDataListSuggestionsDropdown.h" > #include "WebFrameProxy.h" > #include "WebPageCreationParameters.h" > #include "WebPageDiagnosticLoggingClient.h" >@@ -176,6 +177,7 @@ enum class ShouldSample; > > struct ApplicationManifest; > struct BackForwardItemIdentifier; >+struct DataListSuggestionInformation; > struct DictionaryPopupInfo; > struct ExceptionDetails; > struct FileChooserSettings; >@@ -317,6 +319,9 @@ class WebPageProxy : public API::ObjectImpl<API::Object::Type::Page> > #if ENABLE(INPUT_TYPE_COLOR) > , public WebColorPicker::Client > #endif >+#if ENABLE(DATALIST_ELEMENT) >+ , public WebDataListSuggestionsDropdown::Client >+#endif > #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS) > , public WebCore::WebMediaSessionManagerClient > #endif >@@ -1497,6 +1502,16 @@ private: > void didEndColorPicker() override; > #endif > >+#if ENABLE(DATALIST_ELEMENT) >+ void showDataListSuggestions(const WebCore::DataListSuggestionInformation&); >+ void handleKeydownInDataList(const String&); >+ void endDataListSuggestions(); >+ void didSelectOption(String&) override; >+ void didCloseSuggestions() override; >+#endif >+ >+ void closeOverlayedViews(); >+ > void compositionWasCanceled(); > void setHasHadSelectionChangesFromUserInteraction(bool); > void setNeedsHiddenContentEditableQuirk(bool); >@@ -2008,6 +2023,9 @@ private: > #if ENABLE(INPUT_TYPE_COLOR) > RefPtr<WebColorPicker> m_colorPicker; > #endif >+#if ENABLE(DATALIST_ELEMENT) >+ RefPtr<WebDataListSuggestionsDropdown> m_dataListSuggestionsDropdown; >+#endif > #if PLATFORM(COCOA) > RefPtr<WebCore::ValidationBubble> m_validationBubble; > #endif >diff --git a/Source/WebKit/UIProcess/WebPageProxy.messages.in b/Source/WebKit/UIProcess/WebPageProxy.messages.in >index 10500ee49fdcf0833b010232190869b3626aa915..6e057bafd6c5b153e0bc15e4813acc074683ce12 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.messages.in >+++ b/Source/WebKit/UIProcess/WebPageProxy.messages.in >@@ -97,6 +97,12 @@ messages -> WebPageProxy { > EndColorPicker(); > #endif > >+#if ENABLE(DATALIST_ELEMENT) >+ ShowDataListSuggestions(struct WebCore::DataListSuggestionInformation suggestionInformation); >+ HandleKeydownInDataList(String key); >+ EndDataListSuggestions(); >+#endif >+ > # Policy messages > DecidePolicyForResponse(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, uint64_t navigationID, WebCore::ResourceResponse response, WebCore::ResourceRequest request, bool canShowMIMEType, uint64_t listenerID, WebKit::UserData userData) > DecidePolicyForNavigationAction(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, uint64_t navigationID, struct WebKit::NavigationActionData navigationActionData, struct WebKit::FrameInfoData originatingFrameInfoData, uint64_t originatingPageID, WebCore::ResourceRequest originalRequest, WebCore::ResourceRequest request, uint64_t listenerID, WebKit::UserData userData) >diff --git a/Source/WebKit/UIProcess/ios/PageClientImplIOS.h b/Source/WebKit/UIProcess/ios/PageClientImplIOS.h >index 152ff301603d14d17d6fdca5c4d94db2c0805c1c..b91a3a9c3cd61fe40d15a539dc9f887b4868c4e4 100644 >--- a/Source/WebKit/UIProcess/ios/PageClientImplIOS.h >+++ b/Source/WebKit/UIProcess/ios/PageClientImplIOS.h >@@ -100,6 +100,10 @@ private: > RefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy&) override; > Ref<WebCore::ValidationBubble> createValidationBubble(const String& message, const WebCore::ValidationBubble::Settings&) final; > >+#if ENABLE(DATALIST_ELEMENT) >+ RefPtr<WebDataListSuggestionsDropdown> createDataListSuggestionsDropdown(WebPageProxy*) final; >+#endif >+ > void setTextIndicator(Ref<WebCore::TextIndicator>, WebCore::TextIndicatorWindowLifetime) override; > void clearTextIndicator(WebCore::TextIndicatorWindowDismissalAnimation) override; > void setTextIndicatorAnimationProgress(float) override; >diff --git a/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm b/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm >index 5daba6036418f712ca03966fdec70431b505df1a..d9ad160f625991060abe9477072e11ca00dbfd12 100644 >--- a/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm >+++ b/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm >@@ -763,6 +763,13 @@ Ref<ValidationBubble> PageClientImpl::createValidationBubble(const String& messa > return ValidationBubble::create(m_contentView, message, settings); > } > >+#if ENABLE(DATALIST_ELEMENT) >+RefPtr<WebDataListSuggestionsDropdown> PageClientImpl::createDataListSuggestionsDropdown(WebPageProxy* page) >+{ >+ return nullptr; >+} >+#endif >+ > #if ENABLE(DATA_INTERACTION) > void PageClientImpl::didPerformDataInteractionControllerOperation(bool handled) > { >diff --git a/Source/WebKit/UIProcess/mac/PageClientImplMac.h b/Source/WebKit/UIProcess/mac/PageClientImplMac.h >index 7f8301b51a514dd2e60d0656f8eac7cf0acca34b..9d99db28e00e88d9ed9dda5ed402b0adaa9dd4e1 100644 >--- a/Source/WebKit/UIProcess/mac/PageClientImplMac.h >+++ b/Source/WebKit/UIProcess/mac/PageClientImplMac.h >@@ -132,6 +132,10 @@ private: > RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&) override; > #endif > >+#if ENABLE(DATALIST_ELEMENT) >+ RefPtr<WebDataListSuggestionsDropdown> createDataListSuggestionsDropdown(WebPageProxy*) override; >+#endif >+ > Ref<WebCore::ValidationBubble> createValidationBubble(const String& message, const WebCore::ValidationBubble::Settings&) final; > > void setTextIndicator(Ref<WebCore::TextIndicator>, WebCore::TextIndicatorWindowLifetime) override; >diff --git a/Source/WebKit/UIProcess/mac/PageClientImplMac.mm b/Source/WebKit/UIProcess/mac/PageClientImplMac.mm >index 549d7a3d45a002521c55a781bc98c561f3059485..7ed253f0683198ff7be5d58480f7a9806140ce18 100644 >--- a/Source/WebKit/UIProcess/mac/PageClientImplMac.mm >+++ b/Source/WebKit/UIProcess/mac/PageClientImplMac.mm >@@ -48,6 +48,7 @@ > #import "WKWebViewInternal.h" > #import "WebColorPickerMac.h" > #import "WebContextMenuProxyMac.h" >+#import "WebDataListSuggestionsDropdownMac.h" > #import "WebEditCommandProxy.h" > #import "WebPopupMenuProxyMac.h" > #import "WebViewImpl.h" >@@ -458,6 +459,13 @@ RefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy* page, con > } > #endif > >+#if ENABLE(DATALIST_ELEMENT) >+RefPtr<WebDataListSuggestionsDropdown> PageClientImpl::createDataListSuggestionsDropdown(WebPageProxy* page) >+{ >+ return WebDataListSuggestionsDropdownMac::create(page, m_view); >+} >+#endif >+ > Ref<ValidationBubble> PageClientImpl::createValidationBubble(const String& message, const ValidationBubble::Settings& settings) > { > return ValidationBubble::create(m_view, message, settings); >diff --git a/Source/WebKit/UIProcess/mac/WebDataListSuggestionsDropdownMac.h b/Source/WebKit/UIProcess/mac/WebDataListSuggestionsDropdownMac.h >new file mode 100644 >index 0000000000000000000000000000000000000000..3288219b4ebbb0995b026f4232d9a253c82b6655 >--- /dev/null >+++ b/Source/WebKit/UIProcess/mac/WebDataListSuggestionsDropdownMac.h >@@ -0,0 +1,67 @@ >+/* >+ * 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) >+ >+#if USE(APPKIT) >+ >+#import "WebDataListSuggestionsDropdown.h" >+#import <wtf/RetainPtr.h> >+ >+namespace WebCore { >+class IntRect; >+} >+ >+@class WKDataListSuggestionsView; >+ >+namespace WebKit { >+ >+class WebDataListSuggestionsDropdownMac : public WebDataListSuggestionsDropdown { >+public: >+ static Ref<WebDataListSuggestionsDropdownMac> create(WebDataListSuggestionsDropdown::Client*, NSView*); >+ ~WebDataListSuggestionsDropdownMac(); >+ >+ void show(const WebCore::DataListSuggestionInformation&) override; >+ void close() override; >+ void handleKeydownWithIdentifier(const String&) override; >+ >+ void didSelectOption(String&); >+ >+private: >+ WebDataListSuggestionsDropdownMac(WebDataListSuggestionsDropdown::Client*, NSView*); >+ >+ void selectOption(); >+ >+ NSView* m_view; >+ RetainPtr<WKDataListSuggestionsView> m_dropdownUI; >+}; >+ >+} // namespace WebKit >+ >+#endif // USE(APPKIT) >+ >+#endif // ENABLE(DATALIST_ELEMENT) >diff --git a/Source/WebKit/UIProcess/mac/WebDataListSuggestionsDropdownMac.mm b/Source/WebKit/UIProcess/mac/WebDataListSuggestionsDropdownMac.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..942af75d5b9c3b2b8cbb4cb180c8283813d091b0 >--- /dev/null >+++ b/Source/WebKit/UIProcess/mac/WebDataListSuggestionsDropdownMac.mm >@@ -0,0 +1,438 @@ >+/* >+ * 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. >+ */ >+ >+#include "config.h" >+#include "WebDataListSuggestionsDropdownMac.h" >+ >+#include <WebCore/IntRect.h> >+ >+#if ENABLE(DATALIST_ELEMENT) >+ >+#if USE(APPKIT) >+ >+static const int dropdownRowHeight = 20; >+static const CGFloat dropdownShadowHeight = 5; >+static const unsigned long dropdownMaxSuggestions = 6; >+static NSString * const suggestionCellReuseIdentifier = @"WKDataListSuggestionCell"; >+ >+using namespace WebKit; >+ >+@interface WKDataListSuggestionWindow : NSWindow >+@end >+ >+@interface WKDataListSuggestionCell : NSView { >+ RetainPtr<NSTextField> _textField; >+ BOOL _active; >+ BOOL _mouseIsOver; >+} >+ >+- (void)setText:(NSString *)text; >+- (void)activate:(BOOL)shouldActivate; >+- (BOOL)isActive; >+@end >+ >+@interface WKDataListSuggestionTable : NSTableView { >+ RetainPtr<NSScrollView> _enclosingScrollView; >+ NSInteger _activeRow; >+} >+ >+- (id)initWithElementRect:(const WebCore::IntRect&)rect; >+- (void)setVisibleRect:(NSRect)rect; >+- (void)setActiveRow:(NSInteger)row; >+- (NSInteger)currentActiveRow; >+- (void)reload; >+@end >+ >+@interface WKDataListSuggestionsView : NSObject<NSTableViewDataSource, NSTableViewDelegate> { >+@private >+ RetainPtr<WKDataListSuggestionTable> _table; >+ WebDataListSuggestionsDropdownMac *_dropdown; >+ Vector<String> _suggestions; >+ NSView *_view; >+ RetainPtr<NSWindow> _enclosingWindow; >+} >+ >+- (id)initWithInformation:(const WebCore::DataListSuggestionInformation &)information inView:(NSView *)view; >+- (void)showSuggestionsDropdown:(WebDataListSuggestionsDropdownMac*)dropdown; >+- (void)updateWithInformation:(const WebCore::DataListSuggestionInformation &)information; >+- (void)moveSelectionByValue:(NSInteger)value; >+- (void)invalidate; >+ >+- (String)currentSelectedString; >+@end >+ >+namespace WebKit { >+ >+Ref<WebDataListSuggestionsDropdownMac> WebDataListSuggestionsDropdownMac::create(WebDataListSuggestionsDropdown::Client* client, NSView *view) >+{ >+ return adoptRef(*new WebDataListSuggestionsDropdownMac(client, view)); >+} >+ >+WebDataListSuggestionsDropdownMac::~WebDataListSuggestionsDropdownMac() { } >+ >+WebDataListSuggestionsDropdownMac::WebDataListSuggestionsDropdownMac(WebDataListSuggestionsDropdown::Client* client, NSView *view) >+ : WebDataListSuggestionsDropdown(client) >+ , m_view(view) >+{ >+} >+ >+void WebDataListSuggestionsDropdownMac::show(const WebCore::DataListSuggestionInformation& information) >+{ >+ if (m_dropdownUI) { >+ [m_dropdownUI updateWithInformation:information]; >+ return; >+ } >+ >+ m_dropdownUI = adoptNS([[WKDataListSuggestionsView alloc] initWithInformation:information inView:m_view]); >+ [m_dropdownUI showSuggestionsDropdown:this]; >+} >+ >+void WebDataListSuggestionsDropdownMac::didSelectOption(String& selectedOption) >+{ >+ if (!m_client) >+ return; >+ >+ m_client->didSelectOption(selectedOption); >+ close(); >+} >+ >+void WebDataListSuggestionsDropdownMac::selectOption() >+{ >+ if (!m_client) >+ return; >+ >+ String selectedOption = [m_dropdownUI currentSelectedString]; >+ m_client->didSelectOption(selectedOption); >+ close(); >+} >+ >+void WebDataListSuggestionsDropdownMac::close() >+{ >+ [m_dropdownUI invalidate]; >+ m_dropdownUI = nil; >+ m_client->didCloseSuggestions(); >+} >+ >+void WebDataListSuggestionsDropdownMac::handleKeydownWithIdentifier(const String& key) >+{ >+ if (key == "Enter") >+ selectOption(); >+ else if (key == "Up") >+ [m_dropdownUI moveSelectionByValue:-1]; >+ else if (key == "Down") >+ [m_dropdownUI moveSelectionByValue:1]; >+} >+ >+} // namespace WebKit >+ >+@implementation WKDataListSuggestionWindow >+@end >+ >+@implementation WKDataListSuggestionCell >+ >+- (id)initWithFrame:(NSRect)frameRect >+{ >+ if (!(self = [super initWithFrame:frameRect])) >+ return self; >+ >+ _textField = adoptNS([[NSTextField alloc] init]); >+ [_textField setEditable:NO]; >+ [_textField setBezeled:NO]; >+ [_textField setBackgroundColor:[NSColor clearColor]]; >+ [self addSubview:_textField.get()]; >+ >+ [self setIdentifier:@"WKDataListSuggestionCell"]; >+ >+ [self addTrackingRect:NSMakeRect(0, 0, NSWidth(frameRect), NSHeight(frameRect)) owner:self userData:nil assumeInside:NO]; >+ >+ return self; >+} >+ >+- (void)setText:(NSString *)text >+{ >+ [_textField setStringValue:text]; >+ [_textField sizeToFit]; >+ >+ NSRect textFieldFrame = [_textField frame]; >+ [_textField setFrame:CGRectMake(0, (CGRectGetHeight(self.frame) - CGRectGetHeight(textFieldFrame)) / 2, CGRectGetWidth(textFieldFrame), CGRectGetHeight(textFieldFrame))]; >+ >+ _mouseIsOver = NO; >+ [self activate:NO]; >+} >+ >+- (void)activate:(BOOL)shouldActivate >+{ >+ _active = shouldActivate; >+ [self setNeedsDisplay:YES]; >+} >+ >+- (BOOL)isActive >+{ >+ return _active; >+} >+ >+- (void)drawRect:(NSRect)dirtyRect >+{ >+ if (_active) { >+ [[NSColor alternateSelectedControlColor] setFill]; >+ [_textField setTextColor:[NSColor alternateSelectedControlTextColor]]; >+ } else if (_mouseIsOver) { >+ [[NSColor controlColor] setFill]; >+ [_textField setTextColor:[NSColor textColor]]; >+ } else { >+ [[NSColor controlBackgroundColor] setFill]; >+ [_textField setTextColor:[NSColor textColor]]; >+ } >+ >+ NSRectFill(dirtyRect); >+ [super drawRect:dirtyRect]; >+} >+ >+- (void)mouseEntered:(NSEvent *)event >+{ >+ [super mouseEntered:event]; >+ _mouseIsOver = YES; >+ [self setNeedsDisplay:YES]; >+} >+ >+- (void)mouseExited:(NSEvent *)event >+{ >+ [super mouseExited:event]; >+ _mouseIsOver = NO; >+ [self setNeedsDisplay:YES]; >+} >+ >+- (BOOL)acceptsFirstResponder >+{ >+ return NO; >+} >+ >+@end >+ >+@implementation WKDataListSuggestionTable >+ >+- (id)initWithElementRect:(const WebCore::IntRect &)rect >+{ >+ if (!(self = [super initWithFrame:NSMakeRect(0, 0, rect.width() - 2, 0)])) >+ return self; >+ >+ [self setIntercellSpacing:CGSizeZero]; >+ [self setHeaderView:nil]; >+ [self setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone]; >+ >+ RetainPtr<NSTableColumn> column = adoptNS([[NSTableColumn alloc] init]); >+ [column setWidth:rect.width() - 2]; >+ [self addTableColumn:column.get()]; >+ >+ _enclosingScrollView = adoptNS([[NSScrollView alloc] init]); >+ [_enclosingScrollView setHasVerticalScroller:YES]; >+ [_enclosingScrollView setVerticalScrollElasticity:NSScrollElasticityNone]; >+ [_enclosingScrollView setHorizontalScrollElasticity:NSScrollElasticityNone]; >+ [_enclosingScrollView setDocumentView:self]; >+ >+ RetainPtr<NSShadow> dropShadow = adoptNS([[NSShadow alloc] init]); >+ [dropShadow setShadowColor:[NSColor systemGrayColor]]; >+ [dropShadow setShadowOffset:NSMakeSize(0, dropdownShadowHeight)]; >+ [dropShadow setShadowBlurRadius:3]; >+ [_enclosingScrollView setWantsLayer:YES]; >+ [_enclosingScrollView setShadow:dropShadow.get()]; >+ >+ _activeRow = -1; >+ >+ return self; >+} >+ >+- (void)setVisibleRect:(NSRect)rect >+{ >+ [self setFrame:NSMakeRect(0, 0, NSWidth(rect) - dropdownShadowHeight*2, 0)]; >+ [_enclosingScrollView setFrame:NSMakeRect(dropdownShadowHeight, dropdownShadowHeight, NSWidth(rect) - dropdownShadowHeight*2, NSHeight(rect) - dropdownShadowHeight)]; >+} >+ >+- (NSInteger)currentActiveRow >+{ >+ return _activeRow; >+} >+ >+- (void)setActiveRow:(NSInteger)row >+{ >+ _activeRow = row; >+} >+ >+- (void)reload >+{ >+ _activeRow = -1; >+ [self reloadData]; >+ [_enclosingScrollView flashScrollers]; >+} >+ >+- (BOOL)acceptsFirstResponder >+{ >+ return NO; >+} >+ >+- (NSScrollView *)enclosingScrollView >+{ >+ return _enclosingScrollView.get(); >+} >+ >+- (void)removeFromSuperviewWithoutNeedingDisplay >+{ >+ [super removeFromSuperviewWithoutNeedingDisplay]; >+ [_enclosingScrollView removeFromSuperviewWithoutNeedingDisplay]; >+} >+ >+@end >+ >+@implementation WKDataListSuggestionsView >+ >+- (id)initWithInformation:(const WebCore::DataListSuggestionInformation&)information inView:(NSView *)view >+{ >+ if (!(self = [super init])) >+ return self; >+ >+ _view = view; >+ _suggestions = information.suggestions; >+ _table = adoptNS([[WKDataListSuggestionTable alloc] initWithElementRect:information.elementRect]); >+ >+ _enclosingWindow = adoptNS([[WKDataListSuggestionWindow alloc] initWithContentRect:NSZeroRect styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:NO]); >+ [_enclosingWindow setReleasedWhenClosed:NO]; >+ [_enclosingWindow setFrame:[self dropdownRectForElementRect:information.elementRect] display:YES]; >+ [_enclosingWindow setBackgroundColor:[NSColor clearColor]]; >+ [_enclosingWindow setOpaque:NO]; >+ >+ [_table setVisibleRect:[_enclosingWindow frame]]; >+ [_table setDelegate:self]; >+ [_table setDataSource:self]; >+ [_table setAction:@selector(selectedRow:)]; >+ [_table setTarget:self]; >+ >+ return self; >+} >+ >+- (String)currentSelectedString >+{ >+ NSInteger selectedRow = [_table currentActiveRow]; >+ return (selectedRow < 0) ? String("") : _suggestions.at(selectedRow); >+} >+ >+- (void)updateWithInformation:(const WebCore::DataListSuggestionInformation&)information >+{ >+ _suggestions = information.suggestions; >+ [_enclosingWindow setFrame:[self dropdownRectForElementRect:information.elementRect] display:YES]; >+ [_table setVisibleRect:[_enclosingWindow frame]]; >+ [_table reload]; >+} >+ >+- (void)moveSelectionByValue:(NSInteger)value >+{ >+ WKDataListSuggestionCell *cell; >+ NSInteger size = _suggestions.size(); >+ NSInteger oldSelection = [_table currentActiveRow]; >+ NSInteger newSelection = ((oldSelection + value) % size + size) % size; >+ >+ if (oldSelection != -1) { >+ cell = (WKDataListSuggestionCell *)[_table viewAtColumn:0 row:oldSelection makeIfNecessary:NO]; >+ [cell activate:NO]; >+ } else { >+ if (value == -1) >+ newSelection = size - 1; >+ } >+ >+ [_table scrollRowToVisible:newSelection]; >+ >+ cell = (WKDataListSuggestionCell *)[_table viewAtColumn:0 row:newSelection makeIfNecessary:NO]; >+ [cell activate:YES]; >+ >+ [_table setActiveRow:newSelection]; >+} >+ >+- (void)invalidate >+{ >+ [_table removeFromSuperviewWithoutNeedingDisplay]; >+ >+ [_table setDelegate:nil]; >+ [_table setDataSource:nil]; >+ [_table setAction:nil]; >+ [_table setTarget:nil]; >+ >+ _table = nil; >+ >+ [[_view window] removeChildWindow:_enclosingWindow.get()]; >+ [_enclosingWindow close]; >+ _enclosingWindow = nil; >+} >+ >+- (NSRect)dropdownRectForElementRect:(const WebCore::IntRect&)rect >+{ >+ NSRect windowRect = [[_view window] convertRectToScreen:[_view convertRect:rect toView:nil]]; >+ CGFloat height = std::min(_suggestions.size(), dropdownMaxSuggestions) * dropdownRowHeight; >+ return NSMakeRect(NSMinX(windowRect) - dropdownShadowHeight, NSMinY(windowRect) - height - dropdownShadowHeight - 2, rect.width() + dropdownShadowHeight*2, height + dropdownShadowHeight); >+} >+ >+- (void)showSuggestionsDropdown:(WebDataListSuggestionsDropdownMac*)dropdown >+{ >+ _dropdown = dropdown; >+ [[_enclosingWindow contentView] addSubview:[_table enclosingScrollView]]; >+ [_table reload]; >+ [[_view window] addChildWindow:_enclosingWindow.get() ordered:NSWindowAbove]; >+} >+ >+- (void)selectedRow:(NSTableView *)sender >+{ >+ _dropdown->didSelectOption(_suggestions.at([sender selectedRow])); >+} >+ >+- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView >+{ >+ return _suggestions.size(); >+} >+ >+- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row >+{ >+ return dropdownRowHeight; >+} >+ >+- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row >+{ >+ WKDataListSuggestionCell *result = [tableView makeViewWithIdentifier:suggestionCellReuseIdentifier owner:self]; >+ >+ if (!result) { >+ result = [[[WKDataListSuggestionCell alloc] initWithFrame:NSMakeRect(0, 0, tableView.frame.size.width, dropdownRowHeight)] autorelease]; >+ [result setIdentifier:suggestionCellReuseIdentifier]; >+ } >+ >+ [result setText:_suggestions.at(row)]; >+ >+ if (row == [_table currentActiveRow]) >+ [result activate:YES]; >+ >+ return result; >+} >+ >+@end >+ >+#endif // USE(APPKIT) >+ >+#endif // ENABLE(DATALIST_ELEMENT) >diff --git a/Source/WebKit/WebKit.xcodeproj/project.pbxproj b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >index ea51b78f9565ea5a2d1f94a8f2714f89eb370e30..86d5a20dd7efc4d23f6e905b5a81d1f30505055a 100644 >--- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj >+++ b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >@@ -2161,6 +2161,9 @@ > E4E864931B16750700C82F40 /* VersionChecks.h in Headers */ = {isa = PBXBuildFile; fileRef = E4E8648E1B1673FB00C82F40 /* VersionChecks.h */; }; > E52CF55220A35C3A00DADA27 /* WebDataListSuggestionPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = E52CF55020A35C3A00DADA27 /* WebDataListSuggestionPicker.h */; }; > E52CF55320A35C3A00DADA27 /* WebDataListSuggestionPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E52CF55120A35C3A00DADA27 /* WebDataListSuggestionPicker.cpp */; }; >+ E568B91F20A3AB2F00E3C856 /* WebDataListSuggestionsDropdown.h in Headers */ = {isa = PBXBuildFile; fileRef = E568B91E20A3AB2F00E3C856 /* WebDataListSuggestionsDropdown.h */; }; >+ E568B92220A3AC6A00E3C856 /* WebDataListSuggestionsDropdownMac.h in Headers */ = {isa = PBXBuildFile; fileRef = E568B92020A3AC6A00E3C856 /* WebDataListSuggestionsDropdownMac.h */; }; >+ E568B92320A3AC6A00E3C856 /* WebDataListSuggestionsDropdownMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E568B92120A3AC6A00E3C856 /* WebDataListSuggestionsDropdownMac.mm */; }; > ECA680D81E690E2500731D20 /* WebProcessCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = ECA680D71E690DF800731D20 /* WebProcessCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; }; > ED82A7F2128C6FAF004477B3 /* WKBundlePageOverlay.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A22F0FF1289FCD90085E74F /* WKBundlePageOverlay.h */; settings = {ATTRIBUTES = (Private, ); }; }; > EDCA71B7128DDA8C00201B26 /* WKBundlePageOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A22F1001289FCD90085E74F /* WKBundlePageOverlay.cpp */; }; >@@ -4710,6 +4713,9 @@ > E4E8648F1B1673FB00C82F40 /* VersionChecks.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VersionChecks.mm; sourceTree = "<group>"; }; > E52CF55020A35C3A00DADA27 /* WebDataListSuggestionPicker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebDataListSuggestionPicker.h; sourceTree = "<group>"; }; > E52CF55120A35C3A00DADA27 /* WebDataListSuggestionPicker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebDataListSuggestionPicker.cpp; sourceTree = "<group>"; }; >+ E568B91E20A3AB2F00E3C856 /* WebDataListSuggestionsDropdown.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebDataListSuggestionsDropdown.h; sourceTree = "<group>"; }; >+ E568B92020A3AC6A00E3C856 /* WebDataListSuggestionsDropdownMac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebDataListSuggestionsDropdownMac.h; sourceTree = "<group>"; }; >+ E568B92120A3AC6A00E3C856 /* WebDataListSuggestionsDropdownMac.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; path = WebDataListSuggestionsDropdownMac.mm; sourceTree = "<group>"; }; > ECA680D31E6904B500731D20 /* ExtraPrivateSymbolsForTAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtraPrivateSymbolsForTAPI.h; sourceTree = "<group>"; }; > ECA680D71E690DF800731D20 /* WebProcessCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebProcessCocoa.h; sourceTree = "<group>"; }; > ECBFC1DB1E6A4D66000300C7 /* ExtraPublicSymbolsForTAPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExtraPublicSymbolsForTAPI.h; sourceTree = "<group>"; }; >@@ -7350,6 +7356,7 @@ > 330934541315B9750097A7BC /* WebCookieManagerProxy.messages.in */, > 33AA1064131F060000D4A575 /* WebCookieManagerProxyClient.cpp */, > 33AA1065131F060000D4A575 /* WebCookieManagerProxyClient.h */, >+ E568B91E20A3AB2F00E3C856 /* WebDataListSuggestionsDropdown.h */, > BCA0EF9E12332642007D3CFB /* WebEditCommandProxy.cpp */, > BCA0EF9D12332642007D3CFB /* WebEditCommandProxy.h */, > BCE4694F1214E6CB000B98EB /* WebFormClient.cpp */, >@@ -8126,6 +8133,8 @@ > 51ACBB9E127A8F2C00D203B9 /* WebContextMenuProxyMac.h */, > 51ACBB9F127A8F2C00D203B9 /* WebContextMenuProxyMac.mm */, > F6D632BA133D181B00743D77 /* WebCookieManagerProxyMac.mm */, >+ E568B92020A3AC6A00E3C856 /* WebDataListSuggestionsDropdownMac.h */, >+ E568B92120A3AC6A00E3C856 /* WebDataListSuggestionsDropdownMac.mm */, > 1CA8B935127C774E00576C2B /* WebInspectorProxyMac.mm */, > BC857E8512B71EBB00EDEB2E /* WebPageProxyMac.mm */, > BC5750951268F3C6006F0F12 /* WebPopupMenuProxyMac.h */, >@@ -9312,6 +9321,8 @@ > 5760829F202D2C4600116678 /* WebCredentialsMessengerProxyMessages.h in Headers */, > 1AA83F6D1A5B63FF00026EC6 /* WebDatabaseProvider.h in Headers */, > E52CF55220A35C3A00DADA27 /* WebDataListSuggestionPicker.h in Headers */, >+ E568B91F20A3AB2F00E3C856 /* WebDataListSuggestionsDropdown.h in Headers */, >+ E568B92220A3AC6A00E3C856 /* WebDataListSuggestionsDropdownMac.h in Headers */, > CD19A26E1A13E834008D650E /* WebDiagnosticLoggingClient.h in Headers */, > 1A5B1C5518987EDF004FCF9B /* WebDocumentLoader.h in Headers */, > BC032D7B10F4378D0058C15A /* WebDragClient.h in Headers */, >@@ -11141,6 +11152,7 @@ > 5760829E202D2C4300116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp in Sources */, > 1AA83F6C1A5B63FF00026EC6 /* WebDatabaseProvider.cpp in Sources */, > E52CF55320A35C3A00DADA27 /* WebDataListSuggestionPicker.cpp in Sources */, >+ E568B92320A3AC6A00E3C856 /* WebDataListSuggestionsDropdownMac.mm in Sources */, > CD19A26D1A13E82A008D650E /* WebDiagnosticLoggingClient.cpp in Sources */, > 1A5B1C5418987EDF004FCF9B /* WebDocumentLoader.cpp in Sources */, > BC111A5D112F4FBB00337BAB /* WebDragClient.cpp in Sources */, >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebDataListSuggestionPicker.cpp b/Source/WebKit/WebProcess/WebCoreSupport/WebDataListSuggestionPicker.cpp >index 68445271caf337e23851f2b3d4fe0a3b826ba995..0d2d5e9b3431c242ee6a5021955b6d11f06bcd37 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/WebDataListSuggestionPicker.cpp >+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebDataListSuggestionPicker.cpp >@@ -28,6 +28,7 @@ > > #if ENABLE(DATALIST_ELEMENT) > >+#include "WebCoreArgumentCoders.h" > #include "WebPage.h" > #include "WebPageProxyMessages.h" > #include "WebProcess.h" >@@ -47,27 +48,35 @@ WebDataListSuggestionPicker::~WebDataListSuggestionPicker() { } > > void WebDataListSuggestionPicker::handleKeydownWithIdentifier(const WTF::String& key) > { >- >+ WebProcess::singleton().parentProcessConnection()->send(Messages::WebPageProxy::HandleKeydownInDataList(key), m_page->pageID()); > } > > void WebDataListSuggestionPicker::didSelectOption(const WTF::String& selectedOption) > { >- >+ m_dataListSuggestionsClient->didSelectDataListOption(selectedOption); > } > > void WebDataListSuggestionPicker::didCloseSuggestions() > { >- >+ m_dataListSuggestionsClient->didCloseSuggestions(); > } > > void WebDataListSuggestionPicker::close() > { >- >+ WebProcess::singleton().parentProcessConnection()->send(Messages::WebPageProxy::EndDataListSuggestions(), m_page->pageID()); > } > > void WebDataListSuggestionPicker::displayWithActivationType(DataListSuggestionActivationType type) > { >+ if (!m_dataListSuggestionsClient->suggestions().size()) { >+ close(); >+ return; >+ } >+ >+ m_page->setActiveDataListSuggestionPicker(this); > >+ DataListSuggestionInformation info = { type, m_dataListSuggestionsClient->suggestions(), m_dataListSuggestionsClient->elementRectInRootViewCoordinates() }; >+ WebProcess::singleton().parentProcessConnection()->send(Messages::WebPageProxy::ShowDataListSuggestions(info), m_page->pageID()); > } > > } // namespace WebKit >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebDataListSuggestionPicker.h b/Source/WebKit/WebProcess/WebCoreSupport/WebDataListSuggestionPicker.h >index e5b3818022e1200ea8cedd110a24ca4e026c0042..9705359890b7661af6ca807170b353b598c50f79 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/WebDataListSuggestionPicker.h >+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebDataListSuggestionPicker.h >@@ -49,8 +49,8 @@ public: > void close() override; > void displayWithActivationType(WebCore::DataListSuggestionActivationType) override; > private: >- __unused WebCore::DataListSuggestionsClient* m_dataListSuggestionsClient; >- __unused WebPage* m_page; >+ WebCore::DataListSuggestionsClient* m_dataListSuggestionsClient; >+ WebPage* m_page; > }; > > } // namespace WebKit >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 14b806ec9f3d3537ccc3d3e4105cd568878fd846..8aad7b20ce203f5c6197bdad2c757af41667c655 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,22 @@ >+2018-06-11 Aditya Keerthi <akeerthi@apple.com> >+ >+ [Datalist][macOS] Add suggestions UI for TextFieldInputTypes >+ https://bugs.webkit.org/show_bug.cgi?id=186531 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Added isShowingDatalistSuggestions testing hook in order to enable testing of the >+ visibility of the suggestions view. >+ >+ * DumpRenderTree/mac/UIScriptControllerMac.mm: >+ (WTR::UIScriptController::isShowingDatalistSuggestions const): >+ * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: >+ * TestRunnerShared/UIScriptContext/UIScriptController.cpp: >+ (WTR::UIScriptController::isShowingDatalistSuggestions const): >+ * TestRunnerShared/UIScriptContext/UIScriptController.h: >+ * WebKitTestRunner/mac/UIScriptControllerMac.mm: >+ (WTR::UIScriptController::isShowingDatalistSuggestions const): >+ > 2018-06-08 Alicia Boya GarcÃa <aboya@igalia.com> > > [GTK] Update to libva-2.1.0 in jhbuild >diff --git a/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm b/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm >index b3ac6ae69c06c07107a5511ac684103199ef8e36..e77d8937c5ae4264347bac19e0b90e599eecbb46 100644 >--- a/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm >+++ b/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm >@@ -180,6 +180,11 @@ bool UIScriptController::isWindowContentViewFirstResponder() const > return false; > } > >+bool UIScriptController::isShowingDatalistSuggestions() const >+{ >+ return false; >+} >+ > } > > #endif // PLATFORM(MAC) >diff --git a/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl b/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl >index 23f2ba6a48f0f9c1708e25b4d624d67281602be8..52f5600360e657462ab39e9e1c5d6325b3a1d945 100644 >--- a/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl >+++ b/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl >@@ -193,6 +193,9 @@ interface UIScriptController { > > void setTimePickerValue(long hour, long minute); > >+ // <datalist> >+ readonly attribute boolean isShowingDatalistSuggestions; >+ > void keyboardAccessoryBarNext(); > void keyboardAccessoryBarPrevious(); > >diff --git a/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp b/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp >index 619286ae1236994bff097868ef84fc8a499a1417..d7f7d28ddc191abee8c81ae1e729e8e8b7d856c8 100644 >--- a/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp >+++ b/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp >@@ -512,6 +512,11 @@ bool UIScriptController::isWindowContentViewFirstResponder() const > return false; > } > >+bool UIScriptController::isShowingDatalistSuggestions() const >+{ >+ return false; >+} >+ > #endif > > void UIScriptController::uiScriptComplete(JSStringRef result) >diff --git a/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h b/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h >index d3a1d18c1889816551f4e36f0c0ec1ed9e014dd1..4be4014edcf9db71cf0b016bbffadbfb0f93f272 100644 >--- a/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h >+++ b/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h >@@ -101,7 +101,9 @@ public: > JSRetainPtr<JSStringRef> selectFormPopoverTitle() const; > JSRetainPtr<JSStringRef> formInputLabel() const; > void setTimePickerValue(long hour, long minute); >- >+ >+ bool isShowingDatalistSuggestions() const; >+ > JSObjectRef contentsOfUserInterfaceItem(JSStringRef) const; > void overridePreference(JSStringRef preference, JSStringRef value); > >diff --git a/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm b/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm >index 1f4eed439cbd44e9ae0e07a912dbf30755e65f5b..cb64e0c3877ebaac727a9b8a2021bd3b226d6cfb 100644 >--- a/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm >+++ b/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm >@@ -168,6 +168,18 @@ void UIScriptController::findString(JSStringRef, unsigned long options, unsigned > { > } > >+bool UIScriptController::isShowingDatalistSuggestions() const >+{ >+#if WK_API_ENABLED >+ TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView(); >+ for (NSWindow *childWindow in webView.window.childWindows) { >+ if ([childWindow isKindOfClass:NSClassFromString(@"WKDataListSuggestionWindow")]) >+ return true; >+ } >+#endif >+ return false; >+} >+ > void UIScriptController::removeViewFromWindow(JSValueRef callback) > { > #if WK_API_ENABLED >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 94d6f66d5b2ad487bd83e47224855f082ebcea82..e279678b83a405104dd3c5304fa10f210611ba48 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,20 @@ >+2018-06-11 Aditya Keerthi <akeerthi@apple.com> >+ >+ [Datalist][macOS] Add suggestions UI for TextFieldInputTypes >+ https://bugs.webkit.org/show_bug.cgi?id=186531 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Added tests to verify that the suggestions are correctly shown and hidden, and that >+ suggestions can be selected and inserted into an input field. >+ >+ * fast/forms/datalist/datalist-show-hide-expected.txt: Added. >+ * fast/forms/datalist/datalist-show-hide.html: Added. >+ * fast/forms/datalist/datalist-textinput-keydown-expected.txt: Added. >+ * fast/forms/datalist/datalist-textinput-keydown.html: Added. >+ * resources/ui-helper.js: >+ (window.UIHelper.isShowingDatalistSuggestions): >+ > 2018-06-08 Chris Dumez <cdumez@apple.com> > > http/tests/navigation/https-no-store-subframe-in-page-cache.html fails with PSON enabled >diff --git a/LayoutTests/fast/forms/datalist/datalist-show-hide-expected.txt b/LayoutTests/fast/forms/datalist/datalist-show-hide-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..536aa426388cfad0727cac80a704a62d6d439683 >--- /dev/null >+++ b/LayoutTests/fast/forms/datalist/datalist-show-hide-expected.txt >@@ -0,0 +1,8 @@ >+CLICK >+PASS showingList is "true" >+BLUR >+PASS showingList is "false" >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/forms/datalist/datalist-show-hide.html b/LayoutTests/fast/forms/datalist/datalist-show-hide.html >new file mode 100644 >index 0000000000000000000000000000000000000000..9552aaaf7c01b70e5bd3c1d003171b2aacc9b495 >--- /dev/null >+++ b/LayoutTests/fast/forms/datalist/datalist-show-hide.html >@@ -0,0 +1,38 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../../resources/js-test.js"></script> >+<script src="../../../resources/ui-helper.js"></script> >+<head> >+<body onload="runTest()"> >+<input id="fruit" list="fruits" type="text"/> >+<datalist id="fruits"> >+ <option>Apple</option> >+ <option>Orange</option> >+ <option>Pear</option> >+</datalist> >+</body> >+<script> >+jsTestIsAsync = true; >+ >+async function runTest() { >+ let input = document.getElementById("fruit"); >+ >+ await UIHelper.activateElement(input); >+ UIHelper.isShowingDatalistSuggestions().then(async (value) => { >+ showingList = value; >+ debug("CLICK"); >+ shouldBe("showingList", '"true"'); >+ >+ await UIHelper.activateAt(0, 0); >+ UIHelper.isShowingDatalistSuggestions().then((value) => { >+ showingList = value; >+ debug("BLUR"); >+ shouldBe("showingList", '"false"'); >+ finishJSTest(); >+ }); >+ }); >+} >+ >+</script> >+</html> >diff --git a/LayoutTests/fast/forms/datalist/datalist-textinput-keydown-expected.txt b/LayoutTests/fast/forms/datalist/datalist-textinput-keydown-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..4ac50d6ab9b782d57584bb6703d596429af7e88f >--- /dev/null >+++ b/LayoutTests/fast/forms/datalist/datalist-textinput-keydown-expected.txt >@@ -0,0 +1,11 @@ >+Test for keyboard operations for <input type=text> with list attribute >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS input.value is "Apple" >+PASS input.value is "Pear" >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/forms/datalist/datalist-textinput-keydown.html b/LayoutTests/fast/forms/datalist/datalist-textinput-keydown.html >new file mode 100644 >index 0000000000000000000000000000000000000000..33468926678ab58a6ae457a9b3b15c69b7108407 >--- /dev/null >+++ b/LayoutTests/fast/forms/datalist/datalist-textinput-keydown.html >@@ -0,0 +1,40 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../../resources/js-test-pre.js"></script> >+<script src="../../../resources/ui-helper.js"></script> >+</head> >+<body> >+ >+<input id="fruit" list="fruits" type="text"/> >+<datalist id="fruits"> >+ <option>Apple</option> >+ <option>Orange</option> >+ <option>Pear</option> >+</datalist> >+ >+<script> >+ >+description('Test for keyboard operations for <input type=text> with list attribute'); >+ >+var input = document.getElementById("fruit"); >+ >+UIHelper.activateElement(input); >+eventSender.keyDown("downArrow"); >+eventSender.keyDown("\r"); >+ >+shouldBe('input.value', '"Apple"'); >+ >+input.value = ""; >+ >+UIHelper.activateElement(input); >+eventSender.keyDown("upArrow"); >+eventSender.keyDown("\r"); >+ >+shouldBe('input.value', '"Pear"'); >+ >+</script> >+ >+<script src="../../../resources/js-test-post.js"></script> >+</body> >+</html> >diff --git a/LayoutTests/resources/ui-helper.js b/LayoutTests/resources/ui-helper.js >index ddc7d14cedb9b970faa1fe75becc527d937779e5..69163426bebab7713a6425e6aa9e8bc7e4a12117 100644 >--- a/LayoutTests/resources/ui-helper.js >+++ b/LayoutTests/resources/ui-helper.js >@@ -220,6 +220,15 @@ window.UIHelper = class UIHelper { > }); > } > >+ static isShowingDatalistSuggestions() >+ { >+ return new Promise(resolve => { >+ testRunner.runUIScript(`(() => { >+ uiController.uiScriptComplete(uiController.isShowingDatalistSuggestions); >+ })()`, resolve); >+ }); >+ } >+ > static zoomScale() > { > return new Promise(resolve => {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186531
:
342452
|
342477
|
342707
|
342714
|
342723
|
342783
|
342864
|
342878
|
343000
|
343019
|
345100
|
345106