Skip to content

Commit 6ac6a6b

Browse files
lukewarlowdelan
andcommitted
Print action requests from our subtree
Co-authored-by: Delan Azabani <[email protected]> Signed-off-by: Luke Warlow <[email protected]>
1 parent 33ee78f commit 6ac6a6b

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

components/layout/accessibility_tree.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::rc::Rc;
66
use std::sync::LazyLock;
77

88
pub(crate) use accessibility_traits::AccessibilityTree;
9-
use accesskit::{Node as AxNode, NodeId as AxNodeId, Role, Tree as AxTree};
9+
use accesskit::{Action, Node as AxNode, NodeId as AxNodeId, Role, Tree as AxTree};
1010
use html5ever::{LocalName, local_name};
1111
use layout_api::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode};
1212
use log::trace;
@@ -77,6 +77,7 @@ impl AccessibilityTreeCalculator {
7777
}
7878
}
7979
}
80+
ax_next.add_action(Action::Click);
8081
ax_nodes.insert(ax_next_id, ax_next);
8182
}
8283
AccessibilityTree {

ports/servoshell/desktop/app.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@ impl ApplicationHandler<AppEvent> for App {
284284
if let Some(window_id) = app_event.window_id() {
285285
let window_id: u64 = window_id.into();
286286
if let Some(window) = state.window(window_id.into()) {
287-
window.platform_window().handle_winit_app_event(app_event);
287+
window
288+
.platform_window()
289+
.handle_winit_app_event(&window, app_event);
288290
}
289291
}
290292
}

ports/servoshell/desktop/headed_window.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,8 +779,21 @@ impl PlatformWindow for Window {
779779
}
780780
}
781781

782-
fn handle_winit_app_event(&self, app_event: AppEvent) {
782+
fn handle_winit_app_event(&self, _window: &ServoShellWindow, app_event: AppEvent) {
783783
if let AppEvent::Accessibility(ref event) = app_event {
784+
match &event.window_event {
785+
egui_winit::accesskit_winit::WindowEvent::InitialTreeRequested => {
786+
// TODO get the initial tree from servo
787+
},
788+
egui_winit::accesskit_winit::WindowEvent::ActionRequested(req) => {
789+
// TODO use window to get active webview, then do something with action request.
790+
if req.target_tree != TreeId::ROOT {
791+
println!("{:?}", req);
792+
}
793+
},
794+
_ => {},
795+
}
796+
784797
if self
785798
.gui
786799
.borrow_mut()

ports/servoshell/window.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use servo::{
1515
};
1616
use url::Url;
1717

18+
use crate::desktop::event_loop::AppEvent;
1819
use crate::running_app_state::{RunningAppState, UserInterfaceCommand, WebViewCollection};
1920

2021
// This should vary by zoom level and maybe actual text size (focused or under cursor)
@@ -310,7 +311,12 @@ pub(crate) trait PlatformWindow {
310311
/// TODO: This should be handled internally in the winit window if possible so that it
311312
/// makes more sense when we are mixing headed and headless windows.
312313
#[cfg(not(any(target_os = "android", target_env = "ohos")))]
313-
fn handle_winit_app_event(&self, _: crate::desktop::event_loop::AppEvent) {}
314+
fn handle_winit_app_event(
315+
&self,
316+
_: &ServoShellWindow,
317+
_: crate::desktop::event_loop::AppEvent,
318+
) {
319+
}
314320
fn take_user_interface_commands(&self) -> Vec<UserInterfaceCommand> {
315321
Default::default()
316322
}

0 commit comments

Comments
 (0)