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

@ -8,18 +8,18 @@ use crate::dom::bindings::reflector::DomObject;
use crate::dom::globalscope::GlobalScope;
use crate::script_runtime::JSContext;
pub struct AlreadyInRealm(());
pub(crate) struct AlreadyInRealm(());
impl AlreadyInRealm {
#![allow(unsafe_code)]
pub fn assert() -> AlreadyInRealm {
pub(crate) fn assert() -> AlreadyInRealm {
unsafe {
assert!(!GetCurrentRealmOrNull(*GlobalScope::get_cx()).is_null());
}
AlreadyInRealm(())
}
pub fn assert_for_cx(cx: JSContext) -> AlreadyInRealm {
pub(crate) fn assert_for_cx(cx: JSContext) -> AlreadyInRealm {
unsafe {
assert!(!GetCurrentRealmOrNull(*cx).is_null());
}
@ -28,22 +28,22 @@ impl AlreadyInRealm {
}
#[derive(Clone, Copy)]
pub enum InRealm<'a> {
pub(crate) enum InRealm<'a> {
Already(&'a AlreadyInRealm),
Entered(&'a JSAutoRealm),
}
impl InRealm<'_> {
pub fn already(token: &AlreadyInRealm) -> InRealm {
pub(crate) fn already(token: &AlreadyInRealm) -> InRealm {
InRealm::Already(token)
}
pub fn entered(token: &JSAutoRealm) -> InRealm {
pub(crate) fn entered(token: &JSAutoRealm) -> InRealm {
InRealm::Entered(token)
}
}
pub fn enter_realm(object: &impl DomObject) -> JSAutoRealm {
pub(crate) fn enter_realm(object: &impl DomObject) -> JSAutoRealm {
JSAutoRealm::new(
*GlobalScope::get_cx(),
object.reflector().get_jsobject().get(),