/* * Copyright (c) 2025, Jelle Raaijmakers * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include namespace Web::Geolocation { // https://w3c.github.io/geolocation/#dom-positionoptions struct PositionOptions { bool enable_high_accuracy { false }; WebIDL::UnsignedLong timeout { 0xFFFFFFFF }; WebIDL::UnsignedLong maximum_age { 0 }; }; // https://w3c.github.io/geolocation/#dfn-emulated-position-data using EmulatedPositionData = Variant, GeolocationPositionError::ErrorCode>; // https://w3c.github.io/geolocation/#geolocation_interface class Geolocation : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(Geolocation, Bindings::PlatformObject); GC_DECLARE_ALLOCATOR(Geolocation); public: void get_current_position(GC::Ref, GC::Ptr, PositionOptions); WebIDL::Long watch_position(GC::Ref, GC::Ptr, PositionOptions); void clear_watch(WebIDL::Long); private: Geolocation(JS::Realm&); virtual void initialize(JS::Realm&) override; virtual void visit_edges(Visitor&) override; void acquire_a_position(GC::Ref, GC::Ptr, PositionOptions, Optional); void call_back_with_error(GC::Ptr, GeolocationPositionError::ErrorCode) const; EmulatedPositionData get_emulated_position_data() const; void request_a_position(GC::Ref, GC::Ptr, PositionOptions, Optional = {}); void run_in_parallel_when_document_is_visible(DOM::Document&, GC::Ref>); // https://w3c.github.io/geolocation/#dfn-watchids HashTable m_watch_ids; // https://w3c.github.io/geolocation/#dfn-cachedposition GC::Ptr m_cached_position; Vector> m_timeout_timers; }; }