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/dom/servoparser | |
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/dom/servoparser')
-rw-r--r-- | components/script/dom/servoparser/async_html.rs | 16 | ||||
-rw-r--r-- | components/script/dom/servoparser/html.rs | 12 | ||||
-rw-r--r-- | components/script/dom/servoparser/mod.rs | 46 | ||||
-rw-r--r-- | components/script/dom/servoparser/prefetch.rs | 6 | ||||
-rw-r--r-- | components/script/dom/servoparser/xml.rs | 10 |
5 files changed, 45 insertions, 45 deletions
diff --git a/components/script/dom/servoparser/async_html.rs b/components/script/dom/servoparser/async_html.rs index e9be6f8b657..8c80068ef83 100644 --- a/components/script/dom/servoparser/async_html.rs +++ b/components/script/dom/servoparser/async_html.rs @@ -46,7 +46,7 @@ use crate::script_runtime::CanGc; type ParseNodeId = usize; #[derive(Clone, JSTraceable, MallocSizeOf)] -pub struct ParseNode { +pub(crate) struct ParseNode { id: ParseNodeId, #[no_trace] qual_name: Option<QualName>, @@ -206,7 +206,7 @@ fn create_buffer_queue(mut buffers: VecDeque<SendTendril<UTF8>>) -> BufferQueue // #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct Tokenizer { +pub(crate) struct Tokenizer { document: Dom<Document>, #[ignore_malloc_size_of = "Defined in std"] #[no_trace] @@ -222,7 +222,7 @@ pub struct Tokenizer { } impl Tokenizer { - pub fn new( + pub(crate) fn new( document: &Document, url: ServoUrl, fragment_context: Option<super::FragmentContext>, @@ -284,7 +284,7 @@ impl Tokenizer { tokenizer } - pub fn feed( + pub(crate) fn feed( &self, input: &BufferQueue, can_gc: CanGc, @@ -330,7 +330,7 @@ impl Tokenizer { } } - pub fn end(&self, can_gc: CanGc) { + pub(crate) fn end(&self, can_gc: CanGc) { self.html_tokenizer_sender .send(ToHtmlTokenizerMsg::End) .unwrap(); @@ -353,11 +353,11 @@ impl Tokenizer { } } - pub fn url(&self) -> &ServoUrl { + pub(crate) fn url(&self) -> &ServoUrl { &self.url } - pub fn set_plaintext_state(&self) { + pub(crate) fn set_plaintext_state(&self) { self.html_tokenizer_sender .send(ToHtmlTokenizerMsg::SetPlainTextState) .unwrap(); @@ -634,7 +634,7 @@ struct ParseNodeData { is_integration_point: bool, } -pub struct Sink { +pub(crate) struct Sink { current_line: Cell<u64>, parse_node_data: RefCell<HashMap<ParseNodeId, ParseNodeData>>, next_parse_node_id: Cell<ParseNodeId>, diff --git a/components/script/dom/servoparser/html.rs b/components/script/dom/servoparser/html.rs index b4102a2c153..a7fad312af5 100644 --- a/components/script/dom/servoparser/html.rs +++ b/components/script/dom/servoparser/html.rs @@ -34,13 +34,13 @@ use crate::script_runtime::CanGc; #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct Tokenizer { +pub(crate) struct Tokenizer { #[ignore_malloc_size_of = "Defined in html5ever"] inner: HtmlTokenizer<TreeBuilder<Dom<Node>, Sink>>, } impl Tokenizer { - pub fn new( + pub(crate) fn new( document: &Document, url: ServoUrl, fragment_context: Option<super::FragmentContext>, @@ -80,7 +80,7 @@ impl Tokenizer { Tokenizer { inner } } - pub fn feed(&self, input: &BufferQueue) -> TokenizerResult<DomRoot<HTMLScriptElement>> { + pub(crate) fn feed(&self, input: &BufferQueue) -> TokenizerResult<DomRoot<HTMLScriptElement>> { match self.inner.feed(input) { TokenizerResult::Done => TokenizerResult::Done, TokenizerResult::Script(script) => { @@ -89,15 +89,15 @@ impl Tokenizer { } } - pub fn end(&self) { + pub(crate) fn end(&self) { self.inner.end(); } - pub fn url(&self) -> &ServoUrl { + pub(crate) fn url(&self) -> &ServoUrl { &self.inner.sink.sink.base_url } - pub fn set_plaintext_state(&self) { + pub(crate) fn set_plaintext_state(&self) { self.inner.set_plaintext_state(); } } diff --git a/components/script/dom/servoparser/mod.rs b/components/script/dom/servoparser/mod.rs index bc51413f5f3..18a7aed45f0 100644 --- a/components/script/dom/servoparser/mod.rs +++ b/components/script/dom/servoparser/mod.rs @@ -89,7 +89,7 @@ mod xml; /// ^ /// insertion point /// ``` -pub struct ServoParser { +pub(crate) struct ServoParser { reflector: Reflector, /// The document associated with this parser. document: Dom<Document>, @@ -130,29 +130,29 @@ pub struct ServoParser { prefetch_input: BufferQueue, } -pub struct ElementAttribute { +pub(crate) struct ElementAttribute { name: QualName, value: DOMString, } #[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] -pub enum ParsingAlgorithm { +pub(crate) enum ParsingAlgorithm { Normal, Fragment, } impl ElementAttribute { - pub fn new(name: QualName, value: DOMString) -> ElementAttribute { + pub(crate) fn new(name: QualName, value: DOMString) -> ElementAttribute { ElementAttribute { name, value } } } impl ServoParser { - pub fn parser_is_not_active(&self) -> bool { + pub(crate) fn parser_is_not_active(&self) -> bool { self.can_write() } - pub fn parse_html_document( + pub(crate) fn parse_html_document( document: &Document, input: Option<DOMString>, url: ServoUrl, @@ -186,7 +186,7 @@ impl ServoParser { } // https://html.spec.whatwg.org/multipage/#parsing-html-fragments - pub fn parse_html_fragment( + pub(crate) fn parse_html_fragment( context: &Element, input: DOMString, can_gc: CanGc, @@ -251,7 +251,7 @@ impl ServoParser { } } - pub fn parse_html_script_input(document: &Document, url: ServoUrl) { + pub(crate) fn parse_html_script_input(document: &Document, url: ServoUrl) { let parser = ServoParser::new( document, Tokenizer::Html(self::html::Tokenizer::new( @@ -266,7 +266,7 @@ impl ServoParser { document.set_current_parser(Some(&parser)); } - pub fn parse_xml_document( + pub(crate) fn parse_xml_document( document: &Document, input: Option<DOMString>, url: ServoUrl, @@ -286,11 +286,11 @@ impl ServoParser { } } - pub fn script_nesting_level(&self) -> usize { + pub(crate) fn script_nesting_level(&self) -> usize { self.script_nesting_level.get() } - pub fn is_script_created(&self) -> bool { + pub(crate) fn is_script_created(&self) -> bool { self.script_created_parser } @@ -308,7 +308,7 @@ impl ServoParser { /// ^ /// insertion point /// ``` - pub fn resume_with_pending_parsing_blocking_script( + pub(crate) fn resume_with_pending_parsing_blocking_script( &self, script: &HTMLScriptElement, result: ScriptResult, @@ -334,12 +334,12 @@ impl ServoParser { } } - pub fn can_write(&self) -> bool { + pub(crate) fn can_write(&self) -> bool { self.script_created_parser || self.script_nesting_level.get() > 0 } /// Steps 6-8 of <https://html.spec.whatwg.org/multipage/#document.write()> - pub fn write(&self, text: Vec<DOMString>, can_gc: CanGc) { + pub(crate) fn write(&self, text: Vec<DOMString>, can_gc: CanGc) { assert!(self.can_write()); if self.document.has_pending_parsing_blocking_script() { @@ -399,7 +399,7 @@ impl ServoParser { } // Steps 4-6 of https://html.spec.whatwg.org/multipage/#dom-document-close - pub fn close(&self, can_gc: CanGc) { + pub(crate) fn close(&self, can_gc: CanGc) { assert!(self.script_created_parser); // Step 4. @@ -415,7 +415,7 @@ impl ServoParser { } // https://html.spec.whatwg.org/multipage/#abort-a-parser - pub fn abort(&self, can_gc: CanGc) { + pub(crate) fn abort(&self, can_gc: CanGc) { assert!(!self.aborted.get()); self.aborted.set(true); @@ -437,7 +437,7 @@ impl ServoParser { } // https://html.spec.whatwg.org/multipage/#active-parser - pub fn is_active(&self) -> bool { + pub(crate) fn is_active(&self) -> bool { self.script_nesting_level() > 0 && !self.aborted.get() } @@ -773,7 +773,7 @@ impl Tokenizer { /// The context required for asynchronously fetching a document /// and parsing it progressively. -pub struct ParserContext { +pub(crate) struct ParserContext { /// The parser that initiated the request. parser: Option<Trusted<ServoParser>>, /// Is this a synthesized document @@ -789,7 +789,7 @@ pub struct ParserContext { } impl ParserContext { - pub fn new(id: PipelineId, url: ServoUrl) -> ParserContext { + pub(crate) fn new(id: PipelineId, url: ServoUrl) -> ParserContext { ParserContext { parser: None, is_synthesized_document: false, @@ -1057,9 +1057,9 @@ impl FetchResponseListener for ParserContext { impl PreInvoke for ParserContext {} -pub struct FragmentContext<'a> { - pub context_elem: &'a Node, - pub form_elem: Option<&'a Node>, +pub(crate) struct FragmentContext<'a> { + pub(crate) context_elem: &'a Node, + pub(crate) form_elem: Option<&'a Node>, } #[allow(crown::unrooted_must_root)] @@ -1104,7 +1104,7 @@ fn insert( #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct Sink { +pub(crate) struct Sink { #[no_trace] base_url: ServoUrl, document: Dom<Document>, diff --git a/components/script/dom/servoparser/prefetch.rs b/components/script/dom/servoparser/prefetch.rs index 750af5c5f48..835cdc1d1f3 100644 --- a/components/script/dom/servoparser/prefetch.rs +++ b/components/script/dom/servoparser/prefetch.rs @@ -26,7 +26,7 @@ use crate::stylesheet_loader::stylesheet_fetch_request; #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct Tokenizer { +pub(crate) struct Tokenizer { #[ignore_malloc_size_of = "Defined in html5ever"] inner: HtmlTokenizer<PrefetchSink>, } @@ -39,7 +39,7 @@ unsafe impl CustomTraceable for HtmlTokenizer<PrefetchSink> { } impl Tokenizer { - pub fn new(document: &Document) -> Self { + pub(crate) fn new(document: &Document) -> Self { let sink = PrefetchSink { origin: document.origin().immutable().clone(), pipeline_id: document.global().pipeline_id(), @@ -58,7 +58,7 @@ impl Tokenizer { Tokenizer { inner } } - pub fn feed(&self, input: &BufferQueue) { + pub(crate) fn feed(&self, input: &BufferQueue) { while let TokenizerResult::Script(PrefetchHandle) = self.inner.feed(input) {} } } diff --git a/components/script/dom/servoparser/xml.rs b/components/script/dom/servoparser/xml.rs index d0d7b153b99..43248988094 100644 --- a/components/script/dom/servoparser/xml.rs +++ b/components/script/dom/servoparser/xml.rs @@ -22,13 +22,13 @@ use crate::dom::servoparser::{ParsingAlgorithm, Sink}; #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct Tokenizer { +pub(crate) struct Tokenizer { #[ignore_malloc_size_of = "Defined in xml5ever"] inner: XmlTokenizer<XmlTreeBuilder<Dom<Node>, Sink>>, } impl Tokenizer { - pub fn new(document: &Document, url: ServoUrl) -> Self { + pub(crate) fn new(document: &Document, url: ServoUrl) -> Self { let sink = Sink { base_url: url, document: Dom::from_ref(document), @@ -43,7 +43,7 @@ impl Tokenizer { Tokenizer { inner: tok } } - pub fn feed(&self, input: &BufferQueue) -> TokenizerResult<DomRoot<HTMLScriptElement>> { + pub(crate) fn feed(&self, input: &BufferQueue) -> TokenizerResult<DomRoot<HTMLScriptElement>> { self.inner.run(input); match self.inner.sink.sink.script.take() { Some(script) => TokenizerResult::Script(script), @@ -51,11 +51,11 @@ impl Tokenizer { } } - pub fn end(&self) { + pub(crate) fn end(&self) { self.inner.end() } - pub fn url(&self) -> &ServoUrl { + pub(crate) fn url(&self) -> &ServoUrl { &self.inner.sink.sink.base_url } } |