refactor: make changes based on review

Signed-off-by: TG <ebiritg@gmail.com>
This commit is contained in:
TG 2025-05-23 10:53:21 +01:00
parent 8934ca0733
commit 7eef19135c
2 changed files with 17 additions and 17 deletions

View file

@ -3454,7 +3454,7 @@ impl GlobalScope {
} }
pub(crate) fn is_online(&self) -> Arc<Mutex<bool>> { pub(crate) fn is_online(&self) -> Arc<Mutex<bool>> {
Arc::clone(&self.is_online) self.is_online.clone()
} }
/// <https://www.w3.org/TR/CSP/#report-violation> /// <https://www.w3.org/TR/CSP/#report-violation>

View file

@ -1918,7 +1918,7 @@ fn fire_network_events(&self, is_online: bool, can_gc: CanGc) {
Atom::from("offline") Atom::from("offline")
}; };
for document in self.documents.borrow().values() { for (_, document) in self.documents.borrow().iter() {
let window = document.window(); let window = document.window();
let event_target = window.upcast::<EventTarget>(); let event_target = window.upcast::<EventTarget>();
event_target.fire_event(event_name.clone(), can_gc); event_target.fire_event(event_name.clone(), can_gc);
@ -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 { fn handle_network_state(&self, is_online: bool, can_gc: CanGc) {
let previous = *self.is_online.lock().unwrap(); let mut online_lock = self.is_online.lock().unwrap();
*self.is_online.lock().unwrap() = is_online; let previous = *online_lock;
*online_lock = is_online;
drop(online_lock);
if previous != is_online { if previous != is_online {
self.fire_network_events(is_online, can_gc); self.fire_network_events(is_online, can_gc);
} }
false
} }
pub(crate) fn enqueue_microtask(job: Microtask) { pub(crate) fn enqueue_microtask(job: Microtask) {