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

Improve focusable area algorithm for element #19745

Open
CYBAI opened this issue Jan 11, 2018 · 0 comments
Open

Improve focusable area algorithm for element #19745

CYBAI opened this issue Jan 11, 2018 · 0 comments
Labels
A-content/dom Interacting with the DOM from web content

Comments

@CYBAI
Copy link
Member

CYBAI commented Jan 11, 2018

Spec: https://html.spec.whatwg.org/multipage/interaction.html#focusable-area

pub fn is_focusable_area(&self) -> bool {
if self.is_actually_disabled() {
return false;
}
// TODO: Check whether the element is being rendered (i.e. not hidden).
let node = self.upcast::<Node>();
if node.get_flag(NodeFlags::SEQUENTIALLY_FOCUSABLE) {
return true;
}
// https://html.spec.whatwg.org/multipage/#specially-focusable
match node.type_id() {
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLInputElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLSelectElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTextAreaElement)) => {
true
}
_ => false,
}
}

In the current implementation, we only make anchor, input, select and textarea be focusable.
Thus, I think we can improve the algorithm of this method to be up-to-date with spec.

@jdm jdm added the A-content/dom Interacting with the DOM from web content label Jan 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-content/dom Interacting with the DOM from web content
Projects
None yet
Development

No branches or pull requests

2 participants