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::dom::webgltexture::WebGLTexture;
use crate::dom::xrsession::XRSession;
use crate::script_runtime::CanGc;
pub enum CompleteForRendering {
pub(crate) enum CompleteForRendering {
Complete,
Incomplete,
MissingColorAttachment,
@ -86,13 +86,13 @@ impl WebGLFramebufferAttachment {
}
#[derive(Clone, JSTraceable, MallocSizeOf)]
pub enum WebGLFramebufferAttachmentRoot {
pub(crate) enum WebGLFramebufferAttachmentRoot {
Renderbuffer(DomRoot<WebGLRenderbuffer>),
Texture(DomRoot<WebGLTexture>),
}
#[dom_struct]
pub struct WebGLFramebuffer {
pub(crate) struct WebGLFramebuffer {
webgl_object: WebGLObject,
#[no_trace]
webgl_version: WebGLVersion,
@ -139,7 +139,7 @@ impl WebGLFramebuffer {
}
}
pub fn maybe_new(context: &WebGLRenderingContext) -> Option<DomRoot<Self>> {
pub(crate) fn maybe_new(context: &WebGLRenderingContext) -> Option<DomRoot<Self>> {
let (sender, receiver) = webgl_channel().unwrap();
context.send_command(WebGLCommand::CreateFramebuffer(sender));
let id = receiver.recv().unwrap()?;
@ -150,7 +150,7 @@ impl WebGLFramebuffer {
// TODO: depth, stencil and alpha
// https://github.com/servo/servo/issues/24498
#[cfg(feature = "webxr")]
pub fn maybe_new_webxr(
pub(crate) fn maybe_new_webxr(
session: &XRSession,
context: &WebGLRenderingContext,
size: Size2D<i32, Viewport>,
@ -162,7 +162,7 @@ impl WebGLFramebuffer {
Some(framebuffer)
}
pub fn new(context: &WebGLRenderingContext, id: WebGLFramebufferId) -> DomRoot<Self> {
pub(crate) fn new(context: &WebGLRenderingContext, id: WebGLFramebufferId) -> DomRoot<Self> {
reflect_dom_object(
Box::new(WebGLFramebuffer::new_inherited(context, id)),
&*context.global(),
@ -172,7 +172,7 @@ impl WebGLFramebuffer {
}
impl WebGLFramebuffer {
pub fn id(&self) -> WebGLFramebufferId {
pub(crate) fn id(&self) -> WebGLFramebufferId {
self.id
}
@ -186,7 +186,7 @@ impl WebGLFramebuffer {
false
}
pub fn validate_transparent(&self) -> WebGLResult<()> {
pub(crate) fn validate_transparent(&self) -> WebGLResult<()> {
if self.is_in_xr_session() {
Err(WebGLError::InvalidOperation)
} else {
@ -194,7 +194,7 @@ impl WebGLFramebuffer {
}
}
pub fn bind(&self, target: u32) {
pub(crate) fn bind(&self, target: u32) {
if !self.is_in_xr_session() {
// Update the framebuffer status on binding. It may have
// changed if its attachments were resized or deleted while
@ -211,7 +211,7 @@ impl WebGLFramebuffer {
));
}
pub fn delete(&self, operation_fallibility: Operation) {
pub(crate) fn delete(&self, operation_fallibility: Operation) {
if !self.is_deleted.get() {
self.is_deleted.set(true);
let context = self.upcast::<WebGLObject>().context();
@ -223,18 +223,20 @@ impl WebGLFramebuffer {
}
}
pub fn is_deleted(&self) -> bool {
pub(crate) fn is_deleted(&self) -> bool {
// TODO: if a framebuffer has an attachment which is invalid due to
// being outside a webxr rAF, should this make the framebuffer invalid?
// https://github.com/immersive-web/layers/issues/196
self.is_deleted.get()
}
pub fn size(&self) -> Option<(i32, i32)> {
pub(crate) fn size(&self) -> Option<(i32, i32)> {
self.size.get()
}
pub fn get_attachment_formats(&self) -> WebGLResult<(Option<u32>, Option<u32>, Option<u32>)> {
pub(crate) fn get_attachment_formats(
&self,
) -> WebGLResult<(Option<u32>, Option<u32>, Option<u32>)> {
if self.check_status() != constants::FRAMEBUFFER_COMPLETE {
return Err(WebGLError::InvalidFramebufferOperation);
}
@ -296,7 +298,7 @@ impl WebGLFramebuffer {
Ok(())
}
pub fn update_status(&self) {
pub(crate) fn update_status(&self) {
let z = self.depth.borrow();
let s = self.stencil.borrow();
let zs = self.depthstencil.borrow();
@ -476,7 +478,7 @@ impl WebGLFramebuffer {
}
}
pub fn check_status(&self) -> u32 {
pub(crate) fn check_status(&self) -> u32 {
// For opaque framebuffers, check to see if the XR session is currently processing an rAF
// https://immersive-web.github.io/webxr/#opaque-framebuffer
#[cfg(feature = "webxr")]
@ -494,7 +496,7 @@ impl WebGLFramebuffer {
// https://github.com/immersive-web/layers/issues/196
}
pub fn check_status_for_rendering(&self) -> CompleteForRendering {
pub(crate) fn check_status_for_rendering(&self) -> CompleteForRendering {
let result = self.check_status();
if result != constants::FRAMEBUFFER_COMPLETE {
return CompleteForRendering::Incomplete;
@ -550,7 +552,11 @@ impl WebGLFramebuffer {
CompleteForRendering::Complete
}
pub fn renderbuffer(&self, attachment: u32, rb: Option<&WebGLRenderbuffer>) -> WebGLResult<()> {
pub(crate) fn renderbuffer(
&self,
attachment: u32,
rb: Option<&WebGLRenderbuffer>,
) -> WebGLResult<()> {
// Opaque framebuffers cannot have their attachments changed
// https://immersive-web.github.io/webxr/#opaque-framebuffer
self.validate_transparent()?;
@ -672,7 +678,7 @@ impl WebGLFramebuffer {
Ok(())
}
pub fn attachment(&self, attachment: u32) -> Option<WebGLFramebufferAttachmentRoot> {
pub(crate) fn attachment(&self, attachment: u32) -> Option<WebGLFramebufferAttachmentRoot> {
let binding = self.attachment_binding(attachment)?;
binding
.borrow()
@ -680,7 +686,7 @@ impl WebGLFramebuffer {
.map(WebGLFramebufferAttachment::root)
}
pub fn texture2d(
pub(crate) fn texture2d(
&self,
attachment: u32,
textarget: u32,
@ -734,7 +740,7 @@ impl WebGLFramebuffer {
self.texture2d_even_if_opaque(attachment, textarget, texture, level)
}
pub fn texture2d_even_if_opaque(
pub(crate) fn texture2d_even_if_opaque(
&self,
attachment: u32,
textarget: u32,
@ -780,7 +786,7 @@ impl WebGLFramebuffer {
Ok(())
}
pub fn texture_layer(
pub(crate) fn texture_layer(
&self,
attachment: u32,
texture: Option<&WebGLTexture>,
@ -907,7 +913,7 @@ impl WebGLFramebuffer {
}
}
pub fn detach_renderbuffer(&self, rb: &WebGLRenderbuffer) -> WebGLResult<()> {
pub(crate) fn detach_renderbuffer(&self, rb: &WebGLRenderbuffer) -> WebGLResult<()> {
// Opaque framebuffers cannot have their attachments changed
// https://immersive-web.github.io/webxr/#opaque-framebuffer
self.validate_transparent()?;
@ -928,7 +934,7 @@ impl WebGLFramebuffer {
Ok(())
}
pub fn detach_texture(&self, texture: &WebGLTexture) -> WebGLResult<()> {
pub(crate) fn detach_texture(&self, texture: &WebGLTexture) -> WebGLResult<()> {
// Opaque framebuffers cannot have their attachments changed
// https://immersive-web.github.io/webxr/#opaque-framebuffer
self.validate_transparent()?;
@ -949,20 +955,20 @@ impl WebGLFramebuffer {
Ok(())
}
pub fn invalidate_renderbuffer(&self, rb: &WebGLRenderbuffer) {
pub(crate) fn invalidate_renderbuffer(&self, rb: &WebGLRenderbuffer) {
self.with_matching_renderbuffers(rb, |_att, _| {
self.is_initialized.set(false);
self.update_status();
});
}
pub fn invalidate_texture(&self, texture: &WebGLTexture) {
pub(crate) fn invalidate_texture(&self, texture: &WebGLTexture) {
self.with_matching_textures(texture, |_att, _name| {
self.update_status();
});
}
pub fn set_read_buffer(&self, buffer: u32) -> WebGLResult<()> {
pub(crate) fn set_read_buffer(&self, buffer: u32) -> WebGLResult<()> {
let context = self.upcast::<WebGLObject>().context();
match buffer {
@ -976,7 +982,7 @@ impl WebGLFramebuffer {
Ok(())
}
pub fn set_draw_buffers(&self, buffers: Vec<u32>) -> WebGLResult<()> {
pub(crate) fn set_draw_buffers(&self, buffers: Vec<u32>) -> WebGLResult<()> {
let context = self.upcast::<WebGLObject>().context();
if buffers.len() > context.limits().max_draw_buffers as usize {
@ -1002,16 +1008,16 @@ impl WebGLFramebuffer {
Ok(())
}
pub fn read_buffer(&self) -> u32 {
pub(crate) fn read_buffer(&self) -> u32 {
*self.color_read_buffer.borrow()
}
pub fn draw_buffer_i(&self, index: usize) -> u32 {
pub(crate) fn draw_buffer_i(&self, index: usize) -> u32 {
let buffers = &*self.color_draw_buffers.borrow();
*buffers.get(index).unwrap_or(&constants::NONE)
}
pub fn target(&self) -> Option<u32> {
pub(crate) fn target(&self) -> Option<u32> {
self.target.get()
}
}