mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-11 09:27:00 +02:00
Previously we were inconsistent by generating code for enum definitions but not generating code for dictionaries. With future changes to the IDL generator to expose helpers to convert to and from IDL values this produced circular depdendencies. To solve this problem, also generate the dictionary definitions in bindings headers.
62 lines
1.8 KiB
C++
62 lines
1.8 KiB
C++
/*
|
|
* Copyright (c) 2025, Psychpsyo <psychpsyo@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
|
#include <LibWeb/Bindings/XRTest.h>
|
|
#include <LibWeb/Internals/FakeXRDevice.h>
|
|
#include <LibWeb/Internals/XRTest.h>
|
|
#include <LibWeb/WebIDL/AbstractOperations.h>
|
|
#include <LibWeb/WebIDL/Promise.h>
|
|
|
|
namespace Web::Internals {
|
|
|
|
GC_DEFINE_ALLOCATOR(XRTest);
|
|
|
|
XRTest::XRTest(JS::Realm& realm)
|
|
: InternalsBase(realm)
|
|
{
|
|
}
|
|
|
|
XRTest::~XRTest() = default;
|
|
|
|
void XRTest::initialize(JS::Realm& realm)
|
|
{
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(XRTest);
|
|
Base::initialize(realm);
|
|
}
|
|
|
|
GC::Ref<WebIDL::Promise> XRTest::simulate_device_connection(Bindings::FakeXRDeviceInit const&) const
|
|
{
|
|
// Simulates connecting a device to the system.
|
|
// Used to instantiate a fake device for use in tests.
|
|
// FIXME: Actually perform whatever device connection steps are needed once those are implemented.
|
|
auto& realm = HTML::relevant_realm(*this);
|
|
auto promise = WebIDL::create_promise(realm);
|
|
WebIDL::resolve_promise(realm, promise, FakeXRDevice::create(realm));
|
|
return promise;
|
|
}
|
|
|
|
void XRTest::simulate_user_activation(GC::Ref<WebIDL::CallbackType> function) const
|
|
{
|
|
// Simulates a user activation (aka user gesture) for the current scope.
|
|
// The activation is only guaranteed to be valid in the provided function and only applies to WebXR
|
|
// Device API methods.
|
|
// FIXME: Actually simulate a user activation here
|
|
(void)WebIDL::invoke_callback(*function, {}, {});
|
|
}
|
|
|
|
GC::Ref<WebIDL::Promise> XRTest::disconnect_all_devices() const
|
|
{
|
|
// Disconnect all fake devices
|
|
// FIXME: Actually disconnect fake devices once we have any.
|
|
auto& realm = HTML::relevant_realm(*this);
|
|
auto promise = WebIDL::create_promise(realm);
|
|
WebIDL::resolve_promise(realm, promise);
|
|
return promise;
|
|
}
|
|
|
|
}
|