script/dom/geolocation/
geolocationposition.rs1use dom_struct::dom_struct;
6use script_bindings::codegen::GenericBindings::GeolocationPositionBinding::GeolocationPositionMethods;
7use script_bindings::reflector::{Reflector, reflect_dom_object};
8use script_bindings::root::{Dom, DomRoot};
9use script_bindings::script_runtime::CanGc;
10
11use crate::dom::bindings::codegen::DomTypeHolder::DomTypeHolder;
12use crate::dom::geolocationcoordinates::GeolocationCoordinates;
13use crate::dom::globalscope::GlobalScope;
14
15#[dom_struct]
16pub struct GeolocationPosition {
17 reflector_: Reflector,
18 coords: Dom<GeolocationCoordinates>,
19 timestamp: u64,
20}
21
22impl GeolocationPosition {
23 fn new_inherited(coords: &GeolocationCoordinates, timestamp: u64) -> Self {
24 GeolocationPosition {
25 reflector_: Reflector::new(),
26 coords: Dom::from_ref(coords),
27 timestamp,
28 }
29 }
30
31 #[expect(unused)]
32 pub(crate) fn new(
33 global: &GlobalScope,
34 coords: &GeolocationCoordinates,
35 timestamp: u64,
36 can_gc: CanGc,
37 ) -> DomRoot<Self> {
38 reflect_dom_object(
39 Box::new(Self::new_inherited(coords, timestamp)),
40 global,
41 can_gc,
42 )
43 }
44}
45
46impl GeolocationPositionMethods<DomTypeHolder> for GeolocationPosition {
47 fn Coords(&self) -> DomRoot<GeolocationCoordinates> {
48 DomRoot::from_ref(&*self.coords.clone())
49 }
50
51 fn Timestamp(&self) -> u64 {
52 self.timestamp
53 }
54}