Changeset 108278 in webkit


Ignore:
Timestamp:
Feb 20, 2012 6:04:29 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[GTK] Web content oftens steals focus from other widgets
https://bugs.webkit.org/show_bug.cgi?id=77791

Patch by Martin Robinson <mrobinson@igalia.com> on 2012-02-20
Reviewed by Gustavo Noronha Silva.

Source/WebCore:

  • platform/gtk/WidgetGtk.cpp:

(WebCore::Widget::setFocus): No longer do anything special to try
to grab "real" widget focus. This matches the behavior on Qt.

  • plugins/gtk/PluginViewGtk.cpp:

(WebCore::PluginView::setFocus): Moved the focus handling to here.
This ensures that behavior for plugins does not change.

Source/WebKit/gtk:

  • tests/testwebview.c: Added a WebKit1 test to verify this behavior.
Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r108276 r108278  
     12012-02-20  Martin Robinson  <mrobinson@igalia.com>
     2
     3        [GTK] Web content oftens steals focus from other widgets
     4        https://bugs.webkit.org/show_bug.cgi?id=77791
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        * platform/gtk/WidgetGtk.cpp:
     9        (WebCore::Widget::setFocus): No longer do anything special to try
     10        to grab "real" widget focus. This matches the behavior on Qt.
     11        * plugins/gtk/PluginViewGtk.cpp:
     12        (WebCore::PluginView::setFocus): Moved the focus handling to here.
     13        This ensures that behavior for plugins does not change.
     14
    1152012-02-20  Yael Aharon  <yael.aharon@nokia.com>
    216
  • trunk/Source/WebCore/platform/gtk/WidgetGtk.cpp

    r88696 r108278  
    5959void Widget::setFocus(bool focused)
    6060{
    61     if (!focused)
    62         return;
    63 
    64     GtkWidget* widget = platformWidget() ? platformWidget() : root()->hostWindow()->platformPageClient();
    65     if (widget) {
    66         gtk_widget_grab_focus(widget);
    67         return;
    68     }
    69 
    70     // We are running WK2.
    71     if (Frame* frame = Frame::frameForWidget(this))
    72         frame->page()->chrome()->focus();
    7361}
    7462
  • trunk/Source/WebCore/plugins/gtk/PluginViewGtk.cpp

    r106155 r108278  
    166166{
    167167    ASSERT(platformPluginWidget() == platformWidget());
     168    if (focused && platformWidget())
     169        gtk_widget_grab_focus(platformWidget());
    168170    Widget::setFocus(focused);
    169171}
  • trunk/Source/WebKit/gtk/ChangeLog

    r108264 r108278  
     12012-02-20  Martin Robinson  <mrobinson@igalia.com>
     2
     3        [GTK] Web content oftens steals focus from other widgets
     4        https://bugs.webkit.org/show_bug.cgi?id=77791
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        * tests/testwebview.c: Added a WebKit1 test to verify this behavior.
     9
    1102012-02-20  Gustavo Noronha Silva  <gns@gnome.org>
    211
  • trunk/Source/WebKit/gtk/tests/testwebview.c

    r106559 r108278  
    383383}
    384384
     385static void test_webkit_web_view_does_not_steal_focus()
     386{
     387    loop = g_main_loop_new(NULL, TRUE);
     388
     389    GtkWidget *window = gtk_offscreen_window_new();
     390    GtkWidget *webView = webkit_web_view_new();
     391    GtkWidget *entry = gtk_entry_new();
     392    GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
     393
     394    gtk_container_add(GTK_CONTAINER(box), webView);
     395    gtk_container_add(GTK_CONTAINER(box), entry);
     396    gtk_container_add(GTK_CONTAINER(window), box);
     397    gtk_widget_show_all(window);
     398
     399    gtk_widget_grab_focus(entry);
     400    g_assert(gtk_widget_is_focus(entry));
     401
     402    g_signal_connect(webView, "notify::load-status", G_CALLBACK(idle_quit_loop_cb), NULL);
     403    webkit_web_view_load_html_string(WEBKIT_WEB_VIEW(webView),
     404        "<html><body>"
     405        "    <input id=\"entry\" type=\"text\"/>"
     406        "    <script>"
     407        "        document.getElementById(\"entry\").focus();"
     408        "    </script>"
     409        "</body></html>", "file://");
     410
     411    g_main_loop_run(loop);
     412
     413    g_assert(gtk_widget_is_focus(entry));
     414
     415    gtk_widget_destroy(window);
     416    g_main_loop_unref(loop);
     417}
     418
    385419int main(int argc, char** argv)
    386420{
     
    411445    g_test_add_func("/webkit/webview/window-features", test_webkit_web_view_window_features);
    412446    g_test_add_func("/webkit/webview/webview-in-offscreen-window-does-not-crash", test_webkit_web_view_in_offscreen_window_does_not_crash);
     447    g_test_add_func("/webkit/webview/webview-does-not-steal-focus", test_webkit_web_view_does_not_steal_focus);
    413448
    414449    return g_test_run ();
Note: See TracChangeset for help on using the changeset viewer.