mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 16:25:08 +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/StringBuilder.h>
|
||||
#include <LibJS/Runtime/TypedArray.h>
|
||||
#include <LibWeb/Bindings/Wrapper.h>
|
||||
#include <LibWeb/Crypto/Crypto.h>
|
||||
#include <LibWeb/Crypto/SubtleCrypto.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::Crypto {
|
||||
|
||||
Crypto::Crypto(HTML::Window& window)
|
||||
: m_subtle(*SubtleCrypto::create(window))
|
||||
JS::NonnullGCPtr<Crypto> Crypto::create(HTML::Window& 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
|
||||
|
|
|
@ -6,23 +6,19 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
#include <LibWeb/Bindings/Wrappable.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/Crypto/SubtleCrypto.h>
|
||||
#include <LibWeb/DOM/ExceptionOr.h>
|
||||
|
||||
namespace Web::Crypto {
|
||||
|
||||
class Crypto : public Bindings::Wrappable
|
||||
, public RefCounted<Crypto>
|
||||
, public Weakable<Crypto> {
|
||||
public:
|
||||
using WrapperType = Bindings::CryptoWrapper;
|
||||
class Crypto : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(Crypto, Bindings::PlatformObject);
|
||||
|
||||
static NonnullRefPtr<Crypto> create(HTML::Window& window)
|
||||
{
|
||||
return adopt_ref(*new Crypto(window));
|
||||
}
|
||||
public:
|
||||
static JS::NonnullGCPtr<Crypto> create(HTML::Window&);
|
||||
|
||||
virtual ~Crypto() override;
|
||||
|
||||
JS::NonnullGCPtr<SubtleCrypto> subtle() const;
|
||||
|
||||
|
@ -31,14 +27,11 @@ public:
|
|||
|
||||
private:
|
||||
explicit Crypto(HTML::Window&);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
JS::Handle<SubtleCrypto> m_subtle;
|
||||
JS::GCPtr<SubtleCrypto> m_subtle;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
|
||||
CryptoWrapper* wrap(JS::Realm&, Crypto::Crypto&);
|
||||
|
||||
}
|
||||
WRAPPER_HACK(Crypto, Web::Crypto)
|
||||
|
|
|
@ -448,7 +448,6 @@ class URLSearchParamsIterator;
|
|||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
class CryptoWrapper;
|
||||
class DOMExceptionWrapper;
|
||||
class IdleDeadlineWrapper;
|
||||
class IntersectionObserverWrapper;
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include <LibJS/Runtime/Shape.h>
|
||||
#include <LibTextCodec/Decoder.h>
|
||||
#include <LibWeb/Bindings/CSSNamespace.h>
|
||||
#include <LibWeb/Bindings/CryptoWrapper.h>
|
||||
#include <LibWeb/Bindings/EventTargetConstructor.h>
|
||||
#include <LibWeb/Bindings/EventTargetPrototype.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_screen.ptr());
|
||||
visitor.visit(m_location_object);
|
||||
visitor.visit(m_crypto);
|
||||
for (auto& it : m_prototypes)
|
||||
visitor.visit(it.value);
|
||||
for (auto& it : m_constructors)
|
||||
|
|
|
@ -145,7 +145,7 @@ private:
|
|||
HashMap<int, JS::NonnullGCPtr<Timer>> m_timers;
|
||||
|
||||
JS::GCPtr<HighResolutionTime::Performance> m_performance;
|
||||
RefPtr<Crypto::Crypto> m_crypto;
|
||||
JS::GCPtr<Crypto::Crypto> m_crypto;
|
||||
JS::GCPtr<CSS::Screen> m_screen;
|
||||
|
||||
AnimationFrameCallbackDriver m_animation_frame_callback_driver;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# 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
|
||||
|
||||
libweb_js_wrapper(Crypto/Crypto)
|
||||
libweb_js_wrapper(Crypto/Crypto NO_INSTANCE)
|
||||
libweb_js_wrapper(Crypto/SubtleCrypto NO_INSTANCE)
|
||||
libweb_js_wrapper(CSS/CSSConditionRule NO_INSTANCE)
|
||||
libweb_js_wrapper(CSS/CSSFontFaceRule NO_INSTANCE)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue