From 7d931e673af2780f3f62d52cb17324ec2cc68c71 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Mon, 7 Oct 2024 21:51:58 -0400 Subject: script: Include constructors and static methods in generated DOM traits (#33665) * Add all constructors, special operations, and static methods to generated DOM interface traits. Signed-off-by: Josh Matthews * Move all constructors and static methods defined in bare impl blocks inside FooMethods trait impls. Signed-off-by: Josh Matthews * Add missing doc links. Signed-off-by: Josh Matthews --------- Signed-off-by: Josh Matthews --- components/script/dom/performanceobserver.rs | 39 ++++++++++++++-------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'components/script/dom/performanceobserver.rs') diff --git a/components/script/dom/performanceobserver.rs b/components/script/dom/performanceobserver.rs index 62499393455..167a997287d 100644 --- a/components/script/dom/performanceobserver.rs +++ b/components/script/dom/performanceobserver.rs @@ -86,22 +86,6 @@ impl PerformanceObserver { reflect_dom_object_with_proto(Box::new(observer), global, proto, can_gc) } - #[allow(non_snake_case)] - pub fn Constructor( - global: &GlobalScope, - proto: Option, - can_gc: CanGc, - callback: Rc, - ) -> Fallible> { - Ok(PerformanceObserver::new_with_proto( - global, - proto, - callback, - Vec::new(), - can_gc, - )) - } - /// Buffer a new performance entry. pub fn queue_entry(&self, entry: &PerformanceEntry) { self.entries.borrow_mut().push(DomRoot::from_ref(entry)); @@ -132,17 +116,32 @@ impl PerformanceObserver { pub fn set_entries(&self, entries: DOMPerformanceEntryList) { *self.entries.borrow_mut() = entries; } +} + +impl PerformanceObserverMethods for PerformanceObserver { + // https://w3c.github.io/performance-timeline/#dom-performanceobserver-constructor + fn Constructor( + global: &GlobalScope, + proto: Option, + can_gc: CanGc, + callback: Rc, + ) -> Fallible> { + Ok(PerformanceObserver::new_with_proto( + global, + proto, + callback, + Vec::new(), + can_gc, + )) + } // https://w3c.github.io/performance-timeline/#supportedentrytypes-attribute - #[allow(non_snake_case)] - pub fn SupportedEntryTypes(cx: JSContext, global: &GlobalScope) -> JSVal { + fn SupportedEntryTypes(cx: JSContext, global: &GlobalScope) -> JSVal { // While this is exposed through a method of PerformanceObserver, // it is specified as associated with the global scope. global.supported_performance_entry_types(cx) } -} -impl PerformanceObserverMethods for PerformanceObserver { // https://w3c.github.io/performance-timeline/#dom-performanceobserver-observe() fn Observe(&self, options: &PerformanceObserverInit) -> Fallible<()> { // Step 1 is self -- cgit v1.2.3