mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 21:05:07 +00:00
LibWeb: Make Crypto GC-allocated
This commit is contained in:
parent
96f6c7fae5
commit
be9d3860b9
6 changed files with 30 additions and 24 deletions
|
@ -8,15 +8,29 @@
|
||||||
#include <AK/Random.h>
|
#include <AK/Random.h>
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <LibJS/Runtime/TypedArray.h>
|
#include <LibJS/Runtime/TypedArray.h>
|
||||||
#include <LibWeb/Bindings/Wrapper.h>
|
|
||||||
#include <LibWeb/Crypto/Crypto.h>
|
#include <LibWeb/Crypto/Crypto.h>
|
||||||
#include <LibWeb/Crypto/SubtleCrypto.h>
|
#include <LibWeb/Crypto/SubtleCrypto.h>
|
||||||
|
#include <LibWeb/HTML/Window.h>
|
||||||
|
|
||||||
namespace Web::Crypto {
|
namespace Web::Crypto {
|
||||||
|
|
||||||
Crypto::Crypto(HTML::Window& window)
|
JS::NonnullGCPtr<Crypto> Crypto::create(HTML::Window& window)
|
||||||
: m_subtle(*SubtleCrypto::create(window))
|
|
||||||
{
|
{
|
||||||
|
return *window.heap().allocate<Crypto>(window.realm(), window);
|
||||||
|
}
|
||||||
|
|
||||||
|
Crypto::Crypto(HTML::Window& window)
|
||||||
|
: PlatformObject(window.realm())
|
||||||
|
{
|
||||||
|
set_prototype(&window.cached_web_prototype("Crypto"));
|
||||||
|
}
|
||||||
|
|
||||||
|
Crypto::~Crypto() = default;
|
||||||
|
|
||||||
|
void Crypto::initialize(JS::Realm& realm)
|
||||||
|
{
|
||||||
|
Base::initialize(realm);
|
||||||
|
m_subtle = SubtleCrypto::create(global_object());
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::NonnullGCPtr<SubtleCrypto> Crypto::subtle() const
|
JS::NonnullGCPtr<SubtleCrypto> Crypto::subtle() const
|
||||||
|
|
|
@ -6,23 +6,19 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibJS/Runtime/Value.h>
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
#include <LibWeb/Bindings/Wrappable.h>
|
|
||||||
#include <LibWeb/Crypto/SubtleCrypto.h>
|
#include <LibWeb/Crypto/SubtleCrypto.h>
|
||||||
#include <LibWeb/DOM/ExceptionOr.h>
|
#include <LibWeb/DOM/ExceptionOr.h>
|
||||||
|
|
||||||
namespace Web::Crypto {
|
namespace Web::Crypto {
|
||||||
|
|
||||||
class Crypto : public Bindings::Wrappable
|
class Crypto : public Bindings::PlatformObject {
|
||||||
, public RefCounted<Crypto>
|
WEB_PLATFORM_OBJECT(Crypto, Bindings::PlatformObject);
|
||||||
, public Weakable<Crypto> {
|
|
||||||
public:
|
|
||||||
using WrapperType = Bindings::CryptoWrapper;
|
|
||||||
|
|
||||||
static NonnullRefPtr<Crypto> create(HTML::Window& window)
|
public:
|
||||||
{
|
static JS::NonnullGCPtr<Crypto> create(HTML::Window&);
|
||||||
return adopt_ref(*new Crypto(window));
|
|
||||||
}
|
virtual ~Crypto() override;
|
||||||
|
|
||||||
JS::NonnullGCPtr<SubtleCrypto> subtle() const;
|
JS::NonnullGCPtr<SubtleCrypto> subtle() const;
|
||||||
|
|
||||||
|
@ -31,14 +27,11 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Crypto(HTML::Window&);
|
explicit Crypto(HTML::Window&);
|
||||||
|
virtual void initialize(JS::Realm&) override;
|
||||||
|
|
||||||
JS::Handle<SubtleCrypto> m_subtle;
|
JS::GCPtr<SubtleCrypto> m_subtle;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Web::Bindings {
|
WRAPPER_HACK(Crypto, Web::Crypto)
|
||||||
|
|
||||||
CryptoWrapper* wrap(JS::Realm&, Crypto::Crypto&);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -448,7 +448,6 @@ class URLSearchParamsIterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Web::Bindings {
|
namespace Web::Bindings {
|
||||||
class CryptoWrapper;
|
|
||||||
class DOMExceptionWrapper;
|
class DOMExceptionWrapper;
|
||||||
class IdleDeadlineWrapper;
|
class IdleDeadlineWrapper;
|
||||||
class IntersectionObserverWrapper;
|
class IntersectionObserverWrapper;
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include <LibJS/Runtime/Shape.h>
|
#include <LibJS/Runtime/Shape.h>
|
||||||
#include <LibTextCodec/Decoder.h>
|
#include <LibTextCodec/Decoder.h>
|
||||||
#include <LibWeb/Bindings/CSSNamespace.h>
|
#include <LibWeb/Bindings/CSSNamespace.h>
|
||||||
#include <LibWeb/Bindings/CryptoWrapper.h>
|
|
||||||
#include <LibWeb/Bindings/EventTargetConstructor.h>
|
#include <LibWeb/Bindings/EventTargetConstructor.h>
|
||||||
#include <LibWeb/Bindings/EventTargetPrototype.h>
|
#include <LibWeb/Bindings/EventTargetPrototype.h>
|
||||||
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
||||||
|
@ -98,6 +97,7 @@ void Window::visit_edges(JS::Cell::Visitor& visitor)
|
||||||
visitor.visit(m_performance.ptr());
|
visitor.visit(m_performance.ptr());
|
||||||
visitor.visit(m_screen.ptr());
|
visitor.visit(m_screen.ptr());
|
||||||
visitor.visit(m_location_object);
|
visitor.visit(m_location_object);
|
||||||
|
visitor.visit(m_crypto);
|
||||||
for (auto& it : m_prototypes)
|
for (auto& it : m_prototypes)
|
||||||
visitor.visit(it.value);
|
visitor.visit(it.value);
|
||||||
for (auto& it : m_constructors)
|
for (auto& it : m_constructors)
|
||||||
|
|
|
@ -145,7 +145,7 @@ private:
|
||||||
HashMap<int, JS::NonnullGCPtr<Timer>> m_timers;
|
HashMap<int, JS::NonnullGCPtr<Timer>> m_timers;
|
||||||
|
|
||||||
JS::GCPtr<HighResolutionTime::Performance> m_performance;
|
JS::GCPtr<HighResolutionTime::Performance> m_performance;
|
||||||
RefPtr<Crypto::Crypto> m_crypto;
|
JS::GCPtr<Crypto::Crypto> m_crypto;
|
||||||
JS::GCPtr<CSS::Screen> m_screen;
|
JS::GCPtr<CSS::Screen> m_screen;
|
||||||
|
|
||||||
AnimationFrameCallbackDriver m_animation_frame_callback_driver;
|
AnimationFrameCallbackDriver m_animation_frame_callback_driver;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# This file is included from "Meta/CMake/libweb_data.cmake"
|
# This file is included from "Meta/CMake/libweb_data.cmake"
|
||||||
# It is defined here so that there is no need to go to the Meta directory when adding new idl files
|
# It is defined here so that there is no need to go to the Meta directory when adding new idl files
|
||||||
|
|
||||||
libweb_js_wrapper(Crypto/Crypto)
|
libweb_js_wrapper(Crypto/Crypto NO_INSTANCE)
|
||||||
libweb_js_wrapper(Crypto/SubtleCrypto NO_INSTANCE)
|
libweb_js_wrapper(Crypto/SubtleCrypto NO_INSTANCE)
|
||||||
libweb_js_wrapper(CSS/CSSConditionRule NO_INSTANCE)
|
libweb_js_wrapper(CSS/CSSConditionRule NO_INSTANCE)
|
||||||
libweb_js_wrapper(CSS/CSSFontFaceRule NO_INSTANCE)
|
libweb_js_wrapper(CSS/CSSFontFaceRule NO_INSTANCE)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue