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

Support sequential focus navigation #13460

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Create a sequential focus ordering list

This list will hold elements that have their SEQUENTIALLY_FOCUSABLE
flag set. The elements are added to the list in tree order.
  • Loading branch information
nerith committed Sep 26, 2016
commit 9c5dcb93e3a8520db4f11169933c8f2cdd3e1551
@@ -238,6 +238,8 @@ pub struct Document {
dom_complete: Cell<u64>,
load_event_start: Cell<u64>,
load_event_end: Cell<u64>,
/// Vector to store focusable elements
focus_list: DOMRefCell<Vec<JS<Element>>>,
/// https://html.spec.whatwg.org/multipage/#concept-document-https-state
https_state: Cell<HttpsState>,
touchpad_pressure_phase: Cell<TouchpadPressurePhase>,
@@ -496,6 +498,11 @@ impl Document {
}
}

/// Add a focusable element to this document's ordering focus list.
pub fn add_focusable_element(&self, element: &Element) {
self.focus_list.borrow_mut().push(JS::from_ref(element));
}

/// Associate an element present in this document with the provided id.
pub fn register_named_element(&self, element: &Element, id: Atom) {
debug!("Adding named element to document {:p}: {:p} id={}",
@@ -1799,6 +1806,7 @@ impl Document {
dom_complete: Cell::new(Default::default()),
load_event_start: Cell::new(Default::default()),
load_event_end: Cell::new(Default::default()),
focus_list: DOMRefCell::new(vec![]),
https_state: Cell::new(HttpsState::None),
touchpad_pressure_phase: Cell::new(TouchpadPressurePhase::BeforeClick),
origin: origin,
@@ -2203,6 +2203,19 @@ impl VirtualMethods for Element {
return;
}

if self.is_focusable_area() {
let doc = document_from_node(self);
let children = self.upcast::<Node>().traverse_preorder();

for child in children {
if let Some(element) = child.downcast::<Element>() {
if element.is_focusable_area() && !element.disabled_state() {
doc.add_focusable_element(element);
}
}
}
}

This comment has been minimized.

Copy link
@nox

nox Oct 17, 2016

Member

When do you remove focusable elements from the document? Shouldn't that be done in unbind_from_tree?


if let Some(ref value) = *self.id_attribute.borrow() {
let doc = document_from_node(self);
doc.register_named_element(self, value.clone());
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.