WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-206287-20200120103220.patch (text/plain), 64.47 KB, created by
Zan Dobersek
on 2020-01-20 01:32:22 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Zan Dobersek
Created:
2020-01-20 01:32:22 PST
Size:
64.47 KB
patch
obsolete
>Subversion Revision: 254809 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index d5c31991738d759a9501ade15595c02f22fb7be7..201b103949ba564796501f968334815fe73916fc 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,106 @@ >+2020-01-20 Zan Dobersek <zdobersek@igalia.com> >+ >+ [WPE] Expose the WebKitOptionMenu APIs >+ https://bugs.webkit.org/show_bug.cgi?id=206287 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Enable the GLib-based API covering option menu functionality for WPE. >+ >+ Most of this can be shared with the GTK port. The only difference is in >+ the two additional parameters emitted on the WebKitWebView's "show-menu" >+ signal (GdkEvent and GdkRectangle) that WPE doesn't support at the >+ moment. The rectangle information will be possible to emit in the near >+ future once a usable API type is available for this information. >+ >+ The WebKitPopupMenu implementation for WPE would only work with the >+ GLib-based API. To avoid using it with other APIs, this is implemented >+ only on the WebKitWebViewClient interface (renamed from 'WebViewClient' >+ and its declaration moved into a separate header file) inheriting from >+ API::ViewClient. >+ >+ The relevant API test is enabled for WPE. >+ >+ * PlatformWPE.cmake: >+ * SourcesWPE.txt: >+ * UIProcess/API/glib/WebKitWebView.cpp: >+ (WebKitWebViewClient::WebKitWebViewClient): >+ (WebKitWebViewClient::showOptionMenu): >+ (WebKitWebViewClient::handleDownloadRequest): >+ (WebKitWebViewClient::frameDisplayed): >+ (WebKitWebViewClient::willStartLoad): >+ (WebKitWebViewClient::didChangePageID): >+ (WebKitWebViewClient::didReceiveUserMessage): >+ (webkitWebViewConstructed): >+ (webkit_web_view_class_init): >+ (webkitWebViewShowOptionMenu): >+ * UIProcess/API/glib/WebKitWebViewPrivate.h: >+ * UIProcess/API/wpe/APIViewClient.h: >+ (API::ViewClient::isGLibBasedAPI): >+ * UIProcess/API/wpe/PageClientImpl.cpp: >+ (WebKit::PageClientImpl::createPopupMenuProxy): >+ * UIProcess/API/wpe/WPEView.h: >+ (WKWPE::View::client const): >+ * UIProcess/API/wpe/WebKitOptionMenu.h: Added. >+ * UIProcess/API/wpe/WebKitOptionMenuItem.h: Added. >+ * UIProcess/API/wpe/WebKitPopupMenu.cpp: Added. >+ (WebKit::WebKitPopupMenu::create): >+ (WebKit::WebKitPopupMenu::WebKitPopupMenu): >+ (WebKit::menuCloseCallback): >+ (WebKit::WebKitPopupMenu::showPopupMenu): >+ (WebKit::WebKitPopupMenu::hidePopupMenu): >+ (WebKit::WebKitPopupMenu::cancelTracking): >+ (WebKit::WebKitPopupMenu::selectItem): >+ (WebKit::WebKitPopupMenu::activateItem): >+ * UIProcess/API/wpe/WebKitPopupMenu.h: Added. >+ * UIProcess/API/wpe/WebKitWebView.h: >+ * UIProcess/API/wpe/WebKitWebViewClient.h: Added. >+ * UIProcess/API/wpe/docs/wpe-1.0-sections.txt: >+ * UIProcess/API/wpe/webkit.h: >+ >+2020-01-19 Zan Dobersek <zdobersek@igalia.com> >+ >+ [WPE] Expose the WebKitOptionMenu APIs >+ https://bugs.webkit.org/show_bug.cgi?id=206287 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Enable the GLib-based API covering option menu functionality for WPE. >+ >+ >+ The relevant API test is enabled for WPE. >+ >+ * PlatformWPE.cmake: >+ * SourcesWPE.txt: >+ * UIProcess/API/C/wpe/WKView.cpp: >+ (WKViewCreate): >+ * UIProcess/API/glib/WebKitWebView.cpp: >+ (webkit_web_view_class_init): >+ (webkitWebViewCreatePage): >+ (webkitWebViewShowOptionMenu): >+ * UIProcess/API/glib/WebKitWebViewPrivate.h: >+ * UIProcess/API/wpe/PageClientImpl.cpp: >+ (WebKit::PageClientImpl::createPopupMenuProxy): >+ * UIProcess/API/wpe/WPEView.cpp: >+ (WKWPE::View::View): >+ * UIProcess/API/wpe/WPEView.h: >+ (WKWPE::View::create): >+ (WKWPE::View::webView): >+ * UIProcess/API/wpe/WebKitOptionMenu.h: Added. >+ * UIProcess/API/wpe/WebKitOptionMenuItem.h: Added. >+ * UIProcess/API/wpe/WebKitPopupMenu.cpp: Added. >+ (WebKit::WebKitPopupMenu::WebKitPopupMenu): >+ (WebKit::menuCloseCallback): >+ (WebKit::WebKitPopupMenu::showPopupMenu): >+ (WebKit::WebKitPopupMenu::hidePopupMenu): >+ (WebKit::WebKitPopupMenu::cancelTracking): >+ (WebKit::WebKitPopupMenu::selectItem): >+ (WebKit::WebKitPopupMenu::activateItem): >+ * UIProcess/API/wpe/WebKitPopupMenu.h: Added. >+ * UIProcess/API/wpe/WebKitWebView.h: >+ * UIProcess/API/wpe/docs/wpe-1.0-sections.txt: >+ * UIProcess/API/wpe/webkit.h: >+ > 2020-01-19 Eric Carlson <eric.carlson@apple.com> > > Make MediaPlayerPrivateRemote a message receiver >diff --git a/Source/WebKit/PlatformWPE.cmake b/Source/WebKit/PlatformWPE.cmake >index a8a95f4b0db4a50a8ef5b72039c51cc5818ed304..d14b86260889f0d0b7720bbd3b13ece1bc97687e 100644 >--- a/Source/WebKit/PlatformWPE.cmake >+++ b/Source/WebKit/PlatformWPE.cmake >@@ -119,6 +119,8 @@ set(WPE_API_INSTALLED_HEADERS > ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitNetworkProxySettings.h > ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitNotificationPermissionRequest.h > ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitNotification.h >+ ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitOptionMenu.h >+ ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitOptionMenuItem.h > ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitPermissionRequest.h > ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitPlugin.h > ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitPolicyDecision.h >diff --git a/Source/WebKit/SourcesWPE.txt b/Source/WebKit/SourcesWPE.txt >index ea7ff8d73fdf133d7c560c9fbcf015a6247ad839..f4fbc2f7b60a30d60d07dcd93605b2b68bb72ab3 100644 >--- a/Source/WebKit/SourcesWPE.txt >+++ b/Source/WebKit/SourcesWPE.txt >@@ -145,6 +145,8 @@ UIProcess/API/glib/WebKitNetworkProxySettings.cpp @no-unify > UIProcess/API/glib/WebKitNotification.cpp @no-unify > UIProcess/API/glib/WebKitNotificationPermissionRequest.cpp @no-unify > UIProcess/API/glib/WebKitNotificationProvider.cpp @no-unify >+UIProcess/API/glib/WebKitOptionMenu.cpp @no-unify >+UIProcess/API/glib/WebKitOptionMenuItem.cpp @no-unify > UIProcess/API/glib/WebKitPermissionRequest.cpp @no-unify > UIProcess/API/glib/WebKitPlugin.cpp @no-unify > UIProcess/API/glib/WebKitPolicyDecision.cpp @no-unify >@@ -177,6 +179,7 @@ UIProcess/API/wpe/PageClientImpl.cpp @no-unify > UIProcess/API/wpe/ScrollGestureController.cpp @no-unify > UIProcess/API/wpe/WebKitColor.cpp @no-unify > UIProcess/API/wpe/WebKitInputMethodContextWPE.cpp @no-unify >+UIProcess/API/wpe/WebKitPopupMenu.cpp @no-unify > UIProcess/API/wpe/WebKitScriptDialogWPE.cpp @no-unify > UIProcess/API/wpe/WebKitWebViewBackend.cpp @no-unify > UIProcess/API/wpe/WebKitWebViewWPE.cpp @no-unify >diff --git a/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp b/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp >index ff86ecf0f966c4f9741a2a36a28c3dfa1402f453..e9e59a21ec6097341c0803b79242a4935c0abc41 100644 >--- a/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp >+++ b/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp >@@ -92,9 +92,10 @@ > #endif > > #if PLATFORM(WPE) >-#include "APIViewClient.h" > #include "WPEView.h" >+#include "WebKitOptionMenuPrivate.h" > #include "WebKitWebViewBackendPrivate.h" >+#include "WebKitWebViewClient.h" > #endif > > #if USE(LIBNOTIFY) >@@ -165,9 +166,8 @@ enum { > > #if PLATFORM(GTK) > RUN_COLOR_CHOOSER, >- >- SHOW_OPTION_MENU, > #endif >+ SHOW_OPTION_MENU, > > USER_MESSAGE_RECEIVED, > >@@ -412,55 +412,55 @@ private: > }; > > #if PLATFORM(WPE) >-class WebViewClient final : public API::ViewClient { >- WTF_MAKE_FAST_ALLOCATED; >-public: >- explicit WebViewClient(WebKitWebView* webView) >- : m_webView(webView) >- { >- } >+WebKitWebViewClient::WebKitWebViewClient(WebKitWebView* webView) >+ : m_webView(webView) >+{ } > >-private: >- void handleDownloadRequest(WKWPE::View&, DownloadProxy& downloadProxy) override >- { >- webkitWebViewHandleDownloadRequest(m_webView, &downloadProxy); >- } >+GRefPtr<WebKitOptionMenu> WebKitWebViewClient::showOptionMenu(WebKitPopupMenu& popupMenu, const Vector<WebPopupItem>& items, int32_t selectedIndex) >+{ >+ GRefPtr<WebKitOptionMenu> menu = adoptGRef(webkitOptionMenuCreate(popupMenu, items, selectedIndex)); >+ if (webkitWebViewShowOptionMenu(WEBKIT_WEB_VIEW(m_webView), menu.get())) >+ return menu; >+ return nullptr; >+} > >- void frameDisplayed(WKWPE::View&) override >- { >- { >- SetForScope<bool> inFrameDisplayedGuard(m_webView->priv->inFrameDisplayed, true); >- for (const auto& callback : m_webView->priv->frameDisplayedCallbacks) { >- if (!m_webView->priv->frameDisplayedCallbacksToRemove.contains(callback.id)) >- callback.callback(m_webView, callback.userData); >- } >- } >+void WebKitWebViewClient::handleDownloadRequest(WKWPE::View&, DownloadProxy& downloadProxy) >+{ >+ webkitWebViewHandleDownloadRequest(m_webView, &downloadProxy); >+} > >- while (!m_webView->priv->frameDisplayedCallbacksToRemove.isEmpty()) { >- auto id = m_webView->priv->frameDisplayedCallbacksToRemove.takeAny(); >- m_webView->priv->frameDisplayedCallbacks.removeFirstMatching([id](const auto& item) { >- return item.id == id; >- }); >+void WebKitWebViewClient::frameDisplayed(WKWPE::View&) >+{ >+ { >+ SetForScope<bool> inFrameDisplayedGuard(m_webView->priv->inFrameDisplayed, true); >+ for (const auto& callback : m_webView->priv->frameDisplayedCallbacks) { >+ if (!m_webView->priv->frameDisplayedCallbacksToRemove.contains(callback.id)) >+ callback.callback(m_webView, callback.userData); > } > } > >- void willStartLoad(WKWPE::View&) override >- { >- webkitWebViewWillStartLoad(m_webView); >+ while (!m_webView->priv->frameDisplayedCallbacksToRemove.isEmpty()) { >+ auto id = m_webView->priv->frameDisplayedCallbacksToRemove.takeAny(); >+ m_webView->priv->frameDisplayedCallbacks.removeFirstMatching([id](const auto& item) { >+ return item.id == id; >+ }); > } >+} > >- void didChangePageID(WKWPE::View&) override >- { >- webkitWebViewDidChangePageID(m_webView); >- } >+void WebKitWebViewClient::willStartLoad(WKWPE::View&) >+{ >+ webkitWebViewWillStartLoad(m_webView); >+} > >- void didReceiveUserMessage(WKWPE::View&, UserMessage&& message, CompletionHandler<void(UserMessage&&)>&& completionHandler) override >- { >- webkitWebViewDidReceiveUserMessage(m_webView, WTFMove(message), WTFMove(completionHandler)); >- } >+void WebKitWebViewClient::didChangePageID(WKWPE::View&) >+{ >+ webkitWebViewDidChangePageID(m_webView); >+} > >- WebKitWebView* m_webView; >-}; >+void WebKitWebViewClient::didReceiveUserMessage(WKWPE::View&, UserMessage&& message, CompletionHandler<void(UserMessage&&)>&& completionHandler) >+{ >+ webkitWebViewDidReceiveUserMessage(m_webView, WTFMove(message), WTFMove(completionHandler)); >+} > #endif > > static gboolean webkitWebViewLoadFail(WebKitWebView* webView, WebKitLoadEvent, const char* failingURI, GError* error) >@@ -777,7 +777,7 @@ static void webkitWebViewConstructed(GObject* object) > #endif > > #if PLATFORM(WPE) >- priv->view->setClient(makeUnique<WebViewClient>(webView)); >+ priv->view->setClient(makeUnique<WebKitWebViewClient>(webView)); > #endif > > // This needs to be after attachUIClientToView() because WebPageProxy::setUIClient() calls setCanRunModal() with true. >@@ -2133,6 +2133,36 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) > GDK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE); > #endif // PLATFORM(GTK) > >+#if PLATFORM(WPE) >+ /** >+ * WebKitWebView::show-option-menu: >+ * @web_view: the #WebKitWebView on which the signal is emitted >+ * @menu: the #WebKitOptionMenu >+ * @rectangle: the option element area >+ * >+ * This signal is emitted when a select element in @web_view needs to display a >+ * dropdown menu. This signal can be used to show a custom menu, using @menu to get >+ * the details of all items that should be displayed. The area of the element in the >+ * #WebKitWebView is given as @rectangle parameter, it can be used to position the >+ * menu. >+ * To handle this signal asynchronously you should keep a ref of the @menu. >+ * >+ * Returns: %TRUE to stop other handlers from being invoked for the event. >+ * %FALSE to propagate the event further. >+ * >+ * Since: 2.28 >+ */ >+ signals[SHOW_OPTION_MENU] = g_signal_new( >+ "show-option-menu", >+ G_TYPE_FROM_CLASS(webViewClass), >+ G_SIGNAL_RUN_LAST, >+ G_STRUCT_OFFSET(WebKitWebViewClass, show_option_menu), >+ g_signal_accumulator_true_handled, nullptr, >+ g_cclosure_marshal_generic, >+ G_TYPE_BOOLEAN, 1, >+ WEBKIT_TYPE_OPTION_MENU); >+#endif >+ > /** > * WebKitWebView::user-message-received: > * @web_view: the #WebKitWebView on which the signal is emitted >@@ -2721,6 +2751,15 @@ void webkitWebViewDeleteSurrounding(WebKitWebView* webView, int offset, unsigned > getPage(webView).deleteSurrounding(offset, characterCount); > } > >+#if PLATFORM(WPE) >+bool webkitWebViewShowOptionMenu(WebKitWebView* webView, WebKitOptionMenu* menu) >+{ >+ gboolean handled; >+ g_signal_emit(webView, signals[SHOW_OPTION_MENU], 0, menu, &handled); >+ return handled; >+} >+#endif >+ > #if PLATFORM(WPE) > /** > * webkit_web_view_get_backend: >diff --git a/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h b/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h >index 67f69821ea7f62c7b03f513e38734ecdb9c7b539..9a8643963115570f32d6a0f5d6531af87c50ff25 100644 >--- a/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h >+++ b/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h >@@ -100,6 +100,10 @@ bool webkitWebViewEmitRunColorChooser(WebKitWebView*, WebKitColorChooserRequest* > bool webkitWebViewShowOptionMenu(WebKitWebView*, const WebCore::IntRect&, WebKitOptionMenu*, const GdkEvent*); > #endif > >+#if PLATFORM(WPE) >+bool webkitWebViewShowOptionMenu(WebKitWebView*, WebKitOptionMenu*); >+#endif >+ > gboolean webkitWebViewAuthenticate(WebKitWebView*, WebKitAuthenticationRequest*); > gboolean webkitWebViewScriptDialog(WebKitWebView*, WebKitScriptDialog*); > gboolean webkitWebViewRunFileChooser(WebKitWebView*, WebKitFileChooserRequest*); >diff --git a/Source/WebKit/UIProcess/API/wpe/APIViewClient.h b/Source/WebKit/UIProcess/API/wpe/APIViewClient.h >index b13da6d0f5cdf879c3d486b2f6aa4f651a0a1ba7..509f849a12f86299486b1d1a52db56501a61eb42 100644 >--- a/Source/WebKit/UIProcess/API/wpe/APIViewClient.h >+++ b/Source/WebKit/UIProcess/API/wpe/APIViewClient.h >@@ -45,6 +45,8 @@ class ViewClient { > public: > virtual ~ViewClient() = default; > >+ virtual bool isGLibBasedAPI() { return false; } >+ > virtual void frameDisplayed(WKWPE::View&) { } > virtual void handleDownloadRequest(WKWPE::View&, WebKit::DownloadProxy&) { } > virtual void willStartLoad(WKWPE::View&) { } >diff --git a/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp b/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp >index 592d73349998711f17c181c2f0cdea6b4c4f0683..31caf343a206bfeacf5bdad92ba7a1be2eabb78b 100644 >--- a/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp >+++ b/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp >@@ -26,6 +26,7 @@ > #include "config.h" > #include "PageClientImpl.h" > >+#include "APIViewClient.h" > #include "DrawingAreaProxyCoordinatedGraphics.h" > #include "NativeWebMouseEvent.h" > #include "NativeWebWheelEvent.h" >@@ -33,6 +34,7 @@ > #include "WPEView.h" > #include "WebContextMenuProxy.h" > #include "WebContextMenuProxyWPE.h" >+#include "WebKitPopupMenu.h" > #include <WebCore/ActivityState.h> > #include <WebCore/DOMPasteAccess.h> > #include <WebCore/NotImplemented.h> >@@ -253,9 +255,11 @@ void PageClientImpl::wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent& > { > } > >-RefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy&) >+RefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy& page) > { >- return nullptr; >+ if (!m_view.client().isGLibBasedAPI()) >+ return nullptr; >+ return WebKitPopupMenu::create(m_view, page); > } > > #if ENABLE(CONTEXT_MENUS) >diff --git a/Source/WebKit/UIProcess/API/wpe/WPEView.h b/Source/WebKit/UIProcess/API/wpe/WPEView.h >index f23dfc27a7c4b3e0fe1313780f5db286777d66a4..9f86ebc93f76481eff482e82335d6b9ddd752e99 100644 >--- a/Source/WebKit/UIProcess/API/wpe/WPEView.h >+++ b/Source/WebKit/UIProcess/API/wpe/WPEView.h >@@ -41,6 +41,7 @@ > > typedef struct OpaqueJSContext* JSGlobalContextRef; > typedef struct _WebKitInputMethodContext WebKitInputMethodContext; >+typedef struct _WebKitWebView WebKitWebView; > struct wpe_input_keyboard_event; > struct wpe_view_backend; > >@@ -88,6 +89,7 @@ public: > > WebKit::WebPageProxy& page() { return *m_pageProxy; } > >+ API::ViewClient& client() const { return *m_client; } > struct wpe_view_backend* backend() { return m_backend; } > > const WebCore::IntSize& size() const { return m_size; } >diff --git a/Source/WebKit/UIProcess/API/wpe/WebKitOptionMenu.h b/Source/WebKit/UIProcess/API/wpe/WebKitOptionMenu.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0fe2eff094100c1dc7d8f18bc336117512f78559 >--- /dev/null >+++ b/Source/WebKit/UIProcess/API/wpe/WebKitOptionMenu.h >@@ -0,0 +1,82 @@ >+/* >+ * Copyright (C) 2017 Igalia S.L. >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ */ >+ >+#if !defined(__WEBKIT_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) >+#error "Only <wpe/webkit.h> can be included directly." >+#endif >+ >+#ifndef WebKitOptionMenu_h >+#define WebKitOptionMenu_h >+ >+#include <glib-object.h> >+#include <wpe/WebKitDefines.h> >+#include <wpe/WebKitOptionMenuItem.h> >+ >+G_BEGIN_DECLS >+ >+#define WEBKIT_TYPE_OPTION_MENU (webkit_option_menu_get_type()) >+#define WEBKIT_OPTION_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_OPTION_MENU, WebKitOptionMenu)) >+#define WEBKIT_IS_OPTION_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_OPTION_MENU)) >+#define WEBKIT_OPTION_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_OPTION_MENU, WebKitOptionMenuClass)) >+#define WEBKIT_IS_OPTION_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_OPTION_MENU)) >+#define WEBKIT_OPTION_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_OPTION_MENU, WebKitOptionMenuClass)) >+ >+typedef struct _WebKitOptionMenu WebKitOptionMenu; >+typedef struct _WebKitOptionMenuClass WebKitOptionMenuClass; >+typedef struct _WebKitOptionMenuPrivate WebKitOptionMenuPrivate; >+ >+struct _WebKitOptionMenu { >+ GObject parent; >+ >+ WebKitOptionMenuPrivate *priv; >+}; >+ >+struct _WebKitOptionMenuClass { >+ GObjectClass parent_class; >+ >+ void (*_webkit_reserved0) (void); >+ void (*_webkit_reserved1) (void); >+ void (*_webkit_reserved2) (void); >+ void (*_webkit_reserved3) (void); >+}; >+ >+WEBKIT_API GType >+webkit_option_menu_get_type (void); >+ >+WEBKIT_API guint >+webkit_option_menu_get_n_items (WebKitOptionMenu *menu); >+ >+WEBKIT_API WebKitOptionMenuItem * >+webkit_option_menu_get_item (WebKitOptionMenu *menu, >+ guint index); >+ >+WEBKIT_API void >+webkit_option_menu_select_item (WebKitOptionMenu *menu, >+ guint index); >+ >+WEBKIT_API void >+webkit_option_menu_activate_item (WebKitOptionMenu *menu, >+ guint index); >+ >+WEBKIT_API void >+webkit_option_menu_close (WebKitOptionMenu *menu); >+ >+G_END_DECLS >+ >+#endif >diff --git a/Source/WebKit/UIProcess/API/wpe/WebKitOptionMenuItem.h b/Source/WebKit/UIProcess/API/wpe/WebKitOptionMenuItem.h >new file mode 100644 >index 0000000000000000000000000000000000000000..78ff27d6ed2a0785fc817af75aa39e7398ada720 >--- /dev/null >+++ b/Source/WebKit/UIProcess/API/wpe/WebKitOptionMenuItem.h >@@ -0,0 +1,65 @@ >+/* >+ * Copyright (C) 2017 Igalia S.L. >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ */ >+ >+#if !defined(__WEBKIT_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) >+#error "Only <wpe/webkit.h> can be included directly." >+#endif >+ >+#ifndef WebKitOptionMenuItem_h >+#define WebKitOptionMenuItem_h >+ >+#include <glib-object.h> >+#include <wpe/WebKitDefines.h> >+ >+G_BEGIN_DECLS >+ >+#define WEBKIT_TYPE_OPTION_MENU_ITEM (webkit_option_menu_item_get_type()) >+ >+typedef struct _WebKitOptionMenuItem WebKitOptionMenuItem; >+ >+WEBKIT_API GType >+webkit_option_menu_item_get_type (void); >+ >+WEBKIT_API WebKitOptionMenuItem * >+webkit_option_menu_item_copy (WebKitOptionMenuItem *item); >+ >+WEBKIT_API void >+webkit_option_menu_item_free (WebKitOptionMenuItem *item); >+ >+WEBKIT_API const gchar * >+webkit_option_menu_item_get_label (WebKitOptionMenuItem *item); >+ >+WEBKIT_API const gchar * >+webkit_option_menu_item_get_tooltip (WebKitOptionMenuItem *item); >+ >+WEBKIT_API gboolean >+webkit_option_menu_item_is_group_label (WebKitOptionMenuItem *item); >+ >+WEBKIT_API gboolean >+webkit_option_menu_item_is_group_child (WebKitOptionMenuItem *item); >+ >+WEBKIT_API gboolean >+webkit_option_menu_item_is_enabled (WebKitOptionMenuItem *item); >+ >+WEBKIT_API gboolean >+webkit_option_menu_item_is_selected (WebKitOptionMenuItem *item); >+ >+G_END_DECLS >+ >+#endif >diff --git a/Source/WebKit/UIProcess/API/wpe/WebKitPopupMenu.cpp b/Source/WebKit/UIProcess/API/wpe/WebKitPopupMenu.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..2acf9a6a1dcc2c987f7c2adc453260d52ed44ee1 >--- /dev/null >+++ b/Source/WebKit/UIProcess/API/wpe/WebKitPopupMenu.cpp >@@ -0,0 +1,89 @@ >+/* >+ * Copyright (C) 2017 Igalia S.L. >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ */ >+ >+#include "config.h" >+#include "WebKitPopupMenu.h" >+ >+#include "APIViewClient.h" >+#include "WPEView.h" >+#include "WebKitOptionMenuPrivate.h" >+#include "WebKitWebViewClient.h" >+#include "WebKitWebViewPrivate.h" >+ >+namespace WebKit { >+using namespace WebCore; >+ >+Ref<WebKitPopupMenu> WebKitPopupMenu::create(WKWPE::View& view, WebPopupMenuProxy::Client& client) >+{ >+ ASSERT(view.client().isGLibBasedAPI()); >+ return adoptRef(*new WebKitPopupMenu(view, client)); >+} >+ >+WebKitPopupMenu::WebKitPopupMenu(WKWPE::View& view, WebPopupMenuProxy::Client& client) >+ : WebPopupMenuProxy(client) >+ , m_view(view) >+{ >+} >+ >+static void menuCloseCallback(WebKitPopupMenu* popupMenu) >+{ >+ popupMenu->activateItem(WTF::nullopt); >+} >+ >+void WebKitPopupMenu::showPopupMenu(const IntRect& rect, TextDirection direction, double pageScaleFactor, const Vector<WebPopupItem>& items, const PlatformPopupMenuData& platformData, int32_t selectedIndex) >+{ >+ GRefPtr<WebKitOptionMenu> menu = static_cast<WebKitWebViewClient&>(m_view.client()).showOptionMenu(*this, items, selectedIndex); >+ if (menu) { >+ m_menu = WTFMove(menu); >+ g_signal_connect_swapped(m_menu.get(), "close", G_CALLBACK(menuCloseCallback), this); >+ } >+} >+ >+void WebKitPopupMenu::hidePopupMenu() >+{ >+ if (m_menu) { >+ g_signal_handlers_disconnect_matched(m_menu.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this); >+ webkit_option_menu_close(m_menu.get()); >+ } >+} >+ >+void WebKitPopupMenu::cancelTracking() >+{ >+ hidePopupMenu(); >+ m_menu = nullptr; >+} >+ >+void WebKitPopupMenu::selectItem(unsigned itemIndex) >+{ >+ if (m_client) >+ m_client->setTextFromItemForPopupMenu(this, itemIndex); >+ m_selectedItem = itemIndex; >+} >+ >+void WebKitPopupMenu::activateItem(Optional<unsigned> itemIndex) >+{ >+ if (m_client) >+ m_client->valueChangedForPopupMenu(this, itemIndex.valueOr(m_selectedItem.valueOr(-1))); >+ if (m_menu) { >+ g_signal_handlers_disconnect_matched(m_menu.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this); >+ m_menu = nullptr; >+ } >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/UIProcess/API/wpe/WebKitPopupMenu.h b/Source/WebKit/UIProcess/API/wpe/WebKitPopupMenu.h >new file mode 100644 >index 0000000000000000000000000000000000000000..98de76d478104601caef00c51fd60b28d714800a >--- /dev/null >+++ b/Source/WebKit/UIProcess/API/wpe/WebKitPopupMenu.h >@@ -0,0 +1,55 @@ >+/* >+ * Copyright (C) 2017 Igalia S.L. >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ */ >+ >+#pragma once >+ >+#include "WebPopupMenuProxy.h" >+#include <wtf/glib/GRefPtr.h> >+ >+typedef struct _WebKitOptionMenu WebKitOptionMenu; >+typedef struct _WebKitWebView WebKitWebView; >+ >+namespace WKWPE { >+class View; >+} >+ >+namespace WebKit { >+ >+class WebKitPopupMenu final : public WebPopupMenuProxy { >+public: >+ static Ref<WebKitPopupMenu> create(WKWPE::View&, WebPopupMenuProxy::Client&); >+ ~WebKitPopupMenu() = default; >+ >+ void selectItem(unsigned itemIndex); >+ void activateItem(Optional<unsigned> itemIndex); >+ >+private: >+ WebKitPopupMenu(WKWPE::View&, WebPopupMenuProxy::Client&); >+ >+ void showPopupMenu(const WebCore::IntRect&, WebCore::TextDirection, double pageScaleFactor, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex) override; >+ void hidePopupMenu() override; >+ void cancelTracking() override; >+ >+ WKWPE::View& m_view; >+ WebKitWebView* m_webView; >+ GRefPtr<WebKitOptionMenu> m_menu; >+ Optional<unsigned> m_selectedItem; >+}; >+ >+} // namespace WebKit >diff --git a/Source/WebKit/UIProcess/API/wpe/WebKitWebView.h b/Source/WebKit/UIProcess/API/wpe/WebKitWebView.h >index 017434debdf716223f7d6d01d6d7993749cb8d48..e3d97094b13c8c107dc55fee175538d10494efcc 100644 >--- a/Source/WebKit/UIProcess/API/wpe/WebKitWebView.h >+++ b/Source/WebKit/UIProcess/API/wpe/WebKitWebView.h >@@ -41,6 +41,7 @@ > #include <wpe/WebKitJavascriptResult.h> > #include <wpe/WebKitNavigationAction.h> > #include <wpe/WebKitNotification.h> >+#include <wpe/WebKitOptionMenu.h> > #include <wpe/WebKitPermissionRequest.h> > #include <wpe/WebKitPolicyDecision.h> > #include <wpe/WebKitScriptDialog.h> >@@ -245,7 +246,8 @@ struct _WebKitWebViewClass { > WebKitWebProcessTerminationReason reason); > gboolean (* user_message_received) (WebKitWebView *web_view, > WebKitUserMessage *message); >- >+ gboolean (* show_option_menu) (WebKitWebView *web_view, >+ WebKitOptionMenu *menu); > > void (*_webkit_reserved0) (void); > void (*_webkit_reserved1) (void); >@@ -253,7 +255,6 @@ struct _WebKitWebViewClass { > void (*_webkit_reserved3) (void); > void (*_webkit_reserved4) (void); > void (*_webkit_reserved5) (void); >- void (*_webkit_reserved6) (void); > }; > > WEBKIT_API GType >diff --git a/Source/WebKit/UIProcess/API/wpe/WebKitWebViewClient.h b/Source/WebKit/UIProcess/API/wpe/WebKitWebViewClient.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0d3ad6ccb09b3ff2c884dc7c5936871e6f218ac4 >--- /dev/null >+++ b/Source/WebKit/UIProcess/API/wpe/WebKitWebViewClient.h >@@ -0,0 +1,53 @@ >+/* >+ * Copyright (C) 2020 Igalia S.L. >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library General Public >+ * License as published by the Free Software Foundation; either >+ * version 2 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ */ >+ >+#pragma once >+ >+#include "APIViewClient.h" >+#include <wtf/CompletionHandler.h> >+ >+namespace WKWPE { >+class View; >+} >+ >+namespace WebKit { >+class DownloadProxy; >+class WebKitPopupMenu; >+class WebPopupItem; >+struct UserMessage; >+} >+ >+class WebKitWebViewClient final : public API::ViewClient { >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ explicit WebKitWebViewClient(WebKitWebView*); >+ >+ GRefPtr<WebKitOptionMenu> showOptionMenu(WebKit::WebKitPopupMenu&, const Vector<WebKit::WebPopupItem>&, int32_t selectedIndex); >+ >+private: >+ bool isGLibBasedAPI() override { return true; } >+ >+ void frameDisplayed(WKWPE::View&) override; >+ void handleDownloadRequest(WKWPE::View&, WebKit::DownloadProxy&) override; >+ void willStartLoad(WKWPE::View&) override; >+ void didChangePageID(WKWPE::View&) override; >+ void didReceiveUserMessage(WKWPE::View&, WebKit::UserMessage&&, CompletionHandler<void(WebKit::UserMessage&&)>&&) override; >+ >+ WebKitWebView* m_webView; >+}; >diff --git a/Source/WebKit/UIProcess/API/wpe/docs/wpe-1.0-sections.txt b/Source/WebKit/UIProcess/API/wpe/docs/wpe-1.0-sections.txt >index 1d1d57b171857ed8112530e276b1eeba2abef393..83def25a5507a7136ae64fe69f412f9b51443725 100644 >--- a/Source/WebKit/UIProcess/API/wpe/docs/wpe-1.0-sections.txt >+++ b/Source/WebKit/UIProcess/API/wpe/docs/wpe-1.0-sections.txt >@@ -1230,6 +1230,48 @@ WebKitContextMenuItemPrivate > webkit_context_menu_item_get_type > </SECTION> > >+<SECTION> >+<FILE>WebKitOptionMenu</FILE> >+WebKitOptionMenu >+webkit_option_menu_get_n_items >+webkit_option_menu_get_item >+webkit_option_menu_select_item >+webkit_option_menu_activate_item >+webkit_option_menu_close >+ >+<SUBSECTION Standard> >+WebKitOptionMenuClass >+WEBKIT_TYPE_OPTION_MENU >+WEBKIT_OPTION_MENU >+WEBKIT_IS_OPTION_MENU >+WEBKIT_OPTION_MENU_CLASS >+WEBKIT_IS_OPTION_MENU_CLASS >+WEBKIT_OPTION_MENU_GET_CLASS >+ >+<SUBSECTION Private> >+WebKitOptionMenuPrivate >+webkit_option_menu_get_type >+</SECTION> >+ >+<SECTION> >+<FILE>WebKitOptionMenuItem</FILE> >+WebKitOptionMenuItem >+webkit_option_menu_item_copy >+webkit_option_menu_item_free >+webkit_option_menu_item_get_label >+webkit_option_menu_item_get_tooltip >+webkit_option_menu_item_is_group_label >+webkit_option_menu_item_is_group_child >+webkit_option_menu_item_is_enabled >+webkit_option_menu_item_is_selected >+ >+<SUBSECTION Standard> >+WEBKIT_TYPE_OPTION_MENU_ITEM >+ >+<SUBSECTION Private> >+webkit_option_menu_item_get_type >+</SECTION> >+ > <SECTION> > <FILE>WebKitFormSubmissionRequest</FILE> > WebKitFormSubmissionRequest >diff --git a/Source/WebKit/UIProcess/API/wpe/webkit.h b/Source/WebKit/UIProcess/API/wpe/webkit.h >index 15a4c1ff1c4aeee7d807856db0b3a74002e421dd..02e258253e47fbf6594c20f743d0faeac8a4eefe 100644 >--- a/Source/WebKit/UIProcess/API/wpe/webkit.h >+++ b/Source/WebKit/UIProcess/API/wpe/webkit.h >@@ -59,6 +59,8 @@ > #include <wpe/WebKitNetworkProxySettings.h> > #include <wpe/WebKitNotification.h> > #include <wpe/WebKitNotificationPermissionRequest.h> >+#include <wpe/WebKitOptionMenu.h> >+#include <wpe/WebKitOptionMenuItem.h> > #include <wpe/WebKitPermissionRequest.h> > #include <wpe/WebKitPlugin.h> > #include <wpe/WebKitResponsePolicyDecision.h> >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 7c1c7f6907e2f83a16937d7bfd8a01a8ef427ec3..5a59bc51e44643ae4bab7c0940b300343337f558 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,31 @@ >+2020-01-20 Zan Dobersek <zdobersek@igalia.com> >+ >+ [WPE] Expose the WebKitOptionMenu APIs >+ https://bugs.webkit.org/show_bug.cgi?id=206287 >+ >+ Move TestOptionMenu under the WebKitGLib directory, adding the >+ appropriate adjustments for the WPE variant of the API >+ >+ * TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp: Renamed from Tools/TestWebKitAPI/Tests/WebKitGtk/TestOptionMenu.cpp. >+ (OptionMenuTest::OptionMenuTest): >+ (OptionMenuTest::~OptionMenuTest): >+ (OptionMenuTest::destroyMenu): >+ (OptionMenuTest::showOptionMenuCallback): >+ (OptionMenuTest::menuCloseCallback): >+ (OptionMenuTest::showOptionMenu): >+ (OptionMenuTest::clickAtPositionAndWaitUntilOptionMenuShown): >+ (OptionMenuTest::close): >+ (OptionMenuTest::activateItem): >+ (OptionMenuTest::selectItem): >+ (testOptionMenuSimple): >+ (testOptionMenuGroups): >+ (testOptionMenuActivate): >+ (testOptionMenuSelect): >+ (beforeAll): >+ (afterAll): >+ * TestWebKitAPI/glib/CMakeLists.txt: >+ * TestWebKitAPI/glib/PlatformGTK.cmake: >+ > 2020-01-17 Cathie Chen <cathiechen@igalia.com> > > Add support for scroll behavior parsing >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..85fe5ecb2594b04ee994143930e49b8da5b3342f >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp >@@ -0,0 +1,327 @@ >+/* >+ * Copyright (C) 2017 Igalia S.L. >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Lesser General Public >+ * License as published by the Free Software Foundation; either >+ * version 2,1 of the License, or (at your option) any later version. >+ * >+ * This library is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ */ >+ >+#include "config.h" >+#include "WebViewTest.h" >+ >+#include <wtf/RunLoop.h> >+ >+class OptionMenuTest : public WebViewTest { >+public: >+ MAKE_GLIB_TEST_FIXTURE(OptionMenuTest); >+ >+ OptionMenuTest() >+ { >+ g_signal_connect(m_webView, "show-option-menu", G_CALLBACK(showOptionMenuCallback), this); >+ } >+ >+ ~OptionMenuTest() >+ { >+ g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); >+ if (m_menu) >+ close(); >+ } >+ >+ void destroyMenu() >+ { >+ if (!m_menu) >+ return; >+ >+ g_signal_handlers_disconnect_matched(m_menu.get(), G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); >+ m_menu = nullptr; >+ } >+ >+#if PLATFORM(GTK) >+ static gboolean showOptionMenuCallback(WebKitWebView* webView, WebKitOptionMenu* menu, GdkEvent* event, GdkRectangle* rect, OptionMenuTest* test) >+ { >+ g_assert_true(test->m_webView == webView); >+ g_assert_nonnull(rect); >+ g_assert_true(WEBKIT_IS_OPTION_MENU(menu)); >+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(menu)); >+ test->showOptionMenu(menu, rect); >+ return TRUE; >+ } >+#elif PLATFORM(WPE) >+ static gboolean showOptionMenuCallback(WebKitWebView* webView, WebKitOptionMenu* menu, OptionMenuTest* test) >+ { >+ g_assert_true(test->m_webView == webView); >+ g_assert_true(WEBKIT_IS_OPTION_MENU(menu)); >+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(menu)); >+ test->showOptionMenu(menu); >+ return TRUE; >+ } >+#endif >+ >+ static void menuCloseCallback(WebKitOptionMenu* menu, OptionMenuTest* test) >+ { >+ g_assert_true(test->m_menu.get() == menu); >+ test->destroyMenu(); >+ } >+ >+#if PLATFORM(GTK) >+ void showOptionMenu(WebKitOptionMenu* menu, GdkRectangle* rect) >+ { >+ m_rectangle = *rect; >+ m_menu = menu; >+ g_signal_connect(m_menu.get(), "close", G_CALLBACK(menuCloseCallback), this); >+ g_main_loop_quit(m_mainLoop); >+ } >+#elif PLATFORM(WPE) >+ void showOptionMenu(WebKitOptionMenu* menu) >+ { >+ m_menu = menu; >+ g_signal_connect(m_menu.get(), "close", G_CALLBACK(menuCloseCallback), this); >+ g_main_loop_quit(m_mainLoop); >+ } >+#endif >+ >+ void clickAtPositionAndWaitUntilOptionMenuShown(int x, int y) >+ { >+ m_menu = nullptr; >+ RunLoop::main().dispatch([this, x, y] { clickMouseButton(x, y); }); >+ g_main_loop_run(m_mainLoop); >+ } >+ >+ void close() >+ { >+ g_assert_nonnull(m_menu.get()); >+ webkit_option_menu_close(m_menu.get()); >+ g_assert_null(m_menu.get()); >+ } >+ >+ void activateItem(unsigned item) >+ { >+ g_assert_nonnull(m_menu.get()); >+ webkit_option_menu_activate_item(m_menu.get(), item); >+ g_assert_nonnull(m_menu.get()); >+ } >+ >+ void selectItem(unsigned item) >+ { >+ g_assert_nonnull(m_menu.get()); >+ webkit_option_menu_select_item(m_menu.get(), item); >+ g_assert_nonnull(m_menu.get()); >+ } >+ >+ GRefPtr<WebKitOptionMenu> m_menu; >+#if PLATFORM(GTK) >+ GdkRectangle m_rectangle; >+#endif >+}; >+ >+static void testOptionMenuSimple(OptionMenuTest* test, gconstpointer) >+{ >+ static const char html[] = >+ "<html><body>" >+ " <select style='position:absolute; left:1; top:10'>" >+ " <option title='The Foo Option'>Foo</option>" >+ " <option selected>Bar</option>" >+ " <option disabled>Baz</option>" >+ " </select></body></html>"; >+ test->showInWindowAndWaitUntilMapped(); >+ test->loadHtml(html, nullptr); >+ test->waitUntilLoadFinished(); >+ >+ test->clickAtPositionAndWaitUntilOptionMenuShown(5, 15); >+ g_assert_true(WEBKIT_IS_OPTION_MENU(test->m_menu.get())); >+ g_assert_cmpint(webkit_option_menu_get_n_items(test->m_menu.get()), ==, 3); >+ auto* item = webkit_option_menu_get_item(test->m_menu.get(), 0); >+ g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Foo"); >+ g_assert_cmpstr(webkit_option_menu_item_get_tooltip(item), ==, "The Foo Option"); >+ g_assert_false(webkit_option_menu_item_is_group_label(item)); >+ g_assert_false(webkit_option_menu_item_is_group_child(item)); >+ g_assert_true(webkit_option_menu_item_is_enabled(item)); >+ g_assert_false(webkit_option_menu_item_is_selected(item)); >+ item = webkit_option_menu_get_item(test->m_menu.get(), 1); >+ g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Bar"); >+ g_assert_null(webkit_option_menu_item_get_tooltip(item)); >+ g_assert_false(webkit_option_menu_item_is_group_label(item)); >+ g_assert_false(webkit_option_menu_item_is_group_child(item)); >+ g_assert_true(webkit_option_menu_item_is_enabled(item)); >+ g_assert_true(webkit_option_menu_item_is_selected(item)); >+ item = webkit_option_menu_get_item(test->m_menu.get(), 2); >+ g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Baz"); >+ g_assert_null(webkit_option_menu_item_get_tooltip(item)); >+ g_assert_false(webkit_option_menu_item_is_group_label(item)); >+ g_assert_false(webkit_option_menu_item_is_group_child(item)); >+ g_assert_false(webkit_option_menu_item_is_enabled(item)); >+ g_assert_false(webkit_option_menu_item_is_selected(item)); >+ >+ test->close(); >+ g_assert_null(test->m_menu.get()); >+} >+ >+static void testOptionMenuGroups(OptionMenuTest* test, gconstpointer) >+{ >+ static const char html[] = >+ "<html><body>" >+ " <select style='position:absolute; left:1; top:10'>" >+ " <option>Root</option>" >+ " <optgroup label='Group 1'>" >+ " <option>Child 1-1</option>" >+ " <option disabled>Child 1-2</option>" >+ " </optgroup>" >+ " <optgroup label='Group 2'>" >+ " <option selected>Child 2-1</option>" >+ " <option>Child 2-2</option>" >+ " </optgroup>" >+ " <option>Tail</option>" >+ " </select></body></html>"; >+ test->showInWindowAndWaitUntilMapped(); >+ test->loadHtml(html, nullptr); >+ test->waitUntilLoadFinished(); >+ >+ test->clickAtPositionAndWaitUntilOptionMenuShown(5, 15); >+ g_assert_true(WEBKIT_IS_OPTION_MENU(test->m_menu.get())); >+ g_assert_cmpint(webkit_option_menu_get_n_items(test->m_menu.get()), ==, 8); >+ auto* item = webkit_option_menu_get_item(test->m_menu.get(), 0); >+ g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Root"); >+ g_assert_null(webkit_option_menu_item_get_tooltip(item)); >+ g_assert_false(webkit_option_menu_item_is_group_label(item)); >+ g_assert_false(webkit_option_menu_item_is_group_child(item)); >+ g_assert_true(webkit_option_menu_item_is_enabled(item)); >+ g_assert_false(webkit_option_menu_item_is_selected(item)); >+ item = webkit_option_menu_get_item(test->m_menu.get(), 1); >+ g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Group 1"); >+ g_assert_null(webkit_option_menu_item_get_tooltip(item)); >+ g_assert_true(webkit_option_menu_item_is_group_label(item)); >+ g_assert_false(webkit_option_menu_item_is_group_child(item)); >+ g_assert_false(webkit_option_menu_item_is_enabled(item)); >+ g_assert_false(webkit_option_menu_item_is_selected(item)); >+ item = webkit_option_menu_get_item(test->m_menu.get(), 2); >+ g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Child 1-1"); >+ g_assert_null(webkit_option_menu_item_get_tooltip(item)); >+ g_assert_false(webkit_option_menu_item_is_group_label(item)); >+ g_assert_true(webkit_option_menu_item_is_group_child(item)); >+ g_assert_true(webkit_option_menu_item_is_enabled(item)); >+ g_assert_false(webkit_option_menu_item_is_selected(item)); >+ item = webkit_option_menu_get_item(test->m_menu.get(), 3); >+ g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Child 1-2"); >+ g_assert_null(webkit_option_menu_item_get_tooltip(item)); >+ g_assert_false(webkit_option_menu_item_is_group_label(item)); >+ g_assert_true(webkit_option_menu_item_is_group_child(item)); >+ g_assert_false(webkit_option_menu_item_is_enabled(item)); >+ g_assert_false(webkit_option_menu_item_is_selected(item)); >+ item = webkit_option_menu_get_item(test->m_menu.get(), 4); >+ g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Group 2"); >+ g_assert_null(webkit_option_menu_item_get_tooltip(item)); >+ g_assert_true(webkit_option_menu_item_is_group_label(item)); >+ g_assert_false(webkit_option_menu_item_is_group_child(item)); >+ g_assert_false(webkit_option_menu_item_is_enabled(item)); >+ g_assert_false(webkit_option_menu_item_is_selected(item)); >+ item = webkit_option_menu_get_item(test->m_menu.get(), 5); >+ g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Child 2-1"); >+ g_assert_null(webkit_option_menu_item_get_tooltip(item)); >+ g_assert_false(webkit_option_menu_item_is_group_label(item)); >+ g_assert_true(webkit_option_menu_item_is_group_child(item)); >+ g_assert_true(webkit_option_menu_item_is_enabled(item)); >+ g_assert_true(webkit_option_menu_item_is_selected(item)); >+ item = webkit_option_menu_get_item(test->m_menu.get(), 6); >+ g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Child 2-2"); >+ g_assert_null(webkit_option_menu_item_get_tooltip(item)); >+ g_assert_false(webkit_option_menu_item_is_group_label(item)); >+ g_assert_true(webkit_option_menu_item_is_group_child(item)); >+ g_assert_true(webkit_option_menu_item_is_enabled(item)); >+ g_assert_false(webkit_option_menu_item_is_selected(item)); >+ item = webkit_option_menu_get_item(test->m_menu.get(), 7); >+ g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Tail"); >+ g_assert_null(webkit_option_menu_item_get_tooltip(item)); >+ g_assert_false(webkit_option_menu_item_is_group_label(item)); >+ g_assert_false(webkit_option_menu_item_is_group_child(item)); >+ g_assert_true(webkit_option_menu_item_is_enabled(item)); >+ g_assert_false(webkit_option_menu_item_is_selected(item)); >+} >+ >+static void testOptionMenuActivate(OptionMenuTest* test, gconstpointer) >+{ >+ static const char html[] = >+ "<html><body>" >+ " <select id='combo' style='position:absolute; left:1; top:10'>" >+ " <option>Foo</option>" >+ " <option>Bar</option>" >+ " <option>Baz</option>" >+ " </select></body></html>"; >+ test->showInWindowAndWaitUntilMapped(); >+ test->loadHtml(html, nullptr); >+ test->waitUntilLoadFinished(); >+ >+ test->clickAtPositionAndWaitUntilOptionMenuShown(5, 15); >+ g_assert_true(WEBKIT_IS_OPTION_MENU(test->m_menu.get())); >+ g_assert_cmpint(webkit_option_menu_get_n_items(test->m_menu.get()), ==, 3); >+ test->activateItem(1); >+ auto* result = test->runJavaScriptAndWaitUntilFinished("document.getElementById('combo').selectedIndex", nullptr); >+ g_assert_nonnull(result); >+ g_assert_cmpfloat(WebViewTest::javascriptResultToNumber(result), ==, 1); >+ >+ // We should close the menu after activate, further activates will be ignored. >+ test->activateItem(2); >+ result = test->runJavaScriptAndWaitUntilFinished("document.getElementById('combo').selectedIndex", nullptr); >+ g_assert_nonnull(result); >+ g_assert_cmpfloat(WebViewTest::javascriptResultToNumber(result), ==, 1); >+ >+ test->close(); >+} >+ >+static void testOptionMenuSelect(OptionMenuTest* test, gconstpointer) >+{ >+ static const char html[] = >+ "<html><body>" >+ " <select id='combo' style='position:absolute; left:1; top:10'>" >+ " <option>Foo</option>" >+ " <option>Bar</option>" >+ " <option>Baz</option>" >+ " </select></body></html>"; >+ test->showInWindowAndWaitUntilMapped(); >+ test->loadHtml(html, nullptr); >+ test->waitUntilLoadFinished(); >+ >+ test->clickAtPositionAndWaitUntilOptionMenuShown(5, 15); >+ g_assert_true(WEBKIT_IS_OPTION_MENU(test->m_menu.get())); >+ g_assert_cmpint(webkit_option_menu_get_n_items(test->m_menu.get()), ==, 3); >+ >+ // Select item changes the combo text, but not the currently selected item. >+ test->selectItem(2); >+ auto* result = test->runJavaScriptAndWaitUntilFinished("document.getElementById('combo').selectedIndex", nullptr); >+ g_assert_nonnull(result); >+ g_assert_cmpfloat(WebViewTest::javascriptResultToNumber(result), ==, 0); >+ >+ // It can be called multiple times. >+ test->selectItem(1); >+ result = test->runJavaScriptAndWaitUntilFinished("document.getElementById('combo').selectedIndex", nullptr); >+ g_assert_nonnull(result); >+ g_assert_cmpfloat(WebViewTest::javascriptResultToNumber(result), ==, 0); >+ >+ // And closing the menu activates the currently selected item. >+ test->close(); >+ result = test->runJavaScriptAndWaitUntilFinished("document.getElementById('combo').selectedIndex", nullptr); >+ g_assert_nonnull(result); >+ g_assert_cmpfloat(WebViewTest::javascriptResultToNumber(result), ==, 1); >+} >+ >+void beforeAll() >+{ >+ OptionMenuTest::add("WebKitWebView", "option-menu-simple", testOptionMenuSimple); >+ OptionMenuTest::add("WebKitWebView", "option-menu-groups", testOptionMenuGroups); >+ OptionMenuTest::add("WebKitWebView", "option-menu-activate", testOptionMenuActivate); >+ OptionMenuTest::add("WebKitWebView", "option-menu-select", testOptionMenuSelect); >+} >+ >+void afterAll() >+{ >+} >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGtk/TestOptionMenu.cpp b/Tools/TestWebKitAPI/Tests/WebKitGtk/TestOptionMenu.cpp >deleted file mode 100644 >index 57c1c9d32793817eb3464eab297c2e45893c8ef1..0000000000000000000000000000000000000000 >--- a/Tools/TestWebKitAPI/Tests/WebKitGtk/TestOptionMenu.cpp >+++ /dev/null >@@ -1,305 +0,0 @@ >-/* >- * Copyright (C) 2017 Igalia S.L. >- * >- * This library is free software; you can redistribute it and/or >- * modify it under the terms of the GNU Lesser General Public >- * License as published by the Free Software Foundation; either >- * version 2,1 of the License, or (at your option) any later version. >- * >- * This library is distributed in the hope that it will be useful, >- * but WITHOUT ANY WARRANTY; without even the implied warranty of >- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >- * Library General Public License for more details. >- * >- * You should have received a copy of the GNU Library General Public License >- * along with this library; see the file COPYING.LIB. If not, write to >- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >- * Boston, MA 02110-1301, USA. >- */ >- >-#include "config.h" >-#include "WebViewTest.h" >- >-#include <wtf/RunLoop.h> >- >-class OptionMenuTest : public WebViewTest { >-public: >- MAKE_GLIB_TEST_FIXTURE(OptionMenuTest); >- >- OptionMenuTest() >- { >- g_signal_connect(m_webView, "show-option-menu", G_CALLBACK(showOptionMenuCallback), this); >- } >- >- ~OptionMenuTest() >- { >- g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); >- if (m_menu) >- close(); >- } >- >- void destroyMenu() >- { >- if (!m_menu) >- return; >- >- g_signal_handlers_disconnect_matched(m_menu.get(), G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); >- m_menu = nullptr; >- } >- >- static gboolean showOptionMenuCallback(WebKitWebView* webView, WebKitOptionMenu* menu, GdkEvent* event, GdkRectangle* rect, OptionMenuTest* test) >- { >- g_assert_true(test->m_webView == webView); >- g_assert_nonnull(rect); >- g_assert_true(WEBKIT_IS_OPTION_MENU(menu)); >- test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(menu)); >- test->showOptionMenu(menu, rect); >- return TRUE; >- } >- >- static void menuCloseCallback(WebKitOptionMenu* menu, OptionMenuTest* test) >- { >- g_assert_true(test->m_menu.get() == menu); >- test->destroyMenu(); >- } >- >- void showOptionMenu(WebKitOptionMenu* menu, GdkRectangle* rect) >- { >- m_rectangle = *rect; >- m_menu = menu; >- g_signal_connect(m_menu.get(), "close", G_CALLBACK(menuCloseCallback), this); >- g_main_loop_quit(m_mainLoop); >- } >- >- void clickAtPositionAndWaitUntilOptionMenuShown(int x, int y) >- { >- m_menu = nullptr; >- RunLoop::main().dispatch([this, x, y] { clickMouseButton(x, y); }); >- g_main_loop_run(m_mainLoop); >- } >- >- void close() >- { >- g_assert_nonnull(m_menu.get()); >- webkit_option_menu_close(m_menu.get()); >- g_assert_null(m_menu.get()); >- } >- >- void activateItem(unsigned item) >- { >- g_assert_nonnull(m_menu.get()); >- webkit_option_menu_activate_item(m_menu.get(), item); >- g_assert_nonnull(m_menu.get()); >- } >- >- void selectItem(unsigned item) >- { >- g_assert_nonnull(m_menu.get()); >- webkit_option_menu_select_item(m_menu.get(), item); >- g_assert_nonnull(m_menu.get()); >- } >- >- GRefPtr<WebKitOptionMenu> m_menu; >- GdkRectangle m_rectangle; >-}; >- >-static void testOptionMenuSimple(OptionMenuTest* test, gconstpointer) >-{ >- static const char html[] = >- "<html><body>" >- " <select style='position:absolute; left:1; top:10'>" >- " <option title='The Foo Option'>Foo</option>" >- " <option selected>Bar</option>" >- " <option disabled>Baz</option>" >- " </select></body></html>"; >- test->showInWindowAndWaitUntilMapped(); >- test->loadHtml(html, nullptr); >- test->waitUntilLoadFinished(); >- >- test->clickAtPositionAndWaitUntilOptionMenuShown(5, 15); >- g_assert_true(WEBKIT_IS_OPTION_MENU(test->m_menu.get())); >- g_assert_cmpint(webkit_option_menu_get_n_items(test->m_menu.get()), ==, 3); >- auto* item = webkit_option_menu_get_item(test->m_menu.get(), 0); >- g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Foo"); >- g_assert_cmpstr(webkit_option_menu_item_get_tooltip(item), ==, "The Foo Option"); >- g_assert_false(webkit_option_menu_item_is_group_label(item)); >- g_assert_false(webkit_option_menu_item_is_group_child(item)); >- g_assert_true(webkit_option_menu_item_is_enabled(item)); >- g_assert_false(webkit_option_menu_item_is_selected(item)); >- item = webkit_option_menu_get_item(test->m_menu.get(), 1); >- g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Bar"); >- g_assert_null(webkit_option_menu_item_get_tooltip(item)); >- g_assert_false(webkit_option_menu_item_is_group_label(item)); >- g_assert_false(webkit_option_menu_item_is_group_child(item)); >- g_assert_true(webkit_option_menu_item_is_enabled(item)); >- g_assert_true(webkit_option_menu_item_is_selected(item)); >- item = webkit_option_menu_get_item(test->m_menu.get(), 2); >- g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Baz"); >- g_assert_null(webkit_option_menu_item_get_tooltip(item)); >- g_assert_false(webkit_option_menu_item_is_group_label(item)); >- g_assert_false(webkit_option_menu_item_is_group_child(item)); >- g_assert_false(webkit_option_menu_item_is_enabled(item)); >- g_assert_false(webkit_option_menu_item_is_selected(item)); >- >- test->close(); >- g_assert_null(test->m_menu.get()); >-} >- >-static void testOptionMenuGroups(OptionMenuTest* test, gconstpointer) >-{ >- static const char html[] = >- "<html><body>" >- " <select style='position:absolute; left:1; top:10'>" >- " <option>Root</option>" >- " <optgroup label='Group 1'>" >- " <option>Child 1-1</option>" >- " <option disabled>Child 1-2</option>" >- " </optgroup>" >- " <optgroup label='Group 2'>" >- " <option selected>Child 2-1</option>" >- " <option>Child 2-2</option>" >- " </optgroup>" >- " <option>Tail</option>" >- " </select></body></html>"; >- test->showInWindowAndWaitUntilMapped(); >- test->loadHtml(html, nullptr); >- test->waitUntilLoadFinished(); >- >- test->clickAtPositionAndWaitUntilOptionMenuShown(5, 15); >- g_assert_true(WEBKIT_IS_OPTION_MENU(test->m_menu.get())); >- g_assert_cmpint(webkit_option_menu_get_n_items(test->m_menu.get()), ==, 8); >- auto* item = webkit_option_menu_get_item(test->m_menu.get(), 0); >- g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Root"); >- g_assert_null(webkit_option_menu_item_get_tooltip(item)); >- g_assert_false(webkit_option_menu_item_is_group_label(item)); >- g_assert_false(webkit_option_menu_item_is_group_child(item)); >- g_assert_true(webkit_option_menu_item_is_enabled(item)); >- g_assert_false(webkit_option_menu_item_is_selected(item)); >- item = webkit_option_menu_get_item(test->m_menu.get(), 1); >- g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Group 1"); >- g_assert_null(webkit_option_menu_item_get_tooltip(item)); >- g_assert_true(webkit_option_menu_item_is_group_label(item)); >- g_assert_false(webkit_option_menu_item_is_group_child(item)); >- g_assert_false(webkit_option_menu_item_is_enabled(item)); >- g_assert_false(webkit_option_menu_item_is_selected(item)); >- item = webkit_option_menu_get_item(test->m_menu.get(), 2); >- g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Child 1-1"); >- g_assert_null(webkit_option_menu_item_get_tooltip(item)); >- g_assert_false(webkit_option_menu_item_is_group_label(item)); >- g_assert_true(webkit_option_menu_item_is_group_child(item)); >- g_assert_true(webkit_option_menu_item_is_enabled(item)); >- g_assert_false(webkit_option_menu_item_is_selected(item)); >- item = webkit_option_menu_get_item(test->m_menu.get(), 3); >- g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Child 1-2"); >- g_assert_null(webkit_option_menu_item_get_tooltip(item)); >- g_assert_false(webkit_option_menu_item_is_group_label(item)); >- g_assert_true(webkit_option_menu_item_is_group_child(item)); >- g_assert_false(webkit_option_menu_item_is_enabled(item)); >- g_assert_false(webkit_option_menu_item_is_selected(item)); >- item = webkit_option_menu_get_item(test->m_menu.get(), 4); >- g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Group 2"); >- g_assert_null(webkit_option_menu_item_get_tooltip(item)); >- g_assert_true(webkit_option_menu_item_is_group_label(item)); >- g_assert_false(webkit_option_menu_item_is_group_child(item)); >- g_assert_false(webkit_option_menu_item_is_enabled(item)); >- g_assert_false(webkit_option_menu_item_is_selected(item)); >- item = webkit_option_menu_get_item(test->m_menu.get(), 5); >- g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Child 2-1"); >- g_assert_null(webkit_option_menu_item_get_tooltip(item)); >- g_assert_false(webkit_option_menu_item_is_group_label(item)); >- g_assert_true(webkit_option_menu_item_is_group_child(item)); >- g_assert_true(webkit_option_menu_item_is_enabled(item)); >- g_assert_true(webkit_option_menu_item_is_selected(item)); >- item = webkit_option_menu_get_item(test->m_menu.get(), 6); >- g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Child 2-2"); >- g_assert_null(webkit_option_menu_item_get_tooltip(item)); >- g_assert_false(webkit_option_menu_item_is_group_label(item)); >- g_assert_true(webkit_option_menu_item_is_group_child(item)); >- g_assert_true(webkit_option_menu_item_is_enabled(item)); >- g_assert_false(webkit_option_menu_item_is_selected(item)); >- item = webkit_option_menu_get_item(test->m_menu.get(), 7); >- g_assert_cmpstr(webkit_option_menu_item_get_label(item), ==, "Tail"); >- g_assert_null(webkit_option_menu_item_get_tooltip(item)); >- g_assert_false(webkit_option_menu_item_is_group_label(item)); >- g_assert_false(webkit_option_menu_item_is_group_child(item)); >- g_assert_true(webkit_option_menu_item_is_enabled(item)); >- g_assert_false(webkit_option_menu_item_is_selected(item)); >-} >- >-static void testOptionMenuActivate(OptionMenuTest* test, gconstpointer) >-{ >- static const char html[] = >- "<html><body>" >- " <select id='combo' style='position:absolute; left:1; top:10'>" >- " <option>Foo</option>" >- " <option>Bar</option>" >- " <option>Baz</option>" >- " </select></body></html>"; >- test->showInWindowAndWaitUntilMapped(); >- test->loadHtml(html, nullptr); >- test->waitUntilLoadFinished(); >- >- test->clickAtPositionAndWaitUntilOptionMenuShown(5, 15); >- g_assert_true(WEBKIT_IS_OPTION_MENU(test->m_menu.get())); >- g_assert_cmpint(webkit_option_menu_get_n_items(test->m_menu.get()), ==, 3); >- test->activateItem(1); >- auto* result = test->runJavaScriptAndWaitUntilFinished("document.getElementById('combo').selectedIndex", nullptr); >- g_assert_nonnull(result); >- g_assert_cmpfloat(WebViewTest::javascriptResultToNumber(result), ==, 1); >- >- // We should close the menu after activate, further activates will be ignored. >- test->activateItem(2); >- result = test->runJavaScriptAndWaitUntilFinished("document.getElementById('combo').selectedIndex", nullptr); >- g_assert_nonnull(result); >- g_assert_cmpfloat(WebViewTest::javascriptResultToNumber(result), ==, 1); >- >- test->close(); >-} >- >-static void testOptionMenuSelect(OptionMenuTest* test, gconstpointer) >-{ >- static const char html[] = >- "<html><body>" >- " <select id='combo' style='position:absolute; left:1; top:10'>" >- " <option>Foo</option>" >- " <option>Bar</option>" >- " <option>Baz</option>" >- " </select></body></html>"; >- test->showInWindowAndWaitUntilMapped(); >- test->loadHtml(html, nullptr); >- test->waitUntilLoadFinished(); >- >- test->clickAtPositionAndWaitUntilOptionMenuShown(5, 15); >- g_assert_true(WEBKIT_IS_OPTION_MENU(test->m_menu.get())); >- g_assert_cmpint(webkit_option_menu_get_n_items(test->m_menu.get()), ==, 3); >- >- // Select item changes the combo text, but not the currently selected item. >- test->selectItem(2); >- auto* result = test->runJavaScriptAndWaitUntilFinished("document.getElementById('combo').selectedIndex", nullptr); >- g_assert_nonnull(result); >- g_assert_cmpfloat(WebViewTest::javascriptResultToNumber(result), ==, 0); >- >- // It can be called multiple times. >- test->selectItem(1); >- result = test->runJavaScriptAndWaitUntilFinished("document.getElementById('combo').selectedIndex", nullptr); >- g_assert_nonnull(result); >- g_assert_cmpfloat(WebViewTest::javascriptResultToNumber(result), ==, 0); >- >- // And closing the menu activates the currently selected item. >- test->close(); >- result = test->runJavaScriptAndWaitUntilFinished("document.getElementById('combo').selectedIndex", nullptr); >- g_assert_nonnull(result); >- g_assert_cmpfloat(WebViewTest::javascriptResultToNumber(result), ==, 1); >-} >- >-void beforeAll() >-{ >- OptionMenuTest::add("WebKitWebView", "option-menu-simple", testOptionMenuSimple); >- OptionMenuTest::add("WebKitWebView", "option-menu-groups", testOptionMenuGroups); >- OptionMenuTest::add("WebKitWebView", "option-menu-activate", testOptionMenuActivate); >- OptionMenuTest::add("WebKitWebView", "option-menu-select", testOptionMenuSelect); >-} >- >-void afterAll() >-{ >-} >diff --git a/Tools/TestWebKitAPI/glib/CMakeLists.txt b/Tools/TestWebKitAPI/glib/CMakeLists.txt >index 12aaf5f132c5f7185a64c85159e6fd3b3268a27f..35bebee6397fa4a40d201b30c940bde7e19dd43d 100644 >--- a/Tools/TestWebKitAPI/glib/CMakeLists.txt >+++ b/Tools/TestWebKitAPI/glib/CMakeLists.txt >@@ -127,6 +127,7 @@ ADD_WK2_TEST(TestEditor ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGLib/TestEditor.c > ADD_WK2_TEST(TestFrame ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGLib/TestFrame.cpp) > ADD_WK2_TEST(TestLoaderClient ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGLib/TestLoaderClient.cpp) > ADD_WK2_TEST(TestMultiprocess ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGLib/TestMultiprocess.cpp) >+ADD_WK2_TEST(TestOptionMenu ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp) > ADD_WK2_TEST(TestResources ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGLib/TestResources.cpp) > ADD_WK2_TEST(TestSSL ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGLib/TestSSL.cpp) > ADD_WK2_TEST(TestUIClient ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp) >diff --git a/Tools/TestWebKitAPI/glib/PlatformGTK.cmake b/Tools/TestWebKitAPI/glib/PlatformGTK.cmake >index 9b23e74abde0c1b1b4ee479e1209737bafa2f267..a586a6a68a3557af8563d73936afa3f4cb7cc899 100644 >--- a/Tools/TestWebKitAPI/glib/PlatformGTK.cmake >+++ b/Tools/TestWebKitAPI/glib/PlatformGTK.cmake >@@ -41,7 +41,6 @@ ADD_WK2_TEST(TestDOMNodeFilter ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGtk/TestDO > ADD_WK2_TEST(TestDOMXPathNSResolver ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGtk/TestDOMXPathNSResolver.cpp) > ADD_WK2_TEST(TestInspector ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp) > ADD_WK2_TEST(TestInspectorServer ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGtk/TestInspectorServer.cpp) >-ADD_WK2_TEST(TestOptionMenu ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGtk/TestOptionMenu.cpp) > ADD_WK2_TEST(TestPrinting ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp) > ADD_WK2_TEST(TestWebKitFaviconDatabase ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGLib/TestWebKitFaviconDatabase.cpp) > ADD_WK2_TEST(TestWebKitVersion ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGtk/TestWebKitVersion.cpp)
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 206287
:
387787
|
387915
|
388015
|
388218
|
388224