LibWeb: Correctly initialize Storage objects on the Document

Instead of storing all storage objects in static memory, we now
follow the the spec by lazily creating a unique Storage object
on each document object.

Each Storage object now holds a 'proxy' to the underlying backing
storage. For now, this proxy is simply a reference to the backing
object. In the future, it will need to be some type of interface
object that stores on a SQLite database or similar.

Session storage is now correctly stored / tracked as part of the
TraversableNavigable object.

Local storage is still stored in a static map, but eventually this
should be factored into something that is stored at the user agent
level.
This commit is contained in:
Shannon Booth
2024-12-26 11:56:03 +13:00
committed by Andreas Kling
parent c536f65160
commit 2066ed2318
20 changed files with 503 additions and 44 deletions

View File

@@ -13,6 +13,7 @@
#include <LibWeb/HTML/VisibilityState.h>
#include <LibWeb/Page/Page.h>
#include <LibWeb/Painting/DisplayListPlayerSkia.h>
#include <LibWeb/StorageAPI/StorageShed.h>
#include <WebContent/BackingStoreManager.h>
#ifdef AK_OS_MACOS
@@ -107,6 +108,9 @@ public:
RefPtr<Gfx::SkiaBackendContext> skia_backend_context() const { return m_skia_backend_context; }
StorageAPI::StorageShed& storage_shed() { return m_storage_shed; }
StorageAPI::StorageShed const& storage_shed() const { return m_storage_shed; }
private:
TraversableNavigable(GC::Ref<Page>);
@@ -142,6 +146,10 @@ private:
// https://html.spec.whatwg.org/multipage/document-sequences.html#system-visibility-state
VisibilityState m_system_visibility_state { VisibilityState::Hidden };
// https://storage.spec.whatwg.org/#traversable-navigable-storage-shed
// A traversable navigable holds a storage shed, which is a storage shed. A traversable navigables storage shed holds all session storage data.
StorageAPI::StorageShed m_storage_shed;
GC::Ref<SessionHistoryTraversalQueue> m_session_history_traversal_queue;
String m_window_handle;