forked from AccessKit/accesskit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Use common filters across platform adapters (AccessKit#287)
- Loading branch information
1 parent
fdc2624
commit b3a1093
Showing
17 changed files
with
101 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2023 The AccessKit Authors. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0 (found in | ||
// the LICENSE-APACHE file) or the MIT license (found in | ||
// the LICENSE-MIT file), at your option. | ||
|
||
use accesskit::Role; | ||
|
||
use crate::node::{DetachedNode, Node, NodeState}; | ||
|
||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] | ||
pub enum FilterResult { | ||
Include, | ||
ExcludeNode, | ||
ExcludeSubtree, | ||
} | ||
|
||
fn common_filter_base(node: &NodeState) -> FilterResult { | ||
if node.is_hidden() { | ||
return FilterResult::ExcludeSubtree; | ||
} | ||
|
||
let role = node.role(); | ||
if role == Role::Presentation || role == Role::GenericContainer || role == Role::InlineTextBox { | ||
return FilterResult::ExcludeNode; | ||
} | ||
|
||
FilterResult::Include | ||
} | ||
|
||
pub fn common_filter(node: &Node) -> FilterResult { | ||
if node.is_focused() { | ||
return FilterResult::Include; | ||
} | ||
common_filter_base(node.state()) | ||
} | ||
|
||
pub fn common_filter_detached(node: &DetachedNode) -> FilterResult { | ||
if node.is_focused() { | ||
return FilterResult::Include; | ||
} | ||
common_filter_base(node.state()) | ||
} | ||
|
||
pub fn common_filter_with_root_exception(node: &Node) -> FilterResult { | ||
if node.is_root() { | ||
return FilterResult::Include; | ||
} | ||
common_filter(node) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright 2023 The AccessKit Authors. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0 (found in | ||
// the LICENSE-APACHE file) or the MIT license (found in | ||
// the LICENSE-MIT file), at your option. | ||
|
||
pub(crate) use accesskit_consumer::{ | ||
common_filter as filter, common_filter_detached as filter_detached, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
mod appkit; | ||
mod context; | ||
mod filters; | ||
mod node; | ||
mod util; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright 2023 The AccessKit Authors. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0 (found in | ||
// the LICENSE-APACHE file) or the MIT license (found in | ||
// the LICENSE-MIT file), at your option. | ||
|
||
pub(crate) use accesskit_consumer::{ | ||
common_filter as filter, common_filter_detached as filter_detached, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ extern crate zbus; | |
mod adapter; | ||
mod atspi; | ||
mod context; | ||
mod filters; | ||
mod node; | ||
mod util; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright 2023 The AccessKit Authors. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0 (found in | ||
// the LICENSE-APACHE file) or the MIT license (found in | ||
// the LICENSE-MIT file), at your option. | ||
|
||
pub(crate) use accesskit_consumer::{ | ||
common_filter as filter, common_filter_detached as filter_detached, | ||
common_filter_with_root_exception as filter_with_root_exception, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
// the LICENSE-MIT file), at your option. | ||
|
||
mod context; | ||
mod filters; | ||
mod node; | ||
mod text; | ||
mod util; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters