diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index 3bf7622859e..ecee3a75cd7 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -3454,7 +3454,7 @@ impl GlobalScope { } pub(crate) fn is_online(&self) -> Arc> { - Arc::clone(&self.is_online) + self.is_online.clone() } /// diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index d1bff51c747..5b883d9a3fb 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1911,19 +1911,19 @@ impl ScriptThread { } } -fn fire_network_events(&self, is_online: bool, can_gc: CanGc) { - let event_name = if is_online { - Atom::from("online") - } else { - Atom::from("offline") - }; + fn fire_network_events(&self, is_online: bool, can_gc: CanGc) { + let event_name = if is_online { + Atom::from("online") + } else { + Atom::from("offline") + }; - for document in self.documents.borrow().values() { - let window = document.window(); - let event_target = window.upcast::(); - event_target.fire_event(event_name.clone(), can_gc); + for (_, document) in self.documents.borrow().iter() { + let window = document.window(); + let event_target = window.upcast::(); + event_target.fire_event(event_name.clone(), can_gc); + } } -} fn handle_set_scroll_states(&self, pipeline_id: PipelineId, scroll_states: Vec) { let Some(window) = self.documents.borrow().find_window(pipeline_id) else { @@ -3841,15 +3841,15 @@ fn fire_network_events(&self, is_online: bool, can_gc: CanGc) { }; } - fn handle_network_state(&self, is_online: bool, can_gc: CanGc) -> bool { - let previous = *self.is_online.lock().unwrap(); - *self.is_online.lock().unwrap() = is_online; + fn handle_network_state(&self, is_online: bool, can_gc: CanGc) { + let mut online_lock = self.is_online.lock().unwrap(); + let previous = *online_lock; + *online_lock = is_online; + drop(online_lock); if previous != is_online { self.fire_network_events(is_online, can_gc); } - - false } pub(crate) fn enqueue_microtask(job: Microtask) {