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

@ -29,7 +29,7 @@ use crate::script_thread::ScriptThread;
/// A collection of microtasks in FIFO order.
#[derive(Default, JSTraceable, MallocSizeOf)]
pub struct MicrotaskQueue {
pub(crate) struct MicrotaskQueue {
/// The list of enqueued microtasks that will be invoked at the next microtask checkpoint.
microtask_queue: DomRefCell<Vec<Microtask>>,
/// <https://html.spec.whatwg.org/multipage/#performing-a-microtask-checkpoint>
@ -37,7 +37,7 @@ pub struct MicrotaskQueue {
}
#[derive(JSTraceable, MallocSizeOf)]
pub enum Microtask {
pub(crate) enum Microtask {
Promise(EnqueuedPromiseCallback),
User(UserMicrotask),
MediaElement(MediaElementMicrotask),
@ -47,36 +47,36 @@ pub enum Microtask {
NotifyMutationObservers,
}
pub trait MicrotaskRunnable {
pub(crate) trait MicrotaskRunnable {
fn handler(&self, _can_gc: CanGc) {}
fn enter_realm(&self) -> JSAutoRealm;
}
/// A promise callback scheduled to run during the next microtask checkpoint (#4283).
#[derive(JSTraceable, MallocSizeOf)]
pub struct EnqueuedPromiseCallback {
pub(crate) struct EnqueuedPromiseCallback {
#[ignore_malloc_size_of = "Rc has unclear ownership"]
pub callback: Rc<PromiseJobCallback>,
pub(crate) callback: Rc<PromiseJobCallback>,
#[no_trace]
pub pipeline: PipelineId,
pub is_user_interacting: bool,
pub(crate) pipeline: PipelineId,
pub(crate) is_user_interacting: bool,
}
/// A microtask that comes from a queueMicrotask() Javascript call,
/// identical to EnqueuedPromiseCallback once it's on the queue
#[derive(JSTraceable, MallocSizeOf)]
pub struct UserMicrotask {
pub(crate) struct UserMicrotask {
#[ignore_malloc_size_of = "Rc has unclear ownership"]
pub callback: Rc<VoidFunction>,
pub(crate) callback: Rc<VoidFunction>,
#[no_trace]
pub pipeline: PipelineId,
pub(crate) pipeline: PipelineId,
}
impl MicrotaskQueue {
/// Add a new microtask to this queue. It will be invoked as part of the next
/// microtask checkpoint.
#[allow(unsafe_code)]
pub fn enqueue(&self, job: Microtask, cx: JSContext) {
pub(crate) fn enqueue(&self, job: Microtask, cx: JSContext) {
self.microtask_queue.borrow_mut().push(job);
unsafe { JobQueueMayNotBeEmpty(*cx) };
}
@ -84,7 +84,7 @@ impl MicrotaskQueue {
/// <https://html.spec.whatwg.org/multipage/#perform-a-microtask-checkpoint>
/// Perform a microtask checkpoint, executing all queued microtasks until the queue is empty.
#[allow(unsafe_code)]
pub fn checkpoint<F>(
pub(crate) fn checkpoint<F>(
&self,
cx: JSContext,
target_provider: F,
@ -160,11 +160,11 @@ impl MicrotaskQueue {
self.performing_a_microtask_checkpoint.set(false);
}
pub fn empty(&self) -> bool {
pub(crate) fn empty(&self) -> bool {
self.microtask_queue.borrow().is_empty()
}
pub fn clear(&self) {
pub(crate) fn clear(&self) {
self.microtask_queue.borrow_mut().clear();
}
}