script_bindings/traits.rs
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5use style::Atom;
6
7use crate::DomTypes;
8use crate::str::DOMString;
9
10/// Trait for subcrates to use DOM events.
11pub trait DomEventTrait<D: DomTypes> {
12 fn new_inherited() -> Self;
13 fn init_event(&self, type_: Atom, bubbles: bool, cancelable: bool);
14 #[expect(non_snake_case)]
15 fn IsTrusted(&self) -> bool;
16 fn fire(&self, cx: &mut js::context::JSContext, target: &D::EventTarget);
17}
18
19/// Trait for subcrates to use DomExceptions.
20pub trait DomExceptionTrait {
21 fn new_inherited(message: DOMString, name: DOMString) -> Self;
22}