Skip to content

Commit

Permalink
fix: Update windows to 0.54 (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
DataTriny committed Mar 18, 2024
1 parent c9037d8 commit 50f112f
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 108 deletions.
26 changes: 18 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion platforms/windows/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ paste = "1.0"
static_assertions = "1.1.0"

[dependencies.windows]
version = "0.52"
version = "0.54"
features = [
"implement",
"Win32_Foundation",
Expand Down
4 changes: 2 additions & 2 deletions platforms/windows/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ impl QueuedEvents {
UiaRaiseAutomationPropertyChangedEvent(
&element,
property_id,
old_value,
new_value,
&old_value,
&new_value,
)
}
.unwrap();
Expand Down
26 changes: 11 additions & 15 deletions platforms/windows/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ use paste::paste;
use std::sync::{Arc, Weak};
use windows::{
core::*,
Win32::{
Foundation::*,
System::{Com::*, Variant::*},
UI::Accessibility::*,
},
Win32::{Foundation::*, System::Com::*, UI::Accessibility::*},
};

use crate::{
Expand Down Expand Up @@ -461,8 +457,8 @@ impl<'a> NodeWrapper<'a> {
queue: &mut Vec<QueuedEvent>,
element: &IRawElementProviderSimple,
property_id: UIA_PROPERTY_ID,
old_value: VariantFactory,
new_value: VariantFactory,
old_value: Variant,
new_value: Variant,
) {
let old_value: VARIANT = old_value.into();
let new_value: VARIANT = new_value.into();
Expand Down Expand Up @@ -650,7 +646,7 @@ impl IRawElementProviderSimple_Impl for PlatformNode {
if self.node_id == state.root_id() {
unsafe { UiaHostProviderFromHwnd(context.hwnd) }
} else {
Err(Error::OK)
Err(Error::empty())
}
})
}
Expand All @@ -672,7 +668,7 @@ impl IRawElementProviderFragment_Impl for PlatformNode {
};
match result {
Some(result) => Ok(self.relative(result.id()).into()),
None => Err(Error::OK),
None => Err(Error::empty()),
}
})
}
Expand Down Expand Up @@ -730,7 +726,7 @@ impl IRawElementProviderFragmentRoot_Impl for PlatformNode {
let point = Point::new(x - client_top_left.x, y - client_top_left.y);
let point = node.transform().inverse() * point;
node.node_at_point(point, &filter).map_or_else(
|| Err(Error::OK),
|| Err(Error::empty()),
|node| Ok(self.relative(node.id()).into()),
)
})
Expand All @@ -743,20 +739,20 @@ impl IRawElementProviderFragmentRoot_Impl for PlatformNode {
return Ok(self.relative(id).into());
}
}
Err(Error::OK)
Err(Error::empty())
})
}
}

macro_rules! properties {
($(($base_id:ident, $m:ident)),+) => {
impl NodeWrapper<'_> {
fn get_property_value(&self, property_id: UIA_PROPERTY_ID) -> VariantFactory {
fn get_property_value(&self, property_id: UIA_PROPERTY_ID) -> Variant {
match property_id {
$(paste! { [< UIA_ $base_id PropertyId>] } => {
self.$m().into()
})*
_ => VariantFactory::empty()
_ => Variant::empty()
}
}
fn enqueue_simple_property_changes(
Expand Down Expand Up @@ -804,7 +800,7 @@ macro_rules! patterns {
})*
_ => (),
}
Err(Error::OK)
Err(Error::empty())
})
}
}
Expand Down Expand Up @@ -926,7 +922,7 @@ patterns! {
// TODO: implement when we work on list boxes (#23)
// We return E_FAIL here because that's what Chromium does
// if it can't find a container.
Err(Error::new(E_FAIL, "".into()))
Err(E_FAIL.into())
}
)),
(Text, is_text_pattern_supported, (), (
Expand Down
4 changes: 2 additions & 2 deletions platforms/windows/src/tests/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ fn navigation() -> Result<()> {
assert!(equal);

let wrapped_child = unsafe { walker.GetFirstChildElement(&button_1_forward) };
assert_eq!(Err(Error::OK), wrapped_child);
assert_eq!(Err(Error::empty()), wrapped_child);

let wrapped_child = unsafe { walker.GetLastChildElement(&button_1_forward) };
assert_eq!(Err(Error::OK), wrapped_child);
assert_eq!(Err(Error::empty()), wrapped_child);

Ok(())
})
Expand Down
16 changes: 6 additions & 10 deletions platforms/windows/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ use accesskit_consumer::{
use std::sync::{Arc, RwLock, Weak};
use windows::{
core::*,
Win32::{
Foundation::*,
System::{Com::*, Variant::*},
UI::Accessibility::*,
},
Win32::{Foundation::*, System::Com::*, UI::Accessibility::*},
};

use crate::{context::Context, node::PlatformNode, util::*};
Expand Down Expand Up @@ -411,7 +407,7 @@ impl ITextRangeProvider_Impl for PlatformRange {
) -> Result<ITextRangeProvider> {
// TODO: implement when we support variable formatting (part of rich text)
// Justification: JUCE doesn't implement this.
Err(Error::OK)
Err(Error::empty())
}

fn FindText(
Expand All @@ -423,7 +419,7 @@ impl ITextRangeProvider_Impl for PlatformRange {
// TODO: implement when there's a real-world use case that requires it
// Justification: Quorum doesn't implement this and is being used
// by blind students.
Err(Error::OK)
Err(Error::empty())
}

fn GetAttributeValue(&self, id: UIA_TEXTATTRIBUTE_ID) -> Result<VARIANT> {
Expand All @@ -432,7 +428,7 @@ impl ITextRangeProvider_Impl for PlatformRange {
// TBD: do we ever want to support mixed read-only/editable text?
self.with_node(|node| {
let value = node.is_read_only();
Ok(VariantFactory::from(value).into())
Ok(value.into())
})
}
UIA_CaretPositionAttributeId => self.read(|range| {
Expand All @@ -445,12 +441,12 @@ impl ITextRangeProvider_Impl for PlatformRange {
value = CaretPosition_EndOfLine;
}
}
Ok(VariantFactory::from(value).into())
Ok(value.0.into())
}),
// TODO: implement more attributes
_ => {
let value = unsafe { UiaGetReservedNotSupportedValue() }.unwrap();
Ok(VariantFactory::from(value).into())
Ok(value.into())
}
}
}
Expand Down

0 comments on commit 50f112f

Please sign in to comment.