diff options
author | Josh Matthews <josh@joshmatthews.net> | 2025-01-10 03:19:19 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-10 08:19:19 +0000 |
commit | c94d909a8688589209cdf0c7ae58e40f9b8c411e (patch) | |
tree | 12febf23eed4438249fd4d276c4d8b35dee22a97 /components/script/document_loader.rs | |
parent | f220d6d3a52296794cd19935e9e59cc75a179a44 (diff) | |
download | servo-c94d909a8688589209cdf0c7ae58e40f9b8c411e.tar.gz servo-c94d909a8688589209cdf0c7ae58e40f9b8c411e.zip |
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>
Diffstat (limited to 'components/script/document_loader.rs')
-rw-r--r-- | components/script/document_loader.rs | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/components/script/document_loader.rs b/components/script/document_loader.rs index 5d07cea0930..25624c62c1e 100644 --- a/components/script/document_loader.rs +++ b/components/script/document_loader.rs @@ -18,7 +18,7 @@ use crate::fetch::FetchCanceller; use crate::script_runtime::CanGc; #[derive(Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)] -pub enum LoadType { +pub(crate) enum LoadType { Image(#[no_trace] ServoUrl), Script(#[no_trace] ServoUrl), Subframe(#[no_trace] ServoUrl), @@ -32,7 +32,7 @@ pub enum LoadType { /// that the owner is destroyed. #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct LoadBlocker { +pub(crate) struct LoadBlocker { /// The document whose load event is blocked by this object existing. doc: Dom<Document>, /// The load that is blocking the document's load event. @@ -41,7 +41,7 @@ pub struct LoadBlocker { impl LoadBlocker { /// Mark the document's load event as blocked on this new load. - pub fn new(doc: &Document, load: LoadType) -> LoadBlocker { + pub(crate) fn new(doc: &Document, load: LoadType) -> LoadBlocker { doc.loader_mut().add_blocking_load(load.clone()); LoadBlocker { doc: Dom::from_ref(doc), @@ -50,7 +50,7 @@ impl LoadBlocker { } /// Remove this load from the associated document's list of blocking loads. - pub fn terminate(blocker: &DomRefCell<Option<LoadBlocker>>, can_gc: CanGc) { + pub(crate) fn terminate(blocker: &DomRefCell<Option<LoadBlocker>>, can_gc: CanGc) { if let Some(this) = blocker.borrow().as_ref() { let load_data = this.load.clone().unwrap(); this.doc.finish_load(load_data, can_gc); @@ -68,7 +68,7 @@ impl Drop for LoadBlocker { } #[derive(JSTraceable, MallocSizeOf)] -pub struct DocumentLoader { +pub(crate) struct DocumentLoader { #[no_trace] resource_threads: ResourceThreads, blocking_loads: Vec<LoadType>, @@ -77,11 +77,11 @@ pub struct DocumentLoader { } impl DocumentLoader { - pub fn new(existing: &DocumentLoader) -> DocumentLoader { + pub(crate) fn new(existing: &DocumentLoader) -> DocumentLoader { DocumentLoader::new_with_threads(existing.resource_threads.clone(), None) } - pub fn new_with_threads( + pub(crate) fn new_with_threads( resource_threads: ResourceThreads, initial_load: Option<ServoUrl>, ) -> DocumentLoader { @@ -96,7 +96,7 @@ impl DocumentLoader { } } - pub fn cancel_all_loads(&mut self) -> bool { + pub(crate) fn cancel_all_loads(&mut self) -> bool { let canceled_any = !self.cancellers.is_empty(); // Associated fetches will be canceled when dropping the canceller. self.cancellers.clear(); @@ -114,7 +114,7 @@ impl DocumentLoader { } /// Initiate a new fetch given a response callback. - pub fn fetch_async_with_callback( + pub(crate) fn fetch_async_with_callback( &mut self, load: LoadType, request: RequestBuilder, @@ -125,7 +125,7 @@ impl DocumentLoader { } /// Initiate a new fetch that does not block the document load event. - pub fn fetch_async_background( + pub(crate) fn fetch_async_background( &mut self, request: RequestBuilder, callback: BoxedFetchCallback, @@ -147,7 +147,7 @@ impl DocumentLoader { } /// Mark an in-progress network request complete. - pub fn finish_load(&mut self, load: &LoadType) { + pub(crate) fn finish_load(&mut self, load: &LoadType) { debug!( "Removing blocking load {:?} ({}).", load, @@ -165,26 +165,26 @@ impl DocumentLoader { } } - pub fn is_blocked(&self) -> bool { + pub(crate) fn is_blocked(&self) -> bool { // TODO: Ensure that we report blocked if parsing is still ongoing. !self.blocking_loads.is_empty() } - pub fn is_only_blocked_by_iframes(&self) -> bool { + pub(crate) fn is_only_blocked_by_iframes(&self) -> bool { self.blocking_loads .iter() .all(|load| matches!(*load, LoadType::Subframe(_))) } - pub fn inhibit_events(&mut self) { + pub(crate) fn inhibit_events(&mut self) { self.events_inhibited = true; } - pub fn events_inhibited(&self) -> bool { + pub(crate) fn events_inhibited(&self) -> bool { self.events_inhibited } - pub fn resource_threads(&self) -> &ResourceThreads { + pub(crate) fn resource_threads(&self) -> &ResourceThreads { &self.resource_threads } } |