pub(crate) struct SequentialFocusNavigationSearch {
focus_navigation_scope_owner: FocusNavigationScopeOwner,
direction: SequentialFocusDirection,
mechanism: SequentialFocusNavigationMechanism,
starting_point: Option<DomRoot<Node>>,
current_winner: Option<(DomRoot<Element>, i32)>,
passed_starting_point: bool,
search_context: SequentialFocusNavigationSearchContext,
}Expand description
This structure is used to do a traversal search of the DOM in order to find an appropriate target when doing sequential focus navigation, such as when handling tab key presses.
The specification talks about the flattened tabindex-ordered focus navigation scope, which represents all of the tabindex-ordered focus navigation scopes of a particular page, flattened into a single list of all the sequentially focusable areas of the page. Then, the specification describes how to search this list during sequential focus navigation.
The choice that Servo and other browsers make is to trade updating this flattened list during every DOM mutation (frequent) with a DOM traversal of, potentially, the entire document during sequential focus navigation (infrequent).
The search done via SequentialFocusNavigationSearch matches the semantics of the
flattened tabindex-ordered focus navigation scope without having to maintain the
flattened list. It uses a series of nested traversals (one per focus scope) that
only considers each focusable area of a page at most once.
The search performs a linear DOM traversal starting at the containing focus scope of the search start point. When encountering a nested focus scope, if that scope could contain the final target for the search, the search recurses into the nested scope. If the search reaches the end of a focus scope without finding a candidate, the search continues in the focus scope’s containing scope (though never re-ascending back into a scope it recursed from).
Fields§
§direction: SequentialFocusDirection§mechanism: SequentialFocusNavigationMechanism§starting_point: Option<DomRoot<Node>>§current_winner: Option<(DomRoot<Element>, i32)>§passed_starting_point: bool§search_context: SequentialFocusNavigationSearchContextImplementations§
pub(crate) fn new( focus_navigation_scope_owner: FocusNavigationScopeOwner, direction: SequentialFocusDirection, mechanism: SequentialFocusNavigationMechanism, starting_point: Option<DomRoot<Node>>, ) -> Self
pub(crate) fn search(self) -> Option<DomRoot<Element>>
fn process_node(&mut self, node: &Node) -> Continue
Sourcefn process_node_as_sequentially_focusable_node(
&mut self,
node: &Node,
) -> Continue
fn process_node_as_sequentially_focusable_node( &mut self, node: &Node, ) -> Continue
If this node is sequentially focusable, consider whether or not to accept it as the new winner.
Sourcefn process_node_as_focus_scope_owner(&mut self, node: &Node) -> Continue
fn process_node_as_focus_scope_owner(&mut self, node: &Node) -> Continue
If this node itself forms a nested sequential focus scope, decide whether or not to descend and consider its contained focusable areas as candidates.
Sourcefn process_candidate_with_tab_index(
&mut self,
candidate_tab_index: i32,
) -> (bool, Continue)
fn process_candidate_with_tab_index( &mut self, candidate_tab_index: i32, ) -> (bool, Continue)
Process the node or focus scope owner with the provided tab index according to this
search’s search mechanism. Returns a boolean that is true if this candidate is the new
winner and a Continue which says whether to keep searching or stop.
Sourcefn process_element_for_dom_traversal(&self) -> (bool, Continue)
fn process_element_for_dom_traversal(&self) -> (bool, Continue)
Process the node or focus scope owner, given the state of Self::passed_starting_point
with for searches with the SequentialFocusNavigationMechanism::Dom search mechanism.
Returns a boolean that is true if this candidate is the new winner and a Continue which
says whether to keep searching or stop.
Sourcefn process_element_for_first_or_last_traversal(
&self,
candidate_element_tab_index: i32,
) -> bool
fn process_element_for_first_or_last_traversal( &self, candidate_element_tab_index: i32, ) -> bool
Process the node or focus scope owner with the provided tab index for searches with the
SequentialFocusNavigationMechanism::FirstOrLast search mechanism. Returns a boolean
that is true if this candidate is the new winner.
Sourcefn process_element_for_sequential_traversal(
&self,
candidate_element_tab_index: i32,
focused_element_tab_index: i32,
) -> (bool, Continue)
fn process_element_for_sequential_traversal( &self, candidate_element_tab_index: i32, focused_element_tab_index: i32, ) -> (bool, Continue)
Process the node or focus scope owner with the provided tab index for searches with the
SequentialFocusNavigationMechanism::Sequential search mechanism. Returns a boolean
that is true if this candidate is the new winner and a Continue which says whether to
keep searching or stop.
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more