script/dom/
performanceobserverentrylist.rs1use dom_struct::dom_struct;
6
7use crate::dom::bindings::cell::DomRefCell;
8use crate::dom::bindings::codegen::Bindings::PerformanceObserverEntryListBinding::PerformanceObserverEntryListMethods;
9use crate::dom::bindings::reflector::{Reflector, reflect_dom_object};
10use crate::dom::bindings::root::DomRoot;
11use crate::dom::bindings::str::DOMString;
12use crate::dom::globalscope::GlobalScope;
13use crate::dom::performance::PerformanceEntryList;
14use crate::dom::performanceentry::PerformanceEntry;
15use crate::script_runtime::CanGc;
16
17#[dom_struct]
18pub(crate) struct PerformanceObserverEntryList {
19 reflector_: Reflector,
20 entries: DomRefCell<PerformanceEntryList>,
21}
22
23impl PerformanceObserverEntryList {
24 fn new_inherited(entries: PerformanceEntryList) -> PerformanceObserverEntryList {
25 PerformanceObserverEntryList {
26 reflector_: Reflector::new(),
27 entries: DomRefCell::new(entries),
28 }
29 }
30
31 #[cfg_attr(crown, allow(crown::unrooted_must_root))]
32 pub(crate) fn new(
33 global: &GlobalScope,
34 entries: PerformanceEntryList,
35 can_gc: CanGc,
36 ) -> DomRoot<PerformanceObserverEntryList> {
37 let observer_entry_list = PerformanceObserverEntryList::new_inherited(entries);
38 reflect_dom_object(Box::new(observer_entry_list), global, can_gc)
39 }
40}
41
42impl PerformanceObserverEntryListMethods<crate::DomTypeHolder> for PerformanceObserverEntryList {
43 fn GetEntries(&self) -> Vec<DomRoot<PerformanceEntry>> {
45 self.entries
46 .borrow()
47 .get_entries_by_name_and_type(None, None)
48 }
49
50 fn GetEntriesByType(&self, entry_type: DOMString) -> Vec<DomRoot<PerformanceEntry>> {
52 self.entries
53 .borrow()
54 .get_entries_by_name_and_type(None, Some(entry_type))
55 }
56
57 fn GetEntriesByName(
59 &self,
60 name: DOMString,
61 entry_type: Option<DOMString>,
62 ) -> Vec<DomRoot<PerformanceEntry>> {
63 self.entries
64 .borrow()
65 .get_entries_by_name_and_type(Some(name), entry_type)
66 }
67}