From 0afea792e279d0ad4a1ee3f99c3b155e68bfef3b Mon Sep 17 00:00:00 2001 From: stelar7 Date: Fri, 15 Dec 2023 21:05:09 +0100 Subject: [PATCH] LibWeb: Move dictionaries to the Bindings namespace --- Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp | 5 +++-- Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h | 15 ++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp index ace278bee6..3f0c0404d8 100644 --- a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp +++ b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2021-2022, Linus Groh + * Copyright (c) 2023, stelar7 * * SPDX-License-Identifier: BSD-2-Clause */ @@ -36,7 +37,7 @@ void SubtleCrypto::initialize(JS::Realm& realm) } // https://w3c.github.io/webcrypto/#dfn-normalize-an-algorithm -JS::ThrowCompletionOr SubtleCrypto::normalize_an_algorithm(Variant, String> const& algorithm, String operation) +JS::ThrowCompletionOr SubtleCrypto::normalize_an_algorithm(Variant, String> const& algorithm, String operation) { auto& realm = this->realm(); @@ -93,7 +94,7 @@ JS::ThrowCompletionOr SubtleCrypto::normalize_an_algori // 8. Let normalizedAlgorithm be the result of converting the ECMAScript object represented by alg // to the IDL dictionary type desiredType, as defined by [WebIDL]. // FIXME: Should IDL generate a struct for each of these? - SubtleCrypto::Algorithm normalized_algorithm; + Bindings::Algorithm normalized_algorithm; // 9. Set the name attribute of normalizedAlgorithm to algName. normalized_algorithm.name = algorithm_name; diff --git a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h index ded2071113..386e6d8741 100644 --- a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h +++ b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h @@ -10,6 +10,15 @@ #include #include #include +// FIXME: Generate these from IDL +namespace Web::Bindings { + +// https://w3c.github.io/webcrypto/#dfn-Algorithm +struct Algorithm { + String name; +}; + +}; namespace Web::Crypto { @@ -20,10 +29,6 @@ class SubtleCrypto final : public Bindings::PlatformObject { using SupportedAlgorithmsMap = HashMap>; public: - struct Algorithm { - String name; - }; - [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&); virtual ~SubtleCrypto() override; @@ -34,7 +39,7 @@ private: explicit SubtleCrypto(JS::Realm&); virtual void initialize(JS::Realm&) override; - JS::ThrowCompletionOr normalize_an_algorithm(Variant, String> const& algorithm, String operation); + JS::ThrowCompletionOr normalize_an_algorithm(Variant, String> const& algorithm, String operation); static SubtleCrypto::SupportedAlgorithmsMap& supported_algorithms_internal(); static SubtleCrypto::SupportedAlgorithmsMap supported_algorithms();