mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +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
|
@ -4979,8 +4979,12 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
|
|||
if let Some(entry) = self.tag_map.borrow_mut().get(&qualified_name) {
|
||||
return DomRoot::from_ref(entry);
|
||||
}
|
||||
let result =
|
||||
HTMLCollection::by_qualified_name(&self.window, self.upcast(), qualified_name.clone());
|
||||
let result = HTMLCollection::by_qualified_name(
|
||||
&self.window,
|
||||
self.upcast(),
|
||||
qualified_name.clone(),
|
||||
CanGc::note(),
|
||||
);
|
||||
self.tag_map
|
||||
.borrow_mut()
|
||||
.insert(qualified_name, Dom::from_ref(&*result));
|
||||
|
@ -4999,7 +5003,12 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
|
|||
if let Some(collection) = self.tagns_map.borrow().get(&qname) {
|
||||
return DomRoot::from_ref(collection);
|
||||
}
|
||||
let result = HTMLCollection::by_qual_tag_name(&self.window, self.upcast(), qname.clone());
|
||||
let result = HTMLCollection::by_qual_tag_name(
|
||||
&self.window,
|
||||
self.upcast(),
|
||||
qname.clone(),
|
||||
CanGc::note(),
|
||||
);
|
||||
self.tagns_map
|
||||
.borrow_mut()
|
||||
.insert(qname, Dom::from_ref(&*result));
|
||||
|
@ -5012,8 +5021,12 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
|
|||
if let Some(collection) = self.classes_map.borrow().get(&class_atoms) {
|
||||
return DomRoot::from_ref(collection);
|
||||
}
|
||||
let result =
|
||||
HTMLCollection::by_atomic_class_name(&self.window, self.upcast(), class_atoms.clone());
|
||||
let result = HTMLCollection::by_atomic_class_name(
|
||||
&self.window,
|
||||
self.upcast(),
|
||||
class_atoms.clone(),
|
||||
CanGc::note(),
|
||||
);
|
||||
self.classes_map
|
||||
.borrow_mut()
|
||||
.insert(class_atoms, Dom::from_ref(&*result));
|
||||
|
@ -5489,18 +5502,24 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-document-images
|
||||
fn Images(&self) -> DomRoot<HTMLCollection> {
|
||||
self.images.or_init(|| {
|
||||
HTMLCollection::new_with_filter_fn(&self.window, self.upcast(), |element, _| {
|
||||
element.is::<HTMLImageElement>()
|
||||
})
|
||||
HTMLCollection::new_with_filter_fn(
|
||||
&self.window,
|
||||
self.upcast(),
|
||||
|element, _| element.is::<HTMLImageElement>(),
|
||||
CanGc::note(),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-embeds
|
||||
fn Embeds(&self) -> DomRoot<HTMLCollection> {
|
||||
self.embeds.or_init(|| {
|
||||
HTMLCollection::new_with_filter_fn(&self.window, self.upcast(), |element, _| {
|
||||
element.is::<HTMLEmbedElement>()
|
||||
})
|
||||
HTMLCollection::new_with_filter_fn(
|
||||
&self.window,
|
||||
self.upcast(),
|
||||
|element, _| element.is::<HTMLEmbedElement>(),
|
||||
CanGc::note(),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -5512,44 +5531,60 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-document-links
|
||||
fn Links(&self) -> DomRoot<HTMLCollection> {
|
||||
self.links.or_init(|| {
|
||||
HTMLCollection::new_with_filter_fn(&self.window, self.upcast(), |element, _| {
|
||||
(element.is::<HTMLAnchorElement>() || element.is::<HTMLAreaElement>()) &&
|
||||
element.has_attribute(&local_name!("href"))
|
||||
})
|
||||
HTMLCollection::new_with_filter_fn(
|
||||
&self.window,
|
||||
self.upcast(),
|
||||
|element, _| {
|
||||
(element.is::<HTMLAnchorElement>() || element.is::<HTMLAreaElement>()) &&
|
||||
element.has_attribute(&local_name!("href"))
|
||||
},
|
||||
CanGc::note(),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-forms
|
||||
fn Forms(&self) -> DomRoot<HTMLCollection> {
|
||||
self.forms.or_init(|| {
|
||||
HTMLCollection::new_with_filter_fn(&self.window, self.upcast(), |element, _| {
|
||||
element.is::<HTMLFormElement>()
|
||||
})
|
||||
HTMLCollection::new_with_filter_fn(
|
||||
&self.window,
|
||||
self.upcast(),
|
||||
|element, _| element.is::<HTMLFormElement>(),
|
||||
CanGc::note(),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-scripts
|
||||
fn Scripts(&self) -> DomRoot<HTMLCollection> {
|
||||
self.scripts.or_init(|| {
|
||||
HTMLCollection::new_with_filter_fn(&self.window, self.upcast(), |element, _| {
|
||||
element.is::<HTMLScriptElement>()
|
||||
})
|
||||
HTMLCollection::new_with_filter_fn(
|
||||
&self.window,
|
||||
self.upcast(),
|
||||
|element, _| element.is::<HTMLScriptElement>(),
|
||||
CanGc::note(),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-anchors
|
||||
fn Anchors(&self) -> DomRoot<HTMLCollection> {
|
||||
self.anchors.or_init(|| {
|
||||
HTMLCollection::new_with_filter_fn(&self.window, self.upcast(), |element, _| {
|
||||
element.is::<HTMLAnchorElement>() && element.has_attribute(&local_name!("href"))
|
||||
})
|
||||
HTMLCollection::new_with_filter_fn(
|
||||
&self.window,
|
||||
self.upcast(),
|
||||
|element, _| {
|
||||
element.is::<HTMLAnchorElement>() && element.has_attribute(&local_name!("href"))
|
||||
},
|
||||
CanGc::note(),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-applets
|
||||
fn Applets(&self) -> DomRoot<HTMLCollection> {
|
||||
self.applets
|
||||
.or_init(|| HTMLCollection::always_empty(&self.window, self.upcast()))
|
||||
.or_init(|| HTMLCollection::always_empty(&self.window, self.upcast(), CanGc::note()))
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-location
|
||||
|
@ -5563,7 +5598,7 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
|
|||
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
||||
fn Children(&self) -> DomRoot<HTMLCollection> {
|
||||
HTMLCollection::children(&self.window, self.upcast())
|
||||
HTMLCollection::children(&self.window, self.upcast(), CanGc::note())
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue