Move signals_slots to ScriptMutationObservers (#39275)

Both places where we access signals_slots already have a reference to
ScriptMutationObserver. This saves us another access to
with_script_thread.


Testing: This does not change functionality.
Fixes: Part of addressing: https://github.com/servo/servo/issues/37969

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This commit is contained in:
Narfinger 2025-09-12 20:43:59 +02:00 committed by GitHub
parent 250c4cda00
commit 033da09800
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 32 deletions

View file

@ -126,7 +126,6 @@ use crate::dom::document::{
use crate::dom::element::Element;
use crate::dom::globalscope::GlobalScope;
use crate::dom::html::htmliframeelement::HTMLIFrameElement;
use crate::dom::html::htmlslotelement::HTMLSlotElement;
use crate::dom::node::NodeTraits;
use crate::dom::servoparser::{ParserContext, ServoParser};
use crate::dom::types::DebuggerGlobalScope;
@ -281,9 +280,6 @@ pub struct ScriptThread {
mutation_observers: Rc<ScriptMutationObservers>,
/// <https://dom.spec.whatwg.org/#signal-slot-list>
signal_slots: DomRefCell<Vec<Dom<HTMLSlotElement>>>,
/// A handle to the WebGL thread
#[no_trace]
webgl_chan: Option<WebGLPipeline>,
@ -507,29 +503,6 @@ impl ScriptThread {
with_script_thread(|script_thread| script_thread.microtask_queue.clone())
}
pub(crate) fn add_signal_slot(observer: &HTMLSlotElement) {
with_script_thread(|script_thread| {
script_thread
.signal_slots
.borrow_mut()
.push(Dom::from_ref(observer));
})
}
pub(crate) fn take_signal_slots() -> Vec<DomRoot<HTMLSlotElement>> {
with_script_thread(|script_thread| {
script_thread
.signal_slots
.take()
.into_iter()
.inspect(|slot| {
slot.remove_from_signal_slots();
})
.map(|slot| slot.as_rooted())
.collect()
})
}
pub(crate) fn mark_document_with_no_blocked_loads(doc: &Document) {
with_script_thread(|script_thread| {
script_thread
@ -1001,7 +974,6 @@ impl ScriptThread {
js_runtime,
closed_pipelines: DomRefCell::new(FxHashSet::default()),
mutation_observers: Default::default(),
signal_slots: Default::default(),
system_font_service,
webgl_chan: state.webgl_chan,
#[cfg(feature = "webxr")]