Move unsafe to the wrap method for global objects (#38896)

The method now doesn't need unsafe in its signature because it no longer
accepts unsafe pointers as arguments. We move the unsafe marker to the
method itself.

Testing: I opened the browser and went to google.com; I ran some WPT
(IndexedDB) tests.
Fixes: #38361

---------

Signed-off-by: criskell <96352451+criskell@users.noreply.github.com>
This commit is contained in:
criskell 2025-08-25 19:02:55 -03:00 committed by GitHub
parent b9dc228e51
commit 9082217272
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 41 additions and 75 deletions

View file

@ -7,7 +7,6 @@ use std::collections::HashMap;
use base::id::PipelineId;
use crossbeam_channel::Sender;
use dom_struct::dom_struct;
use js::rust::Runtime;
use servo_url::ServoUrl;
use crate::dom::bindings::cell::DomRefCell;
@ -15,9 +14,9 @@ use crate::dom::bindings::codegen::Bindings::TestWorkletGlobalScopeBinding;
use crate::dom::bindings::codegen::Bindings::TestWorkletGlobalScopeBinding::TestWorkletGlobalScopeMethods;
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
use crate::dom::globalscope::GlobalScope;
use crate::dom::worklet::WorkletExecutor;
use crate::dom::workletglobalscope::{WorkletGlobalScope, WorkletGlobalScopeInit};
use crate::script_runtime::JSContext;
// check-tidy: no specs after this line
@ -32,7 +31,6 @@ pub(crate) struct TestWorkletGlobalScope {
impl TestWorkletGlobalScope {
#[allow(unsafe_code)]
pub(crate) fn new(
runtime: &Runtime,
pipeline_id: PipelineId,
base_url: ServoUrl,
executor: WorkletExecutor,
@ -51,12 +49,7 @@ impl TestWorkletGlobalScope {
),
lookup_table: Default::default(),
});
unsafe {
TestWorkletGlobalScopeBinding::Wrap::<crate::DomTypeHolder>(
JSContext::from_ptr(runtime.cx()),
global,
)
}
TestWorkletGlobalScopeBinding::Wrap::<crate::DomTypeHolder>(GlobalScope::get_cx(), global)
}
pub(crate) fn perform_a_worklet_task(&self, task: TestWorkletTask) {