mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Format script component
This commit is contained in:
parent
2ca7a13473
commit
c37a345dc9
357 changed files with 25485 additions and 18076 deletions
|
@ -47,8 +47,7 @@ pub struct Worker {
|
|||
}
|
||||
|
||||
impl Worker {
|
||||
fn new_inherited(sender: Sender<DedicatedWorkerScriptMsg>,
|
||||
closing: Arc<AtomicBool>) -> Worker {
|
||||
fn new_inherited(sender: Sender<DedicatedWorkerScriptMsg>, closing: Arc<AtomicBool>) -> Worker {
|
||||
Worker {
|
||||
eventtarget: EventTarget::new_inherited(),
|
||||
sender: sender,
|
||||
|
@ -57,12 +56,16 @@ impl Worker {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(global: &GlobalScope,
|
||||
sender: Sender<DedicatedWorkerScriptMsg>,
|
||||
closing: Arc<AtomicBool>) -> DomRoot<Worker> {
|
||||
reflect_dom_object(Box::new(Worker::new_inherited(sender, closing)),
|
||||
global,
|
||||
WorkerBinding::Wrap)
|
||||
pub fn new(
|
||||
global: &GlobalScope,
|
||||
sender: Sender<DedicatedWorkerScriptMsg>,
|
||||
closing: Arc<AtomicBool>,
|
||||
) -> DomRoot<Worker> {
|
||||
reflect_dom_object(
|
||||
Box::new(Worker::new_inherited(sender, closing)),
|
||||
global,
|
||||
WorkerBinding::Wrap,
|
||||
)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-worker
|
||||
|
@ -90,21 +93,31 @@ impl Worker {
|
|||
let worker_id = global.get_next_worker_id();
|
||||
if let Some(ref chan) = global.devtools_chan() {
|
||||
let pipeline_id = global.pipeline_id();
|
||||
let title = format!("Worker for {}", worker_url);
|
||||
let page_info = DevtoolsPageInfo {
|
||||
title: title,
|
||||
url: worker_url.clone(),
|
||||
};
|
||||
let _ = chan.send(ScriptToDevtoolsControlMsg::NewGlobal((pipeline_id, Some(worker_id)),
|
||||
devtools_sender.clone(),
|
||||
page_info));
|
||||
let title = format!("Worker for {}", worker_url);
|
||||
let page_info = DevtoolsPageInfo {
|
||||
title: title,
|
||||
url: worker_url.clone(),
|
||||
};
|
||||
let _ = chan.send(ScriptToDevtoolsControlMsg::NewGlobal(
|
||||
(pipeline_id, Some(worker_id)),
|
||||
devtools_sender.clone(),
|
||||
page_info,
|
||||
));
|
||||
}
|
||||
|
||||
let init = prepare_workerscope_init(global, Some(devtools_sender));
|
||||
|
||||
DedicatedWorkerGlobalScope::run_worker_scope(
|
||||
init, worker_url, devtools_receiver, worker_ref,
|
||||
global.script_chan(), sender, receiver, worker_load_origin, closing);
|
||||
init,
|
||||
worker_url,
|
||||
devtools_receiver,
|
||||
worker_ref,
|
||||
global.script_chan(),
|
||||
sender,
|
||||
receiver,
|
||||
worker_load_origin,
|
||||
closing,
|
||||
);
|
||||
|
||||
Ok(worker)
|
||||
}
|
||||
|
@ -117,8 +130,7 @@ impl Worker {
|
|||
self.terminated.get()
|
||||
}
|
||||
|
||||
pub fn handle_message(address: TrustedWorkerAddress,
|
||||
data: StructuredCloneData) {
|
||||
pub fn handle_message(address: TrustedWorkerAddress, data: StructuredCloneData) {
|
||||
let worker = address.root();
|
||||
|
||||
if worker.is_terminated() {
|
||||
|
@ -148,7 +160,10 @@ impl WorkerMethods for Worker {
|
|||
|
||||
// NOTE: step 9 of https://html.spec.whatwg.org/multipage/#dom-messageport-postmessage
|
||||
// indicates that a nonexistent communication channel should result in a silent error.
|
||||
let _ = self.sender.send(DedicatedWorkerScriptMsg::CommonWorker(address, WorkerScriptMsg::DOMMessage(data)));
|
||||
let _ = self.sender.send(DedicatedWorkerScriptMsg::CommonWorker(
|
||||
address,
|
||||
WorkerScriptMsg::DOMMessage(data),
|
||||
));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue