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

Types crate v2 #82

Merged
merged 143 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
39cbeb8
Generate GenericEvent implementations for every event type
TTWNO Apr 30, 2023
c5bd558
Remove signify trait
TTWNO Apr 30, 2023
d99c22a
Use new atspi-codegen output for identify
TTWNO Apr 30, 2023
d80f50e
Remove Signified trait
TTWNO Apr 30, 2023
6b6fa5d
[WIP] Add custom implementation of From<Arc<Message>> and GenericEven…
TTWNO Apr 30, 2023
d6cbdb9
Remove unused macro
TTWNO Apr 30, 2023
ca59df1
Update tests to use new event system
TTWNO Apr 30, 2023
822cc38
Bump version for all crates
TTWNO Apr 30, 2023
3eba032
Update macros dep version
TTWNO Apr 30, 2023
c619100
Cargo format
TTWNO Apr 30, 2023
eee8b89
Add new conversion functions, add new constants to GenericEvent
TTWNO May 3, 2023
4f76ba3
Add auto generated conversion functions for various event types
TTWNO May 3, 2023
63ef5ec
Update identify file
TTWNO May 3, 2023
e625c9d
Update conversion functions on from_zbus macro
TTWNO May 3, 2023
cd78061
Always use message references for conversion
TTWNO May 3, 2023
2584bd4
Dereference Arc<Message> for conversion
TTWNO May 3, 2023
e9a9e5e
Add From<*Events> for Event
TTWNO May 3, 2023
12ef271
Add more From implementations for simple event types
TTWNO May 3, 2023
e5fd3ba
Flatten out EventInterfaces
TTWNO May 3, 2023
c99cb94
Remove AnyEvent<T> type
TTWNO May 3, 2023
6b23480
Remove TryFrom's which reference AnyEvent
TTWNO May 3, 2023
721d2ce
Update tests to reflect new event structure
TTWNO May 3, 2023
412468a
Add Default implementation for Accessible; this is mostly used for tests
TTWNO May 3, 2023
8fd8cb7
Add Default implementation for all event structutes (very useful for …
TTWNO May 3, 2023
b23c0ea
Fix clippy
TTWNO May 3, 2023
f38574c
Cargo fmt
TTWNO May 3, 2023
aac25a2
Make sure build is successful before attempting to use gen_identify b…
TTWNO May 3, 2023
2f39a1a
impl Default only on structs which can not derive it
TTWNO May 3, 2023
fb83108
Update and format identify.rs
TTWNO May 3, 2023
845b7da
Show println content in tests for debugging
TTWNO May 3, 2023
05d9bf5
Add debugging prints for fixing a CI failure that doesn't seem to hap…
TTWNO May 3, 2023
3dcfc08
Add more debug info
TTWNO May 3, 2023
e70f7af
Remove unused variable in test
TTWNO May 3, 2023
c00b6fd
Stop getting the unique name in this test. I suspect it's causing the…
TTWNO May 3, 2023
2469f33
Add HasBody trait, which sets the type of a body for an item.
TTWNO May 3, 2023
0f39ba9
Add send_event function that works for any type that implements HasBo…
TTWNO May 3, 2023
c74c34f
Create new Body type in GenericEvent.
TTWNO May 3, 2023
d6a5d45
Update identify with autogen changes
TTWNO May 3, 2023
ece483b
Panic on unexpected events in tests
TTWNO May 3, 2023
ceb4b94
Macroify TryFrom message to Event and TryFrom event to Message
TTWNO May 3, 2023
dc82caa
Use new macro to generate TryFrom<Event/Message> for Message/Event
TTWNO May 3, 2023
4fb7368
Cargo format
TTWNO May 3, 2023
81105b2
Fix clippy
TTWNO May 3, 2023
6bb3f89
Cargo format
TTWNO May 3, 2023
9f82f35
Fix cargo docs
TTWNO May 3, 2023
410c6f7
Remove properties field on all events, it is not used.
TTWNO May 5, 2023
0806f3e
Add type overrides for zvairnat::Value types, since those are known i…
TTWNO May 5, 2023
43cdd9c
Erase zvariant::Value types, convert to stricter types
TTWNO May 5, 2023
63e5749
Fix clippy
TTWNO May 5, 2023
de99bc5
Cargo format
TTWNO May 5, 2023
2c2c063
Add more tests for custom events, add Default derivation to most even…
TTWNO May 6, 2023
ae37f15
Add new missing/mismatch variants for error; stricter checking for co…
TTWNO May 6, 2023
c8d29cd
cargo format fixes
TTWNO May 6, 2023
3e2fb0f
Add more conversion within doctests for testing purposes
TTWNO May 6, 2023
53747e6
Improve and move macros for generating various traits
TTWNO May 6, 2023
e5a6eb9
Export macro to local crate
TTWNO May 6, 2023
fdadfbf
Add additional traits, use macros, proper deserialization of Accessib…
TTWNO May 6, 2023
a752e07
Add rename-item to dev deps (generate test module names)
TTWNO May 6, 2023
13d4bca
Fix type of body; do not encapsulate
TTWNO May 6, 2023
0cfba71
Update codegen to use macros
TTWNO May 6, 2023
70d8712
Cargo format
TTWNO May 6, 2023
8ec2b64
Fix clippy
TTWNO May 6, 2023
d864ea3
Fix format/clippy fight
TTWNO May 6, 2023
f8a4493
Only compare body of event, since send_event() uses the currently use…
TTWNO May 6, 2023
60a28b0
Add tests for invalid zbus message conversions
TTWNO May 6, 2023
cde6fc4
Fix docs
TTWNO May 6, 2023
5e236db
Add proxy integration tests using firefox webdriver
TTWNO May 8, 2023
cc360b2
Add de/serailize to all event types
TTWNO May 9, 2023
1bc626b
Cargo fmt
TTWNO May 9, 2023
9df6c50
Separate firefox tests into unstable feature flag; implement Default …
TTWNO May 9, 2023
582e91d
Add static assertions about which derives are required
TTWNO May 9, 2023
eb97ef3
Add Eq and Hash to derives of all events
TTWNO May 9, 2023
44923ca
Always use static assertions
TTWNO May 9, 2023
8db8cf5
Add more macros to deal with testing invalid conversions, Event conve…
TTWNO May 9, 2023
bcde9fd
Cargo format
TTWNO May 9, 2023
a45f6e2
Remove doctests for llvm-cov.
TTWNO May 9, 2023
3df5748
Use stable Rust for llvm-cov
TTWNO May 9, 2023
e7dc8de
Cargo format
TTWNO May 9, 2023
174bf64
Actually fix cargo format issue
TTWNO May 9, 2023
56a5fe0
Explicitly set expect value in should_panic
TTWNO May 9, 2023
876db86
Move everything around. Two new crates: -events and -client
TTWNO May 11, 2023
e033fc4
Update CI to cover all workspace tests
TTWNO May 11, 2023
9b0ec13
cargo fmt
TTWNO May 11, 2023
2ac1dcc
remove old test from macro crate
TTWNO May 11, 2023
244ff56
Fix clippy
TTWNO May 12, 2023
aef43d2
formatting
TTWNO May 12, 2023
d137186
fix/remove doc links
TTWNO May 12, 2023
4e53805
Use static assertion macros
TTWNO May 12, 2023
05e1a97
Fix clippy errors
TTWNO May 12, 2023
534bcf7
format
TTWNO May 12, 2023
ddf6233
Fix feature flag problems
TTWNO May 12, 2023
56fe322
Formatting
TTWNO May 12, 2023
c128528
Fix clippy again
TTWNO May 12, 2023
a7871c5
Fix CI MSRV check
TTWNO May 12, 2023
e349bd9
detail1 -> operation for textchanged event
TTWNO May 28, 2023
de25abd
Add serde and zvariant::Type derive imports
TTWNO May 28, 2023
2355e32
Use atspi-types CacheItem
TTWNO May 28, 2023
b715893
Use atspi_types types in cache'
TTWNO May 29, 2023
f85219d
Remove role and relation type, import from types
TTWNO May 29, 2023
6727979
Re-export atspi-types::Interface*
TTWNO May 29, 2023
479e44b
Move CoordType to atspi-types
TTWNO May 31, 2023
864db3c
Move all collection's types to atspi-types
TTWNO May 31, 2023
d85c1e0
Remove unused imports
TTWNO May 31, 2023
e7b2764
Cargo format
TTWNO May 31, 2023
8f254d3
Machete already installed on rust toolchain master
TTWNO May 31, 2023
7fa307b
Restructure crates
TTWNO Jun 9, 2023
de4d9ed
Fix error with unstable-traits
TTWNO Jun 9, 2023
5c024d2
Add a new `atspi-connection` and `atspi-proxies` crates.
TTWNO Jun 9, 2023
f1ed1f6
Rename crate imports to match new subcrate format
TTWNO Jun 9, 2023
1a18883
Remove unused deps (thanks cargo machete)
TTWNO Jun 9, 2023
8e7f5a3
Move *Ext traits to their own crate: atspi-client
TTWNO Jun 10, 2023
fcabdc8
Add atspi-client to main atspi crate
TTWNO Jun 10, 2023
7786589
Fix clippy suggestions
TTWNO Jun 11, 2023
fe8881e
Cargo format
TTWNO Jun 11, 2023
8ffc670
Remove unused dependencies; move dev deps to appropriate section
TTWNO Jun 11, 2023
d5a651f
Merge main
TTWNO Jun 11, 2023
032a155
Use workspace enumflags2
TTWNO Jun 11, 2023
bbc0c72
Fix conflict markers
TTWNO Jun 11, 2023
e93b073
Use atspi-common::ObjectPair in TableCell proxy
TTWNO Jun 11, 2023
4eecc6a
Install cargo machete
TTWNO Jun 11, 2023
e3d32a4
More intuitive features with two meta-features: tokio and async-std
TTWNO Jun 11, 2023
60b86d9
Semver compliance for default features
TTWNO Jun 11, 2023
e752f9a
Fix atspi version number
TTWNO Jun 11, 2023
b423c07
Move text proxy types to common
TTWNO Jun 11, 2023
605e148
Move component types to atspi-common
TTWNO Jun 11, 2023
2a4db39
Move matchertypes to atspi-common
TTWNO Jun 11, 2023
337c743
Cargo format
TTWNO Jun 12, 2023
3311162
Normalize feature flags
TTWNO Jun 12, 2023
c318c7a
Check that tests pass with either executor
TTWNO Jun 12, 2023
7bd2b64
Disable default features for tests
TTWNO Jun 12, 2023
d543883
Remove impossible cyclic doc references between -common and -proxies
TTWNO Jun 12, 2023
990e1d9
Fix rustdoc errors
TTWNO Jun 12, 2023
fe3cceb
Use workspace doc feature
TTWNO Jun 12, 2023
012db27
Use workspace zbus dep, this should fix the stupid semver compiler er…
TTWNO Jun 12, 2023
bf313a4
Update enumflags2 again
TTWNO Jun 12, 2023
6f3fa38
Uncomment test block in events/mod.rs; remove manual tests which have…
TTWNO Jun 12, 2023
4d22f5e
Add test for each event to check that the message produced can be con…
TTWNO Jun 12, 2023
cd8ed90
Update broken signal types
TTWNO Jun 12, 2023
3ff600c
Cargo format
TTWNO Jun 12, 2023
d553c4a
Revert change to signal types, which makes tests fail; this is correc…
TTWNO Jun 12, 2023
1f40986
Remove extra parenthasies around emitting events
TTWNO Jun 14, 2023
3284ebc
Fix DBus Body type in GenericEvent for failing events
TTWNO Jun 14, 2023
918b1c3
Cargo format
TTWNO Jun 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ jobs:
- name: Install Dependencies
run: |
sudo apt -y install at-spi2-core systemd
- name: Run Tests
run: cargo test --features=unstable-traits
- name: Run Tests (tokio)
run: cargo test --workspace --no-default-features --features=unstable-traits,tokio -- --nocapture
- name: Run Tests (async-std)
run: cargo test --workspace --no-default-features --features=unstable-traits,async-std -- --nocapture
rustfmt:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -101,7 +103,7 @@ jobs:
with:
toolchain: nightly
- name: Generate Documentation
run: cargo doc --all-features --no-deps
run: cargo doc --workspace --features unstable-traits --no-deps
no-unused-dependencies:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -154,7 +156,7 @@ jobs:
# no default features so that it uses native Rust TLS instead of trying to link with system TLS.
run: cargo install cargo-semver-checks --no-default-features
- name: Check Semver Compliance
run: cargo semver-checks check-release -p atspi
run: cargo semver-checks check-release -p atspi --default-features
msrv-compliance:
runs-on: ubuntu-latest
steps:
Expand All @@ -180,7 +182,7 @@ jobs:
- name: Install Cargo MSRV Verifier
run: cargo install cargo-msrv
- name: Check MSRV Compliance
run: cargo msrv verify
run: cargo msrv --path atspi verify
coverage:
runs-on: ubuntu-latest
steps:
Expand All @@ -189,7 +191,7 @@ jobs:
- name: Install nightly
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
toolchain: stable
components: llvm-tools-preview
- name: cargo install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
Expand All @@ -200,7 +202,7 @@ jobs:
run: |
sudo apt -y install at-spi2-core systemd
- name: cargo llvm-cov
run: cargo llvm-cov --doctests --locked --features=unstable-traits --lcov --output-path lcov.info
run: cargo llvm-cov --workspace --locked --features=unstable-traits --lcov --output-path lcov.info
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
with:
Expand Down
61 changes: 14 additions & 47 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,47 +1,14 @@
[package]
name = "atspi"
version = "0.15.1"
authors = ["Michael Connor Buchan <mikey@blindcomputing.org>", "Tait Hoyem <tait@tait.tech>", "Alberto Tirla <albertotirla@gmail.com>", "DataTriny <datatriny@gmail.com>", "Luuk Duim <luukvanderduim@gmail.com>"]
description = "Pure-Rust, zbus-based AT-SPI2 protocol implementation."
license = "Apache-2.0 OR MIT" # For ease of integration in the Rust ecosystem.
readme = "README.md"
repository = "https://github.com/odilia-app/atspi"
homepage = "https://github.com/odilia-app/atspi"
keywords = ["screen-reader", "accessibility", "a11y", "tts", "linux"]
categories = ["accessibility", "api-bindings"]
edition = "2021"
rust-version = "1.65"
include = ["src/**/*", "atspi-macros/**/*", "LICENSE-*", "README.md"]

[package.metadata.release]
release = true
publish = true

[features]
default = ["async-io", "client-accessories"]
async-io = ["zbus/async-io"]
gvariant = ["zbus/gvariant"]
tokio = ["zbus/tokio"]
client-accessories = ["dep:tracing", "dep:futures-lite"]
unstable-traits = ["atspi-macros/unstable_atspi_proxy_macro", "atspi-macros/tokio", "dep:static_assertions", "dep:async-trait"]

[dependencies]
atspi-macros = { version = "0.3.0", path = "atspi-macros" }
enumflags2 = "^0.7.7"
serde = { version = "^1.0", default-features = false, features = ["derive"] }
zbus = { version = "^3.6.2", default-features = false }
# optioanl dependencies
futures-lite = { version = "1.12", default-features = false, optional = true }
tracing = { version = "^0.1.37", optional = true }
static_assertions = { version = "^1.1.0", optional = true }
async-trait = { version = "^0.1.59", optional = true }

[dev-dependencies]
byteorder = "1.4"
serde_plain = "1.0.1"
lazy_static = "1.0"
tokio-stream = "0.1"
tokio = { version = "1", default_features = false, features = ["macros", "rt-multi-thread"] }
async-std = { version = "1", features = ["attributes"] }
futures-lite = { version = "1.12", default-features = false }
tokio-test = "0.4.2"
[workspace]
members = [
"atspi",
"atspi-proxies",
"atspi-common",
"atspi-macros",
"atspi-connection",
"atspi-client"
]

[workspace.dependencies]
zbus = "3.12.0"
tracing = "0.1.37"
enumflags2 = "0.7.7"
25 changes: 25 additions & 0 deletions atspi-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "atspi-client"
version = "0.1.0"
edition = "2021"
description = "Client extensions for the atspi crate."
readme = "README.md"
categories = ["accessibility"]
keywords = ["screen-reader", "accessibility", "a11y", "linux"]
license = "Apache-2.0 OR MIT"
repository = "https://github.com/odilia-app/atspi/"
homepage = "https://github.com/odilia-app/atspi/"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["async-std"]
tokio = ["atspi-proxies/tokio", "atspi-common/tokio"]
async-std = ["atspi-proxies/async-std", "atspi-common/async-std"]

[dependencies]
async-trait = "0.1.68"
static_assertions = "1.1.0"
atspi-common = { path = "../atspi-common/", default-features = false }
atspi-proxies = { path = "../atspi-proxies", default-features = false, features = ["unstable-traits"] }
zbus.workspace = true
6 changes: 6 additions & 0 deletions atspi-client/REAMDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# `atspi-client`

For all AT-related extensions to `atspi`.

This employs the use of some additional traits and implementations to make the creation of e.g. a screen reader more simple for developers.
This is intended to work primarily with the Odilia screen reader, but others may find some use.
166 changes: 85 additions & 81 deletions src/accessible_ext.rs → atspi-client/src/accessible_ext.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
use crate::{
accessible::{
Accessible, AccessibleBlocking, AccessibleProxy, AccessibleProxyBlocking, RelationType,
Role,
},
collection::MatchType,
convertable::{Convertable, ConvertableBlocking},
use crate::convertable::{Convertable, ConvertableBlocking};
use async_trait::async_trait;
use atspi_common::{AtspiError as Error, MatcherArgs, ObjectPair, RelationType, Role};
use atspi_proxies::{
accessible::{Accessible, AccessibleBlocking, AccessibleProxy, AccessibleProxyBlocking},
hyperlink::Hyperlink,
text::{Text, TextBlocking},
InterfaceSet,
};
use async_trait::async_trait;
use std::collections::HashMap;

pub type MatcherArgs =
(Vec<Role>, MatchType, HashMap<String, String>, MatchType, InterfaceSet, MatchType);

#[async_trait]
pub trait AccessibleExt {
type Error: std::error::Error;
async fn get_application_ext<'a>(&self) -> Result<Self, Self::Error>
where
Self: Sized;
async fn get_parent_ext<'a>(&self) -> Result<Self, Self::Error>
where
Self: Sized;
Expand All @@ -43,21 +39,20 @@ pub trait AccessibleExt {
&self,
matcher_args: &MatcherArgs,
backward: bool,
already_visited: &'a mut Vec<ObjectPair>,
) -> Result<Option<Self>, Self::Error>
where
Self: Sized;
async fn get_relation_set_ext<'a>(
&self,
) -> Result<HashMap<RelationType, Vec<Self>>, Self::Error>
/// Get all edges for a given accessible object.
/// This means: all children, siblings, and parent, in that order.
/// If a direction is specified, then it will only get the appicable matching siblings/children.
/// This also checks if the element supports the text interface, and then checks if the caret position is contained within the string, if it is, then children are also handled by direction.
async fn edges<'a>(&self, backward: Option<bool>) -> Result<Vec<Self>, Self::Error>
where
Self: Sized;
async fn find_inner<'a>(
async fn get_relation_set_ext<'a>(
&self,
after_or_before: i32,
matcher_args: &MatcherArgs,
backward: bool,
recur: bool,
) -> Result<Option<Self>, <Self as AccessibleExt>::Error>
) -> Result<HashMap<RelationType, Vec<Self>>, Self::Error>
where
Self: Sized;
async fn match_(
Expand All @@ -78,6 +73,9 @@ pub trait AccessibleExtError: Accessible + Convertable {
+ From<std::num::TryFromIntError>
+ Send;
}
impl AccessibleExtError for AccessibleProxy<'_> {
type Error = Error;
}

#[allow(clippy::module_name_repetitions)]
pub trait AccessibleBlockingExtError: AccessibleBlocking + ConvertableBlocking {
Expand All @@ -88,10 +86,22 @@ pub trait AccessibleBlockingExtError: AccessibleBlocking + ConvertableBlocking {
+ From<<<Self as ConvertableBlocking>::Text as TextBlocking>::Error>
+ From<std::num::TryFromIntError>;
}
impl AccessibleBlockingExtError for AccessibleProxyBlocking<'_> {
type Error = Error;
}

#[async_trait]
impl<T: Accessible + Convertable + AccessibleExtError + Send + Sync> AccessibleExt for T {
impl<T: Accessible + Convertable + AccessibleExtError + Send + Sync + Clone> AccessibleExt for T
where
ObjectPair: for<'c> TryFrom<&'c T>,
{
type Error = <T as AccessibleExtError>::Error;
async fn get_application_ext<'a>(&self) -> Result<Self, Self::Error>
where
Self: Sized,
{
Ok(self.get_application().await?)
}
async fn get_parent_ext<'a>(&self) -> Result<Self, Self::Error>
where
Self: Sized,
Expand Down Expand Up @@ -130,7 +140,8 @@ impl<T: Accessible + Convertable + AccessibleExtError + Send + Sync> AccessibleE
Self: Sized,
{
let parent = self.parent().await?;
let index = self.get_index_in_parent().await?.try_into()?;
let pin = self.get_index_in_parent().await?;
let index = pin.try_into()?;
// Clippy false positive: Standard pattern for excluding index item from list.
#[allow(clippy::if_not_else)]
let children: Vec<Self> = parent
Expand Down Expand Up @@ -194,39 +205,68 @@ impl<T: Accessible + Convertable + AccessibleExtError + Send + Sync> AccessibleE
}
Ok(children_after_before)
}
async fn edges<'a>(&self, backward: Option<bool>) -> Result<Vec<Self>, Self::Error>
where
Self: Sized,
{
let mut edge_elements = Vec::new();
let children = match backward {
Some(backward) => {
if let Ok(caret_children) = self.get_children_caret(backward).await {
caret_children
} else {
self.get_children().await?
}
}
None => self.get_children().await?,
};
children.into_iter().for_each(|child| edge_elements.push(child));
let siblings = match backward {
Some(false) => self.get_siblings_before().await?,
Some(true) => self.get_siblings_after().await?,
None => self.get_siblings().await?,
};
siblings.into_iter().for_each(|sibling| edge_elements.push(sibling));
let parent = self.get_parent_ext().await?;
edge_elements.push(parent);
Ok(edge_elements)
}
async fn get_next<'a>(
&self,
matcher_args: &MatcherArgs,
backward: bool,
visited: &'a mut Vec<ObjectPair>,
) -> Result<Option<Self>, Self::Error>
where
Self: Sized,
{
// TODO if backwards, check here
let caret_children = self.get_children_caret(backward).await?;
for child in caret_children {
if child.match_(matcher_args).await? {
return Ok(Some(child));
} else if let Some(found_sub) =
child.find_inner(0, matcher_args, backward, true).await?
{
return Ok(Some(found_sub));
let mut stack: Vec<T> = Vec::new();
let edges = self.edges(Some(backward)).await?;
edges.into_iter().for_each(|edge| stack.push(edge));
while let Some(item) = stack.pop() {
// TODO: properly bubble up error
let Ok(identifier) = ObjectPair::try_from(&item) else {
return Ok(None);
};
// the top of the hirearchy for strctural navigation.
if visited.contains(&identifier) {
continue;
}
}
let mut last_parent_index = self.get_index_in_parent().await?;
if let Ok(mut parent) = self.get_parent_ext().await {
while parent.get_role().await? != Role::InternalFrame {
let found_inner_child = parent
.find_inner(last_parent_index, matcher_args, backward, false)
.await?;
if found_inner_child.is_some() {
return Ok(found_inner_child);
}
last_parent_index = parent.get_index_in_parent().await?;
parent = parent.get_parent_ext().await?;
visited.push(identifier);
if item.get_role().await? == Role::InternalFrame {
return Ok(None);
}
// if it matches, then return it
if item.match_(matcher_args).await? {
return Ok(Some(item));
}
// if it doesnt match, add all edges
self.edges(Some(backward))
.await?
.into_iter()
.for_each(|edge| stack.push(edge));
}
Ok(None)
return Ok(None);
}
async fn get_relation_set_ext<'a>(
&self,
Expand All @@ -245,42 +285,6 @@ impl<T: Accessible + Convertable + AccessibleExtError + Send + Sync> AccessibleE
}
Ok(relations)
}
async fn find_inner<'a>(
&self,
after_or_before: i32,
matcher_args: &MatcherArgs,
backward: bool,
recur: bool,
) -> Result<Option<Self>, <Self as AccessibleExt>::Error>
where
Self: Sized,
{
let children = if backward {
let mut vec = self.get_children_ext().await?;
vec.reverse();
vec
} else {
self.get_children_ext().await?
};
for child in children {
let child_index = child.get_index_in_parent().await?;
if !recur
&& ((child_index <= after_or_before && !backward)
|| (child_index >= after_or_before && backward))
{
continue;
}
if child.match_(matcher_args).await? {
return Ok(Some(child));
}
/* 0 here is ignored because we are recursive; see the line starting with if !recur */
if let Some(found_decendant) = child.find_inner(0, matcher_args, backward, true).await?
{
return Ok(Some(found_decendant));
}
}
Ok(None)
}
// TODO: make match more broad, allow use of other parameters; also, support multiple roles, since right now, multiple will just exit immediately with false
async fn match_(
&self,
Expand Down
Loading