diff options
author | Yerkebulan Tulibergenov <yerkebulan@gmail.com> | 2025-02-22 16:34:31 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-23 00:34:31 +0000 |
commit | 02199520f2b611c9b5ab7b34a2372689cb4c22cd (patch) | |
tree | 86c1f6713ae1b7f2b1e09120ac701c6bf2c4e570 | |
parent | 4d1e9f19b574b2335f679d03db97242a568cc5c5 (diff) | |
download | servo-02199520f2b611c9b5ab7b34a2372689cb4c22cd.tar.gz servo-02199520f2b611c9b5ab7b34a2372689cb4c22cd.zip |
refactor: add CanGc as argument to WindowProxy::set_window (#35609)
Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
-rw-r--r-- | components/script/dom/document.rs | 6 | ||||
-rw-r--r-- | components/script/dom/window.rs | 8 | ||||
-rw-r--r-- | components/script/dom/windowproxy.rs | 9 | ||||
-rw-r--r-- | components/script/script_thread.rs | 15 |
4 files changed, 22 insertions, 16 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 2b746ec75a1..83a9bfa9bc2 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -693,7 +693,7 @@ impl Document { self.activity.get() != DocumentActivity::Inactive } - pub(crate) fn set_activity(&self, activity: DocumentActivity) { + pub(crate) fn set_activity(&self, activity: DocumentActivity, can_gc: CanGc) { // This function should only be called on documents with a browsing context assert!(self.has_browsing_context); if activity == self.activity.get() { @@ -708,14 +708,14 @@ impl Document { ClientContextId::build(pipeline_id.namespace_id.0, pipeline_id.index.0.get()); if activity != DocumentActivity::FullyActive { - self.window().suspend(); + self.window().suspend(can_gc); media.suspend(&client_context_id); return; } self.title_changed(); self.dirty_all_nodes(); - self.window().resume(); + self.window().resume(can_gc); media.resume(&client_context_id); if self.ready_state.get() != DocumentReadyState::Complete { diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index d29e178aa63..18f67661ddf 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -2541,13 +2541,13 @@ impl Window { had_clip_rect } - pub(crate) fn suspend(&self) { + pub(crate) fn suspend(&self, can_gc: CanGc) { // Suspend timer events. self.as_global_scope().suspend(); // Set the window proxy to be a cross-origin window. if self.window_proxy().currently_active() == Some(self.global().pipeline_id()) { - self.window_proxy().unset_currently_active(); + self.window_proxy().unset_currently_active(can_gc); } // A hint to the JS runtime that now would be a good time to @@ -2557,12 +2557,12 @@ impl Window { self.Gc(); } - pub(crate) fn resume(&self) { + pub(crate) fn resume(&self, can_gc: CanGc) { // Resume timer events. self.as_global_scope().resume(); // Set the window proxy to be this object. - self.window_proxy().set_currently_active(self); + self.window_proxy().set_currently_active(self, can_gc); // Push the document title to the compositor since we are // activating this document due to a navigation. diff --git a/components/script/dom/windowproxy.rs b/components/script/dom/windowproxy.rs index 187bddbf16c..62811b2dcc6 100644 --- a/components/script/dom/windowproxy.rs +++ b/components/script/dom/windowproxy.rs @@ -625,7 +625,7 @@ impl WindowProxy { /// Change the Window that this WindowProxy resolves to. // TODO: support setting the window proxy to a dummy value, // to handle the case when the active document is in another script thread. - fn set_window(&self, window: &GlobalScope, handler: &WindowProxyHandler) { + fn set_window(&self, window: &GlobalScope, handler: &WindowProxyHandler, _can_gc: CanGc) { unsafe { debug!("Setting window of {:p}.", self); @@ -675,7 +675,7 @@ impl WindowProxy { } } - pub(crate) fn set_currently_active(&self, window: &Window) { + pub(crate) fn set_currently_active(&self, window: &Window, can_gc: CanGc) { if let Some(pipeline_id) = self.currently_active() { if pipeline_id == window.pipeline_id() { return debug!( @@ -685,11 +685,11 @@ impl WindowProxy { } let global_scope = window.as_global_scope(); - self.set_window(global_scope, WindowProxyHandler::proxy_handler()); + self.set_window(global_scope, WindowProxyHandler::proxy_handler(), can_gc); self.currently_active.set(Some(global_scope.pipeline_id())); } - pub(crate) fn unset_currently_active(&self) { + pub(crate) fn unset_currently_active(&self, can_gc: CanGc) { if self.currently_active().is_none() { return debug!("Attempt to unset the currently active window on a windowproxy that does not have one."); } @@ -698,6 +698,7 @@ impl WindowProxy { self.set_window( window.upcast(), WindowProxyHandler::x_origin_proxy_handler(), + can_gc, ); self.currently_active.set(None); } diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 9938a818e96..34b212ed9fb 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1755,7 +1755,7 @@ impl ScriptThread { }, ScriptThreadMessage::GetTitle(pipeline_id) => self.handle_get_title_msg(pipeline_id), ScriptThreadMessage::SetDocumentActivity(pipeline_id, activity) => { - self.handle_set_document_activity_msg(pipeline_id, activity) + self.handle_set_document_activity_msg(pipeline_id, activity, can_gc) }, ScriptThreadMessage::SetThrottled(pipeline_id, throttled) => { self.handle_set_throttled_msg(pipeline_id, throttled) @@ -2459,7 +2459,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, @@ -2468,7 +2473,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(); @@ -3236,9 +3241,9 @@ impl ScriptThread { } if incomplete.activity == DocumentActivity::FullyActive { - window.resume(); + window.resume(can_gc); } else { - window.suspend(); + window.suspend(can_gc); } if incomplete.throttled { |