mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Enter realms more consistently during the script event loop.
This commit is contained in:
parent
9ea1399c30
commit
864e072d5c
6 changed files with 52 additions and 5 deletions
|
@ -1592,6 +1592,11 @@ impl ScriptThread {
|
|||
let category = self.categorize_msg(&msg);
|
||||
let pipeline_id = self.message_to_pipeline(&msg);
|
||||
|
||||
let _realm = pipeline_id.and_then(|id| {
|
||||
let global = self.documents.borrow().find_global(id);
|
||||
global.map(|global| enter_realm(&*global))
|
||||
});
|
||||
|
||||
if self.closing.load(Ordering::SeqCst) {
|
||||
// If we've received the closed signal from the BHM, only handle exit messages.
|
||||
match msg {
|
||||
|
@ -1656,6 +1661,8 @@ impl ScriptThread {
|
|||
}
|
||||
let window = document.window();
|
||||
|
||||
let _realm = enter_realm(&*document);
|
||||
|
||||
window
|
||||
.upcast::<GlobalScope>()
|
||||
.perform_a_dom_garbage_collection_checkpoint();
|
||||
|
@ -1684,6 +1691,7 @@ impl ScriptThread {
|
|||
}
|
||||
|
||||
for (_, document) in self.documents.borrow().iter() {
|
||||
let _realm = enter_realm(&*document);
|
||||
document.animations().send_pending_events(document.window());
|
||||
}
|
||||
}
|
||||
|
@ -1786,7 +1794,7 @@ impl ScriptThread {
|
|||
DispatchStorageEvent(id, ..) => Some(id),
|
||||
ReportCSSError(id, ..) => Some(id),
|
||||
Reload(id, ..) => Some(id),
|
||||
PaintMetric(..) => None,
|
||||
PaintMetric(id, ..) => Some(id),
|
||||
ExitFullScreen(id, ..) => Some(id),
|
||||
MediaSessionAction(..) => None,
|
||||
SetWebGPUPort(..) => None,
|
||||
|
@ -2070,7 +2078,13 @@ impl ScriptThread {
|
|||
|
||||
fn handle_msg_from_script(&self, msg: MainThreadScriptMsg) {
|
||||
match msg {
|
||||
MainThreadScriptMsg::Common(CommonScriptMsg::Task(_, task, _, _)) => task.run_box(),
|
||||
MainThreadScriptMsg::Common(CommonScriptMsg::Task(_, task, pipeline_id, _)) => {
|
||||
let _realm = pipeline_id.and_then(|id| {
|
||||
let global = self.documents.borrow().find_global(id);
|
||||
global.map(|global| enter_realm(&*global))
|
||||
});
|
||||
task.run_box()
|
||||
},
|
||||
MainThreadScriptMsg::Common(CommonScriptMsg::CollectReports(chan)) => {
|
||||
self.collect_reports(chan)
|
||||
},
|
||||
|
@ -3277,6 +3291,8 @@ impl ScriptThread {
|
|||
incomplete.inherited_secure_context,
|
||||
);
|
||||
|
||||
let _realm = enter_realm(&*window);
|
||||
|
||||
// Initialize the browsing context for the window.
|
||||
let window_proxy = self.local_window_proxy(
|
||||
&window,
|
||||
|
@ -3460,6 +3476,8 @@ impl ScriptThread {
|
|||
);
|
||||
}
|
||||
|
||||
let _realm = enter_realm(&*window);
|
||||
|
||||
// Assuming all CompositionEvent are generated by user interactions.
|
||||
ScriptThread::set_user_interacting(true);
|
||||
match event {
|
||||
|
@ -3978,7 +3996,7 @@ impl ScriptThread {
|
|||
.documents
|
||||
.borrow()
|
||||
.iter()
|
||||
.map(|(_id, document)| document.global())
|
||||
.map(|(_id, document)| DomRoot::from_ref(document.window().upcast()))
|
||||
.collect();
|
||||
|
||||
self.microtask_queue.checkpoint(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue