Changeset 107351 in webkit


Ignore:
Timestamp:
Feb 9, 2012 8:33:33 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[GTK] Add DRT support for modal dialogs
https://bugs.webkit.org/show_bug.cgi?id=53600

Patch by Zan Dobersek <zandobersek@gmail.com> on 2012-02-09
Reviewed by Martin Robinson.

Source/WebKit/gtk:

Add support for running modal dialogs.

A new signal is added to the WebKitWebView. When emitted, the web view
is requesting to be displayed as a modal dialog. If accepted, the
ChromeClient then establishes a loop that is run until the chrome is destroyed.
If denied, nothing is done.

  • WebCoreSupport/ChromeClientGtk.cpp:

(WebKit::ChromeClient::ChromeClient):
(WebKit::ChromeClient::chromeDestroyed):
(WebKit::ChromeClient::canRunModal):
(WebKit::ChromeClient::runModal):

  • WebCoreSupport/ChromeClientGtk.h:

(ChromeClient):

  • webkit/webkitwebview.cpp:

(webkit_web_view_class_init):

Tools:

Implement the modal dialogs handling in DumpRenderTree and GtkLauncher.
Most significantly, when creating a new web view in GtkLauncher, the window
of the web view opener is passed around. In DumpRenderTree, the window of
the main web view is always considered as the opener. This is required so
the modal dialog's toplevel can be made transient for the opener's toplevel.

  • DumpRenderTree/gtk/DumpRenderTree.cpp:

(webViewRunModalDialog):
(createWebView):

  • GtkLauncher/main.c:

(createWebViewCb):
(runModalDialogCb):
(createBrowser):
(createWindow):
(main):

LayoutTests:

Unskip the passing modal dialogs tests and log the remaining skipped test.

  • platform/gtk/Skipped:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r107350 r107351  
     12012-02-09  Zan Dobersek  <zandobersek@gmail.com>
     2
     3        [GTK] Add DRT support for modal dialogs
     4        https://bugs.webkit.org/show_bug.cgi?id=53600
     5
     6        Reviewed by Martin Robinson.
     7
     8        Unskip the passing modal dialogs tests and log the remaining skipped test.
     9
     10        * platform/gtk/Skipped:
     11
    1122012-02-09  Zan Dobersek  <zandobersek@gmail.com>
    213
  • trunk/LayoutTests/platform/gtk/Skipped

    r107350 r107351  
    925925canvas/philip/tests/2d.pattern.paint.repeaty.outside.html
    926926
    927 # Tests that user modal dialogs fail in the DRT for some reason.
    928 # https://bugs.webkit.org/show_bug.cgi?id=53600
    929 fast/animation/request-animation-frame-during-modal.html
     927# This modal dialog test still fails because the blur event is not dispatched on the opener
     928# window when running the modal dialog.
    930929fast/events/show-modal-dialog-onblur-onfocus.html
    931 fast/events/scroll-event-during-modal-dialog.html
    932 fast/harness/show-modal-dialog.html
    933 inspector/console/console-long-eval-crash.html
    934 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.2_T10.html
    935 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.1_T11.html
    936 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.1_T2.html
    937 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.2_T2.html
    938 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.1_T4.html
    939 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.2_T4.html
    940 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.1_T6.html
    941 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.2_T6.html
    942 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.1_T8.html
    943 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.2_T8.html
    944 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.1_T10.html
    945 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.2_T11.html
    946 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.1_T1.html
    947 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.2_T1.html
    948 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.1_T3.html
    949 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.2_T3.html
    950 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.1_T5.html
    951 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.2_T5.html
    952 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.1_T7.html
    953 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.2_T7.html
    954 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.1_T9.html
    955 sputnik/Conformance/10_Execution_Contexts/10.2_Entering_An_Execution_Context/10.2.2_Eval_Code/S10.2.2_A1.2_T9.html
    956930
    957931# pastes a space instead of a tab
  • trunk/Source/WebKit/gtk/ChangeLog

    r107350 r107351  
     12012-02-09  Zan Dobersek  <zandobersek@gmail.com>
     2
     3        [GTK] Add DRT support for modal dialogs
     4        https://bugs.webkit.org/show_bug.cgi?id=53600
     5
     6        Reviewed by Martin Robinson.
     7
     8        Add support for running modal dialogs.
     9
     10        A new signal is added to the WebKitWebView. When emitted, the web view
     11        is requesting to be displayed as a modal dialog. If accepted, the
     12        ChromeClient then establishes a loop that is run until the chrome is destroyed.
     13        If denied, nothing is done.
     14
     15        * WebCoreSupport/ChromeClientGtk.cpp:
     16        (WebKit::ChromeClient::ChromeClient):
     17        (WebKit::ChromeClient::chromeDestroyed):
     18        (WebKit::ChromeClient::canRunModal):
     19        (WebKit::ChromeClient::runModal):
     20        * WebCoreSupport/ChromeClientGtk.h:
     21        (ChromeClient):
     22        * webkit/webkitwebview.cpp:
     23        (webkit_web_view_class_init):
     24
    1252012-02-09  Zan Dobersek  <zandobersek@gmail.com>
    226
  • trunk/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp

    r106901 r107351  
    8080    , m_adjustmentWatcher(webView)
    8181    , m_closeSoonTimer(0)
     82    , m_modalLoop(0)
    8283    , m_displayTimer(this, &ChromeClient::paint)
    8384    , m_lastDisplayTime(0)
     
    9495    if (m_repaintSoonSourceId)
    9596        g_source_remove(m_repaintSoonSourceId);
     97
     98    if (m_modalLoop)
     99        g_main_loop_quit(m_modalLoop);
    96100
    97101    delete this;
     
    181185bool ChromeClient::canRunModal()
    182186{
    183     notImplemented();
    184     return false;
     187    return true;
    185188}
    186189
    187190void ChromeClient::runModal()
    188191{
    189     notImplemented();
     192    gboolean isHandled = false;
     193    g_signal_emit_by_name(m_webView, "run-modal-dialog", &isHandled);
     194    if (!isHandled)
     195        return;
     196
     197    GMainContext* threadDefaultContext = g_main_context_ref_thread_default();
     198    g_main_context_acquire(threadDefaultContext);
     199
     200    m_modalLoop = g_main_loop_new(threadDefaultContext, FALSE);
     201    g_main_loop_run(m_modalLoop);
     202    g_main_loop_unref(m_modalLoop);
     203    m_modalLoop = 0;
     204
     205    g_main_context_release(threadDefaultContext);
     206    g_main_context_unref(threadDefaultContext);
    190207}
    191208
  • trunk/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h

    r106901 r107351  
    177177        KURL m_hoveredLinkURL;
    178178        unsigned int m_closeSoonTimer;
     179        GMainLoop* m_modalLoop;
    179180
    180181        Timer <ChromeClient> m_displayTimer;
  • trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp

    r107252 r107351  
    213213    RESOURCE_CONTENT_LENGTH_RECEIVED,
    214214    RESOURCE_LOAD_FAILED,
     215    RUN_MODAL_DIALOG,
    215216
    216217    LAST_SIGNAL
     
    27422743            WEBKIT_TYPE_WEB_RESOURCE,
    27432744            G_TYPE_POINTER);
     2745
     2746    /*
     2747     * WebKitWebView::run-modal-dialog
     2748     * @webView: the object which received the signal
     2749     *
     2750     * Invoked when the @webView should be run in the modal mode. This can be
     2751     * avoided if FALSE is returned in the signal handler. Otherwise, the
     2752     * @webView (or its toplevel window) should be made transient for its parent,
     2753     * set as a modal window, and TRUE should be returned in the signal handler.
     2754     * After that, a loop will be created and run until the @webView is closed
     2755     * (i.e. its chrome is destroyed).
     2756     *
     2757     * Since: 1.7.6
     2758     */
     2759    webkit_web_view_signals[RESOURCE_LOAD_FAILED] = g_signal_new("run-modal-dialog",
     2760            G_TYPE_FROM_CLASS(webViewClass),
     2761            G_SIGNAL_RUN_LAST,
     2762            0,
     2763            g_signal_accumulator_true_handled, NULL,
     2764            webkit_marshal_BOOLEAN__VOID,
     2765            G_TYPE_BOOLEAN, 0);
    27442766
    27452767    /*
  • trunk/Tools/ChangeLog

    r107350 r107351  
     12012-02-09  Zan Dobersek  <zandobersek@gmail.com>
     2
     3        [GTK] Add DRT support for modal dialogs
     4        https://bugs.webkit.org/show_bug.cgi?id=53600
     5
     6        Reviewed by Martin Robinson.
     7
     8        Implement the modal dialogs handling in DumpRenderTree and GtkLauncher.
     9        Most significantly, when creating a new web view in GtkLauncher, the window
     10        of the web view opener is passed around. In DumpRenderTree, the window of
     11        the main web view is always considered as the opener. This is required so
     12        the modal dialog's toplevel can be made transient for the opener's toplevel.
     13
     14        * DumpRenderTree/gtk/DumpRenderTree.cpp:
     15        (webViewRunModalDialog):
     16        (createWebView):
     17        * GtkLauncher/main.c:
     18        (createWebViewCb):
     19        (runModalDialogCb):
     20        (createBrowser):
     21        (createWindow):
     22        (main):
     23
    1242012-02-09  Zan Dobersek  <zandobersek@gmail.com>
    225
  • trunk/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp

    r106445 r107351  
    958958}
    959959
     960static gboolean webViewRunModalDialog(WebKitWebView* view)
     961{
     962    GtkWindow* viewTopLevel = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(view)));
     963    gtk_window_set_transient_for(GTK_WINDOW(viewTopLevel), GTK_WINDOW(window));
     964    gtk_window_set_modal(GTK_WINDOW(viewTopLevel), TRUE);
     965
     966    return TRUE;
     967}
     968
    960969static void databaseQuotaExceeded(WebKitWebView* view, WebKitWebFrame* frame, WebKitWebDatabase *database)
    961970{
     
    12831292                     "signal::create-web-view", webViewCreate, 0,
    12841293                     "signal::close-web-view", webViewClose, 0,
     1294                     "signal::run-modal-dialog", webViewRunModalDialog, 0,
    12851295                     "signal::database-quota-exceeded", databaseQuotaExceeded, 0,
    12861296                     "signal::document-load-finished", webViewDocumentLoadFinished, 0,
  • trunk/Tools/GtkLauncher/main.c

    r103927 r107351  
    3434static gint windowCount = 0;
    3535
    36 static GtkWidget* createWindow(WebKitWebView** outWebView);
     36static GtkWidget* createWindow(WebKitWebView** outWebView, GtkWidget* openerWindow);
    3737
    3838static void activateUriEntryCb(GtkWidget* entry, gpointer data)
     
    106106{
    107107    WebKitWebView *newWebView;
    108     createWindow(&newWebView);
     108    createWindow(&newWebView, window);
    109109    webkit_web_view_set_settings(newWebView, webkit_web_view_get_settings(webView));
    110110    return newWebView;
     
    124124}
    125125
    126 static GtkWidget* createBrowser(GtkWidget* window, GtkWidget* uriEntry, GtkWidget* statusbar, WebKitWebView* webView)
     126static gboolean runModalDialogCb(WebKitWebView* webView, GtkWidget* openerWindow)
     127{
     128    if (!openerWindow)
     129        return FALSE;
     130
     131    GtkWidget *window = gtk_widget_get_toplevel(GTK_WIDGET(webView));
     132    gtk_window_set_transient_for(GTK_WINDOW(window), GTK_WINDOW(openerWindow));
     133    gtk_window_set_modal(GTK_WINDOW(window), TRUE);
     134    return TRUE;
     135}
     136
     137static GtkWidget* createBrowser(GtkWidget* window, GtkWidget* uriEntry, GtkWidget* statusbar, WebKitWebView* webView, GtkWidget* openerWindow)
    127138{
    128139    GtkWidget *scrolledWindow = gtk_scrolled_window_new(NULL, NULL);
     
    138149    g_signal_connect(webView, "web-view-ready", G_CALLBACK(webViewReadyCb), window);
    139150    g_signal_connect(webView, "close-web-view", G_CALLBACK(closeWebViewCb), window);
     151    g_signal_connect(webView, "run-modal-dialog", G_CALLBACK(runModalDialogCb), openerWindow);
    140152
    141153    return scrolledWindow;
     
    191203}
    192204
    193 static GtkWidget* createWindow(WebKitWebView** outWebView)
     205static GtkWidget* createWindow(WebKitWebView** outWebView, GtkWidget* openerWindow)
    194206{
    195207    WebKitWebView *webView;
     
    215227    statusbar = createStatusbar(webView);
    216228    gtk_box_pack_start(GTK_BOX(vbox), createToolbar(uriEntry, webView), FALSE, FALSE, 0);
    217     gtk_box_pack_start(GTK_BOX(vbox), createBrowser(window, uriEntry, statusbar, webView), TRUE, TRUE, 0);
     229    gtk_box_pack_start(GTK_BOX(vbox), createBrowser(window, uriEntry, statusbar, webView, openerWindow), TRUE, TRUE, 0);
    218230    gtk_box_pack_start(GTK_BOX(vbox), statusbar, FALSE, FALSE, 0);
    219231
     
    418430
    419431    WebKitWebView *webView;
    420     GtkWidget *main_window = createWindow(&webView);
     432    GtkWidget *main_window = createWindow(&webView, 0);
    421433
    422434    if (webkitSettings) {
Note: See TracChangeset for help on using the changeset viewer.