aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/promisenativehandler.rs
diff options
context:
space:
mode:
authortanishka <109246904+taniishkaaa@users.noreply.github.com>2024-11-07 17:41:33 +0530
committerGitHub <noreply@github.com>2024-11-07 12:11:33 +0000
commitac7419cf57d13c73fc35fe156e6f38d378814868 (patch)
treefdda1d6f2eb4d21449205d315abc5cf2b7845d85 /components/script/dom/promisenativehandler.rs
parent05ee551af8b6ccbd18aaf27b04237ee4751bd2cb (diff)
downloadservo-ac7419cf57d13c73fc35fe156e6f38d378814868.tar.gz
servo-ac7419cf57d13c73fc35fe156e6f38d378814868.zip
Consistently use `Dom` in native promise handlers (#34167)
* Consistently use Dom in native promise handlers Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> * Fix crown errors Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> --------- Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
Diffstat (limited to 'components/script/dom/promisenativehandler.rs')
-rw-r--r--components/script/dom/promisenativehandler.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs
index 42614a4cc34..4b57cd08f63 100644
--- a/components/script/dom/promisenativehandler.rs
+++ b/components/script/dom/promisenativehandler.rs
@@ -14,6 +14,10 @@ use crate::dom::globalscope::GlobalScope;
use crate::realms::InRealm;
use crate::script_runtime::{CanGc, JSContext as SafeJSContext};
+/// Types that implement the `Callback` trait follow the same rooting requirements
+/// as types that use the `#[dom_struct]` attribute.
+/// Prefer storing `Dom<T>` members inside them instead of `DomRoot<T>`
+/// to minimize redundant work by the garbage collector.
pub trait Callback: JSTraceable + MallocSizeOf {
fn callback(&self, cx: SafeJSContext, v: HandleValue, realm: InRealm, can_gc: CanGc);
}