Nacre/vendor/servo-script/dom/geolocation/geolocationposition.rs
astar76 0ecfd0f573 S031: root due timers in vendored servo-script (R5-01 SIGSEGV), crash-adblock regression smoke
fire_timer moved due timers into an unrooted Vec; a GC inside one callback swept
the functions of the timers still waiting. Heavy-web reruns and cargo test still pending.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 20:38:47 -06:00

50 lines
1.6 KiB
Rust

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use dom_struct::dom_struct;
use js::context::JSContext;
use script_bindings::codegen::GenericBindings::GeolocationPositionBinding::GeolocationPositionMethods;
use script_bindings::reflector::{Reflector, reflect_dom_object};
use script_bindings::root::{Dom, DomRoot};
use crate::dom::bindings::codegen::DomTypeHolder::DomTypeHolder;
use crate::dom::geolocationcoordinates::GeolocationCoordinates;
use crate::dom::globalscope::GlobalScope;
#[dom_struct]
pub struct GeolocationPosition {
reflector_: Reflector,
coords: Dom<GeolocationCoordinates>,
timestamp: u64,
}
impl GeolocationPosition {
fn new_inherited(coords: &GeolocationCoordinates, timestamp: u64) -> Self {
GeolocationPosition {
reflector_: Reflector::new(),
coords: Dom::from_ref(coords),
timestamp,
}
}
#[expect(unused)]
pub(crate) fn new(
cx: &mut JSContext,
global: &GlobalScope,
coords: &GeolocationCoordinates,
timestamp: u64,
) -> DomRoot<Self> {
reflect_dom_object(cx, Box::new(Self::new_inherited(coords, timestamp)), global)
}
}
impl GeolocationPositionMethods<DomTypeHolder> for GeolocationPosition {
fn Coords(&self) -> DomRoot<GeolocationCoordinates> {
DomRoot::from_ref(&*self.coords.clone())
}
fn Timestamp(&self) -> u64 {
self.timestamp
}
}