diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index c4d17d65352..6370eb026b9 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -4163,6 +4163,7 @@ static void generate_using_namespace_definitions(SourceGenerator& generator) using namespace Web::NavigationTiming; using namespace Web::PerformanceTimeline; using namespace Web::UserTiming; + using namespace Web::StorageAPI; using namespace Web::Streams; using namespace Web::SVG; using namespace Web::UIEvents; diff --git a/Meta/gn/secondary/Userland/Libraries/LibWeb/StorageAPI/BUILD.gn b/Meta/gn/secondary/Userland/Libraries/LibWeb/StorageAPI/BUILD.gn new file mode 100644 index 00000000000..e517dccf086 --- /dev/null +++ b/Meta/gn/secondary/Userland/Libraries/LibWeb/StorageAPI/BUILD.gn @@ -0,0 +1,5 @@ +source_set("StorageAPI") { + configs += [ "//Userland/Libraries/LibWeb:configs" ] + deps = [ "//Userland/Libraries/LibWeb:all_generated" ] + sources = [ "StorageManager.cpp" ] +} diff --git a/Meta/gn/secondary/Userland/Libraries/LibWeb/idl_files.gni b/Meta/gn/secondary/Userland/Libraries/LibWeb/idl_files.gni index f9b4b5fc4b8..a609573c978 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibWeb/idl_files.gni +++ b/Meta/gn/secondary/Userland/Libraries/LibWeb/idl_files.gni @@ -256,6 +256,7 @@ standard_idl_files = [ "//Userland/Libraries/LibWeb/ResizeObserver/ResizeObserverEntry.idl", "//Userland/Libraries/LibWeb/ResizeObserver/ResizeObserverSize.idl", "//Userland/Libraries/LibWeb/Selection/Selection.idl", + "//Userland/Libraries/LibWeb/StorageAPI/StorageManager.idl", "//Userland/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.idl", "//Userland/Libraries/LibWeb/Streams/CountQueuingStrategy.idl", "//Userland/Libraries/LibWeb/Streams/ReadableByteStreamController.idl", diff --git a/Tests/LibWeb/Text/expected/all-window-properties.txt b/Tests/LibWeb/Text/expected/all-window-properties.txt index 1521f134eae..834b2f2bf3e 100644 --- a/Tests/LibWeb/Text/expected/all-window-properties.txt +++ b/Tests/LibWeb/Text/expected/all-window-properties.txt @@ -317,6 +317,7 @@ ShadowRoot SharedArrayBuffer StaticRange Storage +StorageManager String StyleSheet StyleSheetList diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 81e838a11fc..ffac28c2935 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -609,6 +609,7 @@ set(SOURCES ResizeObserver/ResizeObserverSize.cpp SecureContexts/AbstractOperations.cpp SRI/SRI.cpp + StorageAPI/StorageManager.cpp Streams/AbstractOperations.cpp Streams/ByteLengthQueuingStrategy.cpp Streams/CountQueuingStrategy.cpp diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index 1404cad5add..d8c5768207e 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -662,6 +662,10 @@ struct UnderlyingSink; struct UnderlyingSource; } +namespace Web::StorageAPI { +class StorageManager; +} + namespace Web::SVG { class SVGAnimatedLength; class SVGAnimatedRect; diff --git a/Userland/Libraries/LibWeb/StorageAPI/StorageManager.cpp b/Userland/Libraries/LibWeb/StorageAPI/StorageManager.cpp new file mode 100644 index 00000000000..943500559a7 --- /dev/null +++ b/Userland/Libraries/LibWeb/StorageAPI/StorageManager.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024, Jamie Mansfield + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include +#include +#include + +namespace Web::StorageAPI { + +JS_DEFINE_ALLOCATOR(StorageManager); + +WebIDL::ExceptionOr> StorageManager::create(JS::Realm& realm) +{ + return realm.heap().allocate(realm, realm); +} + +StorageManager::StorageManager(JS::Realm& realm) + : PlatformObject(realm) +{ +} + +void StorageManager::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + WEB_SET_PROTOTYPE_FOR_INTERFACE(StorageManager); +} + +} diff --git a/Userland/Libraries/LibWeb/StorageAPI/StorageManager.h b/Userland/Libraries/LibWeb/StorageAPI/StorageManager.h new file mode 100644 index 00000000000..a2156451242 --- /dev/null +++ b/Userland/Libraries/LibWeb/StorageAPI/StorageManager.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024, Jamie Mansfield + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +namespace Web::StorageAPI { + +class StorageManager final : public Bindings::PlatformObject { + WEB_PLATFORM_OBJECT(StorageManager, Bindings::PlatformObject); + JS_DECLARE_ALLOCATOR(StorageManager); + +public: + static WebIDL::ExceptionOr> create(JS::Realm&); + virtual ~StorageManager() override = default; + +private: + StorageManager(JS::Realm&); + + virtual void initialize(JS::Realm&) override; +}; + +} diff --git a/Userland/Libraries/LibWeb/StorageAPI/StorageManager.idl b/Userland/Libraries/LibWeb/StorageAPI/StorageManager.idl new file mode 100644 index 00000000000..c20b36e48c7 --- /dev/null +++ b/Userland/Libraries/LibWeb/StorageAPI/StorageManager.idl @@ -0,0 +1,14 @@ +// https://storage.spec.whatwg.org/#storagemanager +[SecureContext, Exposed=(Window,Worker)] +interface StorageManager { + [FIXME] Promise persisted(); + [FIXME, Exposed=Window] Promise persist(); + + [FIXME] Promise estimate(); +}; + +// https://storage.spec.whatwg.org/#dictdef-storageestimate +dictionary StorageEstimate { + unsigned long long usage; + unsigned long long quota; +}; diff --git a/Userland/Libraries/LibWeb/idl_files.cmake b/Userland/Libraries/LibWeb/idl_files.cmake index 14714cd140c..ef5b3b1174e 100644 --- a/Userland/Libraries/LibWeb/idl_files.cmake +++ b/Userland/Libraries/LibWeb/idl_files.cmake @@ -298,6 +298,7 @@ libweb_js_bindings(SVG/SVGTransformList) libweb_js_bindings(SVG/SVGTSpanElement) libweb_js_bindings(SVG/SVGUseElement) libweb_js_bindings(Selection/Selection) +libweb_js_bindings(StorageAPI/StorageManager) libweb_js_bindings(UIEvents/FocusEvent) libweb_js_bindings(UIEvents/KeyboardEvent) libweb_js_bindings(UIEvents/MouseEvent)