script/dom/
debuggerpauseevent.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 std::fmt::Debug;
6
7use dom_struct::dom_struct;
8
9use crate::dom::bindings::codegen::Bindings::DebuggerPauseEventBinding::DebuggerPauseEventMethods;
10use crate::dom::bindings::codegen::Bindings::EventBinding::Event_Binding::EventMethods;
11use crate::dom::bindings::reflector::reflect_dom_object;
12use crate::dom::bindings::root::DomRoot;
13use crate::dom::event::Event;
14use crate::dom::types::GlobalScope;
15use crate::script_runtime::CanGc;
16
17#[dom_struct]
18/// Event for Rust → JS calls in [`crate::dom::DebuggerGlobalScope`].
19pub(crate) struct DebuggerPauseEvent {
20    event: Event,
21}
22
23impl DebuggerPauseEvent {
24    pub(crate) fn new(debugger_global: &GlobalScope, can_gc: CanGc) -> DomRoot<Self> {
25        let result = Box::new(Self {
26            event: Event::new_inherited(),
27        });
28        let result = reflect_dom_object(result, debugger_global, can_gc);
29        result.event.init_event("pause".into(), false, false);
30
31        result
32    }
33}
34
35impl DebuggerPauseEventMethods<crate::DomTypeHolder> for DebuggerPauseEvent {
36    // check-tidy: no specs after this line
37    fn IsTrusted(&self) -> bool {
38        self.event.IsTrusted()
39    }
40}
41
42impl Debug for DebuggerPauseEvent {
43    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
44        f.debug_struct("DebuggerPauseEvent").finish()
45    }
46}