accesskit_consumer/
filters.rsuse accesskit::Role;
use crate::node::Node;
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub enum FilterResult {
Include,
ExcludeNode,
ExcludeSubtree,
}
pub fn common_filter(node: &Node) -> FilterResult {
if node.is_focused() {
return FilterResult::Include;
}
if node.is_hidden() {
return FilterResult::ExcludeSubtree;
}
if let Some(parent) = node.parent() {
if common_filter(&parent) == FilterResult::ExcludeSubtree {
return FilterResult::ExcludeSubtree;
}
}
let role = node.role();
if role == Role::GenericContainer || role == Role::InlineTextBox {
return FilterResult::ExcludeNode;
}
FilterResult::Include
}
pub fn common_filter_with_root_exception(node: &Node) -> FilterResult {
if node.is_root() {
return FilterResult::Include;
}
common_filter(node)
}