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

@ -33,7 +33,7 @@ use crate::dom::underlyingsourcecontainer::UnderlyingSourceType;
use crate::script_runtime::{CanGc, StreamConsumer};
#[dom_struct]
pub struct Response {
pub(crate) struct Response {
reflector_: Reflector,
headers_reflector: MutNullableDom<Headers>,
#[no_trace]
@ -52,7 +52,7 @@ pub struct Response {
#[allow(non_snake_case)]
impl Response {
pub fn new_inherited(global: &GlobalScope, can_gc: CanGc) -> Response {
pub(crate) fn new_inherited(global: &GlobalScope, can_gc: CanGc) -> Response {
let stream = ReadableStream::new_with_external_underlying_source(
global,
UnderlyingSourceType::FetchResponse,
@ -73,7 +73,7 @@ impl Response {
}
// https://fetch.spec.whatwg.org/#dom-response
pub fn new(global: &GlobalScope, can_gc: CanGc) -> DomRoot<Response> {
pub(crate) fn new(global: &GlobalScope, can_gc: CanGc) -> DomRoot<Response> {
Self::new_with_proto(global, None, can_gc)
}
@ -90,7 +90,7 @@ impl Response {
)
}
pub fn error_stream(&self, error: Error) {
pub(crate) fn error_stream(&self, error: Error) {
if let Some(body) = self.body_stream.get() {
body.error_native(error);
}
@ -393,12 +393,16 @@ fn serialize_without_fragment(url: &ServoUrl) -> &str {
}
impl Response {
pub fn set_type(&self, new_response_type: DOMResponseType, can_gc: CanGc) {
pub(crate) fn set_type(&self, new_response_type: DOMResponseType, can_gc: CanGc) {
*self.response_type.borrow_mut() = new_response_type;
self.set_response_members_by_type(new_response_type, can_gc);
}
pub fn set_headers(&self, option_hyper_headers: Option<Serde<HyperHeaders>>, can_gc: CanGc) {
pub(crate) fn set_headers(
&self,
option_hyper_headers: Option<Serde<HyperHeaders>>,
can_gc: CanGc,
) {
self.Headers(can_gc)
.set_headers(match option_hyper_headers {
Some(hyper_headers) => hyper_headers.into_inner(),
@ -406,15 +410,15 @@ impl Response {
});
}
pub fn set_status(&self, status: &HttpStatus) {
pub(crate) fn set_status(&self, status: &HttpStatus) {
self.status.borrow_mut().clone_from(status);
}
pub fn set_final_url(&self, final_url: ServoUrl) {
pub(crate) fn set_final_url(&self, final_url: ServoUrl) {
*self.url.borrow_mut() = Some(final_url);
}
pub fn set_redirected(&self, is_redirected: bool) {
pub(crate) fn set_redirected(&self, is_redirected: bool) {
*self.redirected.borrow_mut() = is_redirected;
}
@ -441,11 +445,11 @@ impl Response {
}
}
pub fn set_stream_consumer(&self, sc: Option<StreamConsumer>) {
pub(crate) fn set_stream_consumer(&self, sc: Option<StreamConsumer>) {
*self.stream_consumer.borrow_mut() = sc;
}
pub fn stream_chunk(&self, chunk: Vec<u8>) {
pub(crate) fn stream_chunk(&self, chunk: Vec<u8>) {
// Note, are these two actually mutually exclusive?
if let Some(stream_consumer) = self.stream_consumer.borrow().as_ref() {
stream_consumer.consume_chunk(chunk.as_slice());
@ -455,7 +459,7 @@ impl Response {
}
#[allow(crown::unrooted_must_root)]
pub fn finish(&self) {
pub(crate) fn finish(&self) {
if let Some(body) = self.body_stream.get() {
body.controller_close_native();
}