Skip to content

Truly independent web browser

LibWeb: Implement StorageManager in Rust

Shannon Booth3e99a71b34bf
diff --git a/Libraries/LibWeb/Bindings/Rust/src/bindings/environment_settings_object.rs b/Libraries/LibWeb/Bindings/Rust/src/bindings/environment_settings_object.rs
new file mode 100644
index 00000000000..80cd4744bf4
--- /dev/null
+++ b/Libraries/LibWeb/Bindings/Rust/src/bindings/environment_settings_object.rs
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+//! Handles to the C++ environment settings objects.
+
+use core::ffi::c_void;
+
+use libjs_rust::api::{Gc, Object, Trace};
+
+use crate::bindings::cpp_cell::CppCell;
+
+unsafe extern "C" {
+ fn web_bindings_relevant_settings_object(global_object: *mut c_void) -> *mut c_void;
+}
+
+/// https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object
+#[derive(Clone, Trace)]
+#[gc(crate = libjs_rust)]
+pub(crate) struct CppEnvironmentSettingsObject(CppCell);
+
+/// https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object
+pub(crate) fn relevant_settings_object(global_object: Gc<Object>) -> CppEnvironmentSettingsObject {
+ // SAFETY: The global object is live, and LibWeb returns its live environment settings object.
+ CppEnvironmentSettingsObject(unsafe {
+ CppCell::from_raw(web_bindings_relevant_settings_object(global_object.as_ptr().cast()))
+ })
+}
+
+impl CppEnvironmentSettingsObject {
+ pub(crate) fn as_ptr(&self) -> *mut c_void {
+ self.0.as_ptr()
+ }
+}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/bindings/mod.rs b/Libraries/LibWeb/Bindings/Rust/src/bindings/mod.rs
index c06a903a22b..ec6cc7b2b5c 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/bindings/mod.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/bindings/mod.rs
@@ -22,6 +22,7 @@ pub(crate) mod async_iterable;
pub(crate) mod callback;
pub(crate) mod conversions;
pub(crate) mod cpp_cell;
+pub(crate) mod environment_settings_object;
pub(crate) mod event_target;
#[cfg(web_idl_bindings)]
pub(crate) mod generated;
diff --git a/Libraries/LibWeb/Bindings/Rust/src/bindings/promise.rs b/Libraries/LibWeb/Bindings/Rust/src/bindings/promise.rs
index f2a1cb0b954..f77ab9fefa7 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/bindings/promise.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/bindings/promise.rs
@@ -72,6 +72,7 @@ pub(crate) enum TaskSource {
PostedMessage = 6,
FileReading = 13,
FontLoading = 19,
+ Storage = 29,
}
// SAFETY: A task source holds no cells.
diff --git a/Libraries/LibWeb/Bindings/Rust/src/lib.rs b/Libraries/LibWeb/Bindings/Rust/src/lib.rs
index fd1efdc3008..5b4a7feaa82 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/lib.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/lib.rs
@@ -132,6 +132,14 @@ pub(crate) mod notifications_api;
)]
pub(crate) mod speech;
#[cfg(not(test))]
+#[cfg_attr(
+ not(web_idl_bindings),
+ allow(dead_code, reason = "only the generated bindings use the interfaces")
+)]
+#[allow(
+ clippy::unnecessary_wraps,
+ reason = "the bindings call every attribute and operation as one that can throw"
+)]
pub(crate) mod storage_api;
#[cfg_attr(
not(web_idl_bindings),
diff --git a/Libraries/LibWeb/Bindings/Rust/src/storage_api/exports.rs b/Libraries/LibWeb/Bindings/Rust/src/storage_api/exports.rs
new file mode 100644
index 00000000000..54edd70c4a1
--- /dev/null
+++ b/Libraries/LibWeb/Bindings/Rust/src/storage_api/exports.rs
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+//! The C ABI of the Storage Standard's interfaces implemented in Rust, which LibWeb's C++ code calls.
+
+use core::ffi::c_void;
+
+use super::storage_manager::StorageManager;
+use crate::bindings::interface::{cell_into_abi, realm_arguments};
+
+/// A new StorageManager in the realm, the StorageManager object of the realm's settings object.
+///
+/// # Safety
+///
+/// The pointers must be the live VM and a live realm.
+#[unsafe(no_mangle)]
+pub unsafe extern "C" fn web_rust_storage_api_create_storage_manager(
+ vm: *mut c_void,
+ realm: *mut c_void,
+) -> *mut c_void {
+ // SAFETY: The caller passes the live VM and a live realm.
+ let (vm, realm) = unsafe { realm_arguments(vm, realm) };
+ cell_into_abi(StorageManager::create(vm, realm))
+}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/storage_api/mod.rs b/Libraries/LibWeb/Bindings/Rust/src/storage_api/mod.rs
index f3b52eaae1b..0be87b6bbc0 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/storage_api/mod.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/storage_api/mod.rs
@@ -6,5 +6,8 @@
//! The Storage Standard, https://storage.spec.whatwg.org/
+pub(crate) mod exports;
pub(crate) mod storage_bottle;
pub(crate) mod storage_key;
+pub(crate) mod storage_manager;
+pub(crate) mod storage_shelf;
diff --git a/Libraries/LibWeb/Bindings/Rust/src/storage_api/storage_manager.rs b/Libraries/LibWeb/Bindings/Rust/src/storage_api/storage_manager.rs
new file mode 100644
index 00000000000..ab6cf5e77de
--- /dev/null
+++ b/Libraries/LibWeb/Bindings/Rust/src/storage_api/storage_manager.rs
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2024, Jamie Mansfield <[email protected]>
+ * Copyright (c) 2026, Tim Ledbetter <[email protected]>
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+//! StorageManager, https://storage.spec.whatwg.org/#storagemanager
+
+use libjs_rust::api::{Gc, Object, PropertyKey, Realm, Trace, Value, Vm};
+
+use crate::bindings::conversions::ToJs;
+use crate::bindings::environment_settings_object::relevant_settings_object;
+use crate::bindings::global_object::relevant_global_object;
+use crate::bindings::interface::{
+ Ref, Wrappable, allocate, create_dictionary_object, set_dictionary_member,
+ with_temporary_execution_context_and_callbacks,
+};
+use crate::bindings::promise::{
+ TaskSource, WebIdlPromise, create_promise, in_parallel, promise_realm, queue_a_global_task,
+ reject_promise_with_exception, resolve_promise,
+};
+use crate::bindings::{CallContext, Exception, WebIdlResult};
+use crate::storage_api::storage_shelf::obtain_a_local_storage_shelf;
+
+/// The dictionary StorageEstimate of StorageAPI/StorageManager.idl.
+pub(crate) struct StorageEstimate {
+ pub(crate) usage: Option<u64>,
+ pub(crate) quota: Option<u64>,
+}
+
+// https://storage.spec.whatwg.org/#storagemanager
+#[derive(Trace)]
+#[gc(crate = libjs_rust)]
+pub(crate) struct StorageManager {
+ realm: Gc<Realm>,
+}
+
+impl Wrappable for StorageManager {
+ fn relevant_realm(&self) -> Option<Gc<Realm>> {
+ Some(self.realm)
+ }
+}
+
+/// https://storage.spec.whatwg.org/#queue-a-storage-task
+fn queue_a_storage_task<C: Trace + Copy + 'static>(vm: &Vm, global: Gc<Object>, captures: C, steps: fn(&Vm, C)) {
+ // To queue a storage task given a global object global and a series of steps steps, queue a global task on the
+ // storage task source with global and steps.
+ queue_a_global_task(vm, global, TaskSource::Storage, captures, steps);
+}
+
+impl StorageManager {
+ pub(crate) fn create(vm: &Vm, realm: Gc<Realm>) -> Ref<StorageManager> {
+ allocate(vm, |_| StorageManager { realm })
+ }
+
+ // https://storage.spec.whatwg.org/#dom-storagemanager-estimate
+ pub(crate) fn estimate(&self, cx: &mut CallContext) -> WebIdlResult<WebIdlPromise> {
+ let vm = cx.vm();
+
+ // 1. Let promise be a new promise.
+ let promise = create_promise(vm, self.realm);
+
+ // 2. Let global be this's relevant global object.
+ let global = relevant_global_object(self);
+
+ // 3. Let shelf be the result of running obtain a local storage shelf with this's relevant settings object.
+ let shelf = obtain_a_local_storage_shelf(vm, &relevant_settings_object(global));
+
+ // 4. If shelf is failure, then reject promise with a TypeError.
+ let Some(shelf) = shelf else {
+ reject_promise_with_exception(
+ vm,
+ promise,
+ Exception::type_error("Failed to obtain local storage shelf."),
+ );
+ return Ok(promise);
+ };
+
+ // 5. Otherwise, run these steps in parallel:
+ in_parallel(
+ vm,
+ self.realm,
+ (promise, global, shelf),
+ |vm, (promise, global, shelf)| {
+ // 1. Let usage be storage usage for shelf.
+ let usage = shelf.storage_usage();
+
+ // 2. Let quota be storage quota for shelf.
+ let quota = shelf.storage_quota();
+
+ // 3. Let dictionary be a new StorageEstimate dictionary whose usage member is usage and quota member is quota.
+ // 4. If there was an internal error while obtaining usage and quota, then queue a storage task with global to
+ // reject promise with a TypeError.
+ // 5. Otherwise, queue a storage task with global to resolve promise with dictionary.
+ queue_a_storage_task(vm, global, (promise, usage, quota), |vm, (promise, usage, quota)| {
+ let realm = promise_realm(promise);
+ with_temporary_execution_context_and_callbacks(realm, || {
+ let dictionary = StorageEstimate {
+ usage: Some(usage),
+ quota: Some(quota),
+ };
+ resolve_promise(
+ vm,
+ promise,
+ storage_estimate_to_js(&CallContext::new(vm, realm), dictionary),
+ );
+ });
+ });
+ },
+ );
+
+ // 6. Return promise.
+ Ok(promise)
+ }
+}
+
+// NB: The generated conversion of StorageEstimate is only built with the bindings, so the dictionary is converted here.
+fn storage_estimate_to_js(cx: &CallContext, dictionary: StorageEstimate) -> Value {
+ let object = create_dictionary_object(cx);
+ let members = [("usage", dictionary.usage), ("quota", dictionary.quota)];
+ for (name, value) in members {
+ if let Some(value) = value {
+ let value = value.to_js(cx).expect("converting a number does not throw");
+ set_dictionary_member(cx, object, &PropertyKey::from_utf8(name), value)
+ .expect("defining a member of a new object does not throw");
+ }
+ }
+ Value::from_object(object)
+}
diff --git a/Libraries/LibWeb/Bindings/Rust/src/storage_api/storage_shelf.rs b/Libraries/LibWeb/Bindings/Rust/src/storage_api/storage_shelf.rs
new file mode 100644
index 00000000000..637bb54d194
--- /dev/null
+++ b/Libraries/LibWeb/Bindings/Rust/src/storage_api/storage_shelf.rs
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+//! Storage shelves, https://storage.spec.whatwg.org/#storage-shelf
+
+use core::ffi::c_void;
+
+use libjs_rust::api::{EmbedderCell, EmbedderClass, EmbedderValue, Gc, Trace, Vm};
+
+use crate::bindings::cpp_cell::CppCell;
+use crate::bindings::environment_settings_object::CppEnvironmentSettingsObject;
+
+unsafe extern "C" {
+ fn web_storage_api_obtain_a_local_storage_shelf(environment: *mut c_void) -> *mut c_void;
+ fn web_storage_api_storage_shelf_storage_usage(shelf: *mut c_void) -> u64;
+ fn web_storage_api_storage_shelf_storage_quota(shelf: *mut c_void) -> u64;
+}
+
+/// A storage shelf of LibWeb's C++ code, StorageAPI::StorageShelf.
+#[derive(Trace)]
+#[gc(crate = libjs_rust)]
+pub(crate) struct StorageShelf(CppCell);
+
+static STORAGE_SHELF_CLASS: EmbedderClass<StorageShelf> = EmbedderClass::new("StorageShelf");
+
+impl EmbedderValue for StorageShelf {
+ const CLASS: &'static EmbedderClass<Self> = &STORAGE_SHELF_CLASS;
+}
+
+impl StorageShelf {
+ /// https://storage.spec.whatwg.org/#storage-usage
+ pub(crate) fn storage_usage(&self) -> u64 {
+ // SAFETY: The shelf is live.
+ unsafe { web_storage_api_storage_shelf_storage_usage(self.0.as_ptr()) }
+ }
+
+ /// https://storage.spec.whatwg.org/#storage-quota
+ pub(crate) fn storage_quota(&self) -> u64 {
+ // SAFETY: The shelf is live.
+ unsafe { web_storage_api_storage_shelf_storage_quota(self.0.as_ptr()) }
+ }
+}
+
+/// https://storage.spec.whatwg.org/#obtain-a-local-storage-shelf
+pub(crate) fn obtain_a_local_storage_shelf(
+ vm: &Vm,
+ environment: &CppEnvironmentSettingsObject,
+) -> Option<Gc<EmbedderCell<StorageShelf>>> {
+ // SAFETY: The environment settings object is live.
+ let shelf = unsafe { web_storage_api_obtain_a_local_storage_shelf(environment.as_ptr()) };
+ if shelf.is_null() {
+ return None;
+ }
+ // SAFETY: LibWeb returns a live shelf.
+ let shelf = unsafe { CppCell::from_raw(shelf) };
+ Some(STORAGE_SHELF_CLASS.allocate(vm, |_| StorageShelf(shelf)))
+}
diff --git a/Libraries/LibWeb/Bindings/RustBindingsServices.cpp b/Libraries/LibWeb/Bindings/RustBindingsServices.cpp
index ee041f31d7d..0d76babd749 100644
--- a/Libraries/LibWeb/Bindings/RustBindingsServices.cpp
+++ b/Libraries/LibWeb/Bindings/RustBindingsServices.cpp
@@ -123,6 +123,7 @@ bool web_bindings_document_has_navigable(DOM::Document*);
bool web_bindings_document_is_fully_active(DOM::Document*);
URL::FFI::RustUrl web_bindings_document_url(DOM::Document*);
HTML::WorkerGlobalScope* web_bindings_worker_global_scope_from_global_object(JSObject* global_object);
+HTML::EnvironmentSettingsObject* web_bindings_relevant_settings_object(JSObject* global_object);
bool web_bindings_worker_global_scope_is_closing(HTML::WorkerGlobalScope*);
void web_bindings_with_temporary_execution_context(void* realm, bool callbacks_enabled, void* context, void (*steps)(void*));
bool web_bindings_object_implements_interface(JSObject* object, u16 interface_name);
@@ -248,6 +249,11 @@ URL::FFI::RustUrl web_bindings_document_url(DOM::Document* document)
return document->url().to_rust();
}
+HTML::EnvironmentSettingsObject* web_bindings_relevant_settings_object(JSObject* global_object)
+{
+ return &HTML::relevant_settings_object(*JS::HostABI::object_from_abi(global_object));
+}
+
HTML::WorkerGlobalScope* web_bindings_worker_global_scope_from_global_object(JSObject* global_object)
{
return Bindings::worker_global_scope_from_global_object(*JS::HostABI::object_from_abi(global_object));
@@ -472,6 +478,7 @@ void web_bindings_run_in_parallel(void* realm, void* cell, void (*steps)(JSVM*,
static_assert(to_underlying(HTML::Task::Source::Unspecified) == 0);
static_assert(to_underlying(HTML::Task::Source::Networking) == 3);
static_assert(to_underlying(HTML::Task::Source::FileReading) == 13);
+static_assert(to_underlying(HTML::Task::Source::Storage) == 29);
void web_bindings_queue_a_task(void* realm, u8 task_source, void* cell, void (*steps)(JSVM*, void*))
{
diff --git a/Libraries/LibWeb/HTML/Scripting/Environments.cpp b/Libraries/LibWeb/HTML/Scripting/Environments.cpp
index f0c7430e165..1461cace6fb 100644
--- a/Libraries/LibWeb/HTML/Scripting/Environments.cpp
+++ b/Libraries/LibWeb/HTML/Scripting/Environments.cpp
@@ -774,7 +774,7 @@ SerializedEnvironmentSettingsObject EnvironmentSettingsObject::serialize()
GC::Ref<StorageAPI::StorageManager> EnvironmentSettingsObject::storage_manager()
{
if (!m_storage_manager)
- m_storage_manager = StorageAPI::StorageManager::create(*this);
+ m_storage_manager = StorageAPI::StorageManager::create(realm());
return *m_storage_manager;
}
diff --git a/Libraries/LibWeb/StorageAPI/StorageManager.cpp b/Libraries/LibWeb/StorageAPI/StorageManager.cpp
index e1b9705376d..ab4b8bfab06 100644
--- a/Libraries/LibWeb/StorageAPI/StorageManager.cpp
+++ b/Libraries/LibWeb/StorageAPI/StorageManager.cpp
@@ -1,68 +1,26 @@
/*
* Copyright (c) 2024, Jamie Mansfield <[email protected]>
* Copyright (c) 2026, Tim Ledbetter <[email protected]>
+ * Copyright (c) 2026-present, the Ladybird developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include <LibGC/Heap.h>
-#include <LibWeb/HTML/EventLoop/EventLoop.h>
-#include <LibWeb/HTML/Scripting/Environments.h>
-#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
-#include <LibWeb/Platform/EventLoopPlugin.h>
+#include <LibJS/HostClassBuilder.h>
+#include <LibJS/Runtime/Realm.h>
#include <LibWeb/StorageAPI/StorageManager.h>
-#include <LibWeb/StorageAPI/StorageShelf.h>
namespace Web::StorageAPI {
-GC_DEFINE_ALLOCATOR(StorageManager);
+extern "C" {
-GC::Ref<StorageManager> StorageManager::create(GC::Ref<HTML::EnvironmentSettingsObject> environment)
-{
- return GC::Heap::the().allocate<StorageManager>(environment);
-}
-
-StorageManager::StorageManager(GC::Ref<HTML::EnvironmentSettingsObject> environment)
- : m_environment(environment)
-{
-}
-
-void StorageManager::visit_edges(GC::Cell::Visitor& visitor)
-{
- Base::visit_edges(visitor);
- visitor.visit(m_environment);
-}
-
-void StorageManager::queue_a_storage_task(JS::Object& global, Function<void()> steps)
-{
- HTML::queue_global_task(HTML::Task::Source::Storage, global, GC::create_function(GC::Heap::the(), move(steps)));
+// Defined in Bindings/Rust/src/storage_api/exports.rs.
+void* web_rust_storage_api_create_storage_manager(JSVM*, void* realm);
}
-GC::Ref<WebIDL::Promise> StorageManager::estimate() const
+GC::Ref<StorageManager> StorageManager::create(JS::Realm& realm)
{
- auto& realm = m_environment->realm();
- auto promise = WebIDL::create_promise_for(m_environment->global_object());
- auto& global = m_environment->global_object();
- auto shelf = obtain_a_local_storage_shelf(*m_environment);
-
- if (!shelf) {
- WebIDL::reject_promise(promise, JS::TypeError::create(realm, "Failed to obtain local storage shelf."_utf16));
- } else {
- Platform::EventLoopPlugin::the().deferred_invoke(GC::create_function(realm.heap(), [&realm, &global, shelf = GC::Ref { *shelf }, promise] {
- auto usage = shelf->storage_usage();
- auto quota = shelf->storage_quota();
- auto dictionary_object = JS::Object::create(realm, realm.intrinsics().object_prototype());
- dictionary_object->define_direct_property("usage"_utf16_fly_string, JS::Value(usage), JS::default_attributes);
- dictionary_object->define_direct_property("quota"_utf16_fly_string, JS::Value(quota), JS::default_attributes);
- auto dictionary_value = JS::Value { dictionary_object };
- queue_a_storage_task(global, [&realm, promise, dictionary_value] {
- HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
- WebIDL::resolve_promise(*promise, dictionary_value);
- });
- }));
- }
-
- return promise;
+ return *static_cast<StorageManager*>(web_rust_storage_api_create_storage_manager(JS::HostABI::vm_to_abi(realm.vm()), &realm));
}
}
diff --git a/Libraries/LibWeb/StorageAPI/StorageManager.h b/Libraries/LibWeb/StorageAPI/StorageManager.h
index 4874213c224..59e71113cdb 100644
--- a/Libraries/LibWeb/StorageAPI/StorageManager.h
+++ b/Libraries/LibWeb/StorageAPI/StorageManager.h
@@ -1,31 +1,25 @@
/*
* Copyright (c) 2024, Jamie Mansfield <[email protected]>
+ * Copyright (c) 2026-present, the Ladybird developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
-#include <LibWeb/Bindings/Wrappable.h>
+#include <LibJS/Forward.h>
+#include <LibWeb/Bindings/RustInterface.h>
+#include <LibWeb/Bindings/StorageManager.h>
namespace Web::StorageAPI {
-class StorageManager final : public Bindings::GCAllocatedWrappable {
- WEB_WRAPPABLE(StorageManager, Bindings::GCAllocatedWrappable);
- GC_DECLARE_ALLOCATOR(StorageManager);
+// https://storage.spec.whatwg.org/#storagemanager
+// The C++ side of a StorageManager, which is implemented in Rust (Libraries/LibWeb/Bindings/Rust/src/storage_api).
+class StorageManager : public Bindings::RustInterfaceCell {
+ WEB_RUST_INTERFACE(StorageManager, storage_manager)
public:
- static GC::Ref<StorageManager> create(GC::Ref<HTML::EnvironmentSettingsObject>);
- virtual ~StorageManager() override = default;
-
- GC::Ref<WebIDL::Promise> estimate() const;
-
-private:
- explicit StorageManager(GC::Ref<HTML::EnvironmentSettingsObject>);
- static void queue_a_storage_task(JS::Object&, Function<void()>);
- virtual void visit_edges(GC::Cell::Visitor&) override;
-
- GC::Ref<HTML::EnvironmentSettingsObject> m_environment;
+ [[nodiscard]] static GC::Ref<StorageManager> create(JS::Realm&);
};
}
diff --git a/Libraries/LibWeb/StorageAPI/StorageManager.idl b/Libraries/LibWeb/StorageAPI/StorageManager.idl
index 1de7cb4bad3..54bca5897e5 100644
--- a/Libraries/LibWeb/StorageAPI/StorageManager.idl
+++ b/Libraries/LibWeb/StorageAPI/StorageManager.idl
@@ -1,5 +1,5 @@
// https://storage.spec.whatwg.org/#storagemanager
-[SecureContext, Exposed=(Window,Worker)]
+[SecureContext, Exposed=(Window,Worker), ImplementedIn=Rust]
interface StorageManager {
[FIXME] Promise<boolean> persisted();
[FIXME, Exposed=Window] Promise<boolean> persist();
diff --git a/Libraries/LibWeb/StorageAPI/StorageShelf.cpp b/Libraries/LibWeb/StorageAPI/StorageShelf.cpp
index 7efa46f27fd..1bfa96cdfbd 100644
--- a/Libraries/LibWeb/StorageAPI/StorageShelf.cpp
+++ b/Libraries/LibWeb/StorageAPI/StorageShelf.cpp
@@ -69,4 +69,27 @@ GC::Ptr<StorageShelf> obtain_a_local_storage_shelf(HTML::EnvironmentSettingsObje
return StorageShelf::create(window.page(), settings.id, *key, StorageType::Local);
}
+// Declared on the Rust side in Libraries/LibWeb/Bindings/Rust/src/storage_api/storage_shelf.rs.
+extern "C" {
+
+StorageShelf* web_storage_api_obtain_a_local_storage_shelf(HTML::EnvironmentSettingsObject*);
+u64 web_storage_api_storage_shelf_storage_usage(StorageShelf*);
+u64 web_storage_api_storage_shelf_storage_quota(StorageShelf*);
+}
+
+StorageShelf* web_storage_api_obtain_a_local_storage_shelf(HTML::EnvironmentSettingsObject* environment)
+{
+ return obtain_a_local_storage_shelf(*environment).ptr();
+}
+
+u64 web_storage_api_storage_shelf_storage_usage(StorageShelf* shelf)
+{
+ return shelf->storage_usage();
+}
+
+u64 web_storage_api_storage_shelf_storage_quota(StorageShelf* shelf)
+{
+ return shelf->storage_quota();
+}
+
}
diff --git a/Meta/Linters/check_libweb_realm_mentions.py b/Meta/Linters/check_libweb_realm_mentions.py
index 0e09dbae42d..3b636b80aac 100755
--- a/Meta/Linters/check_libweb_realm_mentions.py
+++ b/Meta/Linters/check_libweb_realm_mentions.py
@@ -79,7 +79,12 @@ ALLOWED_REALM_MENTIONS = {
41,
"service worker jobs, caches, and container promises still materialize results in selected realms",
),
- "StorageAPI": (1, 3, "the C++ glue of the Rust storage keys reads the settings object of a realm's global"),
+ "StorageAPI": (
+ 3,
+ 6,
+ "the C++ glue of the Rust storage keys reads the settings object of a realm's global, and the C++ glue of the "
+ "Rust StorageManager creates one in a realm",
+ ),
"Streams": (7, 17, "the C++ facade of the Rust streams creates streams and promises in caller-selected realms"),
"TrustedTypes": (2, 9, "Trusted Types policy factory operations still use selected realms"),
"WebAssembly": (