mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 08:10:02 +00:00
LibWeb: Stub Geolocation API
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This commit is contained in:
parent
f3c1dfb2f1
commit
22bda8e5e2
Notes:
github-actions[bot]
2025-06-21 08:01:30 +00:00
Author: https://github.com/gmta
Commit: 22bda8e5e2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5143
25 changed files with 480 additions and 57 deletions
|
@ -316,6 +316,10 @@ set(SOURCES
|
||||||
FileAPI/FileList.cpp
|
FileAPI/FileList.cpp
|
||||||
FileAPI/FileReader.cpp
|
FileAPI/FileReader.cpp
|
||||||
FileAPI/FileReaderSync.cpp
|
FileAPI/FileReaderSync.cpp
|
||||||
|
Geolocation/Geolocation.cpp
|
||||||
|
Geolocation/GeolocationCoordinates.cpp
|
||||||
|
Geolocation/GeolocationPosition.cpp
|
||||||
|
Geolocation/GeolocationPositionError.cpp
|
||||||
Geometry/DOMMatrix.cpp
|
Geometry/DOMMatrix.cpp
|
||||||
Geometry/DOMMatrixReadOnly.cpp
|
Geometry/DOMMatrixReadOnly.cpp
|
||||||
Geometry/DOMPoint.cpp
|
Geometry/DOMPoint.cpp
|
||||||
|
|
|
@ -460,6 +460,15 @@ class FileList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Web::Geolocation {
|
||||||
|
|
||||||
|
class Geolocation;
|
||||||
|
class GeolocationCoordinates;
|
||||||
|
class GeolocationPosition;
|
||||||
|
class GeolocationPositionError;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
namespace Web::Geometry {
|
namespace Web::Geometry {
|
||||||
|
|
||||||
class DOMMatrix;
|
class DOMMatrix;
|
||||||
|
|
70
Libraries/LibWeb/Geolocation/Geolocation.cpp
Normal file
70
Libraries/LibWeb/Geolocation/Geolocation.cpp
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/GeolocationPrototype.h>
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
|
#include <LibWeb/Geolocation/Geolocation.h>
|
||||||
|
|
||||||
|
namespace Web::Geolocation {
|
||||||
|
|
||||||
|
GC_DEFINE_ALLOCATOR(Geolocation);
|
||||||
|
|
||||||
|
Geolocation::Geolocation(JS::Realm& realm)
|
||||||
|
: PlatformObject(realm)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Geolocation::initialize(JS::Realm& realm)
|
||||||
|
{
|
||||||
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(Geolocation);
|
||||||
|
Base::initialize(realm);
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://w3c.github.io/geolocation/#dom-geolocation-getcurrentposition
|
||||||
|
void Geolocation::get_current_position([[maybe_unused]] GC::Ref<WebIDL::CallbackType> success_callback,
|
||||||
|
[[maybe_unused]] GC::Ptr<WebIDL::CallbackType> error_callback, [[maybe_unused]] Optional<PositionOptions> options)
|
||||||
|
{
|
||||||
|
// FIXME: 1. If this's relevant global object's associated Document is not fully active:
|
||||||
|
{
|
||||||
|
// FIXME: 1. Call back with error errorCallback and POSITION_UNAVAILABLE.
|
||||||
|
|
||||||
|
// FIXME: 2. Terminate this algorithm.
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: 2. Request a position passing this, successCallback, errorCallback, and options.
|
||||||
|
dbgln("FIXME: Geolocation::get_current_position() not implemented yet");
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://w3c.github.io/geolocation/#watchposition-method
|
||||||
|
WebIDL::Long Geolocation::watch_position([[maybe_unused]] GC::Ref<WebIDL::CallbackType> success_callback,
|
||||||
|
[[maybe_unused]] GC::Ptr<WebIDL::CallbackType> error_callback, [[maybe_unused]] Optional<PositionOptions> options)
|
||||||
|
{
|
||||||
|
// FIXME: 1. If this's relevant global object's associated Document is not fully active:
|
||||||
|
{
|
||||||
|
// FIXME: 1. Call back with error passing errorCallback and POSITION_UNAVAILABLE.
|
||||||
|
|
||||||
|
// FIXME: 2. Return 0.
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: 2. Let watchId be an implementation-defined unsigned long that is greater than zero.
|
||||||
|
|
||||||
|
// FIXME: 3. Append watchId to this's [[watchIDs]].
|
||||||
|
|
||||||
|
// FIXME: 4. Request a position passing this, successCallback, errorCallback, options, and watchId.
|
||||||
|
|
||||||
|
// FIXME: 5. Return watchId.
|
||||||
|
dbgln("FIXME: Geolocation::watch_position() not implemented yet");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://w3c.github.io/geolocation/#clearwatch-method
|
||||||
|
void Geolocation::clear_watch([[maybe_unused]] WebIDL::Long watch_id)
|
||||||
|
{
|
||||||
|
// FIXME: 1. Remove watchId from this's [[watchIDs]].
|
||||||
|
dbgln("FIXME: Geolocation::clear_watch() not implemented yet");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
36
Libraries/LibWeb/Geolocation/Geolocation.h
Normal file
36
Libraries/LibWeb/Geolocation/Geolocation.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
|
#include <LibWeb/WebIDL/Types.h>
|
||||||
|
|
||||||
|
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/#geolocation_interface
|
||||||
|
class Geolocation : public Bindings::PlatformObject {
|
||||||
|
WEB_PLATFORM_OBJECT(Geolocation, Bindings::PlatformObject);
|
||||||
|
GC_DECLARE_ALLOCATOR(Geolocation);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void get_current_position(GC::Ref<WebIDL::CallbackType>, GC::Ptr<WebIDL::CallbackType>, Optional<PositionOptions>);
|
||||||
|
WebIDL::Long watch_position(GC::Ref<WebIDL::CallbackType>, GC::Ptr<WebIDL::CallbackType>, Optional<PositionOptions>);
|
||||||
|
void clear_watch(WebIDL::Long);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Geolocation(JS::Realm&);
|
||||||
|
|
||||||
|
virtual void initialize(JS::Realm&) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
30
Libraries/LibWeb/Geolocation/Geolocation.idl
Normal file
30
Libraries/LibWeb/Geolocation/Geolocation.idl
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
// https://w3c.github.io/geolocation/#geolocation_interface
|
||||||
|
[Exposed=Window]
|
||||||
|
interface Geolocation {
|
||||||
|
undefined getCurrentPosition (
|
||||||
|
PositionCallback successCallback,
|
||||||
|
optional PositionErrorCallback? errorCallback = null,
|
||||||
|
optional PositionOptions options = {},
|
||||||
|
);
|
||||||
|
|
||||||
|
long watchPosition (
|
||||||
|
PositionCallback successCallback,
|
||||||
|
optional PositionErrorCallback? errorCallback = null,
|
||||||
|
optional PositionOptions options = {},
|
||||||
|
);
|
||||||
|
|
||||||
|
undefined clearWatch (long watchId);
|
||||||
|
};
|
||||||
|
|
||||||
|
// https://w3c.github.io/geolocation/#dom-positionoptions
|
||||||
|
dictionary PositionOptions {
|
||||||
|
boolean enableHighAccuracy = false;
|
||||||
|
[Clamp] unsigned long timeout = 0xFFFFFFFF;
|
||||||
|
[Clamp] unsigned long maximumAge = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
callback PositionCallback = undefined (
|
||||||
|
GeolocationPosition position);
|
||||||
|
|
||||||
|
callback PositionErrorCallback = undefined (
|
||||||
|
GeolocationPositionError positionError);
|
26
Libraries/LibWeb/Geolocation/GeolocationCoordinates.cpp
Normal file
26
Libraries/LibWeb/Geolocation/GeolocationCoordinates.cpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/GeolocationCoordinatesPrototype.h>
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
|
#include <LibWeb/Geolocation/GeolocationCoordinates.h>
|
||||||
|
|
||||||
|
namespace Web::Geolocation {
|
||||||
|
|
||||||
|
GC_DEFINE_ALLOCATOR(GeolocationCoordinates);
|
||||||
|
|
||||||
|
GeolocationCoordinates::GeolocationCoordinates(JS::Realm& realm)
|
||||||
|
: PlatformObject(realm)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void GeolocationCoordinates::initialize(JS::Realm& realm)
|
||||||
|
{
|
||||||
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(GeolocationCoordinates);
|
||||||
|
Base::initialize(realm);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
41
Libraries/LibWeb/Geolocation/GeolocationCoordinates.h
Normal file
41
Libraries/LibWeb/Geolocation/GeolocationCoordinates.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
|
|
||||||
|
namespace Web::Geolocation {
|
||||||
|
|
||||||
|
// https://w3c.github.io/geolocation/#coordinates_interface
|
||||||
|
class GeolocationCoordinates : public Bindings::PlatformObject {
|
||||||
|
WEB_PLATFORM_OBJECT(GeolocationCoordinates, Bindings::PlatformObject);
|
||||||
|
GC_DECLARE_ALLOCATOR(GeolocationCoordinates);
|
||||||
|
|
||||||
|
public:
|
||||||
|
double accuracy() const { return m_accuracy; }
|
||||||
|
double latitude() const { return m_latitude; }
|
||||||
|
double longitude() const { return m_longitude; }
|
||||||
|
Optional<double> altitude() const { return m_altitude; }
|
||||||
|
Optional<double> altitude_accuracy() const { return m_altitude_accuracy; }
|
||||||
|
Optional<double> heading() const { return m_heading; }
|
||||||
|
Optional<double> speed() const { return m_speed; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
GeolocationCoordinates(JS::Realm&);
|
||||||
|
|
||||||
|
virtual void initialize(JS::Realm&) override;
|
||||||
|
|
||||||
|
double m_accuracy { 0.0 };
|
||||||
|
double m_latitude { 0.0 };
|
||||||
|
double m_longitude { 0.0 };
|
||||||
|
Optional<double> m_altitude;
|
||||||
|
Optional<double> m_altitude_accuracy;
|
||||||
|
Optional<double> m_heading;
|
||||||
|
Optional<double> m_speed;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
12
Libraries/LibWeb/Geolocation/GeolocationCoordinates.idl
Normal file
12
Libraries/LibWeb/Geolocation/GeolocationCoordinates.idl
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// https://w3c.github.io/geolocation/#coordinates_interface
|
||||||
|
[Exposed=Window, SecureContext]
|
||||||
|
interface GeolocationCoordinates {
|
||||||
|
readonly attribute double accuracy;
|
||||||
|
readonly attribute double latitude;
|
||||||
|
readonly attribute double longitude;
|
||||||
|
readonly attribute double? altitude;
|
||||||
|
readonly attribute double? altitudeAccuracy;
|
||||||
|
readonly attribute double? heading;
|
||||||
|
readonly attribute double? speed;
|
||||||
|
[Default] object toJSON();
|
||||||
|
};
|
34
Libraries/LibWeb/Geolocation/GeolocationPosition.cpp
Normal file
34
Libraries/LibWeb/Geolocation/GeolocationPosition.cpp
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/GeolocationPositionPrototype.h>
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
|
#include <LibWeb/Geolocation/GeolocationPosition.h>
|
||||||
|
|
||||||
|
namespace Web::Geolocation {
|
||||||
|
|
||||||
|
GC_DEFINE_ALLOCATOR(GeolocationPosition);
|
||||||
|
|
||||||
|
GeolocationPosition::GeolocationPosition(JS::Realm& realm, GC::Ref<GeolocationCoordinates> coords, HighResolutionTime::EpochTimeStamp timestamp)
|
||||||
|
: PlatformObject(realm)
|
||||||
|
, m_coords(coords)
|
||||||
|
, m_timestamp(timestamp)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void GeolocationPosition::initialize(JS::Realm& realm)
|
||||||
|
{
|
||||||
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(GeolocationPosition);
|
||||||
|
Base::initialize(realm);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GeolocationPosition::visit_edges(Visitor& visitor)
|
||||||
|
{
|
||||||
|
Base::visit_edges(visitor);
|
||||||
|
visitor.visit(m_coords);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
34
Libraries/LibWeb/Geolocation/GeolocationPosition.h
Normal file
34
Libraries/LibWeb/Geolocation/GeolocationPosition.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
|
#include <LibWeb/Geolocation/GeolocationCoordinates.h>
|
||||||
|
#include <LibWeb/HighResolutionTime/EpochTimeStamp.h>
|
||||||
|
|
||||||
|
namespace Web::Geolocation {
|
||||||
|
|
||||||
|
// https://w3c.github.io/geolocation/#dom-geolocationposition
|
||||||
|
class GeolocationPosition : public Bindings::PlatformObject {
|
||||||
|
WEB_PLATFORM_OBJECT(GeolocationPosition, Bindings::PlatformObject);
|
||||||
|
GC_DECLARE_ALLOCATOR(GeolocationPosition);
|
||||||
|
|
||||||
|
public:
|
||||||
|
GC::Ref<GeolocationCoordinates const> coords() const { return m_coords; }
|
||||||
|
HighResolutionTime::EpochTimeStamp timestamp() const { return m_timestamp; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
GeolocationPosition(JS::Realm&, GC::Ref<GeolocationCoordinates>, HighResolutionTime::EpochTimeStamp);
|
||||||
|
|
||||||
|
virtual void initialize(JS::Realm&) override;
|
||||||
|
virtual void visit_edges(Visitor&) override;
|
||||||
|
|
||||||
|
GC::Ref<GeolocationCoordinates const> m_coords;
|
||||||
|
HighResolutionTime::EpochTimeStamp m_timestamp;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
10
Libraries/LibWeb/Geolocation/GeolocationPosition.idl
Normal file
10
Libraries/LibWeb/Geolocation/GeolocationPosition.idl
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#import <Geolocation/GeolocationCoordinates.idl>
|
||||||
|
#import <HighResolutionTime/EpochTimeStamp.idl>
|
||||||
|
|
||||||
|
// https://w3c.github.io/geolocation/#position_interface
|
||||||
|
[Exposed=Window, SecureContext]
|
||||||
|
interface GeolocationPosition {
|
||||||
|
readonly attribute GeolocationCoordinates coords;
|
||||||
|
readonly attribute EpochTimeStamp timestamp;
|
||||||
|
[Default] object toJSON();
|
||||||
|
};
|
28
Libraries/LibWeb/Geolocation/GeolocationPositionError.cpp
Normal file
28
Libraries/LibWeb/Geolocation/GeolocationPositionError.cpp
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/GeolocationPositionErrorPrototype.h>
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
|
#include <LibWeb/Geolocation/GeolocationPositionError.h>
|
||||||
|
|
||||||
|
namespace Web::Geolocation {
|
||||||
|
|
||||||
|
GC_DEFINE_ALLOCATOR(GeolocationPositionError);
|
||||||
|
|
||||||
|
GeolocationPositionError::GeolocationPositionError(JS::Realm& realm, ErrorCode code, String message)
|
||||||
|
: PlatformObject(realm)
|
||||||
|
, m_code(code)
|
||||||
|
, m_message(move(message))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void GeolocationPositionError::initialize(JS::Realm& realm)
|
||||||
|
{
|
||||||
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(GeolocationPositionError);
|
||||||
|
Base::initialize(realm);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
38
Libraries/LibWeb/Geolocation/GeolocationPositionError.h
Normal file
38
Libraries/LibWeb/Geolocation/GeolocationPositionError.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
|
#include <LibWeb/WebIDL/Types.h>
|
||||||
|
|
||||||
|
namespace Web::Geolocation {
|
||||||
|
|
||||||
|
// https://w3c.github.io/geolocation/#dom-geolocationpositionerror
|
||||||
|
class GeolocationPositionError : public Bindings::PlatformObject {
|
||||||
|
WEB_PLATFORM_OBJECT(GeolocationPositionError, Bindings::PlatformObject);
|
||||||
|
GC_DECLARE_ALLOCATOR(GeolocationPositionError);
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum class ErrorCode : WebIDL::UnsignedShort {
|
||||||
|
PermissionDenied = 1,
|
||||||
|
PositionUnavailable = 2,
|
||||||
|
Timeout = 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
ErrorCode code() const { return m_code; }
|
||||||
|
String message() const { return m_message; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
GeolocationPositionError(JS::Realm&, ErrorCode, String);
|
||||||
|
|
||||||
|
virtual void initialize(JS::Realm&) override;
|
||||||
|
|
||||||
|
ErrorCode m_code { 0 };
|
||||||
|
String m_message;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
// https://w3c.github.io/geolocation/#dom-geolocationpositionerror
|
||||||
|
[Exposed=Window]
|
||||||
|
interface GeolocationPositionError {
|
||||||
|
const unsigned short PERMISSION_DENIED = 1;
|
||||||
|
const unsigned short POSITION_UNAVAILABLE = 2;
|
||||||
|
const unsigned short TIMEOUT = 3;
|
||||||
|
readonly attribute unsigned short code;
|
||||||
|
readonly attribute DOMString message;
|
||||||
|
};
|
|
@ -2,6 +2,7 @@
|
||||||
* Copyright (c) 2022, Andrew Kaster <akaster@serenityos.org>
|
* Copyright (c) 2022, Andrew Kaster <akaster@serenityos.org>
|
||||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||||
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
|
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
|
||||||
|
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -12,6 +13,7 @@
|
||||||
#include <LibWeb/Bindings/NavigatorPrototype.h>
|
#include <LibWeb/Bindings/NavigatorPrototype.h>
|
||||||
#include <LibWeb/Clipboard/Clipboard.h>
|
#include <LibWeb/Clipboard/Clipboard.h>
|
||||||
#include <LibWeb/CredentialManagement/CredentialsContainer.h>
|
#include <LibWeb/CredentialManagement/CredentialsContainer.h>
|
||||||
|
#include <LibWeb/Geolocation/Geolocation.h>
|
||||||
#include <LibWeb/HTML/Navigator.h>
|
#include <LibWeb/HTML/Navigator.h>
|
||||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
#include <LibWeb/HTML/Window.h>
|
||||||
|
@ -66,6 +68,7 @@ void Navigator::visit_edges(Cell::Visitor& visitor)
|
||||||
visitor.visit(m_mime_type_array);
|
visitor.visit(m_mime_type_array);
|
||||||
visitor.visit(m_plugin_array);
|
visitor.visit(m_plugin_array);
|
||||||
visitor.visit(m_clipboard);
|
visitor.visit(m_clipboard);
|
||||||
|
visitor.visit(m_geolocation);
|
||||||
visitor.visit(m_user_activation);
|
visitor.visit(m_user_activation);
|
||||||
visitor.visit(m_service_worker_container);
|
visitor.visit(m_service_worker_container);
|
||||||
visitor.visit(m_media_capabilities);
|
visitor.visit(m_media_capabilities);
|
||||||
|
@ -93,6 +96,13 @@ GC::Ref<Clipboard::Clipboard> Navigator::clipboard()
|
||||||
return *m_clipboard;
|
return *m_clipboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GC::Ref<Geolocation::Geolocation> Navigator::geolocation()
|
||||||
|
{
|
||||||
|
if (!m_geolocation)
|
||||||
|
m_geolocation = realm().create<Geolocation::Geolocation>(realm());
|
||||||
|
return *m_geolocation;
|
||||||
|
}
|
||||||
|
|
||||||
GC::Ref<UserActivation> Navigator::user_activation()
|
GC::Ref<UserActivation> Navigator::user_activation()
|
||||||
{
|
{
|
||||||
if (!m_user_activation)
|
if (!m_user_activation)
|
||||||
|
|
|
@ -53,6 +53,7 @@ public:
|
||||||
[[nodiscard]] GC::Ref<MimeTypeArray> mime_types();
|
[[nodiscard]] GC::Ref<MimeTypeArray> mime_types();
|
||||||
[[nodiscard]] GC::Ref<PluginArray> plugins();
|
[[nodiscard]] GC::Ref<PluginArray> plugins();
|
||||||
[[nodiscard]] GC::Ref<Clipboard::Clipboard> clipboard();
|
[[nodiscard]] GC::Ref<Clipboard::Clipboard> clipboard();
|
||||||
|
[[nodiscard]] GC::Ref<Geolocation::Geolocation> geolocation();
|
||||||
[[nodiscard]] GC::Ref<UserActivation> user_activation();
|
[[nodiscard]] GC::Ref<UserActivation> user_activation();
|
||||||
[[nodiscard]] GC::Ref<CredentialManagement::CredentialsContainer> credentials();
|
[[nodiscard]] GC::Ref<CredentialManagement::CredentialsContainer> credentials();
|
||||||
|
|
||||||
|
@ -83,6 +84,9 @@ private:
|
||||||
// https://w3c.github.io/clipboard-apis/#dom-navigator-clipboard
|
// https://w3c.github.io/clipboard-apis/#dom-navigator-clipboard
|
||||||
GC::Ptr<Clipboard::Clipboard> m_clipboard;
|
GC::Ptr<Clipboard::Clipboard> m_clipboard;
|
||||||
|
|
||||||
|
// https://w3c.github.io/geolocation/#navigator_interface
|
||||||
|
GC::Ptr<Geolocation::Geolocation> m_geolocation;
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-navigator-useractivation
|
// https://html.spec.whatwg.org/multipage/interaction.html#dom-navigator-useractivation
|
||||||
GC::Ptr<UserActivation> m_user_activation;
|
GC::Ptr<UserActivation> m_user_activation;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#import <Clipboard/Clipboard.idl>
|
#import <Clipboard/Clipboard.idl>
|
||||||
#import <CredentialManagement/CredentialsContainer.idl>
|
#import <CredentialManagement/CredentialsContainer.idl>
|
||||||
|
#import <Geolocation/Geolocation.idl>
|
||||||
#import <HTML/MimeTypeArray.idl>
|
#import <HTML/MimeTypeArray.idl>
|
||||||
#import <HTML/NavigatorBeacon.idl>
|
#import <HTML/NavigatorBeacon.idl>
|
||||||
#import <HTML/NavigatorConcurrentHardware.idl>
|
#import <HTML/NavigatorConcurrentHardware.idl>
|
||||||
|
@ -21,6 +22,9 @@ interface Navigator {
|
||||||
// https://w3c.github.io/clipboard-apis/#navigator-interface
|
// https://w3c.github.io/clipboard-apis/#navigator-interface
|
||||||
[SecureContext, SameObject] readonly attribute Clipboard clipboard;
|
[SecureContext, SameObject] readonly attribute Clipboard clipboard;
|
||||||
|
|
||||||
|
// https://w3c.github.io/geolocation/#navigator_interface
|
||||||
|
[SameObject] readonly attribute Geolocation geolocation;
|
||||||
|
|
||||||
// https://w3c.github.io/pointerevents/#extensions-to-the-navigator-interface
|
// https://w3c.github.io/pointerevents/#extensions-to-the-navigator-interface
|
||||||
readonly attribute long maxTouchPoints;
|
readonly attribute long maxTouchPoints;
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,10 @@ libweb_js_bindings(FileAPI/File)
|
||||||
libweb_js_bindings(FileAPI/FileList)
|
libweb_js_bindings(FileAPI/FileList)
|
||||||
libweb_js_bindings(FileAPI/FileReader)
|
libweb_js_bindings(FileAPI/FileReader)
|
||||||
libweb_js_bindings(FileAPI/FileReaderSync)
|
libweb_js_bindings(FileAPI/FileReaderSync)
|
||||||
|
libweb_js_bindings(Geolocation/Geolocation)
|
||||||
|
libweb_js_bindings(Geolocation/GeolocationCoordinates)
|
||||||
|
libweb_js_bindings(Geolocation/GeolocationPosition)
|
||||||
|
libweb_js_bindings(Geolocation/GeolocationPositionError)
|
||||||
libweb_js_bindings(Geometry/DOMMatrix)
|
libweb_js_bindings(Geometry/DOMMatrix)
|
||||||
libweb_js_bindings(Geometry/DOMMatrixReadOnly)
|
libweb_js_bindings(Geometry/DOMMatrixReadOnly)
|
||||||
libweb_js_bindings(Geometry/DOMPoint)
|
libweb_js_bindings(Geometry/DOMPoint)
|
||||||
|
|
|
@ -4724,6 +4724,7 @@ using namespace Web::EntriesAPI;
|
||||||
using namespace Web::EventTiming;
|
using namespace Web::EventTiming;
|
||||||
using namespace Web::Fetch;
|
using namespace Web::Fetch;
|
||||||
using namespace Web::FileAPI;
|
using namespace Web::FileAPI;
|
||||||
|
using namespace Web::Geolocation;
|
||||||
using namespace Web::Geometry;
|
using namespace Web::Geometry;
|
||||||
using namespace Web::HighResolutionTime;
|
using namespace Web::HighResolutionTime;
|
||||||
using namespace Web::HTML;
|
using namespace Web::HTML;
|
||||||
|
|
|
@ -23,6 +23,7 @@ static constexpr Array libweb_interface_namespaces = {
|
||||||
"Encoding"sv,
|
"Encoding"sv,
|
||||||
"Fetch"sv,
|
"Fetch"sv,
|
||||||
"FileAPI"sv,
|
"FileAPI"sv,
|
||||||
|
"Geolocation"sv,
|
||||||
"Geometry"sv,
|
"Geometry"sv,
|
||||||
"HTML"sv,
|
"HTML"sv,
|
||||||
"HighResolutionTime"sv,
|
"HighResolutionTime"sv,
|
||||||
|
|
|
@ -341,6 +341,7 @@ shared_library("LibWeb") {
|
||||||
"EventTiming",
|
"EventTiming",
|
||||||
"Fetch",
|
"Fetch",
|
||||||
"FileAPI",
|
"FileAPI",
|
||||||
|
"Geolocation",
|
||||||
"Geometry",
|
"Geometry",
|
||||||
"HTML",
|
"HTML",
|
||||||
"HighResolutionTime",
|
"HighResolutionTime",
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
source_set("Geolocation") {
|
||||||
|
configs += [ "//Userland/Libraries/LibWeb:configs" ]
|
||||||
|
deps = [ "//Userland/Libraries/LibWeb:all_generated" ]
|
||||||
|
sources = [
|
||||||
|
"Geolocation.cpp",
|
||||||
|
"GeolocationCoordinates.cpp",
|
||||||
|
"GeolocationPosition.cpp",
|
||||||
|
"GeolocationPositionError.cpp",
|
||||||
|
]
|
||||||
|
}
|
|
@ -105,6 +105,10 @@ standard_idl_files = [
|
||||||
"//Userland/Libraries/LibWeb/FileAPI/File.idl",
|
"//Userland/Libraries/LibWeb/FileAPI/File.idl",
|
||||||
"//Userland/Libraries/LibWeb/FileAPI/FileList.idl",
|
"//Userland/Libraries/LibWeb/FileAPI/FileList.idl",
|
||||||
"//Userland/Libraries/LibWeb/FileAPI/FileReader.idl",
|
"//Userland/Libraries/LibWeb/FileAPI/FileReader.idl",
|
||||||
|
"//Userland/Libraries/LibWeb/Geolocation/Geolocation.idl",
|
||||||
|
"//Userland/Libraries/LibWeb/Geolocation/GeolocationCoordinates.idl",
|
||||||
|
"//Userland/Libraries/LibWeb/Geolocation/GeolocationPosition.idl",
|
||||||
|
"//Userland/Libraries/LibWeb/Geolocation/GeolocationPositionError.idl",
|
||||||
"//Userland/Libraries/LibWeb/Geometry/DOMMatrix.idl",
|
"//Userland/Libraries/LibWeb/Geometry/DOMMatrix.idl",
|
||||||
"//Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.idl",
|
"//Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.idl",
|
||||||
"//Userland/Libraries/LibWeb/Geometry/DOMPoint.idl",
|
"//Userland/Libraries/LibWeb/Geometry/DOMPoint.idl",
|
||||||
|
|
|
@ -137,6 +137,10 @@ FormData
|
||||||
FormDataEvent
|
FormDataEvent
|
||||||
Function
|
Function
|
||||||
GainNode
|
GainNode
|
||||||
|
Geolocation
|
||||||
|
GeolocationCoordinates
|
||||||
|
GeolocationPosition
|
||||||
|
GeolocationPositionError
|
||||||
HTMLAllCollection
|
HTMLAllCollection
|
||||||
HTMLAnchorElement
|
HTMLAnchorElement
|
||||||
HTMLAreaElement
|
HTMLAreaElement
|
||||||
|
|
|
@ -2,8 +2,7 @@ Harness status: OK
|
||||||
|
|
||||||
Found 68 tests
|
Found 68 tests
|
||||||
|
|
||||||
13 Pass
|
68 Pass
|
||||||
55 Fail
|
|
||||||
Pass idl_test setup
|
Pass idl_test setup
|
||||||
Pass idl_test validation
|
Pass idl_test validation
|
||||||
Pass Partial interface Navigator: original interface defined
|
Pass Partial interface Navigator: original interface defined
|
||||||
|
@ -17,58 +16,58 @@ Pass Navigator includes NavigatorContentUtils: member names are unique
|
||||||
Pass Navigator includes NavigatorCookies: member names are unique
|
Pass Navigator includes NavigatorCookies: member names are unique
|
||||||
Pass Navigator includes NavigatorPlugins: member names are unique
|
Pass Navigator includes NavigatorPlugins: member names are unique
|
||||||
Pass Navigator includes NavigatorConcurrentHardware: member names are unique
|
Pass Navigator includes NavigatorConcurrentHardware: member names are unique
|
||||||
Fail Geolocation interface: existence and properties of interface object
|
Pass Geolocation interface: existence and properties of interface object
|
||||||
Fail Geolocation interface object length
|
Pass Geolocation interface object length
|
||||||
Fail Geolocation interface object name
|
Pass Geolocation interface object name
|
||||||
Fail Geolocation interface: existence and properties of interface prototype object
|
Pass Geolocation interface: existence and properties of interface prototype object
|
||||||
Fail Geolocation interface: existence and properties of interface prototype object's "constructor" property
|
Pass Geolocation interface: existence and properties of interface prototype object's "constructor" property
|
||||||
Fail Geolocation interface: existence and properties of interface prototype object's @@unscopables property
|
Pass Geolocation interface: existence and properties of interface prototype object's @@unscopables property
|
||||||
Fail Geolocation interface: operation getCurrentPosition(PositionCallback, optional PositionErrorCallback?, optional PositionOptions)
|
Pass Geolocation interface: operation getCurrentPosition(PositionCallback, optional PositionErrorCallback?, optional PositionOptions)
|
||||||
Fail Geolocation interface: operation watchPosition(PositionCallback, optional PositionErrorCallback?, optional PositionOptions)
|
Pass Geolocation interface: operation watchPosition(PositionCallback, optional PositionErrorCallback?, optional PositionOptions)
|
||||||
Fail Geolocation interface: operation clearWatch(long)
|
Pass Geolocation interface: operation clearWatch(long)
|
||||||
Fail Geolocation must be primary interface of navigator.geolocation
|
Pass Geolocation must be primary interface of navigator.geolocation
|
||||||
Fail Stringification of navigator.geolocation
|
Pass Stringification of navigator.geolocation
|
||||||
Fail Geolocation interface: navigator.geolocation must inherit property "getCurrentPosition(PositionCallback, optional PositionErrorCallback?, optional PositionOptions)" with the proper type
|
Pass Geolocation interface: navigator.geolocation must inherit property "getCurrentPosition(PositionCallback, optional PositionErrorCallback?, optional PositionOptions)" with the proper type
|
||||||
Fail Geolocation interface: calling getCurrentPosition(PositionCallback, optional PositionErrorCallback?, optional PositionOptions) on navigator.geolocation with too few arguments must throw TypeError
|
Pass Geolocation interface: calling getCurrentPosition(PositionCallback, optional PositionErrorCallback?, optional PositionOptions) on navigator.geolocation with too few arguments must throw TypeError
|
||||||
Fail Geolocation interface: navigator.geolocation must inherit property "watchPosition(PositionCallback, optional PositionErrorCallback?, optional PositionOptions)" with the proper type
|
Pass Geolocation interface: navigator.geolocation must inherit property "watchPosition(PositionCallback, optional PositionErrorCallback?, optional PositionOptions)" with the proper type
|
||||||
Fail Geolocation interface: calling watchPosition(PositionCallback, optional PositionErrorCallback?, optional PositionOptions) on navigator.geolocation with too few arguments must throw TypeError
|
Pass Geolocation interface: calling watchPosition(PositionCallback, optional PositionErrorCallback?, optional PositionOptions) on navigator.geolocation with too few arguments must throw TypeError
|
||||||
Fail Geolocation interface: navigator.geolocation must inherit property "clearWatch(long)" with the proper type
|
Pass Geolocation interface: navigator.geolocation must inherit property "clearWatch(long)" with the proper type
|
||||||
Fail Geolocation interface: calling clearWatch(long) on navigator.geolocation with too few arguments must throw TypeError
|
Pass Geolocation interface: calling clearWatch(long) on navigator.geolocation with too few arguments must throw TypeError
|
||||||
Fail GeolocationPosition interface: existence and properties of interface object
|
Pass GeolocationPosition interface: existence and properties of interface object
|
||||||
Fail GeolocationPosition interface object length
|
Pass GeolocationPosition interface object length
|
||||||
Fail GeolocationPosition interface object name
|
Pass GeolocationPosition interface object name
|
||||||
Fail GeolocationPosition interface: existence and properties of interface prototype object
|
Pass GeolocationPosition interface: existence and properties of interface prototype object
|
||||||
Fail GeolocationPosition interface: existence and properties of interface prototype object's "constructor" property
|
Pass GeolocationPosition interface: existence and properties of interface prototype object's "constructor" property
|
||||||
Fail GeolocationPosition interface: existence and properties of interface prototype object's @@unscopables property
|
Pass GeolocationPosition interface: existence and properties of interface prototype object's @@unscopables property
|
||||||
Fail GeolocationPosition interface: attribute coords
|
Pass GeolocationPosition interface: attribute coords
|
||||||
Fail GeolocationPosition interface: attribute timestamp
|
Pass GeolocationPosition interface: attribute timestamp
|
||||||
Fail GeolocationPosition interface: operation toJSON()
|
Pass GeolocationPosition interface: operation toJSON()
|
||||||
Fail GeolocationCoordinates interface: existence and properties of interface object
|
Pass GeolocationCoordinates interface: existence and properties of interface object
|
||||||
Fail GeolocationCoordinates interface object length
|
Pass GeolocationCoordinates interface object length
|
||||||
Fail GeolocationCoordinates interface object name
|
Pass GeolocationCoordinates interface object name
|
||||||
Fail GeolocationCoordinates interface: existence and properties of interface prototype object
|
Pass GeolocationCoordinates interface: existence and properties of interface prototype object
|
||||||
Fail GeolocationCoordinates interface: existence and properties of interface prototype object's "constructor" property
|
Pass GeolocationCoordinates interface: existence and properties of interface prototype object's "constructor" property
|
||||||
Fail GeolocationCoordinates interface: existence and properties of interface prototype object's @@unscopables property
|
Pass GeolocationCoordinates interface: existence and properties of interface prototype object's @@unscopables property
|
||||||
Fail GeolocationCoordinates interface: attribute accuracy
|
Pass GeolocationCoordinates interface: attribute accuracy
|
||||||
Fail GeolocationCoordinates interface: attribute latitude
|
Pass GeolocationCoordinates interface: attribute latitude
|
||||||
Fail GeolocationCoordinates interface: attribute longitude
|
Pass GeolocationCoordinates interface: attribute longitude
|
||||||
Fail GeolocationCoordinates interface: attribute altitude
|
Pass GeolocationCoordinates interface: attribute altitude
|
||||||
Fail GeolocationCoordinates interface: attribute altitudeAccuracy
|
Pass GeolocationCoordinates interface: attribute altitudeAccuracy
|
||||||
Fail GeolocationCoordinates interface: attribute heading
|
Pass GeolocationCoordinates interface: attribute heading
|
||||||
Fail GeolocationCoordinates interface: attribute speed
|
Pass GeolocationCoordinates interface: attribute speed
|
||||||
Fail GeolocationCoordinates interface: operation toJSON()
|
Pass GeolocationCoordinates interface: operation toJSON()
|
||||||
Fail GeolocationPositionError interface: existence and properties of interface object
|
Pass GeolocationPositionError interface: existence and properties of interface object
|
||||||
Fail GeolocationPositionError interface object length
|
Pass GeolocationPositionError interface object length
|
||||||
Fail GeolocationPositionError interface object name
|
Pass GeolocationPositionError interface object name
|
||||||
Fail GeolocationPositionError interface: existence and properties of interface prototype object
|
Pass GeolocationPositionError interface: existence and properties of interface prototype object
|
||||||
Fail GeolocationPositionError interface: existence and properties of interface prototype object's "constructor" property
|
Pass GeolocationPositionError interface: existence and properties of interface prototype object's "constructor" property
|
||||||
Fail GeolocationPositionError interface: existence and properties of interface prototype object's @@unscopables property
|
Pass GeolocationPositionError interface: existence and properties of interface prototype object's @@unscopables property
|
||||||
Fail GeolocationPositionError interface: constant PERMISSION_DENIED on interface object
|
Pass GeolocationPositionError interface: constant PERMISSION_DENIED on interface object
|
||||||
Fail GeolocationPositionError interface: constant PERMISSION_DENIED on interface prototype object
|
Pass GeolocationPositionError interface: constant PERMISSION_DENIED on interface prototype object
|
||||||
Fail GeolocationPositionError interface: constant POSITION_UNAVAILABLE on interface object
|
Pass GeolocationPositionError interface: constant POSITION_UNAVAILABLE on interface object
|
||||||
Fail GeolocationPositionError interface: constant POSITION_UNAVAILABLE on interface prototype object
|
Pass GeolocationPositionError interface: constant POSITION_UNAVAILABLE on interface prototype object
|
||||||
Fail GeolocationPositionError interface: constant TIMEOUT on interface object
|
Pass GeolocationPositionError interface: constant TIMEOUT on interface object
|
||||||
Fail GeolocationPositionError interface: constant TIMEOUT on interface prototype object
|
Pass GeolocationPositionError interface: constant TIMEOUT on interface prototype object
|
||||||
Fail GeolocationPositionError interface: attribute code
|
Pass GeolocationPositionError interface: attribute code
|
||||||
Fail GeolocationPositionError interface: attribute message
|
Pass GeolocationPositionError interface: attribute message
|
||||||
Fail Navigator interface: attribute geolocation
|
Pass Navigator interface: attribute geolocation
|
Loading…
Add table
Add a link
Reference in a new issue