mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
refactor: make changes based on review
Signed-off-by: TG <ebiritg@gmail.com>
This commit is contained in:
parent
8934ca0733
commit
7eef19135c
2 changed files with 17 additions and 17 deletions
|
@ -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>
|
||||||
|
|
|
@ -1911,19 +1911,19 @@ impl ScriptThread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fire_network_events(&self, is_online: bool, can_gc: CanGc) {
|
fn fire_network_events(&self, is_online: bool, can_gc: CanGc) {
|
||||||
let event_name = if is_online {
|
let event_name = if is_online {
|
||||||
Atom::from("online")
|
Atom::from("online")
|
||||||
} else {
|
} else {
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_set_scroll_states(&self, pipeline_id: PipelineId, scroll_states: Vec<ScrollState>) {
|
fn handle_set_scroll_states(&self, pipeline_id: PipelineId, scroll_states: Vec<ScrollState>) {
|
||||||
let Some(window) = self.documents.borrow().find_window(pipeline_id) else {
|
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 {
|
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) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue