Various CanGc fixes (#33800)

* CanGc fix for pagetransitionevent

Signed-off-by: webbeef <me@webbeef.org>

* CanGc fix for dom/node

Signed-off-by: webbeef <me@webbeef.org>

* CanGc fix for gamepad

Signed-off-by: webbeef <me@webbeef.org>

* CanGc fix for gpu

Signed-off-by: webbeef <me@webbeef.org>

* CanGc fix for dom/element

Signed-off-by: webbeef <me@webbeef.org>

* CanGc fix for xhr

Signed-off-by: webbeef <me@webbeef.org>

* CanGc fix for dom/worker

Signed-off-by: webbeef <me@webbeef.org>

* CanGc fix for rtcdatachannel

Signed-off-by: webbeef <me@webbeef.org>

* CanGc fix for rtcerror

Signed-off-by: webbeef <me@webbeef.org>

* Address review comments

Signed-off-by: webbeef <me@webbeef.org>

---------

Signed-off-by: webbeef <me@webbeef.org>
This commit is contained in:
webbeef 2024-10-10 20:53:39 -07:00 committed by GitHub
parent c00c6e728d
commit 2b71130a8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 168 additions and 119 deletions

View file

@ -1538,7 +1538,7 @@ impl ScriptThread {
}
/// Process compositor events as part of a "update the rendering task".
fn process_pending_compositor_events(&self, pipeline_id: PipelineId) {
fn process_pending_compositor_events(&self, pipeline_id: PipelineId, can_gc: CanGc) {
let Some(document) = self.documents.borrow().find_document(pipeline_id) else {
warn!("Processing pending compositor events for closed pipeline {pipeline_id}.");
return;
@ -1630,7 +1630,7 @@ impl ScriptThread {
CompositorEvent::GamepadEvent(gamepad_event) => {
let global = window.upcast::<GlobalScope>();
global.handle_gamepad_event(gamepad_event);
global.handle_gamepad_event(gamepad_event, can_gc);
},
}
}
@ -1638,7 +1638,7 @@ impl ScriptThread {
}
/// <https://html.spec.whatwg.org/multipage/#update-the-rendering>
fn update_the_rendering(&self) {
fn update_the_rendering(&self, can_gc: CanGc) {
self.update_the_rendering_task_queued_for_pipeline
.borrow_mut()
.clear();
@ -1687,7 +1687,7 @@ impl ScriptThread {
// TODO: Should this be broken and to match the specification more closely? For instance see
// https://html.spec.whatwg.org/multipage/#flush-autofocus-candidates.
self.process_pending_compositor_events(pipeline_id);
self.process_pending_compositor_events(pipeline_id, can_gc);
// TODO(#31665): Implement the "run the scroll steps" from
// https://drafts.csswg.org/cssom-view/#document-run-the-scroll-steps.
@ -1781,7 +1781,7 @@ impl ScriptThread {
SCRIPT_THREAD_ROOT.with(|root| {
if let Some(script_thread) = root.get() {
let script_thread = unsafe {&*script_thread};
script_thread.update_the_rendering();
script_thread.update_the_rendering(CanGc::note());
}
})
}),
@ -2311,7 +2311,7 @@ impl ScriptThread {
can_gc,
),
ConstellationControlMsg::UnloadDocument(pipeline_id) => {
self.handle_unload_document(pipeline_id)
self.handle_unload_document(pipeline_id, can_gc)
},
ConstellationControlMsg::ResizeInactive(id, new_size) => {
self.handle_resize_inactive_msg(id, new_size)
@ -2320,7 +2320,7 @@ impl ScriptThread {
self.handle_get_title_msg(pipeline_id)
},
ConstellationControlMsg::SetDocumentActivity(pipeline_id, activity) => {
self.handle_set_document_activity_msg(pipeline_id, activity)
self.handle_set_document_activity_msg(pipeline_id, activity, can_gc)
},
ConstellationControlMsg::SetThrottled(pipeline_id, throttled) => {
self.handle_set_throttled_msg(pipeline_id, throttled)
@ -2988,7 +2988,12 @@ impl ScriptThread {
}
/// Handles activity change message
fn handle_set_document_activity_msg(&self, id: PipelineId, activity: DocumentActivity) {
fn handle_set_document_activity_msg(
&self,
id: PipelineId,
activity: DocumentActivity,
can_gc: CanGc,
) {
debug!(
"Setting activity of {} to be {:?} in {:?}.",
id,
@ -2997,7 +3002,7 @@ impl ScriptThread {
);
let document = self.documents.borrow().find_document(id);
if let Some(document) = document {
document.set_activity(activity);
document.set_activity(activity, can_gc);
return;
}
let mut loads = self.incomplete_loads.borrow_mut();
@ -3073,10 +3078,10 @@ impl ScriptThread {
}
}
fn handle_unload_document(&self, pipeline_id: PipelineId) {
fn handle_unload_document(&self, pipeline_id: PipelineId, can_gc: CanGc) {
let document = self.documents.borrow().find_document(pipeline_id);
if let Some(document) = document {
document.unload(false);
document.unload(false, can_gc);
}
}