[webkit-dev] problem with css :focus

Alex Vazquez alexvazquezfente at gmail.com
Tue Jun 8 01:33:50 PDT 2010


Hello list,

We're running a customized build of WebKit (actually a DirectFB port) and we
are experiencing problems with the css :focus pseudo-class. We use webkit as
GUI renderer and, when changing the focused element through JavaScript
(using the focus function), the style associated to the  :focus pseudo-class
is not applied. The attached page is our reduced testcase, it should show
two links, the first of them focused but it shows two unfocused links:

<html>

    <head>

        <style type="text/css">

        body {
                color: #f00;
                background-color:#ddd;
                font-size:26px;
        }

        div {
                float: left;
                padding: 50px;
        }

        a, span {
                float:left;
                display:block;
                clear:both;
        }

        a:focus {
                color:#f0f;
        }

        </style>

        <script type="text/javascript">

        function init() {
        document.getElementById("uno").focus();
        }

        </script>

    </head>

    <body onload="init();">
        <div>

            <a id="uno" href="http://www.webkit.org/">WebKit</a>
            <a id="dos" href="http://nightly.webkit.org">Nightly Builds</a>

        </div>
    </body>

</html>


The version with this problem is based on r58260 revision while a previously
one (with nearly the same adapted patches) based in r40084 worked fine. We
build webkit for an embedded MIPS processor and for x86 too. Both versions
show the undesired behaviour.

Investigating through the WebKit code, we've found that applying the
following patch fixes the problem:

--- a/WebCore/css/CSSStyleSelector.cpp    2010-06-04 13:35:19.000000000
+0000
+++ b/WebCore/css/CSSStyleSelector.cpp    2010-06-04 13:35:35.000000000
+0000
@@ -2428,7 +2428,7 @@
                 break;
             }
             case CSSSelector::PseudoFocus:
-                if (e && e->focused() &&
e->document()->frame()->selection()->isFocusedAndActive())
+        if (e && e->focused())
                     return true;
                 break;
             case CSSSelector::PseudoHover: {

That line was there since r40084 and it worked so we have some questions
about the patch:

* Does it have any problem that we have overlooked?

* Can someone with knowledge on the css component explain why the active
state of the selection is checked in that line? We also try to change that
check by e->document()->frame()->selection()->isFocused() but it didn't fix
it.

Kind regards,

-- 
Alejandro Vazquez Fente
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20100608/63e62093/attachment.html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20100608/63e62093/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: css_style_selector_focus.patch
Type: text/x-diff
Size: 485 bytes
Desc: not available
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20100608/63e62093/attachment.bin>


More information about the webkit-dev mailing list