Propagate CanGc from Document::new() (#33386)

* Add canGc as a parameter to autogenerated trait methods

Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com>

* Propagate CanGc from Document::new()

Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com>

---------

Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com>
This commit is contained in:
Andriy Sultanov 2024-09-09 23:38:01 +01:00 committed by GitHub
parent 10e5bb72d9
commit e5150dbda1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 704 additions and 393 deletions

View file

@ -29,7 +29,7 @@ use crate::dom::serviceworkerglobalscope::{
ServiceWorkerControlMsg, ServiceWorkerGlobalScope, ServiceWorkerScriptMsg,
};
use crate::dom::serviceworkerregistration::longest_prefix_match;
use crate::script_runtime::ContextForRequestInterrupt;
use crate::script_runtime::{CanGc, ContextForRequestInterrupt};
enum Message {
FromResource(CustomResponseMediator),
@ -250,10 +250,12 @@ impl ServiceWorkerManager {
None
}
fn handle_message(&mut self) {
fn handle_message(&mut self, _can_gc: CanGc) {
while let Ok(message) = self.receive_message() {
let should_continue = match message {
Message::FromConstellation(msg) => self.handle_message_from_constellation(msg),
Message::FromConstellation(msg) => {
self.handle_message_from_constellation(msg, CanGc::note())
},
Message::FromResource(msg) => self.handle_message_from_resource(msg),
};
if !should_continue {
@ -288,7 +290,7 @@ impl ServiceWorkerManager {
}
}
fn handle_message_from_constellation(&mut self, msg: ServiceWorkerMsg) -> bool {
fn handle_message_from_constellation(&mut self, msg: ServiceWorkerMsg, can_gc: CanGc) -> bool {
match msg {
ServiceWorkerMsg::Timeout(_scope) => {
// TODO: https://w3c.github.io/ServiceWorker/#terminate-service-worker
@ -305,7 +307,7 @@ impl ServiceWorkerManager {
self.handle_register_job(job);
},
JobType::Update => {
self.handle_update_job(job);
self.handle_update_job(job, can_gc);
},
JobType::Unregister => {
// TODO: https://w3c.github.io/ServiceWorker/#unregister-algorithm
@ -380,7 +382,7 @@ impl ServiceWorkerManager {
}
/// <https://w3c.github.io/ServiceWorker/#update>
fn handle_update_job(&mut self, job: Job) {
fn handle_update_job(&mut self, job: Job, can_gc: CanGc) {
// Step 1: Get registation
if let Some(registration) = self.registrations.get_mut(&job.scope_url) {
// Step 3.
@ -403,8 +405,12 @@ impl ServiceWorkerManager {
// Very roughly steps 5 to 18.
// TODO: implement all steps precisely.
let (new_worker, join_handle, control_sender, context, closing) =
update_serviceworker(self.own_sender.clone(), job.scope_url.clone(), scope_things);
let (new_worker, join_handle, control_sender, context, closing) = update_serviceworker(
self.own_sender.clone(),
job.scope_url.clone(),
scope_things,
can_gc,
);
// Since we've just started the worker thread, ensure we can shut it down later.
registration.note_worker_thread(join_handle, control_sender, context, closing);
@ -443,6 +449,7 @@ fn update_serviceworker(
own_sender: IpcSender<ServiceWorkerMsg>,
scope_url: ServoUrl,
scope_things: ScopeThings,
can_gc: CanGc,
) -> (
ServiceWorker,
JoinHandle<()>,
@ -468,6 +475,7 @@ fn update_serviceworker(
control_receiver,
context_sender,
closing.clone(),
can_gc,
);
let context = context_receiver
@ -504,7 +512,7 @@ impl ServiceWorkerManagerFactory for ServiceWorkerManager {
resource_port,
constellation_sender,
)
.handle_message()
.handle_message(CanGc::note())
};
if thread::Builder::new()
.name("SvcWorkerManager".to_owned())