dpad navigation of a HTML page

513 views
Skip to first unread message

Tim Graupmann

unread,
Jan 28, 2014, 4:26:57 PM1/28/14
to Tim Graupmann, input-dev
Hello Input-Devs,

I'm comparing the stock-webView with Chromium and wondering if the ContentView has a specific input feature.

With the Stock Android browser when I browse a page with links/input fields and use the gamepad/controller, the dpad will automatically jump between links and input fields and highlight them. It's very nice.

It's smart enough to know when links are hidden and nicely jumps between the visible links and input fields.

I like the stock Android browser behaviour and I want the same in Chromium.



I'm just wondering if the contentView has access an interface like:
-contentView.hasVisibleLink(direction) //up, down, left, right
-contentView.setVisibleLinkFocus(direction) //up, down, left, right

It's either something like this or I need access to a collection of render objects that have a visible/not visible state and position so I can find the nearest input field in a specific direction.

I've also used the JavaScript interface to iterate through document.links but JavaScript has no idea if it's visible to the ContentView, on screen, there's no magic CSS property display:none, or link method to test if it's visible.

Anyway I'm just checking off-hand if there's a chromium mode that turns on nice controller focus navigation.

If you need more info, I can make a video of the experience on the OUYA with the stock browser. It's nice and logical. The DPAD switches between links and input fields with a nice highlight.

Anyway that's my question. I appreciate your feedback.

Thanks,

Tim Graupmann | OUYA Android Developer | skype: tgraupmann_prey | phone: 425-422-8221

Jared Duke

unread,
Jan 28, 2014, 5:19:43 PM1/28/14
to Tim Graupmann, input-dev
Hi Tim,

There has been some work to this end, though it appears such efforts are restricted to Chromium-based WebView.

In short, spatial navigation via the keyboard interacts poorly with touch event focus.  WebView has a current workaround (efforts detailed in this issue), but longer term it would be good for us to properly support keyboard-based spatial navigation.  There may be some code you can use in the patches associated with the issue above.  Let us know if you have any other questions, and I'll see what I can do about revisiting efforts to support this feature.

Jared

Tim Graupmann

unread,
Jan 28, 2014, 6:35:11 PM1/28/14
to Jared Duke, Tim Graupmann, input-dev
Hi Jared,

That worked like a charm. Big thanks as always.

I just needed to edit: content/renderer/web_preferences.cc

#if defined(OS_ANDROID)
  settings->setSpatialNavigationEnabled(true);
#endif

Thanks again,

Tim Graupmann | OUYA Android Developer | skype: tgraupmann_prey | phone: 425-422-8221


Tim Graupmann

unread,
Jan 30, 2014, 1:27:02 PM1/30/14
to Jared Duke, Tim Graupmann, input-dev
Hi Jared,

That link and referenced links all point to settings for turning the feature on for spatial navigation.

I'm interested in finding the heart of the logic so I can add to the filter to include things that might be getting skipped. Specifically I'd like to make it easier to land on media controls.

Can I get a pointer for where the selection logic happens for spatial navigation?

Thanks as always,

Tim Graupmann | OUYA Android Developer | skype: tgraupmann_prey | phone: 425-422-8221


On Tue, Jan 28, 2014 at 2:19 PM, Jared Duke <jdd...@google.com> wrote:

Jared Duke

unread,
Jan 30, 2014, 1:33:58 PM1/30/14
to Tim Graupmann, input-dev
You'll want to look in blink for anything that references |spatialNavigationEnabled()|.  

In particular, |HTMLElement::supportsSpatialNavigationFocus()| and third_party/WebKit/Source/core/page/SpatialNavigation.{h,cpp} should be of interest.  Git blame and blink-dev@ should help you find the right people to ask about anything more specific; this list probably won't be of much more help on specific details.
Reply all
Reply to author
Forward
0 new messages