-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css-nav-1] Remove kAlignWeight? #4567
Comments
Great question! I would explain how to come up with The alignment factor has recently added to the distance formula for prioritizing quite aligned candidates. However, what the new factor applies into the existing distance formula has several consideration. As you mentioned, when two candidates are at the same distance, a number between 0 and 1 would have no problem. But we need to consider the case of none the same distance as per [1] of the following image. Without the alignment factor in [1], B is the best candidate from A with a right direction, but we want it to C as the best candidate. That's one of the reasons that we added the alignment factor, so the value of kAlignWeight was a number much more than 5 at first for even covering 490px from A to B. However, we found unreachability and jumping cases like as [2] above. With the alignment factor more than 5 in [2], F could be the best candidate from D with a down direction so that E becomes an unreachable element from D and F. In the text-based web contents (e.g. Wikipedia), it could happen a lot between hyperlinks. In the background, we set kAlignWeight to 5 for avoiding the unreachable case. That's the history about |
Thanks for explaining how you came up with 5. From also reading http://crbug.com/1032430, I understand you chose 5 to compensate for the removal of Perhaps it's cleaner to keep Having hardcoded pixels in the formula seems unscalable anyway? To better handle different layouts, zoom levels etc the forumla should, ideally, only use ratios based on actual rects (focus candidate's and current focus' size) - not hardcoded pixel values? |
We thought In case you suggested (keep B's Distance = ... + I agree your below point.
I'm worried that 1 might be too small. |
I summarize the current status on some factor and constant of SpatNav distance formula.
With Hugo's suggestion, the focus moves from A to B on the example [1] above in an improper way. From Please share your opinion on it, or you can close this now. |
I found an example where Chrome's current formula doesn't work well: When going right from "Agreements", I'd expect focus to stay on the same line (and go to "export controls"). Instead we go to the link on the line below because it's, with the current formula, a tiny bit "closer". If you can find a formula (preferably without constants) that works in this example, that would be lovely. |
Today Alignment() always returns a value between 0 and 5. [1]
That's a very small number so Alignment is, in practice, only used to break ties (when two candidates are at the same distance we take the one that is more aligned [2]).
As we only use alignment to break ties, alignment might as well be a number between 0 and 1. This means we can remove the multiplication of
alignWeight
from the formula?[1] https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/page/spatial_navigation.cc?q=file:spatial+symbol:Alignment&sq=package:chromium
[2] https://chromium-review.googlesource.com/c/chromium/src/+/1594724/11/third_party/blink/web_tests/fast/spatial-navigation/snav-aligned-insiders.html
The text was updated successfully, but these errors were encountered: