diff --git a/components/script/dom/html/htmlslotelement.rs b/components/script/dom/html/htmlslotelement.rs
index e77cf89c30b..35153a9e1f9 100644
--- a/components/script/dom/html/htmlslotelement.rs
+++ b/components/script/dom/html/htmlslotelement.rs
@@ -352,11 +352,11 @@ impl HTMLSlotElement {
}
self.is_in_agents_signal_slots.set(true);
+ let mutation_observers = ScriptThread::mutation_observers();
// Step 1. Append slot to slot’s relevant agent’s signal slots.
- ScriptThread::add_signal_slot(self);
+ mutation_observers.add_signal_slot(self);
// Step 2. Queue a mutation observer microtask.
- let mutation_observers = ScriptThread::mutation_observers();
mutation_observers.queue_mutation_observer_microtask(ScriptThread::microtask_queue());
}
diff --git a/components/script/script_mutation_observers.rs b/components/script/script_mutation_observers.rs
index 670e45b5a52..5134712d05e 100644
--- a/components/script/script_mutation_observers.rs
+++ b/components/script/script_mutation_observers.rs
@@ -10,7 +10,6 @@ use script_bindings::inheritance::Castable;
use script_bindings::root::{Dom, DomRoot};
use script_bindings::script_runtime::CanGc;
-use crate::ScriptThread;
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::types::{EventTarget, HTMLSlotElement, MutationObserver, MutationRecord};
use crate::microtask::{Microtask, MicrotaskQueue};
@@ -26,6 +25,9 @@ pub(crate) struct ScriptMutationObservers {
/// The unit of related similar-origin browsing contexts' list of MutationObserver objects
mutation_observers: DomRefCell>>,
+
+ ///
+ signal_slots: DomRefCell>>,
}
impl ScriptMutationObservers {
@@ -46,7 +48,7 @@ impl ScriptMutationObservers {
// Step 4. Let signalSet be a clone of the surrounding agent’s signal slots.
// Step 5. Empty the surrounding agent’s signal slots.
- let signal_set: Vec> = ScriptThread::take_signal_slots();
+ let signal_set: Vec> = self.take_signal_slots();
// Step 6. For each mo of notifySet:
for mo in notify_list.iter() {
@@ -93,4 +95,19 @@ impl ScriptMutationObservers {
microtask_queue.enqueue(Microtask::NotifyMutationObservers, script_thread.get_cx());
});
}
+
+ pub(crate) fn add_signal_slot(&self, observer: &HTMLSlotElement) {
+ self.signal_slots.borrow_mut().push(Dom::from_ref(observer));
+ }
+
+ pub(crate) fn take_signal_slots(&self) -> Vec> {
+ self.signal_slots
+ .take()
+ .into_iter()
+ .inspect(|slot| {
+ slot.remove_from_signal_slots();
+ })
+ .map(|slot| slot.as_rooted())
+ .collect()
+ }
}
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index 92a4070b4bf..280a47801a6 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -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,
- ///
- signal_slots: DomRefCell>>,
-
/// A handle to the WebGL thread
#[no_trace]
webgl_chan: Option,
@@ -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> {
- 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")]