Skip to main content

script/dom/debugger/
debuggergetpossiblebreakpointsevent.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;
8use js::context::JSContext;
9use script_bindings::reflector::reflect_dom_object_with_cx;
10
11use crate::dom::bindings::codegen::Bindings::DebuggerGetPossibleBreakpointsEventBinding::DebuggerGetPossibleBreakpointsEventMethods;
12use crate::dom::bindings::codegen::Bindings::EventBinding::Event_Binding::EventMethods;
13use crate::dom::bindings::root::DomRoot;
14use crate::dom::event::Event;
15use crate::dom::types::GlobalScope;
16
17#[dom_struct]
18/// Event for Rust → JS calls in [`crate::dom::debugger::DebuggerGlobalScope`].
19pub(crate) struct DebuggerGetPossibleBreakpointsEvent {
20    event: Event,
21    spidermonkey_id: u32,
22}
23
24impl DebuggerGetPossibleBreakpointsEvent {
25    pub(crate) fn new(
26        cx: &mut JSContext,
27        debugger_global: &GlobalScope,
28        spidermonkey_id: u32,
29    ) -> DomRoot<Self> {
30        let result = Box::new(Self {
31            event: Event::new_inherited(),
32            spidermonkey_id,
33        });
34        let result = reflect_dom_object_with_cx(result, debugger_global, cx);
35        result
36            .event
37            .init_event("getPossibleBreakpoints".into(), false, false);
38
39        result
40    }
41}
42
43impl DebuggerGetPossibleBreakpointsEventMethods<crate::DomTypeHolder>
44    for DebuggerGetPossibleBreakpointsEvent
45{
46    // check-tidy: no specs after this line
47    fn SpidermonkeyId(&self) -> u32 {
48        self.spidermonkey_id
49    }
50
51    fn IsTrusted(&self) -> bool {
52        self.event.IsTrusted()
53    }
54}
55
56impl Debug for DebuggerGetPossibleBreakpointsEvent {
57    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
58        f.debug_struct("DebuggerGetPossibleBreakpointsEvent")
59            .field("spidermonkey_id", &self.spidermonkey_id)
60            .finish()
61    }
62}