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