It seems like you are reading my mind because i&#39;m porting that same function now :) First try failed, though, i&#39;ll keep trying.<br><br>Thanks,<br><br><div class="gmail_quote">2010/6/9 Antonio Gomes (:tonikitoo) <span dir="ltr">&lt;<a href="mailto:tonikitoo@gmail.com">tonikitoo@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Note you need to call both setActive and setFocused of FocusController<br>
for it to work for you.<br>
<br>
In gtk:<br>
<br>
static void webkit_web_view_grab_focus(GtkWidget* widget)<br>
{<br>
  ...<br>
  FocusController* focusController = core(webView)-&gt;focusController();<br>
  focusController-&gt;setActive(true);<br>
  if (focusController-&gt;focusedFrame())<br>
    focusController-&gt;setFocused(true);<br>
  else<br>
    focusController-&gt;setFocusedFrame(core(webView)-&gt;mainFrame());<br>
<div><div></div><div class="h5">}<br>
<br>
On Wed, Jun 9, 2010 at 8:24 AM, Alex Vazquez &lt;<a href="mailto:alexvazquezfente@gmail.com">alexvazquezfente@gmail.com</a>&gt; wrote:<br>
&gt; Right, the problem is the frame not being focused. That&#39;s why changing the<br>
&gt; condition to just e-&gt;document()-&gt;frame()-&gt;selection()-&gt;isFocused didn&#39;t work<br>
&gt; either.<br>
&gt;<br>
&gt; In the webkit/GTK port, it is focused, so we are trying to find the<br>
&gt; difference regarding to that in both ports. Maybe some GTK platform check<br>
&gt; ...<br>
&gt;<br>
&gt; Any further idea is greatly appreciated and i&#39;ll post back for reference if<br>
&gt; we find the fix.<br>
&gt;<br>
&gt; Thanks and kind regards,<br>
&gt;<br>
&gt; 2010/6/8 David Hyatt &lt;<a href="mailto:hyatt@apple.com">hyatt@apple.com</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt; isFocusedAndActive is asking if your frame is the focused frame and if the<br>
&gt;&gt; window that contains your frame is also active.  I would guess that you are<br>
&gt;&gt; not setting the state of your frames/windows correctly.  If your window is<br>
&gt;&gt; considered inactive or if your frame is not considered focused, then :focus<br>
&gt;&gt; is not going to be honored.<br>
&gt;&gt; dave<br>
&gt;&gt; (<a href="mailto:hyatt@apple.com">hyatt@apple.com</a>)<br>
&gt;&gt; On Jun 8, 2010, at 3:33 AM, Alex Vazquez wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hello list,<br>
&gt;&gt;<br>
&gt;&gt; We&#39;re running a customized build of WebKit (actually a DirectFB port) and<br>
&gt;&gt; we are experiencing problems with the css :focus pseudo-class. We use webkit<br>
&gt;&gt; as GUI renderer and, when changing the focused element through JavaScript<br>
&gt;&gt; (using the focus function), the style associated to the  :focus pseudo-class<br>
&gt;&gt; is not applied. The attached page is our reduced testcase, it should show<br>
&gt;&gt; two links, the first of them focused but it shows two unfocused links:<br>
&gt;&gt;<br>
&gt;&gt; &lt;html&gt;<br>
&gt;&gt;<br>
&gt;&gt;     &lt;head&gt;<br>
&gt;&gt;<br>
&gt;&gt;         &lt;style type=&quot;text/css&quot;&gt;<br>
&gt;&gt;<br>
&gt;&gt;         body {<br>
&gt;&gt;                 color: #f00;<br>
&gt;&gt;                 background-color:#ddd;<br>
&gt;&gt;                 font-size:26px;<br>
&gt;&gt;         }<br>
&gt;&gt;<br>
&gt;&gt;         div {<br>
&gt;&gt;                 float: left;<br>
&gt;&gt;                 padding: 50px;<br>
&gt;&gt;         }<br>
&gt;&gt;<br>
&gt;&gt;         a, span {<br>
&gt;&gt;                 float:left;<br>
&gt;&gt;                 display:block;<br>
&gt;&gt;                 clear:both;<br>
&gt;&gt;         }<br>
&gt;&gt;<br>
&gt;&gt;         a:focus {<br>
&gt;&gt;                 color:#f0f;<br>
&gt;&gt;         }<br>
&gt;&gt;<br>
&gt;&gt;         &lt;/style&gt;<br>
&gt;&gt;<br>
&gt;&gt;         &lt;script type=&quot;text/javascript&quot;&gt;<br>
&gt;&gt;<br>
&gt;&gt;         function init() {<br>
&gt;&gt;         document.getElementById(&quot;uno&quot;).focus();<br>
&gt;&gt;         }<br>
&gt;&gt;<br>
&gt;&gt;         &lt;/script&gt;<br>
&gt;&gt;<br>
&gt;&gt;     &lt;/head&gt;<br>
&gt;&gt;<br>
&gt;&gt;     &lt;body onload=&quot;init();&quot;&gt;<br>
&gt;&gt;         &lt;div&gt;<br>
&gt;&gt;<br>
&gt;&gt;             &lt;a id=&quot;uno&quot; href=&quot;<a href="http://www.webkit.org/" target="_blank">http://www.webkit.org/</a>&quot;&gt;WebKit&lt;/a&gt;<br>
&gt;&gt;             &lt;a id=&quot;dos&quot; href=&quot;<a href="http://nightly.webkit.org" target="_blank">http://nightly.webkit.org</a>&quot;&gt;Nightly<br>
&gt;&gt; Builds&lt;/a&gt;<br>
&gt;&gt;<br>
&gt;&gt;         &lt;/div&gt;<br>
&gt;&gt;     &lt;/body&gt;<br>
&gt;&gt;<br>
&gt;&gt; &lt;/html&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; The version with this problem is based on r58260 revision while a<br>
&gt;&gt; previously one (with nearly the same adapted patches) based in r40084 worked<br>
&gt;&gt; fine. We build webkit for an embedded MIPS processor and for x86 too. Both<br>
&gt;&gt; versions show the undesired behaviour.<br>
&gt;&gt;<br>
&gt;&gt; Investigating through the WebKit code, we&#39;ve found that applying the<br>
&gt;&gt; following patch fixes the problem:<br>
&gt;&gt;<br>
&gt;&gt; --- a/WebCore/css/CSSStyleSelector.cpp    2010-06-04 13:35:19.000000000<br>
&gt;&gt; +0000<br>
&gt;&gt; +++ b/WebCore/css/CSSStyleSelector.cpp    2010-06-04 13:35:35.000000000<br>
&gt;&gt; +0000<br>
&gt;&gt; @@ -2428,7 +2428,7 @@<br>
&gt;&gt;                  break;<br>
&gt;&gt;              }<br>
&gt;&gt;              case CSSSelector::PseudoFocus:<br>
&gt;&gt; -                if (e &amp;&amp; e-&gt;focused() &amp;&amp;<br>
&gt;&gt; e-&gt;document()-&gt;frame()-&gt;selection()-&gt;isFocusedAndActive())<br>
&gt;&gt; +        if (e &amp;&amp; e-&gt;focused())<br>
&gt;&gt;                      return true;<br>
&gt;&gt;                  break;<br>
&gt;&gt;              case CSSSelector::PseudoHover: {<br>
&gt;&gt;<br>
&gt;&gt; That line was there since r40084 and it worked so we have some questions<br>
&gt;&gt; about the patch:<br>
&gt;&gt;<br>
&gt;&gt; * Does it have any problem that we have overlooked?<br>
&gt;&gt;<br>
&gt;&gt; * Can someone with knowledge on the css component explain why the active<br>
&gt;&gt; state of the selection is checked in that line? We also try to change that<br>
&gt;&gt; check by e-&gt;document()-&gt;frame()-&gt;selection()-&gt;isFocused() but it didn&#39;t fix<br>
&gt;&gt; it.<br>
&gt;&gt;<br>
&gt;&gt; Kind regards,<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Alejandro Vazquez Fente<br>
&gt;&gt;<br>
&gt;&gt; &lt;focus_index.html&gt;&lt;css_style_selector_focus.patch&gt;_______________________________________________<br>
&gt;&gt; webkit-dev mailing list<br>
&gt;&gt; <a href="mailto:webkit-dev@lists.webkit.org">webkit-dev@lists.webkit.org</a><br>
&gt;&gt; <a href="http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev" target="_blank">http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev</a><br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Alejandro Vazquez Fente<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; webkit-dev mailing list<br>
&gt; <a href="mailto:webkit-dev@lists.webkit.org">webkit-dev@lists.webkit.org</a><br>
&gt; <a href="http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev" target="_blank">http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev</a><br>
&gt;<br>
&gt;<br>
<br>
<br>
<br>
--<br>
</div></div><font color="#888888">--Antonio Gomes<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Alejandro Vazquez Fente<br>