Refine crown annotations for HTML parser. (#32956)

* Refine crown annotations for HTML parser.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Add missing annotation.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2024-08-08 03:20:26 -04:00 committed by GitHub
parent 1379cd5779
commit a5df51ea56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1083,19 +1083,21 @@ impl Sink {
}
}
#[allow(crown::unrooted_must_root)] // FIXME: really?
impl TreeSink for Sink {
type Output = Self;
#[allow(crown::unrooted_must_root)]
fn finish(self) -> Self {
self
}
type Handle = Dom<Node>;
#[allow(crown::unrooted_must_root)]
fn get_document(&mut self) -> Dom<Node> {
Dom::from_ref(self.document.upcast())
}
#[allow(crown::unrooted_must_root)]
fn get_template_contents(&mut self, target: &Dom<Node>) -> Dom<Node> {
let template = target
.downcast::<HTMLTemplateElement>()
@ -1117,6 +1119,7 @@ impl TreeSink for Sink {
}
}
#[allow(crown::unrooted_must_root)]
fn create_element(
&mut self,
name: QualName,
@ -1137,11 +1140,13 @@ impl TreeSink for Sink {
Dom::from_ref(element.upcast())
}
#[allow(crown::unrooted_must_root)]
fn create_comment(&mut self, text: StrTendril) -> Dom<Node> {
let comment = Comment::new(DOMString::from(String::from(text)), &self.document, None);
Dom::from_ref(comment.upcast())
}
#[allow(crown::unrooted_must_root)]
fn create_pi(&mut self, target: StrTendril, data: StrTendril) -> Dom<Node> {
let doc = &*self.document;
let pi = ProcessingInstruction::new(
@ -1182,6 +1187,7 @@ impl TreeSink for Sink {
}
}
#[allow(crown::unrooted_must_root)]
fn append_before_sibling(&mut self, sibling: &Dom<Node>, new_node: NodeOrText<Dom<Node>>) {
let parent = sibling
.GetParentNode()
@ -1203,10 +1209,12 @@ impl TreeSink for Sink {
self.document.set_quirks_mode(mode);
}
#[allow(crown::unrooted_must_root)]
fn append(&mut self, parent: &Dom<Node>, child: NodeOrText<Dom<Node>>) {
insert(parent, None, child, self.parsing_algorithm);
}
#[allow(crown::unrooted_must_root)]
fn append_based_on_parent_node(
&mut self,
elem: &Dom<Node>,