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

@ -28,14 +28,14 @@ use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext};
use crate::script_runtime::CanGc;
#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)]
pub enum ShaderCompilationStatus {
pub(crate) enum ShaderCompilationStatus {
NotCompiled,
Succeeded,
Failed,
}
#[dom_struct]
pub struct WebGLShader {
pub(crate) struct WebGLShader {
webgl_object: WebGLObject,
#[no_trace]
id: WebGLShaderId,
@ -64,7 +64,10 @@ impl WebGLShader {
}
}
pub fn maybe_new(context: &WebGLRenderingContext, shader_type: u32) -> Option<DomRoot<Self>> {
pub(crate) fn maybe_new(
context: &WebGLRenderingContext,
shader_type: u32,
) -> Option<DomRoot<Self>> {
let (sender, receiver) = webgl_channel().unwrap();
context.send_command(WebGLCommand::CreateShader(shader_type, sender));
receiver
@ -73,7 +76,7 @@ impl WebGLShader {
.map(|id| WebGLShader::new(context, id, shader_type))
}
pub fn new(
pub(crate) fn new(
context: &WebGLRenderingContext,
id: WebGLShaderId,
shader_type: u32,
@ -87,16 +90,16 @@ impl WebGLShader {
}
impl WebGLShader {
pub fn id(&self) -> WebGLShaderId {
pub(crate) fn id(&self) -> WebGLShaderId {
self.id
}
pub fn gl_type(&self) -> u32 {
pub(crate) fn gl_type(&self) -> u32 {
self.gl_type
}
/// glCompileShader
pub fn compile(
pub(crate) fn compile(
&self,
api_type: GlType,
webgl_version: WebGLVersion,
@ -229,7 +232,7 @@ impl WebGLShader {
/// Mark this shader as deleted (if it wasn't previously)
/// and delete it as if calling glDeleteShader.
/// Currently does not check if shader is attached
pub fn mark_for_deletion(&self, operation_fallibility: Operation) {
pub(crate) fn mark_for_deletion(&self, operation_fallibility: Operation) {
if !self.marked_for_deletion.get() {
self.marked_for_deletion.set(true);
let context = self.upcast::<WebGLObject>().context();
@ -241,43 +244,43 @@ impl WebGLShader {
}
}
pub fn is_marked_for_deletion(&self) -> bool {
pub(crate) fn is_marked_for_deletion(&self) -> bool {
self.marked_for_deletion.get()
}
pub fn is_deleted(&self) -> bool {
pub(crate) fn is_deleted(&self) -> bool {
self.marked_for_deletion.get() && !self.is_attached()
}
pub fn is_attached(&self) -> bool {
pub(crate) fn is_attached(&self) -> bool {
self.attached_counter.get() > 0
}
pub fn increment_attached_counter(&self) {
pub(crate) fn increment_attached_counter(&self) {
self.attached_counter.set(self.attached_counter.get() + 1);
}
pub fn decrement_attached_counter(&self) {
pub(crate) fn decrement_attached_counter(&self) {
assert!(self.attached_counter.get() > 0);
self.attached_counter.set(self.attached_counter.get() - 1);
}
/// glGetShaderInfoLog
pub fn info_log(&self) -> DOMString {
pub(crate) fn info_log(&self) -> DOMString {
self.info_log.borrow().clone()
}
/// Get the shader source
pub fn source(&self) -> DOMString {
pub(crate) fn source(&self) -> DOMString {
self.source.borrow().clone()
}
/// glShaderSource
pub fn set_source(&self, source: DOMString) {
pub(crate) fn set_source(&self, source: DOMString) {
*self.source.borrow_mut() = source;
}
pub fn successfully_compiled(&self) -> bool {
pub(crate) fn successfully_compiled(&self) -> bool {
self.compilation_status.get() == ShaderCompilationStatus::Succeeded
}
}