CanGc fixes in several files (#33958)

* few cangc fixes

Signed-off-by: L Ashwin B <lashwinib@gmail.com>

* few cangc fixes

Signed-off-by: L Ashwin B <lashwinib@gmail.com>

---------

Signed-off-by: L Ashwin B <lashwinib@gmail.com>
This commit is contained in:
chickenleaf 2024-10-22 03:02:22 +05:30 committed by GitHub
parent 1bf68567b8
commit ebfea9b352
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 170 additions and 129 deletions

View file

@ -158,22 +158,22 @@ struct SerializationIterator {
stack: Vec<SerializationCommand>,
}
fn rev_children_iter(n: &Node) -> impl Iterator<Item = DomRoot<Node>> {
fn rev_children_iter(n: &Node, can_gc: CanGc) -> impl Iterator<Item = DomRoot<Node>> {
if n.downcast::<Element>().is_some_and(|e| e.is_void()) {
return Node::new_document_node().rev_children();
}
match n.downcast::<HTMLTemplateElement>() {
Some(t) => t.Content(CanGc::note()).upcast::<Node>().rev_children(),
Some(t) => t.Content(can_gc).upcast::<Node>().rev_children(),
None => n.rev_children(),
}
}
impl SerializationIterator {
fn new(node: &Node, skip_first: bool) -> SerializationIterator {
fn new(node: &Node, skip_first: bool, can_gc: CanGc) -> SerializationIterator {
let mut ret = SerializationIterator { stack: vec![] };
if skip_first || node.is::<DocumentFragment>() || node.is::<Document>() {
for c in rev_children_iter(node) {
for c in rev_children_iter(node, can_gc) {
ret.push_node(&c);
}
} else {
@ -203,7 +203,7 @@ impl Iterator for SerializationIterator {
if let Some(SerializationCommand::OpenElement(ref e)) = res {
self.stack
.push(SerializationCommand::CloseElement(e.clone()));
for c in rev_children_iter(e.upcast::<Node>()) {
for c in rev_children_iter(e.upcast::<Node>(), CanGc::note()) {
self.push_node(&c);
}
}
@ -220,7 +220,7 @@ impl<'a> Serialize for &'a Node {
) -> io::Result<()> {
let node = *self;
let iter = SerializationIterator::new(node, traversal_scope != IncludeNode);
let iter = SerializationIterator::new(node, traversal_scope != IncludeNode, CanGc::note());
for cmd in iter {
match cmd {