Changeset 190717 in webkit


Ignore:
Timestamp:
Oct 8, 2015 3:06:41 AM (9 years ago)
Author:
Carlos Garcia Campos
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:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r190715 r190717  
     12015-10-08  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Stop using a nested main loop for popup menus
     4        https://bugs.webkit.org/show_bug.cgi?id=149920
     5
     6        Reviewed by Sergio Villar Senin.
     7
     8        Unskip platform/gtk/fast/forms/menulist-typeahead-find.html that
     9        was timing out because of the nested main loop.
     10
     11        * platform/gtk/TestExpectations:
     12
    1132015-10-08  Carlos Garcia Campos  <cgarcia@igalia.com>
    214
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r190715 r190717  
    15871587Bug(GTK) http/tests/security/storage-blocking-strengthened-private-browsing-plugin.html [ Failure ]
    15881588Bug(GTK) platform/gtk/fast/events/event-sender-metakey.html [ Failure ]
    1589 Bug(GTK) platform/gtk/fast/forms/menulist-typeahead-find.html [ Failure ]
    15901589Bug(GTK) plugins/keyboard-events.html [ Failure ]
    15911590Bug(GTK) plugins/netscape-plugin-setwindow-size-2.html [ Failure ]
  • trunk/Source/WebKit2/ChangeLog

    r190693 r190717  
     12015-10-08  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Stop using a nested main loop for popup menus
     4        https://bugs.webkit.org/show_bug.cgi?id=149920
     5
     6        Reviewed by Sergio Villar Senin.
     7
     8        WebPageProxy used to expect the popup menus to run in a nested
     9        main loop and invalidated the menu right after showing it. But
     10        this is no longer the case, so there's no reason to keep using
     11        the nested main loop.
     12
     13        * UIProcess/gtk/WebPopupMenuProxyGtk.cpp:
     14        (WebKit::WebPopupMenuProxyGtk::~WebPopupMenuProxyGtk):
     15        (WebKit::WebPopupMenuProxyGtk::cancelTracking):
     16        (WebKit::WebPopupMenuProxyGtk::menuItemActivated):
     17        (WebKit::WebPopupMenuProxyGtk::WebPopupMenuProxyGtk): Deleted.
     18        (WebKit::WebPopupMenuProxyGtk::showPopupMenu): Deleted.
     19        (WebKit::WebPopupMenuProxyGtk::shutdownRunLoop): Deleted.
     20        (WebKit::WebPopupMenuProxyGtk::menuUnmapped): Deleted.
     21        * UIProcess/gtk/WebPopupMenuProxyGtk.h:
     22        (WebKit::WebPopupMenuProxyGtk::setActiveItem): Deleted.
     23
    1242015-10-07  Anders Carlsson  <andersca@apple.com>
    225
  • trunk/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.cpp

    r187542 r190717  
    4343    , m_webView(webView)
    4444    , m_popup(gtk_menu_new())
    45     , m_activeItem(-1)
    4645    , m_previousKeyEventCharacter(0)
    4746    , m_previousKeyEventTimestamp(0)
     
    5352WebPopupMenuProxyGtk::~WebPopupMenuProxyGtk()
    5453{
    55     if (m_popup) {
    56         g_signal_handlers_disconnect_matched(m_popup, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
    57         hidePopupMenu();
    58         gtk_widget_destroy(m_popup);
    59     }
     54    cancelTracking();
    6055}
    6156
     
    128123    }
    129124
    130     gulong unmapHandler = g_signal_connect(m_popup, "unmap", G_CALLBACK(menuUnmapped), this);
    131 
    132125    const GdkEvent* event = m_client->currentlyProcessedMouseDownEvent() ? m_client->currentlyProcessedMouseDownEvent()->nativeEvent() : nullptr;
    133126    gtk_menu_popup_for_device(GTK_MENU(m_popup), event ? gdk_event_get_device(event) : nullptr, nullptr, nullptr,
     
    150143       return;
    151144    }
    152 
    153     // WebPageProxy expects the menu to run in a nested run loop, since it invalidates the
    154     // menu right after calling WebPopupMenuProxy::showPopupMenu().
    155     m_runLoop = adoptGRef(g_main_loop_new(nullptr, FALSE));
    156 
    157 // This is to suppress warnings about gdk_threads_leave and gdk_threads_enter.
    158 #pragma GCC diagnostic push
    159 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
    160     gdk_threads_leave();
    161     g_main_loop_run(m_runLoop.get());
    162     gdk_threads_enter();
    163 #pragma GCC diagnostic pop
    164 
    165     m_runLoop.clear();
    166 
    167     g_signal_handler_disconnect(m_popup, unmapHandler);
    168 
    169     if (!m_client)
    170         return;
    171 
    172     m_client->valueChangedForPopupMenu(this, m_activeItem);
    173145}
    174146
     
    177149    gtk_menu_popdown(GTK_MENU(m_popup));
    178150    resetTypeAheadFindState();
     151}
     152
     153void WebPopupMenuProxyGtk::cancelTracking()
     154{
     155    if (!m_popup)
     156        return;
     157
     158    g_signal_handlers_disconnect_matched(m_popup, G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this);
     159    hidePopupMenu();
     160    gtk_widget_destroy(m_popup);
     161    m_popup = nullptr;
    179162}
    180163
     
    257240}
    258241
    259 void WebPopupMenuProxyGtk::shutdownRunLoop()
    260 {
    261     if (g_main_loop_is_running(m_runLoop.get()))
    262         g_main_loop_quit(m_runLoop.get());
    263 }
    264 
    265242void WebPopupMenuProxyGtk::menuItemActivated(GtkAction* action, WebPopupMenuProxyGtk* popupMenu)
    266243{
    267     popupMenu->setActiveItem(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "popup-menu-action-index")));
    268     popupMenu->shutdownRunLoop();
    269 }
    270 
    271 void WebPopupMenuProxyGtk::menuUnmapped(GtkWidget*, WebPopupMenuProxyGtk* popupMenu)
    272 {
    273     popupMenu->shutdownRunLoop();
     244    if (popupMenu->m_client)
     245        popupMenu->m_client->valueChangedForPopupMenu(popupMenu, GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "popup-menu-action-index")));
    274246}
    275247
  • trunk/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.h

    r185637 r190717  
    4444    ~WebPopupMenuProxyGtk();
    4545
    46     virtual void showPopupMenu(const WebCore::IntRect&, WebCore::TextDirection, double pageScaleFactor, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex);
    47     virtual void hidePopupMenu();
     46    virtual void showPopupMenu(const WebCore::IntRect&, WebCore::TextDirection, double pageScaleFactor, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex) override;
     47    virtual void hidePopupMenu() override;
     48    virtual void cancelTracking() override;
    4849
    4950private:
    5051    WebPopupMenuProxyGtk(GtkWidget*, WebPopupMenuProxy::Client*);
    51     void shutdownRunLoop();
    52     void setActiveItem(int activeItem) { m_activeItem = activeItem; }
     52
    5353    void setCurrentlySelectedMenuItem(GtkWidget* item) { m_currentlySelectedMenuItem = item; }
    5454    GtkAction* createGtkActionForMenuItem(const WebPopupItem&, int itemIndex);
     
    5959
    6060    static void menuItemActivated(GtkAction*, WebPopupMenuProxyGtk*);
    61     static void menuUnmapped(GtkWidget*, WebPopupMenuProxyGtk*);
    6261    static void selectItemCallback(GtkWidget*, WebPopupMenuProxyGtk*);
    6362    static gboolean keyPressEventCallback(GtkWidget*, GdkEventKey*, WebPopupMenuProxyGtk*);
     
    6564    GtkWidget* m_webView;
    6665    GtkWidget* m_popup;
    67     int m_activeItem;
    68     GRefPtr<GMainLoop> m_runLoop;
    6966
    7067    // Typeahead find.
Note: See TracChangeset for help on using the changeset viewer.