mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-24 11:21:34 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
22
Libraries/LibWeb/StorageAPI/NavigatorStorage.cpp
Normal file
22
Libraries/LibWeb/StorageAPI/NavigatorStorage.cpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/StorageAPI/NavigatorStorage.h>
|
||||
#include <LibWeb/StorageAPI/StorageManager.h>
|
||||
|
||||
namespace Web::StorageAPI {
|
||||
|
||||
// https://storage.spec.whatwg.org/#dom-navigatorstorage-storage
|
||||
JS::NonnullGCPtr<StorageManager> NavigatorStorage::storage()
|
||||
{
|
||||
// The storage getter steps are to return this’s relevant settings object’s StorageManager object.
|
||||
return HTML::relevant_settings_object(this_navigator_storage_object()).storage_manager();
|
||||
}
|
||||
|
||||
}
|
27
Libraries/LibWeb/StorageAPI/NavigatorStorage.h
Normal file
27
Libraries/LibWeb/StorageAPI/NavigatorStorage.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::StorageAPI {
|
||||
|
||||
class NavigatorStorage {
|
||||
public:
|
||||
virtual ~NavigatorStorage() = default;
|
||||
|
||||
JS::NonnullGCPtr<StorageManager> storage();
|
||||
|
||||
protected:
|
||||
virtual Bindings::PlatformObject const& this_navigator_storage_object() const = 0;
|
||||
};
|
||||
|
||||
}
|
7
Libraries/LibWeb/StorageAPI/NavigatorStorage.idl
Normal file
7
Libraries/LibWeb/StorageAPI/NavigatorStorage.idl
Normal file
|
@ -0,0 +1,7 @@
|
|||
#import <StorageAPI/StorageManager.idl>
|
||||
|
||||
// https://storage.spec.whatwg.org/#navigatorstorage
|
||||
[SecureContext]
|
||||
interface mixin NavigatorStorage {
|
||||
[SameObject] readonly attribute StorageManager storage;
|
||||
};
|
42
Libraries/LibWeb/StorageAPI/StorageKey.cpp
Normal file
42
Libraries/LibWeb/StorageAPI/StorageKey.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Andrew Kaster <andrew@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/DOMURL/DOMURL.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/StorageAPI/StorageKey.h>
|
||||
|
||||
namespace Web::StorageAPI {
|
||||
|
||||
// https://storage.spec.whatwg.org/#obtain-a-storage-key
|
||||
Optional<StorageKey> obtain_a_storage_key(HTML::Environment const& environment)
|
||||
{
|
||||
// 1. Let key be the result of running obtain a storage key for non-storage purposes with environment.
|
||||
auto key = obtain_a_storage_key_for_non_storage_purposes(environment);
|
||||
|
||||
// 2. If key’s origin is an opaque origin, then return failure.
|
||||
if (key.origin.is_opaque())
|
||||
return {};
|
||||
|
||||
// FIXME: 3. If the user has disabled storage, then return failure.
|
||||
|
||||
// 4. Return key.
|
||||
return key;
|
||||
}
|
||||
|
||||
// https://storage.spec.whatwg.org/#obtain-a-storage-key-for-non-storage-purposes
|
||||
StorageKey obtain_a_storage_key_for_non_storage_purposes(HTML::Environment const& environment)
|
||||
{
|
||||
// 1. Let origin be environment’s origin if environment is an environment settings object; otherwise environment’s creation URL’s origin.
|
||||
if (is<HTML::EnvironmentSettingsObject>(environment)) {
|
||||
auto const& settings = static_cast<HTML::EnvironmentSettingsObject const&>(environment);
|
||||
// FIXME: EnvironmentSettingsObject::origin() should be const :|
|
||||
auto& mutable_settings = const_cast<HTML::EnvironmentSettingsObject&>(settings);
|
||||
return { mutable_settings.origin() };
|
||||
}
|
||||
return { environment.creation_url.origin() };
|
||||
}
|
||||
|
||||
}
|
45
Libraries/LibWeb/StorageAPI/StorageKey.h
Normal file
45
Libraries/LibWeb/StorageAPI/StorageKey.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Andrew Kaster <andrew@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/Traits.h>
|
||||
#include <LibURL/Origin.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::StorageAPI {
|
||||
|
||||
// https://storage.spec.whatwg.org/#storage-keys
|
||||
struct StorageKey {
|
||||
|
||||
// A storage key is a tuple consisting of an origin (an origin). [HTML]
|
||||
// NOTE: This is expected to change; see Client-Side Storage Partitioning https://privacycg.github.io/storage-partitioning/.
|
||||
URL::Origin origin;
|
||||
|
||||
friend bool operator==(StorageKey const& a, StorageKey const& b)
|
||||
{
|
||||
// To determine whether a storage key A equals storage key B, run these steps:
|
||||
// 1. If A’s origin is not same origin with B’s origin, then return false.
|
||||
// 2. Return true.
|
||||
return a.origin.is_same_origin(b.origin);
|
||||
}
|
||||
};
|
||||
|
||||
Optional<StorageKey> obtain_a_storage_key(HTML::Environment const&);
|
||||
StorageKey obtain_a_storage_key_for_non_storage_purposes(HTML::Environment const&);
|
||||
|
||||
}
|
||||
|
||||
namespace AK {
|
||||
template<>
|
||||
struct Traits<Web::StorageAPI::StorageKey> : public DefaultTraits<Web::StorageAPI::StorageKey> {
|
||||
static unsigned hash(Web::StorageAPI::StorageKey const& key)
|
||||
{
|
||||
return Traits<URL::Origin>::hash(key.origin);
|
||||
}
|
||||
};
|
||||
}
|
32
Libraries/LibWeb/StorageAPI/StorageManager.cpp
Normal file
32
Libraries/LibWeb/StorageAPI/StorageManager.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/StorageManagerPrototype.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/StorageAPI/StorageManager.h>
|
||||
|
||||
namespace Web::StorageAPI {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(StorageManager);
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<StorageManager>> StorageManager::create(JS::Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<StorageManager>(realm, realm);
|
||||
}
|
||||
|
||||
StorageManager::StorageManager(JS::Realm& realm)
|
||||
: PlatformObject(realm)
|
||||
{
|
||||
}
|
||||
|
||||
void StorageManager::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(StorageManager);
|
||||
}
|
||||
|
||||
}
|
27
Libraries/LibWeb/StorageAPI/StorageManager.h
Normal file
27
Libraries/LibWeb/StorageAPI/StorageManager.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
|
||||
namespace Web::StorageAPI {
|
||||
|
||||
class StorageManager final : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(StorageManager, Bindings::PlatformObject);
|
||||
JS_DECLARE_ALLOCATOR(StorageManager);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<StorageManager>> create(JS::Realm&);
|
||||
virtual ~StorageManager() override = default;
|
||||
|
||||
private:
|
||||
StorageManager(JS::Realm&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
}
|
14
Libraries/LibWeb/StorageAPI/StorageManager.idl
Normal file
14
Libraries/LibWeb/StorageAPI/StorageManager.idl
Normal file
|
@ -0,0 +1,14 @@
|
|||
// https://storage.spec.whatwg.org/#storagemanager
|
||||
[SecureContext, Exposed=(Window,Worker)]
|
||||
interface StorageManager {
|
||||
[FIXME] Promise<boolean> persisted();
|
||||
[FIXME, Exposed=Window] Promise<boolean> persist();
|
||||
|
||||
[FIXME] Promise<StorageEstimate> estimate();
|
||||
};
|
||||
|
||||
// https://storage.spec.whatwg.org/#dictdef-storageestimate
|
||||
dictionary StorageEstimate {
|
||||
unsigned long long usage;
|
||||
unsigned long long quota;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue