script: Align focusable area logic to be closer to the specification#43058
Merged
Conversation
Member
Author
|
cc @TimvdLippe PTAL |
TimvdLippe
approved these changes
Mar 6, 2026
TimvdLippe
left a comment
Contributor
There was a problem hiding this comment.
Only a couple of nits. Nice solution to use bitflags for this.
Comment on lines
+1782
to
+1783
| /// > An element is being rendered if it has any associated CSS layout boxes, SVG layout boxes, | ||
| /// > or some equivalent in other styling languages. |
Contributor
There was a problem hiding this comment.
Nit: generally we only have the link to the spec in the rustdoc and then the explanation of the spec inside the method body.
Member
Author
There was a problem hiding this comment.
Sure. I'm happy to move this.
| // > navigation scope owners, except the elements whose tabindex value is a negative integer. | ||
| // > - It contains all of the focusable areas whose DOM anchor is an element in owner's focus | ||
| // > navigation scope, except the focusable areas whose tabindex value is a negative integer. | ||
| Some(-1) => return FocusableAreaKind::Click, |
Contributor
There was a problem hiding this comment.
Nit: should cover all negative integers
Suggested change
| Some(-1) => return FocusableAreaKind::Click, | |
| Some(index) if index < 0 => return FocusableAreaKind::Click, |
| // > Modulo platform conventions, it is suggested that the following elements should be | ||
| // > considered as focusable areas and be sequentially focusable: | ||
| match node.type_id() { | ||
| let is_focusable_are_due_to_type = match node.type_id() { |
Contributor
There was a problem hiding this comment.
It took me a while to figure out what the typo was here 😛
Suggested change
| let is_focusable_are_due_to_type = match node.type_id() { | |
| let is_focusable_area_due_to_type = match node.type_id() { |
mrobinson
commented
Mar 6, 2026
mrobinson
left a comment
Member
Author
There was a problem hiding this comment.
Thanks for the review.
| // > Modulo platform conventions, it is suggested that the following elements should be | ||
| // > considered as focusable areas and be sequentially focusable: | ||
| match node.type_id() { | ||
| let is_focusable_are_due_to_type = match node.type_id() { |
| // > navigation scope owners, except the elements whose tabindex value is a negative integer. | ||
| // > - It contains all of the focusable areas whose DOM anchor is an element in owner's focus | ||
| // > navigation scope, except the focusable areas whose tabindex value is a negative integer. | ||
| Some(-1) => return FocusableAreaKind::Click, |
Comment on lines
+1782
to
+1783
| /// > An element is being rendered if it has any associated CSS layout boxes, SVG layout boxes, | ||
| /// > or some equivalent in other styling languages. |
Member
Author
There was a problem hiding this comment.
Sure. I'm happy to move this.
This abstracts out a common helper to determine focusable area kind which is used by `Element::is_click_focusable`, `Element::is_sequentially_focusable`, and `Element::is_focusable_area`. This avoid having the latter depend on the former two, which was the reverse of what the specification said. The helper is necessary because the specification defines click and sequential focusability as subsets of focusable elements, but going from "This is a focusable element" to determining what kind of focusable element something is requires duplicating a lot of the logic that was used to determine that something is a focusable area. It's likely that the specification needs more work here to improve the definition (and indeed to unify all of the places that talk about what elements are focusable areas). For now, this just tries to make our code more similar to the text. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
b520208 to
0f5fb0e
Compare
offline-ant
pushed a commit
to offline-ant/havi
that referenced
this pull request
Jun 4, 2026
…ervo#43058) This abstracts out a common helper to determine focusable area kind which is used by `Element::is_click_focusable`, `Element::is_sequentially_focusable`, and `Element::is_focusable_area`. This avoid having the latter depend on the former two, which was the reverse of what the specification said. The helper is necessary because the specification defines click and sequential focusability as subsets of focusable elements, but going from "This is a focusable element" to determining what kind of focusable element something is requires duplicating a lot of the logic that was used to determine that something is a focusable area. It's likely that the specification needs more work here to improve the definition (and indeed to unify all of the places that talk about what elements are focusable areas). For now, this just tries to make our code more similar to the text. See: whatwg/html#4607 Testing: This shouldn't change behavior, so should be tested by existing tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com> (cherry picked from commit e2f6852)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This abstracts out a common helper to determine focusable area kind
which is used by
Element::is_click_focusable,Element::is_sequentially_focusable, andElement::is_focusable_area.This avoid having the latter depend on the former two, which was the
reverse of what the specification said. The helper is necessary because
the specification defines click and sequential focusability as subsets
of focusable elements, but going from "This is a focusable element" to
determining what kind of focusable element something is requires
duplicating a lot of the logic that was used to determine that something
is a focusable area.
It's likely that the specification needs more work here to improve the
definition (and indeed to unify all of the places that talk about what
elements are focusable areas). For now, this just tries to make our code
more similar to the text.
See: whatwg/html#4607
Testing: This shouldn't change behavior, so should be tested by existing tests.