mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Propagate CanGc arguments through HTMLCollection constructors (#36180)
Signed-off-by: dericko681 <abonghoderick@gmail.com>
This commit is contained in:
parent
83da63f638
commit
40133ce29a
11 changed files with 125 additions and 53 deletions
|
@ -87,7 +87,7 @@ impl HTMLCollection {
|
|||
}
|
||||
|
||||
/// Returns a collection which is always empty.
|
||||
pub(crate) fn always_empty(window: &Window, root: &Node) -> DomRoot<Self> {
|
||||
pub(crate) fn always_empty(window: &Window, root: &Node, can_gc: CanGc) -> DomRoot<Self> {
|
||||
#[derive(JSTraceable)]
|
||||
struct NoFilter;
|
||||
impl CollectionFilter for NoFilter {
|
||||
|
@ -96,7 +96,7 @@ impl HTMLCollection {
|
|||
}
|
||||
}
|
||||
|
||||
Self::new(window, root, Box::new(NoFilter), CanGc::note())
|
||||
Self::new(window, root, Box::new(NoFilter), can_gc)
|
||||
}
|
||||
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
|
@ -114,6 +114,7 @@ impl HTMLCollection {
|
|||
window: &Window,
|
||||
root: &Node,
|
||||
filter_function: fn(&Element, &Node) -> bool,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<Self> {
|
||||
#[derive(JSTraceable, MallocSizeOf)]
|
||||
pub(crate) struct StaticFunctionFilter(
|
||||
|
@ -132,7 +133,7 @@ impl HTMLCollection {
|
|||
window,
|
||||
root,
|
||||
Box::new(StaticFunctionFilter(filter_function)),
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -176,6 +177,7 @@ impl HTMLCollection {
|
|||
window: &Window,
|
||||
root: &Node,
|
||||
qualified_name: LocalName,
|
||||
_can_gc: CanGc,
|
||||
) -> DomRoot<HTMLCollection> {
|
||||
// case 1
|
||||
if qualified_name == local_name!("*") {
|
||||
|
@ -231,17 +233,19 @@ impl HTMLCollection {
|
|||
root: &Node,
|
||||
tag: DOMString,
|
||||
maybe_ns: Option<DOMString>,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<HTMLCollection> {
|
||||
let local = LocalName::from(tag);
|
||||
let ns = namespace_from_domstring(maybe_ns);
|
||||
let qname = QualName::new(None, ns, local);
|
||||
HTMLCollection::by_qual_tag_name(window, root, qname)
|
||||
HTMLCollection::by_qual_tag_name(window, root, qname, can_gc)
|
||||
}
|
||||
|
||||
pub(crate) fn by_qual_tag_name(
|
||||
window: &Window,
|
||||
root: &Node,
|
||||
qname: QualName,
|
||||
_can_gc: CanGc,
|
||||
) -> DomRoot<HTMLCollection> {
|
||||
#[derive(JSTraceable, MallocSizeOf)]
|
||||
struct TagNameNSFilter {
|
||||
|
@ -263,15 +267,17 @@ impl HTMLCollection {
|
|||
window: &Window,
|
||||
root: &Node,
|
||||
classes: DOMString,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<HTMLCollection> {
|
||||
let class_atoms = split_html_space_chars(&classes).map(Atom::from).collect();
|
||||
HTMLCollection::by_atomic_class_name(window, root, class_atoms)
|
||||
HTMLCollection::by_atomic_class_name(window, root, class_atoms, can_gc)
|
||||
}
|
||||
|
||||
pub(crate) fn by_atomic_class_name(
|
||||
window: &Window,
|
||||
root: &Node,
|
||||
classes: Vec<Atom>,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<HTMLCollection> {
|
||||
#[derive(JSTraceable, MallocSizeOf)]
|
||||
struct ClassNameFilter {
|
||||
|
@ -292,17 +298,20 @@ impl HTMLCollection {
|
|||
}
|
||||
|
||||
if classes.is_empty() {
|
||||
return HTMLCollection::always_empty(window, root);
|
||||
return HTMLCollection::always_empty(window, root, can_gc);
|
||||
}
|
||||
|
||||
let filter = ClassNameFilter { classes };
|
||||
HTMLCollection::create(window, root, Box::new(filter))
|
||||
}
|
||||
|
||||
pub(crate) fn children(window: &Window, root: &Node) -> DomRoot<HTMLCollection> {
|
||||
HTMLCollection::new_with_filter_fn(window, root, |element, root| {
|
||||
root.is_parent_of(element.upcast())
|
||||
})
|
||||
pub(crate) fn children(window: &Window, root: &Node, can_gc: CanGc) -> DomRoot<HTMLCollection> {
|
||||
HTMLCollection::new_with_filter_fn(
|
||||
window,
|
||||
root,
|
||||
|element, root| root.is_parent_of(element.upcast()),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn elements_iter_after<'a>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue