diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 649aab10c1b..5d3750b1308 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -3151,7 +3151,7 @@ where webview.accessibility_active = active; self.constellation_to_embedder_proxy.send( - ConstellationToEmbedderMsg::AccessibilityTreeIdChanged( + ConstellationToEmbedderMsg::DocumentAccessibilityTreeIdChanged( webview_id, webview.active_top_level_pipeline_id.into(), ), @@ -5799,7 +5799,7 @@ where if frame_tree.pipeline.id != webview.active_top_level_pipeline_id { webview.active_top_level_pipeline_id = frame_tree.pipeline.id; self.constellation_to_embedder_proxy.send( - ConstellationToEmbedderMsg::AccessibilityTreeIdChanged( + ConstellationToEmbedderMsg::DocumentAccessibilityTreeIdChanged( webview_id, webview.active_top_level_pipeline_id.into(), ), diff --git a/components/constellation/constellation_webview.rs b/components/constellation/constellation_webview.rs index c05c0c21482..2b0a8ee58f1 100644 --- a/components/constellation/constellation_webview.rs +++ b/components/constellation/constellation_webview.rs @@ -67,10 +67,12 @@ impl ConstellationWebView { focused_browsing_context_id: BrowsingContextId, user_content_manager_id: Option, ) -> Self { - embedder_proxy.send(ConstellationToEmbedderMsg::AccessibilityTreeIdChanged( - webview_id, - active_top_level_pipeline_id.into(), - )); + embedder_proxy.send( + ConstellationToEmbedderMsg::DocumentAccessibilityTreeIdChanged( + webview_id, + active_top_level_pipeline_id.into(), + ), + ); Self { webview_id, diff --git a/components/constellation/embedder.rs b/components/constellation/embedder.rs index 66dbf9583cd..e98746f1061 100644 --- a/components/constellation/embedder.rs +++ b/components/constellation/embedder.rs @@ -50,5 +50,5 @@ pub enum ConstellationToEmbedderMsg { HistoryChanged(WebViewId, Vec, usize), /// Notifies the embedder that the AccessKit [`TreeId`] for the top-level document in this /// WebView has been changed (or initially set). - AccessibilityTreeIdChanged(WebViewId, TreeId), + DocumentAccessibilityTreeIdChanged(WebViewId, TreeId), } diff --git a/components/servo/servo.rs b/components/servo/servo.rs index 3f144d7f385..2776b74336f 100644 --- a/components/servo/servo.rs +++ b/components/servo/servo.rs @@ -771,9 +771,9 @@ impl ServoInner { .notify_media_session_event(webview, media_session_event); } }, - ConstellationToEmbedderMsg::AccessibilityTreeIdChanged(webview_id, tree_id) => { + ConstellationToEmbedderMsg::DocumentAccessibilityTreeIdChanged(webview_id, tree_id) => { if let Some(webview) = self.get_webview_handle(webview_id) { - webview.notify_accessibility_tree_id(tree_id); + webview.notify_document_accessibility_tree_id(tree_id); } }, } diff --git a/components/servo/tests/accessibility.rs b/components/servo/tests/accessibility.rs index d567be45b4f..016c4a9137c 100644 --- a/components/servo/tests/accessibility.rs +++ b/components/servo/tests/accessibility.rs @@ -48,7 +48,7 @@ fn test_basic_accessibility_update() { let load_webview = webview.clone(); servo_test.spin(move || load_webview.load_status() != LoadStatus::Complete); - let updates = wait_for_min_updates(&servo_test, delegate.clone(), 2); + let updates = wait_for_min_updates(&servo_test, delegate.clone(), 1); let tree = build_tree(updates); let root_node = tree.state().root(); diff --git a/components/servo/webview.rs b/components/servo/webview.rs index da59a00d2cd..0c42992996d 100644 --- a/components/servo/webview.rs +++ b/components/servo/webview.rs @@ -787,10 +787,9 @@ impl WebView { /// sending any tree updates from the webview to your AccessKit adapter. Otherwise you may /// violate AccessKit’s subtree invariants and **panic**. /// - /// This method may call [`WebViewDelegate::notify_accessibility_tree_update()`] synchronously - /// with an initial tree update, so if your impl for that method can’t create the graft node - /// (and send *that* update to AccessKit) before sending this update to AccessKit, then it must - /// queue the update for later. + /// If your impl for [`WebViewDelegate::notify_accessibility_tree_update()`] can’t create the + /// graft node (and send *that* update to AccessKit) before sending any updates from this + /// webview to AccessKit, then it must queue those updates until it can guarantee that. /// /// [graft]: https://docs.rs/accesskit/0.24.0/accesskit/struct.Node.html#method.tree_id /// [`set_tree_id()`]: https://docs.rs/accesskit/0.24.0/accesskit/struct.Node.html#method.set_tree_id @@ -806,23 +805,6 @@ impl WebView { if active { let accesskit_tree_id = TreeId(AccesskitUuid::new_v4()); self.inner_mut().accesskit_tree_id = Some(accesskit_tree_id); - - // Synchronously emit a TreeUpdate containing just a ScrollView, but no graft node yet. - let root_node_id = NodeId(0); - let root_node = AccesskitNode::new(Role::ScrollView); - self.delegate().notify_accessibility_tree_update( - self.clone(), - TreeUpdate { - nodes: vec![(root_node_id, root_node)], - tree: Some(Tree { - root: root_node_id, - toolkit_name: None, - toolkit_version: None, - }), - tree_id: accesskit_tree_id, - focus: root_node_id, - }, - ); } else { self.inner_mut().accesskit_tree_id = None; } @@ -834,7 +816,7 @@ impl WebView { self.accesskit_tree_id() } - pub fn notify_accessibility_tree_id(&self, grafted_tree_id: TreeId) { + pub(crate) fn notify_document_accessibility_tree_id(&self, grafted_tree_id: TreeId) { let Some(webview_accesskit_tree_id) = self.inner().accesskit_tree_id else { return; }; @@ -850,7 +832,6 @@ impl WebView { let mut root_node = AccesskitNode::new(Role::ScrollView); let graft_node_id = NodeId(1); let mut graft_node = AccesskitNode::new(Role::GenericContainer); - graft_node.set_label("graft"); graft_node.set_tree_id(grafted_tree_id); root_node.set_children(vec![graft_node_id]); self.delegate().notify_accessibility_tree_update(