Skip to content
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

core: Implement proper automatic tab ordering #16323

Merged
merged 3 commits into from
May 16, 2024

Conversation

kjarosh
Copy link
Member

@kjarosh kjarosh commented May 14, 2024

Related to #5443. Fixes #15853.

This PR implements proper automatic tab ordering that behaves exactly the same as in FP.

The Behavior of Automatic Tab Ordering

The automatic order depends only on the position of the top-left highlight bound corner, referred to as (x,y). It does not depend on object's size or other corners.

The value of 6y+x is used to order objects by it. This means that the next object to be tabbed is the next one that touches the line y=-(x-p)/6 (with the smallest p).

When two objects have the same value of 6y+x (i.e. when the line touches two objects at the same time), only one of them is included.

This behavior is similar to the naive approach of "left-to-right, top-to-bottom", but (besides being sometimes seen as random jumps) takes into account the fact that the next object to the right may be positioned slightly higher. This is especially true for objects placed by hand or objects with different heights (as FP uses the top left corner instead of the center).

The following image presents this behavior visually.

This behavior has been discovered experimentally by placing tabbable objects randomly and bisecting one of their coordinates to find a difference in behavior.

@torokati44 torokati44 force-pushed the proper-auto-tab-order branch from 4cf99ef to 3b5397a Compare May 16, 2024 18:11
@Dinnerbone Dinnerbone enabled auto-merge (rebase) May 16, 2024 18:15
kjarosh added 3 commits May 16, 2024 21:26
This test was passing totally by accident.

It contained two objects that were lying on the same y=-(x-p)/6 line.
Using the automatic order, only one of these objects should be tabbable,
however in output.txt we can see them both (clipInner2 and clip5b).
That's because the test was performed in FP with a zoom less than 100%,
which apparently changed how FP sees coordinates.
This patch implements proper automatic tab ordering that
behaves exactly the same as in FP.

The automatic order depends only on the position of
the top-left highlight bound corner, referred to as `(x,y)`.
It does not depend on object's size or other corners.

The value of `6y+x` is used to order objects by it.
This means that the next object to be tabbed is the next one
that touches the line `y=-(x-p)/6` (with the smallest `p`).

When two objects have the same value of `6y+x`
(i.e. when the line touches two objects at the same time),
only one of them is included.

This behavior is similar to the naive approach of
"left-to-right, top-to-bottom", but (besides being sometimes
seen as random jumps) takes into account the fact that
the next object to the right may be positioned slightly higher.
This is especially true for objects placed by hand or objects with
different heights (as FP uses the top left corner instead of the center).

This behavior has been discovered experimentally by placing
tabbable objects randomly and bisecting one of their
coordinates to find a difference in behavior.
This test verifies the exact behavior of the automatic tab order.
@Dinnerbone Dinnerbone force-pushed the proper-auto-tab-order branch from 3b5397a to d07bac8 Compare May 16, 2024 19:26
@Dinnerbone Dinnerbone merged commit 710232e into ruffle-rs:master May 16, 2024
17 checks passed
@kjarosh kjarosh deleted the proper-auto-tab-order branch May 16, 2024 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Major difference in tab key behavior on https://www.dnai.org/timeline/index.html?m=1
2 participants