script/dom/geolocation/
geolocationpositionerror.rs1use dom_struct::dom_struct;
6use js::context::JSContext;
7use script_bindings::codegen::GenericBindings::GeolocationPositionErrorBinding::GeolocationPositionErrorConstants::{PERMISSION_DENIED, POSITION_UNAVAILABLE, TIMEOUT};
8use script_bindings::codegen::GenericBindings::GeolocationPositionErrorBinding::GeolocationPositionErrorMethods;
9use script_bindings::reflector::{Reflector, reflect_dom_object_with_cx};
10use script_bindings::root::DomRoot;
11use script_bindings::str::DOMString;
12
13use crate::dom::bindings::codegen::DomTypeHolder::DomTypeHolder;
14use crate::dom::globalscope::GlobalScope;
15
16#[dom_struct]
17pub struct GeolocationPositionError {
18 reflector_: Reflector,
19 code: u16,
20 message: DOMString,
21}
22
23impl GeolocationPositionError {
24 fn new_inherited(code: u16, message: DOMString) -> Self {
25 GeolocationPositionError {
26 reflector_: Reflector::new(),
27 code,
28 message,
29 }
30 }
31
32 fn new(
33 cx: &mut JSContext,
34 global: &GlobalScope,
35 code: u16,
36 message: DOMString,
37 ) -> DomRoot<Self> {
38 reflect_dom_object_with_cx(Box::new(Self::new_inherited(code, message)), global, cx)
39 }
40
41 pub(crate) fn permission_denied(
42 cx: &mut JSContext,
43 global: &GlobalScope,
44 message: DOMString,
45 ) -> DomRoot<Self> {
46 Self::new(cx, global, PERMISSION_DENIED, message)
47 }
48
49 pub(crate) fn position_unavailable(
50 cx: &mut JSContext,
51 global: &GlobalScope,
52 message: DOMString,
53 ) -> DomRoot<Self> {
54 Self::new(cx, global, POSITION_UNAVAILABLE, message)
55 }
56
57 #[expect(unused)]
58 pub(crate) fn timeout(
59 cx: &mut JSContext,
60 global: &GlobalScope,
61 message: DOMString,
62 ) -> DomRoot<Self> {
63 Self::new(cx, global, TIMEOUT, message)
64 }
65}
66
67impl GeolocationPositionErrorMethods<DomTypeHolder> for GeolocationPositionError {
68 fn Code(&self) -> u16 {
69 self.code
70 }
71
72 fn Message(&self) -> DOMString {
73 self.message.clone()
74 }
75}