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,7 +28,7 @@ use crate::script_thread::ScriptThread;
// https://dom.spec.whatwg.org/#interface-attr
#[dom_struct]
pub struct Attr {
pub(crate) struct Attr {
node_: Node,
#[no_trace]
identifier: AttrIdentifier,
@ -62,7 +62,7 @@ impl Attr {
}
}
#[allow(clippy::too_many_arguments)]
pub fn new(
pub(crate) fn new(
document: &Document,
local_name: LocalName,
value: AttrValue,
@ -82,17 +82,17 @@ impl Attr {
}
#[inline]
pub fn name(&self) -> &LocalName {
pub(crate) fn name(&self) -> &LocalName {
&self.identifier.name.0
}
#[inline]
pub fn namespace(&self) -> &Namespace {
pub(crate) fn namespace(&self) -> &Namespace {
&self.identifier.namespace.0
}
#[inline]
pub fn prefix(&self) -> Option<&Prefix> {
pub(crate) fn prefix(&self) -> Option<&Prefix> {
Some(&self.identifier.prefix.as_ref()?.0)
}
}
@ -152,7 +152,7 @@ impl AttrMethods<crate::DomTypeHolder> for Attr {
}
impl Attr {
pub fn set_value(&self, mut value: AttrValue, owner: &Element) {
pub(crate) fn set_value(&self, mut value: AttrValue, owner: &Element) {
let name = self.local_name().clone();
let namespace = self.namespace().clone();
let old_value = DOMString::from(&**self.value());
@ -185,25 +185,25 @@ impl Attr {
}
/// Used to swap the attribute's value without triggering mutation events
pub fn swap_value(&self, value: &mut AttrValue) {
pub(crate) fn swap_value(&self, value: &mut AttrValue) {
mem::swap(&mut *self.value.borrow_mut(), value);
}
pub fn identifier(&self) -> &AttrIdentifier {
pub(crate) fn identifier(&self) -> &AttrIdentifier {
&self.identifier
}
pub fn value(&self) -> Ref<AttrValue> {
pub(crate) fn value(&self) -> Ref<AttrValue> {
self.value.borrow()
}
pub fn local_name(&self) -> &LocalName {
pub(crate) fn local_name(&self) -> &LocalName {
&self.identifier.local_name
}
/// Sets the owner element. Should be called after the attribute is added
/// or removed from its older parent.
pub fn set_owner(&self, owner: Option<&Element>) {
pub(crate) fn set_owner(&self, owner: Option<&Element>) {
let ns = self.namespace();
match (self.owner(), owner) {
(Some(old), None) => {
@ -220,11 +220,11 @@ impl Attr {
self.owner.set(owner);
}
pub fn owner(&self) -> Option<DomRoot<Element>> {
pub(crate) fn owner(&self) -> Option<DomRoot<Element>> {
self.owner.get()
}
pub fn summarize(&self) -> AttrInfo {
pub(crate) fn summarize(&self) -> AttrInfo {
AttrInfo {
namespace: (**self.namespace()).to_owned(),
name: String::from(self.Name()),
@ -232,7 +232,7 @@ impl Attr {
}
}
pub fn qualified_name(&self) -> DOMString {
pub(crate) fn qualified_name(&self) -> DOMString {
match self.prefix() {
Some(ref prefix) => DOMString::from(format!("{}:{}", prefix, &**self.local_name())),
None => DOMString::from(&**self.local_name()),
@ -241,7 +241,7 @@ impl Attr {
}
#[allow(unsafe_code)]
pub trait AttrHelpersForLayout<'dom> {
pub(crate) trait AttrHelpersForLayout<'dom> {
fn value(self) -> &'dom AttrValue;
fn as_str(&self) -> &'dom str;
fn to_tokens(self) -> Option<&'dom [Atom]>;