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