script: Limit public exports. (#34915)

* script: Restrict reexport visibility of DOM types.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Mass pub->pub(crate) conversion.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Hide existing dead code warnings.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Formatting.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix clippy warnings.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Formatting.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix unit tests.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix clippy.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* More formatting.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-01-10 03:19:19 -05:00 committed by GitHub
parent f220d6d3a5
commit c94d909a86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
585 changed files with 5411 additions and 5013 deletions

View file

@ -34,7 +34,7 @@ use crate::script_runtime::{CanGc, JSContext};
#[dom_struct]
/// <https://drafts.css-houdini.org/worklets/#workletglobalscope>
pub struct WorkletGlobalScope {
pub(crate) struct WorkletGlobalScope {
/// The global for this worklet.
globalscope: GlobalScope,
/// The base URL for this worklet.
@ -110,12 +110,12 @@ impl WorkletGlobalScope {
}
/// Get the JS context.
pub fn get_cx() -> JSContext {
pub(crate) fn get_cx() -> JSContext {
GlobalScope::get_cx()
}
/// Evaluate a JS script in this global.
pub fn evaluate_js(&self, script: &str, can_gc: CanGc) -> bool {
pub(crate) fn evaluate_js(&self, script: &str, can_gc: CanGc) -> bool {
debug!("Evaluating Dom in a worklet.");
rooted!(in (*GlobalScope::get_cx()) let mut rval = UndefinedValue());
self.globalscope.evaluate_js_on_global_with_result(
@ -128,7 +128,7 @@ impl WorkletGlobalScope {
}
/// Register a paint worklet to the script thread.
pub fn register_paint_worklet(
pub(crate) fn register_paint_worklet(
&self,
name: Atom,
properties: Vec<Atom>,
@ -145,17 +145,17 @@ impl WorkletGlobalScope {
}
/// The base URL of this global.
pub fn base_url(&self) -> ServoUrl {
pub(crate) fn base_url(&self) -> ServoUrl {
self.base_url.clone()
}
/// The worklet executor.
pub fn executor(&self) -> WorkletExecutor {
pub(crate) fn executor(&self) -> WorkletExecutor {
self.executor.clone()
}
/// Perform a worklet task
pub fn perform_a_worklet_task(&self, task: WorkletTask) {
pub(crate) fn perform_a_worklet_task(&self, task: WorkletTask) {
match task {
WorkletTask::Test(task) => match self.downcast::<TestWorkletGlobalScope>() {
Some(global) => global.perform_a_worklet_task(task),
@ -173,33 +173,33 @@ impl WorkletGlobalScope {
#[derive(Clone)]
pub(crate) struct WorkletGlobalScopeInit {
/// Channel to the main script thread
pub to_script_thread_sender: Sender<MainThreadScriptMsg>,
pub(crate) to_script_thread_sender: Sender<MainThreadScriptMsg>,
/// Channel to a resource thread
pub resource_threads: ResourceThreads,
pub(crate) resource_threads: ResourceThreads,
/// Channel to the memory profiler
pub mem_profiler_chan: mem::ProfilerChan,
pub(crate) mem_profiler_chan: mem::ProfilerChan,
/// Channel to the time profiler
pub time_profiler_chan: time::ProfilerChan,
pub(crate) time_profiler_chan: time::ProfilerChan,
/// Channel to devtools
pub devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
pub(crate) devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
/// Messages to send to constellation
pub to_constellation_sender: IpcSender<(PipelineId, ScriptMsg)>,
pub(crate) to_constellation_sender: IpcSender<(PipelineId, ScriptMsg)>,
/// The image cache
pub image_cache: Arc<dyn ImageCache>,
pub(crate) image_cache: Arc<dyn ImageCache>,
/// True if in headless mode
pub is_headless: bool,
pub(crate) is_headless: bool,
/// An optional string allowing the user agent to be set for testing
pub user_agent: Cow<'static, str>,
pub(crate) user_agent: Cow<'static, str>,
/// Identity manager for WebGPU resources
#[cfg(feature = "webgpu")]
pub gpu_id_hub: Arc<IdentityHub>,
pub(crate) gpu_id_hub: Arc<IdentityHub>,
/// Is considered secure
pub inherited_secure_context: Option<bool>,
pub(crate) inherited_secure_context: Option<bool>,
}
/// <https://drafts.css-houdini.org/worklets/#worklet-global-scope-type>
#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf)]
pub enum WorkletGlobalScopeType {
pub(crate) enum WorkletGlobalScopeType {
/// A servo-specific testing worklet
Test,
/// A paint worklet
@ -207,7 +207,7 @@ pub enum WorkletGlobalScopeType {
}
/// A task which can be performed in the context of a worklet global.
pub enum WorkletTask {
pub(crate) enum WorkletTask {
Test(TestWorkletTask),
Paint(PaintWorkletTask),
}