Title: [190717] trunk
Revision
190717
Author
[email protected]
Date
2015-10-08 03:06:41 -0700 (Thu, 08 Oct 2015)

Log Message

[GTK] Stop using a nested main loop for popup menus
https://bugs.webkit.org/show_bug.cgi?id=149920

Reviewed by Sergio Villar Senin.

Source/WebKit2:

WebPageProxy used to expect the popup menus to run in a nested
main loop and invalidated the menu right after showing it. But
this is no longer the case, so there's no reason to keep using
the nested main loop.

* UIProcess/gtk/WebPopupMenuProxyGtk.cpp:
(WebKit::WebPopupMenuProxyGtk::~WebPopupMenuProxyGtk):
(WebKit::WebPopupMenuProxyGtk::cancelTracking):
(WebKit::WebPopupMenuProxyGtk::menuItemActivated):
(WebKit::WebPopupMenuProxyGtk::WebPopupMenuProxyGtk): Deleted.
(WebKit::WebPopupMenuProxyGtk::showPopupMenu): Deleted.
(WebKit::WebPopupMenuProxyGtk::shutdownRunLoop): Deleted.
(WebKit::WebPopupMenuProxyGtk::menuUnmapped): Deleted.
* UIProcess/gtk/WebPopupMenuProxyGtk.h:
(WebKit::WebPopupMenuProxyGtk::setActiveItem): Deleted.

LayoutTests:

Unskip platform/gtk/fast/forms/menulist-typeahead-find.html that
was timing out because of the nested main loop.

* platform/gtk/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (190716 => 190717)


--- trunk/LayoutTests/ChangeLog	2015-10-08 09:55:30 UTC (rev 190716)
+++ trunk/LayoutTests/ChangeLog	2015-10-08 10:06:41 UTC (rev 190717)
@@ -1,5 +1,17 @@
 2015-10-08  Carlos Garcia Campos  <[email protected]>
 
+        [GTK] Stop using a nested main loop for popup menus
+        https://bugs.webkit.org/show_bug.cgi?id=149920
+
+        Reviewed by Sergio Villar Senin.
+
+        Unskip platform/gtk/fast/forms/menulist-typeahead-find.html that
+        was timing out because of the nested main loop.
+
+        * platform/gtk/TestExpectations:
+
+2015-10-08  Carlos Garcia Campos  <[email protected]>
+
         Unreviewed GTK+ gardening. Mark several inspector tests as slow.
 
         * platform/gtk/TestExpectations:

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (190716 => 190717)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2015-10-08 09:55:30 UTC (rev 190716)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2015-10-08 10:06:41 UTC (rev 190717)
@@ -1586,7 +1586,6 @@
 Bug(GTK) http/tests/security/storage-blocking-strengthened-plugin.html [ Failure ]
 Bug(GTK) http/tests/security/storage-blocking-strengthened-private-browsing-plugin.html [ Failure ]
 Bug(GTK) platform/gtk/fast/events/event-sender-metakey.html [ Failure ]
-Bug(GTK) platform/gtk/fast/forms/menulist-typeahead-find.html [ Failure ]
 Bug(GTK) plugins/keyboard-events.html [ Failure ]
 Bug(GTK) plugins/netscape-plugin-setwindow-size-2.html [ Failure ]
 Bug(GTK) plugins/npp-set-window-called-during-destruction.html [ Failure ]

Modified: trunk/Source/WebKit2/ChangeLog (190716 => 190717)


--- trunk/Source/WebKit2/ChangeLog	2015-10-08 09:55:30 UTC (rev 190716)
+++ trunk/Source/WebKit2/ChangeLog	2015-10-08 10:06:41 UTC (rev 190717)
@@ -1,3 +1,26 @@
+2015-10-08  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Stop using a nested main loop for popup menus
+        https://bugs.webkit.org/show_bug.cgi?id=149920
+
+        Reviewed by Sergio Villar Senin.
+
+        WebPageProxy used to expect the popup menus to run in a nested
+        main loop and invalidated the menu right after showing it. But
+        this is no longer the case, so there's no reason to keep using
+        the nested main loop.
+
+        * UIProcess/gtk/WebPopupMenuProxyGtk.cpp:
+        (WebKit::WebPopupMenuProxyGtk::~WebPopupMenuProxyGtk):
+        (WebKit::WebPopupMenuProxyGtk::cancelTracking):
+        (WebKit::WebPopupMenuProxyGtk::menuItemActivated):
+        (WebKit::WebPopupMenuProxyGtk::WebPopupMenuProxyGtk): Deleted.
+        (WebKit::WebPopupMenuProxyGtk::showPopupMenu): Deleted.
+        (WebKit::WebPopupMenuProxyGtk::shutdownRunLoop): Deleted.
+        (WebKit::WebPopupMenuProxyGtk::menuUnmapped): Deleted.
+        * UIProcess/gtk/WebPopupMenuProxyGtk.h:
+        (WebKit::WebPopupMenuProxyGtk::setActiveItem): Deleted.
+
 2015-10-07  Anders Carlsson  <[email protected]>
 
         Add API for getting a group identifier from a bundle page

Modified: trunk/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.cpp (190716 => 190717)


--- trunk/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.cpp	2015-10-08 09:55:30 UTC (rev 190716)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.cpp	2015-10-08 10:06:41 UTC (rev 190717)
@@ -42,7 +42,6 @@
     : WebPopupMenuProxy(client)
     , m_webView(webView)
     , m_popup(gtk_menu_new())
-    , m_activeItem(-1)
     , m_previousKeyEventCharacter(0)
     , m_previousKeyEventTimestamp(0)
     , m_currentlySelectedMenuItem(nullptr)
@@ -52,11 +51,7 @@
 
 WebPopupMenuProxyGtk::~WebPopupMenuProxyGtk()
 {
-    if (m_popup) {
-        g_signal_handlers_disconnect_matched(m_popup, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
-        hidePopupMenu();
-        gtk_widget_destroy(m_popup);
-    }
+    cancelTracking();
 }
 
 GtkAction* WebPopupMenuProxyGtk::createGtkActionForMenuItem(const WebPopupItem& item, int itemIndex)
@@ -127,8 +122,6 @@
         menuPosition.setY(menuPosition.y() - rect.height() / 2);
     }
 
-    gulong unmapHandler = g_signal_connect(m_popup, "unmap", G_CALLBACK(menuUnmapped), this);
-
     const GdkEvent* event = m_client->currentlyProcessedMouseDownEvent() ? m_client->currentlyProcessedMouseDownEvent()->nativeEvent() : nullptr;
     gtk_menu_popup_for_device(GTK_MENU(m_popup), event ? gdk_event_get_device(event) : nullptr, nullptr, nullptr,
         [](GtkMenu*, gint* x, gint* y, gboolean* pushIn, gpointer userData) {
@@ -149,27 +142,6 @@
        m_client->failedToShowPopupMenu();
        return;
     }
-
-    // WebPageProxy expects the menu to run in a nested run loop, since it invalidates the
-    // menu right after calling WebPopupMenuProxy::showPopupMenu().
-    m_runLoop = adoptGRef(g_main_loop_new(nullptr, FALSE));
-
-// This is to suppress warnings about gdk_threads_leave and gdk_threads_enter.
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-    gdk_threads_leave();
-    g_main_loop_run(m_runLoop.get());
-    gdk_threads_enter();
-#pragma GCC diagnostic pop
-
-    m_runLoop.clear();
-
-    g_signal_handler_disconnect(m_popup, unmapHandler);
-
-    if (!m_client)
-        return;
-
-    m_client->valueChangedForPopupMenu(this, m_activeItem);
 }
 
 void WebPopupMenuProxyGtk::hidePopupMenu()
@@ -178,6 +150,17 @@
     resetTypeAheadFindState();
 }
 
+void WebPopupMenuProxyGtk::cancelTracking()
+{
+    if (!m_popup)
+        return;
+
+    g_signal_handlers_disconnect_matched(m_popup, G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this);
+    hidePopupMenu();
+    gtk_widget_destroy(m_popup);
+    m_popup = nullptr;
+}
+
 bool WebPopupMenuProxyGtk::typeAheadFind(GdkEventKey* event)
 {
     // If we were given a non-printable character just skip it.
@@ -256,23 +239,12 @@
     m_currentSearchString = emptyString();
 }
 
-void WebPopupMenuProxyGtk::shutdownRunLoop()
-{
-    if (g_main_loop_is_running(m_runLoop.get()))
-        g_main_loop_quit(m_runLoop.get());
-}
-
 void WebPopupMenuProxyGtk::menuItemActivated(GtkAction* action, WebPopupMenuProxyGtk* popupMenu)
 {
-    popupMenu->setActiveItem(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "popup-menu-action-index")));
-    popupMenu->shutdownRunLoop();
+    if (popupMenu->m_client)
+        popupMenu->m_client->valueChangedForPopupMenu(popupMenu, GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "popup-menu-action-index")));
 }
 
-void WebPopupMenuProxyGtk::menuUnmapped(GtkWidget*, WebPopupMenuProxyGtk* popupMenu)
-{
-    popupMenu->shutdownRunLoop();
-}
-
 void WebPopupMenuProxyGtk::selectItemCallback(GtkWidget* item, WebPopupMenuProxyGtk* popupMenu)
 {
     popupMenu->setCurrentlySelectedMenuItem(item);

Modified: trunk/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.h (190716 => 190717)


--- trunk/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.h	2015-10-08 09:55:30 UTC (rev 190716)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.h	2015-10-08 10:06:41 UTC (rev 190717)
@@ -43,13 +43,13 @@
     }
     ~WebPopupMenuProxyGtk();
 
-    virtual void showPopupMenu(const WebCore::IntRect&, WebCore::TextDirection, double pageScaleFactor, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex);
-    virtual void hidePopupMenu();
+    virtual void showPopupMenu(const WebCore::IntRect&, WebCore::TextDirection, double pageScaleFactor, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex) override;
+    virtual void hidePopupMenu() override;
+    virtual void cancelTracking() override;
 
 private:
     WebPopupMenuProxyGtk(GtkWidget*, WebPopupMenuProxy::Client*);
-    void shutdownRunLoop();
-    void setActiveItem(int activeItem) { m_activeItem = activeItem; }
+
     void setCurrentlySelectedMenuItem(GtkWidget* item) { m_currentlySelectedMenuItem = item; }
     GtkAction* createGtkActionForMenuItem(const WebPopupItem&, int itemIndex);
     void populatePopupMenu(const Vector<WebPopupItem>&);
@@ -58,14 +58,11 @@
     void resetTypeAheadFindState();
 
     static void menuItemActivated(GtkAction*, WebPopupMenuProxyGtk*);
-    static void menuUnmapped(GtkWidget*, WebPopupMenuProxyGtk*);
     static void selectItemCallback(GtkWidget*, WebPopupMenuProxyGtk*);
     static gboolean keyPressEventCallback(GtkWidget*, GdkEventKey*, WebPopupMenuProxyGtk*);
 
     GtkWidget* m_webView;
     GtkWidget* m_popup;
-    int m_activeItem;
-    GRefPtr<GMainLoop> m_runLoop;
 
     // Typeahead find.
     unsigned m_previousKeyEventCharacter;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to