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

@ -103,7 +103,7 @@ enum ParseState {
AfterDescriptor,
}
pub struct SourceSet {
pub(crate) struct SourceSet {
image_sources: Vec<ImageSource>,
source_size: SourceSizeList,
}
@ -161,7 +161,7 @@ struct ImageRequest {
current_pixel_density: Option<f64>,
}
#[dom_struct]
pub struct HTMLImageElement {
pub(crate) struct HTMLImageElement {
htmlelement: HTMLElement,
image_request: Cell<ImageRequestPhase>,
current_request: DomRefCell<ImageRequest>,
@ -176,11 +176,11 @@ pub struct HTMLImageElement {
}
impl HTMLImageElement {
pub fn get_url(&self) -> Option<ServoUrl> {
pub(crate) fn get_url(&self) -> Option<ServoUrl> {
self.current_request.borrow().parsed_url.clone()
}
// https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument
pub fn is_usable(&self) -> Fallible<bool> {
pub(crate) fn is_usable(&self) -> Fallible<bool> {
// If image has an intrinsic width or intrinsic height (or both) equal to zero, then return bad.
if let Some(image) = &self.current_request.borrow().image {
if image.width == 0 || image.height == 0 {
@ -197,7 +197,7 @@ impl HTMLImageElement {
}
}
pub fn image_data(&self) -> Option<Arc<Image>> {
pub(crate) fn image_data(&self) -> Option<Arc<Image>> {
self.current_request.borrow().image.clone()
}
}
@ -939,7 +939,7 @@ impl HTMLImageElement {
}
/// <https://html.spec.whatwg.org/multipage/#update-the-image-data>
pub fn update_the_image_data(&self, can_gc: CanGc) {
pub(crate) fn update_the_image_data(&self, can_gc: CanGc) {
let document = self.owner_document();
let window = document.window();
let elem = self.upcast::<Element>();
@ -1043,7 +1043,7 @@ impl HTMLImageElement {
}
/// <https://html.spec.whatwg.org/multipage/#img-environment-changes>
pub fn react_to_environment_changes(&self) {
pub(crate) fn react_to_environment_changes(&self) {
// Step 1
let task = ImageElementMicrotask::EnvironmentChanges {
elem: DomRoot::from_ref(self),
@ -1325,7 +1325,7 @@ impl HTMLImageElement {
}
#[allow(crown::unrooted_must_root)]
pub fn new(
pub(crate) fn new(
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
@ -1342,7 +1342,7 @@ impl HTMLImageElement {
)
}
pub fn areas(&self) -> Option<Vec<DomRoot<HTMLAreaElement>>> {
pub(crate) fn areas(&self) -> Option<Vec<DomRoot<HTMLAreaElement>>> {
let elem = self.upcast::<Element>();
let usemap_attr = elem.get_attribute(&ns!(), &local_name!("usemap"))?;
@ -1372,7 +1372,7 @@ impl HTMLImageElement {
useMapElements.map(|mapElem| mapElem.get_area_elements())
}
pub fn same_origin(&self, origin: &MutableOrigin) -> bool {
pub(crate) fn same_origin(&self, origin: &MutableOrigin) -> bool {
if let Some(ref image) = self.current_request.borrow().image {
return image.cors_status == CorsStatus::Safe;
}
@ -1386,7 +1386,7 @@ impl HTMLImageElement {
}
#[derive(JSTraceable, MallocSizeOf)]
pub enum ImageElementMicrotask {
pub(crate) enum ImageElementMicrotask {
StableStateUpdateImageData {
elem: DomRoot<HTMLImageElement>,
generation: u32,
@ -1439,7 +1439,7 @@ impl MicrotaskRunnable for ImageElementMicrotask {
}
}
pub trait LayoutHTMLImageElementHelpers {
pub(crate) trait LayoutHTMLImageElementHelpers {
fn image_url(self) -> Option<ServoUrl>;
fn image_density(self) -> Option<f64>;
fn image_data(self) -> (Option<Arc<Image>>, Option<ImageMetadata>);
@ -1489,7 +1489,7 @@ impl LayoutHTMLImageElementHelpers for LayoutDom<'_, HTMLImageElement> {
}
//https://html.spec.whatwg.org/multipage/#parse-a-sizes-attribute
pub fn parse_a_sizes_attribute(value: DOMString) -> SourceSizeList {
pub(crate) fn parse_a_sizes_attribute(value: DOMString) -> SourceSizeList {
let mut input = ParserInput::new(&value);
let mut parser = Parser::new(&mut input);
let url_data = Url::parse("about:blank").unwrap().into();
@ -1914,7 +1914,7 @@ fn image_dimension_setter(element: &Element, attr: LocalName, value: u32, can_gc
}
/// Collect sequence of code points
pub fn collect_sequence_characters(
pub(crate) fn collect_sequence_characters(
s: &str,
mut predicate: impl FnMut(&char) -> bool,
) -> (&str, &str) {