Bug 35402

Summary: [GTK] Make webkit_web_view_grab_focus to active focus controller.
Product: WebKit Reporter: Antonio Gomes <tonikitoo>
Component: WebKitGTKAssignee: Antonio Gomes <tonikitoo>
Status: CLOSED FIXED    
Severity: Normal CC: gns, hausmann, jdiggs, xan.lopez
Priority: P2 Keywords: Gtk
Version: 528+ (Nightly build)   
Hardware: PC   
OS: All   
Bug Depends on:    
Bug Blocks: 18662    
Attachments:
Description Flags
proposed patch none

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:

<html>
<script>
function _focus_()
{
var innerDoc = document.defaultView.frames[0].document;
innerDoc.getElementById("link").focus();
if (innerDoc.hasFocus())
    dump("has focus");
}
</script>

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

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

<html>
<body>
<a id="link" href="http://abc.def">test</a>
</body>
</html>
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>