Skip to main content

SequentialFocusNavigationSearch

Struct SequentialFocusNavigationSearch 

Source
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§

§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

Implementations§

Source§

impl SequentialFocusNavigationSearch

Source

pub(crate) fn new( focus_navigation_scope_owner: FocusNavigationScopeOwner, direction: SequentialFocusDirection, mechanism: SequentialFocusNavigationMechanism, starting_point: Option<DomRoot<Node>>, ) -> Self

Source

pub(crate) fn search(self) -> Option<DomRoot<Element>>

Source

fn maybe_search_in_containing_focus_navigation_scope( &self, ) -> Option<DomRoot<Element>>

Source

fn process_node(&mut self, node: &Node) -> Continue

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Filterable for T

Source§

fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> MaybeBoxed<Box<T>> for T

Source§

fn maybe_boxed(self) -> Box<T>

Convert
Source§

impl<T> MaybeBoxed<T> for T

Source§

fn maybe_boxed(self) -> T

Convert
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T