Title: [108278] trunk/Source
- Revision
- 108278
- Author
- [email protected]
- Date
- 2012-02-20 18:04:29 -0800 (Mon, 20 Feb 2012)
Log Message
[GTK] Web content oftens steals focus from other widgets
https://bugs.webkit.org/show_bug.cgi?id=77791
Patch by Martin Robinson <[email protected]> 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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (108277 => 108278)
--- trunk/Source/WebCore/ChangeLog 2012-02-21 02:02:23 UTC (rev 108277)
+++ trunk/Source/WebCore/ChangeLog 2012-02-21 02:04:29 UTC (rev 108278)
@@ -1,3 +1,17 @@
+2012-02-20 Martin Robinson <[email protected]>
+
+ [GTK] Web content oftens steals focus from other widgets
+ https://bugs.webkit.org/show_bug.cgi?id=77791
+
+ Reviewed by Gustavo Noronha Silva.
+
+ * 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.
+
2012-02-20 Yael Aharon <[email protected]>
Regression (108135) isOpaque() returns uninitialized variable.
Modified: trunk/Source/WebCore/platform/gtk/WidgetGtk.cpp (108277 => 108278)
--- trunk/Source/WebCore/platform/gtk/WidgetGtk.cpp 2012-02-21 02:02:23 UTC (rev 108277)
+++ trunk/Source/WebCore/platform/gtk/WidgetGtk.cpp 2012-02-21 02:04:29 UTC (rev 108278)
@@ -58,18 +58,6 @@
void Widget::setFocus(bool focused)
{
- if (!focused)
- return;
-
- GtkWidget* widget = platformWidget() ? platformWidget() : root()->hostWindow()->platformPageClient();
- if (widget) {
- gtk_widget_grab_focus(widget);
- return;
- }
-
- // We are running WK2.
- if (Frame* frame = Frame::frameForWidget(this))
- frame->page()->chrome()->focus();
}
void Widget::setCursor(const Cursor& cursor)
Modified: trunk/Source/WebCore/plugins/gtk/PluginViewGtk.cpp (108277 => 108278)
--- trunk/Source/WebCore/plugins/gtk/PluginViewGtk.cpp 2012-02-21 02:02:23 UTC (rev 108277)
+++ trunk/Source/WebCore/plugins/gtk/PluginViewGtk.cpp 2012-02-21 02:04:29 UTC (rev 108278)
@@ -165,6 +165,8 @@
void PluginView::setFocus(bool focused)
{
ASSERT(platformPluginWidget() == platformWidget());
+ if (focused && platformWidget())
+ gtk_widget_grab_focus(platformWidget());
Widget::setFocus(focused);
}
Modified: trunk/Source/WebKit/gtk/ChangeLog (108277 => 108278)
--- trunk/Source/WebKit/gtk/ChangeLog 2012-02-21 02:02:23 UTC (rev 108277)
+++ trunk/Source/WebKit/gtk/ChangeLog 2012-02-21 02:04:29 UTC (rev 108278)
@@ -1,3 +1,12 @@
+2012-02-20 Martin Robinson <[email protected]>
+
+ [GTK] Web content oftens steals focus from other widgets
+ https://bugs.webkit.org/show_bug.cgi?id=77791
+
+ Reviewed by Gustavo Noronha Silva.
+
+ * tests/testwebview.c: Added a WebKit1 test to verify this behavior.
+
2012-02-20 Gustavo Noronha Silva <[email protected]>
[GTK] Needs to claim being a more up-to-date Chrome
Modified: trunk/Source/WebKit/gtk/tests/testwebview.c (108277 => 108278)
--- trunk/Source/WebKit/gtk/tests/testwebview.c 2012-02-21 02:02:23 UTC (rev 108277)
+++ trunk/Source/WebKit/gtk/tests/testwebview.c 2012-02-21 02:04:29 UTC (rev 108278)
@@ -382,6 +382,40 @@
g_main_loop_unref(loop);
}
+static void test_webkit_web_view_does_not_steal_focus()
+{
+ loop = g_main_loop_new(NULL, TRUE);
+
+ GtkWidget *window = gtk_offscreen_window_new();
+ GtkWidget *webView = webkit_web_view_new();
+ GtkWidget *entry = gtk_entry_new();
+ GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+
+ gtk_container_add(GTK_CONTAINER(box), webView);
+ gtk_container_add(GTK_CONTAINER(box), entry);
+ gtk_container_add(GTK_CONTAINER(window), box);
+ gtk_widget_show_all(window);
+
+ gtk_widget_grab_focus(entry);
+ g_assert(gtk_widget_is_focus(entry));
+
+ g_signal_connect(webView, "notify::load-status", G_CALLBACK(idle_quit_loop_cb), NULL);
+ webkit_web_view_load_html_string(WEBKIT_WEB_VIEW(webView),
+ "<html><body>"
+ " <input id=\"entry\" type=\"text\"/>"
+ " <script>"
+ " document.getElementById(\"entry\").focus();"
+ " </script>"
+ "</body></html>", "file://");
+
+ g_main_loop_run(loop);
+
+ g_assert(gtk_widget_is_focus(entry));
+
+ gtk_widget_destroy(window);
+ g_main_loop_unref(loop);
+}
+
int main(int argc, char** argv)
{
SoupServer* server;
@@ -410,6 +444,7 @@
g_test_add_func("/webkit/webview/grab_focus", test_webkit_web_view_grab_focus);
g_test_add_func("/webkit/webview/window-features", test_webkit_web_view_window_features);
g_test_add_func("/webkit/webview/webview-in-offscreen-window-does-not-crash", test_webkit_web_view_in_offscreen_window_does_not_crash);
+ g_test_add_func("/webkit/webview/webview-does-not-steal-focus", test_webkit_web_view_does_not_steal_focus);
return g_test_run ();
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes