mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-07 00:19:27 +00:00
LibWeb: Add stub for IDBFactory
This commit is contained in:
parent
74aeb57631
commit
8d5665ebe1
|
@ -3764,6 +3764,7 @@ static void generate_using_namespace_definitions(SourceGenerator& generator)
|
|||
using namespace Web::Geometry;
|
||||
using namespace Web::HighResolutionTime;
|
||||
using namespace Web::HTML;
|
||||
using namespace Web::IndexedDB;
|
||||
using namespace Web::Internals;
|
||||
using namespace Web::IntersectionObserver;
|
||||
using namespace Web::RequestIdleCallback;
|
||||
|
|
|
@ -447,6 +447,7 @@ set(SOURCES
|
|||
Infra/ByteSequences.cpp
|
||||
Infra/JSON.cpp
|
||||
Infra/Strings.cpp
|
||||
IndexedDB/IDBFactory.cpp
|
||||
Internals/Inspector.cpp
|
||||
Internals/InternalAnimationTimeline.cpp
|
||||
Internals/Internals.cpp
|
||||
|
|
|
@ -498,6 +498,10 @@ namespace Web::HighResolutionTime {
|
|||
class Performance;
|
||||
}
|
||||
|
||||
namespace Web::IndexedDB {
|
||||
class IDBFactory;
|
||||
}
|
||||
|
||||
namespace Web::Internals {
|
||||
class Inspector;
|
||||
class Internals;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include <LibTextCodec/Decoder.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/Fetch/FetchMethod.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/HTML/CanvasRenderingContext2D.h>
|
||||
#include <LibWeb/HTML/EventLoop/EventLoop.h>
|
||||
#include <LibWeb/HTML/ImageBitmap.h>
|
||||
|
@ -30,6 +29,7 @@
|
|||
#include <LibWeb/HTML/WindowOrWorkerGlobalScope.h>
|
||||
#include <LibWeb/HighResolutionTime/Performance.h>
|
||||
#include <LibWeb/HighResolutionTime/SupportedPerformanceTypes.h>
|
||||
#include <LibWeb/IndexedDB/IDBFactory.h>
|
||||
#include <LibWeb/Infra/Base64.h>
|
||||
#include <LibWeb/PerformanceTimeline/EntryTypes.h>
|
||||
#include <LibWeb/PerformanceTimeline/PerformanceObserver.h>
|
||||
|
@ -67,6 +67,7 @@ void WindowOrWorkerGlobalScopeMixin::visit_edges(JS::Cell::Visitor& visitor)
|
|||
visitor.visit(m_supported_entry_types_array);
|
||||
visitor.visit(m_timers);
|
||||
visitor.visit(m_registered_performance_observer_objects);
|
||||
visitor.visit(m_indexed_db);
|
||||
for (auto& entry : m_performance_entry_buffer_map)
|
||||
entry.value.visit_edges(visitor);
|
||||
}
|
||||
|
@ -689,6 +690,16 @@ JS::NonnullGCPtr<HighResolutionTime::Performance> WindowOrWorkerGlobalScopeMixin
|
|||
return JS::NonnullGCPtr { *m_performance };
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<IndexedDB::IDBFactory> WindowOrWorkerGlobalScopeMixin::indexed_db()
|
||||
{
|
||||
auto& vm = this_impl().vm();
|
||||
auto& realm = this_impl().realm();
|
||||
|
||||
if (!m_indexed_db)
|
||||
m_indexed_db = vm.heap().allocate<IndexedDB::IDBFactory>(realm, realm);
|
||||
return *m_indexed_db;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/performance-timeline/#dfn-frozen-array-of-supported-entry-types
|
||||
JS::NonnullGCPtr<JS::Object> WindowOrWorkerGlobalScopeMixin::supported_entry_types() const
|
||||
{
|
||||
|
|
|
@ -70,6 +70,8 @@ public:
|
|||
|
||||
JS::NonnullGCPtr<JS::Object> supported_entry_types() const;
|
||||
|
||||
JS::NonnullGCPtr<IndexedDB::IDBFactory> indexed_db();
|
||||
|
||||
protected:
|
||||
void initialize(JS::Realm&);
|
||||
void visit_edges(JS::Cell::Visitor&);
|
||||
|
@ -103,6 +105,8 @@ private:
|
|||
|
||||
JS::GCPtr<HighResolutionTime::Performance> m_performance;
|
||||
|
||||
JS::GCPtr<IndexedDB::IDBFactory> m_indexed_db;
|
||||
|
||||
mutable JS::GCPtr<JS::Object> m_supported_entry_types_array;
|
||||
};
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#import <HighResolutionTime/Performance.idl>
|
||||
#import <HTML/ImageBitmap.idl>
|
||||
#import <HTML/MessagePort.idl>
|
||||
#import <IndexedDB/IDBFactory.idl>
|
||||
|
||||
// FIXME: Support VoidFunction in the IDL parser
|
||||
callback VoidFunction = undefined ();
|
||||
|
@ -43,4 +44,7 @@ interface mixin WindowOrWorkerGlobalScope {
|
|||
|
||||
// https://w3c.github.io/hr-time/#the-performance-attribute
|
||||
[Replaceable] readonly attribute Performance performance;
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#factory-interface
|
||||
[SameObject] readonly attribute IDBFactory indexedDB;
|
||||
};
|
||||
|
|
28
Userland/Libraries/LibWeb/IndexedDB/IDBFactory.cpp
Normal file
28
Userland/Libraries/LibWeb/IndexedDB/IDBFactory.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/IDBFactoryPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/IndexedDB/IDBFactory.h>
|
||||
|
||||
namespace Web::IndexedDB {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(IDBFactory);
|
||||
|
||||
IDBFactory::IDBFactory(JS::Realm& realm)
|
||||
: Bindings::PlatformObject(realm)
|
||||
{
|
||||
}
|
||||
|
||||
IDBFactory::~IDBFactory() = default;
|
||||
|
||||
void IDBFactory::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(IDBFactory);
|
||||
}
|
||||
|
||||
}
|
27
Userland/Libraries/LibWeb/IndexedDB/IDBFactory.h
Normal file
27
Userland/Libraries/LibWeb/IndexedDB/IDBFactory.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
|
||||
namespace Web::IndexedDB {
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#idbfactory
|
||||
class IDBFactory : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(IDBFactory, Bindings::PlatformObject);
|
||||
JS_DECLARE_ALLOCATOR(IDBFactory);
|
||||
|
||||
public:
|
||||
virtual ~IDBFactory() override;
|
||||
|
||||
protected:
|
||||
explicit IDBFactory(JS::Realm&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
}
|
16
Userland/Libraries/LibWeb/IndexedDB/IDBFactory.idl
Normal file
16
Userland/Libraries/LibWeb/IndexedDB/IDBFactory.idl
Normal file
|
@ -0,0 +1,16 @@
|
|||
// https://w3c.github.io/IndexedDB/#idbfactory
|
||||
[Exposed=(Window,Worker)]
|
||||
interface IDBFactory {
|
||||
// FIXME: [NewObject] IDBOpenDBRequest open(DOMString name,
|
||||
// optional [EnforceRange] unsigned long long version);
|
||||
// FIXME: [NewObject] IDBOpenDBRequest deleteDatabase(DOMString name);
|
||||
|
||||
// FIXME: Promise<sequence<IDBDatabaseInfo>> databases();
|
||||
|
||||
// FIXME: short cmp(any first, any second);
|
||||
};
|
||||
|
||||
dictionary IDBDatabaseInfo {
|
||||
DOMString name;
|
||||
unsigned long long version;
|
||||
};
|
|
@ -216,6 +216,7 @@ libweb_js_bindings(HTML/WorkerGlobalScope)
|
|||
libweb_js_bindings(HTML/WorkerLocation)
|
||||
libweb_js_bindings(HTML/WorkerNavigator)
|
||||
libweb_js_bindings(HighResolutionTime/Performance)
|
||||
libweb_js_bindings(IndexedDB/IDBFactory)
|
||||
libweb_js_bindings(Internals/Inspector)
|
||||
libweb_js_bindings(Internals/InternalAnimationTimeline)
|
||||
libweb_js_bindings(Internals/Internals)
|
||||
|
|
Loading…
Reference in a new issue