Bug 35402 - [GTK] Make webkit_web_view_grab_focus to active focus controller.
Summary: [GTK] Make webkit_web_view_grab_focus to active focus controller.
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P2 Normal
Assignee: Antonio Gomes
Keywords: Gtk
Depends on:
Blocks: 18662
  Show dependency treegraph
Reported: 2010-02-25 13:21 PST by Antonio Gomes
Modified: 2010-04-20 13:24 PDT (History)
4 users (show)

See Also:

proposed patch (7.00 KB, patch)
2010-02-25 13:40 PST, Antonio Gomes
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antonio Gomes 2010-02-25 13:21:48 PST
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.

ps: It does not happen if |document| is the main document.
Making webkit_web_view_grab_focus to actually activate the FocusController, fixes the issue.

patch coming, including API unit test.

* sample failing pseudo html/JS code:

function _focus_()
var innerDoc = document.defaultView.frames[0].document;
if (innerDoc.hasFocus())
    dump("has focus");

<body onload="_focus_()">
    <iframe src=iframe.html/>

********* iframe.html *********

<a id="link" href="http://abc.def">test</a>
Comment 1 Antonio Gomes 2010-02-25 13:40:27 PST
Created attachment 49529 [details]
proposed patch
Comment 2 Xan Lopez 2010-02-26 07:28:36 PST
Comment on attachment 49529 [details]
proposed patch

>+       The code below is an wordaround: if the node has focus, a scroll

typo in 'wordaround'

>+       action is performed and afterward it is checked if the adjustment
>+       has to be different from 0.
>+    */

It would be nicer to not duplicate so much code between the tests by using common setup/teardown methods like in other testfiles, but you can do it in a follow-up if you feel like it.
Comment 3 Xan Lopez 2010-02-26 07:29:21 PST
Comment on attachment 49529 [details]
proposed patch

>+    g_object_connect(G_OBJECT(view),
>+                     "signal::notify::progress", idle_quit_loop_cb, NULL,
>+                     NULL);

Bah, this was cut in the previous comment. You can just use g_signal_connect here.
Comment 4 Antonio Gomes 2010-02-26 13:27:10 PST
fixed: r55300 and r55305

thx xan and kov
Comment 5 Antonio Gomes 2010-04-11 19:58:46 PDT
Comment on attachment 49529 [details]
proposed patch

Clearing flags on attachment: 49529

Committed r55300: <http://trac.webkit.org/changeset/55300>