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

Update windows crate to v0.48 #257

Merged
merged 11 commits into from
Aug 8, 2023
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,9 @@ jobs:
- name: cargo test
run: cargo test

- name: cargo test -p accesskit_windows
if: matrix.os == 'windows-2019'
run: cargo test -p accesskit_windows

generate-headers:
uses: AccessKit/accesskit/.github/workflows/generate-headers.yml@main
101 changes: 79 additions & 22 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions platforms/windows/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ once_cell = "1.13.0"
paste = "1.0"

[dependencies.windows]
version = "0.44.0"
version = "0.48.0"
features = [
"implement",
"Win32_Foundation",
"Win32_Graphics_Gdi",
"Win32_System_Com",
"Win32_System_LibraryLoader",
"Win32_System_Ole",
"Win32_System_Threading",
"Win32_UI_Accessibility",
"Win32_UI_Input_KeyboardAndMouse",
"Win32_UI_WindowsAndMessaging",
Expand Down
6 changes: 3 additions & 3 deletions platforms/windows/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ macro_rules! patterns {
// SAFETY: We know we're running inside a full COM implementation.
let intermediate: paste! { [< I $base_pattern_id Provider>] } =
unsafe { self.cast() }?;
return Ok(intermediate.into());
return intermediate.cast();
}
})*
_ => (),
Expand Down Expand Up @@ -926,7 +926,7 @@ patterns! {
self.resolve_for_text_pattern(|node| {
if let Some(range) = node.text_selection() {
let platform_range: ITextRangeProvider = PlatformTextRange::new(&self.context, range).into();
let iunknown: IUnknown = platform_range.into();
let iunknown: IUnknown = platform_range.cast()?;
Ok(safe_array_from_com_slice(&[iunknown]))
} else {
Ok(std::ptr::null_mut())
Expand All @@ -941,7 +941,7 @@ patterns! {
Ok(std::ptr::null_mut())
},

fn RangeFromChild(&self, _child: &Option<IRawElementProviderSimple>) -> Result<ITextRangeProvider> {
fn RangeFromChild(&self, _child: Option<&IRawElementProviderSimple>) -> Result<ITextRangeProvider> {
// We don't support embedded objects in text.
Err(not_implemented())
},
Expand Down
4 changes: 2 additions & 2 deletions platforms/windows/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ impl FocusEventHandler {
}

impl IUIAutomationFocusChangedEventHandler_Impl for FocusEventHandler {
fn HandleFocusChangedEvent(&self, sender: &Option<IUIAutomationElement>) -> Result<()> {
self.received.put(sender.as_ref().unwrap().clone());
fn HandleFocusChangedEvent(&self, sender: Option<&IUIAutomationElement>) -> Result<()> {
self.received.put(sender.unwrap().clone());
Ok(())
}
}
Expand Down
6 changes: 3 additions & 3 deletions platforms/windows/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ impl ITextRangeProvider_Impl for PlatformRange {
Ok(self.clone().into())
}

fn Compare(&self, other: &Option<ITextRangeProvider>) -> Result<BOOL> {
fn Compare(&self, other: Option<&ITextRangeProvider>) -> Result<BOOL> {
let other = required_param(other)?.as_impl();
Ok((self.context.ptr_eq(&other.context)
&& *self.state.read().unwrap() == *other.state.read().unwrap())
Expand All @@ -337,7 +337,7 @@ impl ITextRangeProvider_Impl for PlatformRange {
fn CompareEndpoints(
&self,
endpoint: TextPatternRangeEndpoint,
other: &Option<ITextRangeProvider>,
other: Option<&ITextRangeProvider>,
other_endpoint: TextPatternRangeEndpoint,
) -> Result<i32> {
let other = required_param(other)?.as_impl();
Expand Down Expand Up @@ -527,7 +527,7 @@ impl ITextRangeProvider_Impl for PlatformRange {
fn MoveEndpointByRange(
&self,
endpoint: TextPatternRangeEndpoint,
other: &Option<ITextRangeProvider>,
other: Option<&ITextRangeProvider>,
other_endpoint: TextPatternRangeEndpoint,
) -> Result<()> {
let other = required_param(other)?.as_impl();
Expand Down
4 changes: 2 additions & 2 deletions platforms/windows/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ pub(crate) fn invalid_arg() -> Error {
Error::new(E_INVALIDARG, "".into())
}

pub(crate) fn required_param<T>(param: &Option<T>) -> Result<&T> {
param.as_ref().map_or_else(|| Err(invalid_arg()), Ok)
pub(crate) fn required_param<T>(param: Option<&T>) -> Result<&T> {
param.map_or_else(|| Err(invalid_arg()), Ok)
}

pub(crate) fn element_not_available() -> Error {
Expand Down