mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:47:44 +00:00
LibWeb/HTML: Port Window.crypto to IDL
This commit is contained in:
parent
7de9179a6d
commit
198db2ebd9
3 changed files with 14 additions and 12 deletions
|
@ -1038,14 +1038,12 @@ WebIDL::ExceptionOr<void> Window::initialize_web_interfaces(Badge<WindowEnvironm
|
||||||
|
|
||||||
Object::set_prototype(&Bindings::ensure_web_prototype<Bindings::WindowPrototype>(realm, "Window"));
|
Object::set_prototype(&Bindings::ensure_web_prototype<Bindings::WindowPrototype>(realm, "Window"));
|
||||||
|
|
||||||
m_crypto = MUST_OR_THROW_OOM(heap().allocate<Crypto::Crypto>(realm, realm));
|
|
||||||
m_location = MUST_OR_THROW_OOM(heap().allocate<Location>(realm, realm));
|
m_location = MUST_OR_THROW_OOM(heap().allocate<Location>(realm, realm));
|
||||||
m_navigator = MUST_OR_THROW_OOM(heap().allocate<Navigator>(realm, realm));
|
m_navigator = MUST_OR_THROW_OOM(heap().allocate<Navigator>(realm, realm));
|
||||||
|
|
||||||
MUST_OR_THROW_OOM(Bindings::WindowGlobalMixin::initialize(realm, *this));
|
MUST_OR_THROW_OOM(Bindings::WindowGlobalMixin::initialize(realm, *this));
|
||||||
|
|
||||||
// FIXME: These should be native accessors, not properties
|
// FIXME: These should be native accessors, not properties
|
||||||
define_native_accessor(realm, "crypto", crypto_getter, {}, JS::Attribute::Enumerable);
|
|
||||||
define_native_accessor(realm, "screen", screen_getter, screen_setter, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
define_native_accessor(realm, "screen", screen_getter, screen_setter, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||||
define_native_accessor(realm, "innerWidth", inner_width_getter, {}, JS::Attribute::Enumerable);
|
define_native_accessor(realm, "innerWidth", inner_width_getter, {}, JS::Attribute::Enumerable);
|
||||||
define_native_accessor(realm, "innerHeight", inner_height_getter, {}, JS::Attribute::Enumerable);
|
define_native_accessor(realm, "innerHeight", inner_height_getter, {}, JS::Attribute::Enumerable);
|
||||||
|
@ -1340,6 +1338,14 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<HighResolutionTime::Performance>> Window::p
|
||||||
return JS::NonnullGCPtr { *m_performance };
|
return JS::NonnullGCPtr { *m_performance };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://w3c.github.io/webcrypto/#dom-windoworworkerglobalscope-crypto
|
||||||
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<Crypto::Crypto>> Window::crypto()
|
||||||
|
{
|
||||||
|
if (!m_crypto)
|
||||||
|
m_crypto = MUST_OR_THROW_OOM(heap().allocate<Crypto::Crypto>(realm(), realm()));
|
||||||
|
return JS::NonnullGCPtr { *m_crypto };
|
||||||
|
}
|
||||||
|
|
||||||
static JS::ThrowCompletionOr<TimerHandler> make_timer_handler(JS::VM& vm, JS::Value handler)
|
static JS::ThrowCompletionOr<TimerHandler> make_timer_handler(JS::VM& vm, JS::Value handler)
|
||||||
{
|
{
|
||||||
if (handler.is_function())
|
if (handler.is_function())
|
||||||
|
@ -1531,12 +1537,6 @@ JS_DEFINE_NATIVE_FUNCTION(Window::location_setter)
|
||||||
return JS::js_undefined();
|
return JS::js_undefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_DEFINE_NATIVE_FUNCTION(Window::crypto_getter)
|
|
||||||
{
|
|
||||||
auto* impl = TRY(impl_from(vm));
|
|
||||||
return &impl->crypto();
|
|
||||||
}
|
|
||||||
|
|
||||||
JS_DEFINE_NATIVE_FUNCTION(Window::inner_width_getter)
|
JS_DEFINE_NATIVE_FUNCTION(Window::inner_width_getter)
|
||||||
{
|
{
|
||||||
auto* impl = TRY(impl_from(vm));
|
auto* impl = TRY(impl_from(vm));
|
||||||
|
|
|
@ -96,8 +96,6 @@ public:
|
||||||
|
|
||||||
void deallocate_timer_id(Badge<Timer>, i32);
|
void deallocate_timer_id(Badge<Timer>, i32);
|
||||||
|
|
||||||
Crypto::Crypto& crypto() { return *m_crypto; }
|
|
||||||
|
|
||||||
CSS::Screen& screen();
|
CSS::Screen& screen();
|
||||||
|
|
||||||
DOM::Event* current_event() { return m_current_event.ptr(); }
|
DOM::Event* current_event() { return m_current_event.ptr(); }
|
||||||
|
@ -169,6 +167,8 @@ public:
|
||||||
|
|
||||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<HighResolutionTime::Performance>> performance();
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<HighResolutionTime::Performance>> performance();
|
||||||
|
|
||||||
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<Crypto::Crypto>> crypto();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Window(JS::Realm&);
|
explicit Window(JS::Realm&);
|
||||||
|
|
||||||
|
@ -274,8 +274,6 @@ private:
|
||||||
JS_DECLARE_NATIVE_FUNCTION(request_idle_callback);
|
JS_DECLARE_NATIVE_FUNCTION(request_idle_callback);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(cancel_idle_callback);
|
JS_DECLARE_NATIVE_FUNCTION(cancel_idle_callback);
|
||||||
|
|
||||||
JS_DECLARE_NATIVE_FUNCTION(crypto_getter);
|
|
||||||
|
|
||||||
HTML::Location* m_location { nullptr };
|
HTML::Location* m_location { nullptr };
|
||||||
|
|
||||||
// [[CrossOriginPropertyDescriptorMap]], https://html.spec.whatwg.org/multipage/browsers.html#crossoriginpropertydescriptormap
|
// [[CrossOriginPropertyDescriptorMap]], https://html.spec.whatwg.org/multipage/browsers.html#crossoriginpropertydescriptormap
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#import <Crypto/Crypto.idl>
|
||||||
#import <DOM/Document.idl>
|
#import <DOM/Document.idl>
|
||||||
#import <DOM/EventHandler.idl>
|
#import <DOM/EventHandler.idl>
|
||||||
#import <DOM/EventTarget.idl>
|
#import <DOM/EventTarget.idl>
|
||||||
|
@ -44,6 +45,9 @@ interface Window : EventTarget {
|
||||||
// FIXME: Everything from here on should be shared through WindowOrWorkerGlobalScope
|
// FIXME: Everything from here on should be shared through WindowOrWorkerGlobalScope
|
||||||
// https://w3c.github.io/hr-time/#the-performance-attribute
|
// https://w3c.github.io/hr-time/#the-performance-attribute
|
||||||
[Replaceable] readonly attribute Performance performance;
|
[Replaceable] readonly attribute Performance performance;
|
||||||
|
|
||||||
|
// https://w3c.github.io/webcrypto/#crypto-interface
|
||||||
|
[SameObject] readonly attribute Crypto crypto;
|
||||||
};
|
};
|
||||||
Window includes GlobalEventHandlers;
|
Window includes GlobalEventHandlers;
|
||||||
Window includes WindowEventHandlers;
|
Window includes WindowEventHandlers;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue