[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.22-985-g3c00f00
tonikitoo at webkit.org
tonikitoo at webkit.org
Wed Mar 17 18:02:52 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 7b59d765bcc9a1f8958eed80a07815b7319b4748
Author: tonikitoo at webkit.org <tonikitoo at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Feb 26 20:32:52 2010 +0000
[GTK] Make webkit_web_view_grab_focus to active focus controller.
https://bugs.webkit.org/show_bug.cgi?id=35402
Reviewed by Xan Lopez.
Patch by Antonio Gomes <tonikitoo at webkit.org>
When programatically setting focus to an element in an inner document,
calling "hasFocus()" from this document returns FALSE, because
document's FocusController is not activated. It does not happen
if |document| is the main document.
Making webkit_web_view_grab_focus to actually activate the FocusController,
fixes the issue.
* tests/testwebview.c:
(server_callback):
(test_webkit_web_view_grab_focus):
* webkit/webkitwebview.cpp:
(webkit_web_view_grab_focus):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55300 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
index 66d24e2..a9b3e2f 100644
--- a/WebKit/gtk/ChangeLog
+++ b/WebKit/gtk/ChangeLog
@@ -1,3 +1,25 @@
+2010-02-26 Antonio Gomes <tonikitoo at webkit.org>
+
+ Reviewed by Xan Lopez.
+ Patch by Antonio Gomes <tonikitoo at webkit.org>
+
+ [GTK] Make webkit_web_view_grab_focus to active focus controller.
+ https://bugs.webkit.org/show_bug.cgi?id=35402
+
+ When programatically setting focus to an element in an inner document,
+ calling "hasFocus()" from this document returns FALSE, because
+ document's FocusController is not activated. It does not happen
+ if |document| is the main document.
+
+ Making webkit_web_view_grab_focus to actually activate the FocusController,
+ fixes the issue.
+
+ * tests/testwebview.c:
+ (server_callback):
+ (test_webkit_web_view_grab_focus):
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_grab_focus):
+
2010-02-26 Alejandro G. Castro <alex at igalia.com>
Unreviewed.
diff --git a/WebKit/gtk/tests/testwebview.c b/WebKit/gtk/tests/testwebview.c
index 8c61afe..1447e1b 100644
--- a/WebKit/gtk/tests/testwebview.c
+++ b/WebKit/gtk/tests/testwebview.c
@@ -58,10 +58,10 @@ server_callback(SoupServer* server, SoupMessage* msg,
soup_message_body_append(msg->response_body, SOUP_MEMORY_TAKE, contents, length);
} else if (g_str_equal(path, "/bigdiv.html")) {
- char* contents = g_strdup("<html><body><div style=\"background-color: green; height: 1200px;\"></div></body></html>");
+ char* contents = g_strdup("<html><body><a id=\"link\" href=\"http://abc.def\">test</a><div style=\"background-color: green; height: 1200px;\"></div></body></html>");
soup_message_body_append(msg->response_body, SOUP_MEMORY_TAKE, contents, strlen(contents));
} else if (g_str_equal(path, "/iframe.html")) {
- char* contents = g_strdup("<html><body><div style=\"background-color: green; height: 50px;\"></div><iframe src=\"bigdiv.html\"></iframe></body></html>");
+ char* contents = g_strdup("<html><body id=\"some-content\"><div style=\"background-color: green; height: 50px;\"></div><iframe src=\"bigdiv.html\"></iframe></body></html>");
soup_message_body_append(msg->response_body, SOUP_MEMORY_TAKE, contents, strlen(contents));
} else {
char* contents = g_strdup("<html><body>test</body></html>");
@@ -137,6 +137,61 @@ static gboolean map_event_cb(GtkWidget *widget, GdkEvent* event, gpointer data)
return FALSE;
}
+static void test_webkit_web_view_grab_focus()
+{
+ char* uri = g_strconcat(base_uri, "iframe.html", NULL);
+ GtkWidget* window = gtk_window_new(GTK_WINDOW_POPUP);
+ GtkWidget* scrolled_window = gtk_scrolled_window_new(NULL, NULL);
+ WebKitWebView* view = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ GtkAdjustment* adjustment;
+
+ gtk_window_set_default_size(GTK_WINDOW(window), 400, 200);
+
+ gtk_container_add(GTK_CONTAINER(window), scrolled_window);
+ gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(view));
+
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ loop = g_main_loop_new(NULL, TRUE);
+
+ g_signal_connect(view, "progress", G_CALLBACK(idle_quit_loop_cb), NULL);
+
+ /* Wait for window to show up */
+ gtk_widget_show_all(window);
+ g_signal_connect(window, "map-event",
+ G_CALLBACK(map_event_cb), loop);
+ g_main_loop_run(loop);
+
+ /* Load a page with a big div that will cause scrollbars to appear */
+ webkit_web_view_load_uri(view, uri);
+ g_main_loop_run(loop);
+
+ adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scrolled_window));
+ g_assert_cmpfloat(gtk_adjustment_get_value(adjustment), ==, 0.0);
+
+ /* Since webkit_web_view_execute_script does not return a value,
+ it is impossible to know if an inner document has focus after
+ a node of it was focused via .focus() method.
+ The code below is an workaround: if the node has focus, a scroll
+ action is performed and afterward it is checked if the adjustment
+ has to be different from 0.
+ */
+ char script[] = "var innerDoc = document.defaultView.frames[0].document; \
+ innerDoc.getElementById(\"link\").focus(); \
+ if (innerDoc.hasFocus()) \
+ window.scrollBy(0, 100);";
+
+ /* Focus an element using JavaScript */
+ webkit_web_view_execute_script(view, script);
+
+ /* Make sure the ScrolledWindow noticed the scroll */
+ g_assert_cmpfloat(gtk_adjustment_get_value(adjustment), !=, 0.0);
+
+ g_free(uri);
+ gtk_widget_destroy(window);
+}
+
static void do_test_webkit_web_view_adjustments(gboolean with_page_cache)
{
char* effective_uri = g_strconcat(base_uri, "bigdiv.html", NULL);
@@ -283,6 +338,7 @@ int main(int argc, char** argv)
g_test_add_func("/webkit/webview/icon-uri", test_webkit_web_view_icon_uri);
g_test_add_func("/webkit/webview/adjustments", test_webkit_web_view_adjustments);
g_test_add_func("/webkit/webview/destroy", test_webkit_web_view_destroy);
+ g_test_add_func("/webkit/webview/grab_focus", test_webkit_web_view_grab_focus);
return g_test_run ();
}
diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp
index 993cd3a..b83e49d 100644
--- a/WebKit/gtk/webkit/webkitwebview.cpp
+++ b/WebKit/gtk/webkit/webkitwebview.cpp
@@ -640,6 +640,8 @@ static void webkit_web_view_grab_focus(GtkWidget* widget)
WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
FocusController* focusController = core(webView)->focusController();
+ focusController->setActive(true);
+
if (focusController->focusedFrame())
focusController->setFocused(true);
else
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list