[webkit-dev] problem with css :focus

Alex Vazquez alexvazquezfente at gmail.com
Wed Jun 9 08:46:54 PDT 2010


It seems like you are reading my mind because i'm porting that same function
now :) First try failed, though, i'll keep trying.

Thanks,

2010/6/9 Antonio Gomes (:tonikitoo) <tonikitoo at gmail.com>

> Note you need to call both setActive and setFocused of FocusController
> for it to work for you.
>
> In gtk:
>
> static void webkit_web_view_grab_focus(GtkWidget* widget)
> {
>  ...
>  FocusController* focusController = core(webView)->focusController();
>  focusController->setActive(true);
>  if (focusController->focusedFrame())
>    focusController->setFocused(true);
>  else
>    focusController->setFocusedFrame(core(webView)->mainFrame());
> }
>
> On Wed, Jun 9, 2010 at 8:24 AM, Alex Vazquez <alexvazquezfente at gmail.com>
> wrote:
> > Right, the problem is the frame not being focused. That's why changing
> the
> > condition to just e->document()->frame()->selection()->isFocused didn't
> work
> > either.
> >
> > In the webkit/GTK port, it is focused, so we are trying to find the
> > difference regarding to that in both ports. Maybe some GTK platform check
> > ...
> >
> > Any further idea is greatly appreciated and i'll post back for reference
> if
> > we find the fix.
> >
> > Thanks and kind regards,
> >
> > 2010/6/8 David Hyatt <hyatt at apple.com>
> >>
> >> isFocusedAndActive is asking if your frame is the focused frame and if
> the
> >> window that contains your frame is also active.  I would guess that you
> are
> >> not setting the state of your frames/windows correctly.  If your window
> is
> >> considered inactive or if your frame is not considered focused, then
> :focus
> >> is not going to be honored.
> >> dave
> >> (hyatt at apple.com)
> >> On Jun 8, 2010, at 3:33 AM, Alex Vazquez wrote:
> >>
> >> 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
> >>
> >>
> <focus_index.html><css_style_selector_focus.patch>_______________________________________________
> >> webkit-dev mailing list
> >> webkit-dev at lists.webkit.org
> >> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
> >>
> >
> >
> >
> > --
> > Alejandro Vazquez Fente
> >
> > _______________________________________________
> > webkit-dev mailing list
> > webkit-dev at lists.webkit.org
> > http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
> >
> >
>
>
>
> --
> --Antonio Gomes
>



-- 
Alejandro Vazquez Fente
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20100609/4e687a58/attachment.html>


More information about the webkit-dev mailing list