layout: Send accessibility updates directly to embedder from layout. (#44208)

This introduces a `ScriptToEmbedderChan` property on `LayoutThread`,
which is used to send accessibility updates directly to the embedder.

Follow-up to https://github.com/servo/servo/pull/42338.

Testing: Covered by existing tests.

Signed-off-by: Alice Boxhall <alice@igalia.com>
This commit is contained in:
Alice
2026-04-15 11:14:40 +02:00
committed by GitHub
parent 0f935df0c8
commit 31be152bfa
5 changed files with 10 additions and 12 deletions

View File

@@ -13,7 +13,7 @@ use std::sync::{Arc, LazyLock};
use app_units::Au;
use bitflags::bitflags;
use embedder_traits::{Theme, ViewportDetails};
use embedder_traits::{EmbedderMsg, ScriptToEmbedderChan, Theme, ViewportDetails};
use euclid::{Point2D, Rect, Scale, Size2D};
use fonts::{FontContext, FontContextWebFontMethods, WebFontDocumentContext};
use fonts_traits::StylesheetWebFontLoadFinishedCallback;
@@ -137,6 +137,9 @@ pub struct LayoutThread {
/// The channel on which messages can be sent to the time profiler.
time_profiler_chan: profile_time::ProfilerChan,
/// The channel to send messages to the Embedder.
embedder_chan: ScriptToEmbedderChan,
/// Reference to the script thread image cache.
image_cache: Arc<dyn ImageCache>,
@@ -730,6 +733,7 @@ impl LayoutThread {
is_iframe: config.is_iframe,
script_chan: config.script_chan.clone(),
time_profiler_chan: config.time_profiler_chan,
embedder_chan: config.embedder_chan.clone(),
registered_painters: RegisteredPaintersImpl(Default::default()),
image_cache: config.image_cache,
font_context: config.font_context,
@@ -890,8 +894,8 @@ impl LayoutThread {
// finalise after sending, removing accessibility damage? On fail, retain damage
// for next reflow, as well as retaining document.needs_accessibility_update.
let _ = self
.script_chan
.send(ScriptThreadMessage::AccessibilityTreeUpdate(
.embedder_chan
.send(EmbedderMsg::AccessibilityTreeUpdate(
self.webview_id,
tree_update,
accessibility_tree.epoch(),

View File

@@ -106,7 +106,6 @@ impl MixedMessage {
ScriptThreadMessage::EmbedderControlResponse(id, _) => Some(id.pipeline_id),
ScriptThreadMessage::SetUserContents(..) => None,
ScriptThreadMessage::DestroyUserContentManager(..) => None,
ScriptThreadMessage::AccessibilityTreeUpdate(..) => None,
ScriptThreadMessage::UpdatePinchZoomInfos(id, _) => Some(*id),
ScriptThreadMessage::SetAccessibilityActive(..) => None,
ScriptThreadMessage::TriggerGarbageCollection => None,

View File

@@ -1969,11 +1969,6 @@ impl ScriptThread {
.borrow_mut()
.remove(&user_content_manager_id);
},
ScriptThreadMessage::AccessibilityTreeUpdate(webview_id, tree_update, epoch) => {
let _ = self.senders.pipeline_to_embedder_sender.send(
EmbedderMsg::AccessibilityTreeUpdate(webview_id, tree_update, epoch),
);
},
ScriptThreadMessage::UpdatePinchZoomInfos(id, pinch_zoom_infos) => {
self.handle_update_pinch_zoom_infos(id, pinch_zoom_infos, CanGc::from_cx(cx));
},
@@ -3397,6 +3392,7 @@ impl ScriptThread {
viewport_details: incomplete.viewport_details,
user_stylesheets,
theme: incomplete.theme,
embedder_chan: self.senders.pipeline_to_embedder_sender.clone(),
};
// Create the window and document objects.

View File

@@ -25,7 +25,7 @@ use app_units::Au;
use atomic_refcell::AtomicRefCell;
use background_hang_monitor_api::BackgroundHangMonitorRegister;
use bitflags::bitflags;
use embedder_traits::{Cursor, Theme, UntrustedNodeAddress, ViewportDetails};
use embedder_traits::{Cursor, ScriptToEmbedderChan, Theme, UntrustedNodeAddress, ViewportDetails};
use euclid::{Point2D, Rect};
use fonts::{FontContext, TextByteRange, WebFontDocumentContext};
pub use layout_damage::LayoutDamage;
@@ -252,6 +252,7 @@ pub struct LayoutConfig {
pub viewport_details: ViewportDetails,
pub user_stylesheets: Rc<Vec<DocumentStyleSheet>>,
pub theme: Theme,
pub embedder_chan: ScriptToEmbedderChan,
}
pub trait LayoutFactory: Send + Sync {

View File

@@ -312,8 +312,6 @@ pub enum ScriptThreadMessage {
/// Release all data for the given `UserContentManagerId` from the `ScriptThread`'s
/// `user_contents_for_manager_id` map.
DestroyUserContentManager(UserContentManagerId),
/// Send the embedder an accessibility tree update.
AccessibilityTreeUpdate(WebViewId, accesskit::TreeUpdate, Epoch),
/// Update the pinch zoom details of a pipeline. Each `Window` stores a `VisualViewport` DOM
/// instance that gets updated according to the changes from the `Compositor``.
UpdatePinchZoomInfos(PipelineId, PinchZoomInfos),