mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:57:34 +00:00
LibWeb: Use prototype and constructor methods from new Intrinsics
This will let us remove the helpers from Window that simply defer to the Intrinsics that are hanging off the [[HostDefined]] slot on the realm
This commit is contained in:
parent
beb3519a49
commit
f1367e0e4c
10 changed files with 19 additions and 31 deletions
|
@ -21,10 +21,9 @@ AudioConstructor::AudioConstructor(JS::Realm& realm)
|
|||
void AudioConstructor::initialize(JS::Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||
NativeFunction::initialize(realm);
|
||||
|
||||
define_direct_property(vm.names.prototype, &window.cached_web_prototype("HTMLAudioElement"), 0);
|
||||
define_direct_property(vm.names.prototype, &cached_web_prototype(realm, "HTMLAudioElement"), 0);
|
||||
define_direct_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,10 +21,9 @@ ImageConstructor::ImageConstructor(JS::Realm& realm)
|
|||
void ImageConstructor::initialize(JS::Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||
NativeFunction::initialize(realm);
|
||||
|
||||
define_direct_property(vm.names.prototype, &window.cached_web_prototype("HTMLImageElement"), 0);
|
||||
NativeFunction::initialize(realm);
|
||||
define_direct_property(vm.names.prototype, &cached_web_prototype(realm, "HTMLImageElement"), 0);
|
||||
define_direct_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,10 +4,9 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/LocationConstructor.h>
|
||||
#include <LibWeb/Bindings/LocationPrototype.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::Bindings {
|
||||
|
||||
|
@ -31,10 +30,9 @@ JS::ThrowCompletionOr<JS::Object*> LocationConstructor::construct(FunctionObject
|
|||
void LocationConstructor::initialize(JS::Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||
|
||||
NativeFunction::initialize(realm);
|
||||
define_direct_property(vm.names.prototype, &window.cached_web_prototype("Location"), 0);
|
||||
define_direct_property(vm.names.prototype, &cached_web_prototype(realm, "Location"), 0);
|
||||
define_direct_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Web::Bindings {
|
|||
LocationObject::LocationObject(JS::Realm& realm)
|
||||
: PlatformObject(realm)
|
||||
{
|
||||
set_prototype(&verify_cast<HTML::Window>(realm.global_object()).cached_web_prototype("Location"));
|
||||
set_prototype(&cached_web_prototype(realm, "Location"));
|
||||
}
|
||||
|
||||
LocationObject::~LocationObject() = default;
|
||||
|
@ -315,7 +315,7 @@ JS::ThrowCompletionOr<bool> LocationObject::internal_define_own_property(JS::Pro
|
|||
}
|
||||
|
||||
// 2. Throw a "SecurityError" DOMException.
|
||||
return throw_completion(WebIDL::SecurityError::create(global_object(), String::formatted("Can't define property '{}' on cross-origin object", property_key)));
|
||||
return throw_completion(WebIDL::SecurityError::create(realm(), String::formatted("Can't define property '{}' on cross-origin object", property_key)));
|
||||
}
|
||||
|
||||
// 7.10.5.7 [[Get]] ( P, Receiver ), https://html.spec.whatwg.org/multipage/history.html#location-get
|
||||
|
@ -352,7 +352,7 @@ JS::ThrowCompletionOr<bool> LocationObject::internal_delete(JS::PropertyKey cons
|
|||
return JS::Object::internal_delete(property_key);
|
||||
|
||||
// 2. Throw a "SecurityError" DOMException.
|
||||
return throw_completion(WebIDL::SecurityError::create(global_object(), String::formatted("Can't delete property '{}' on cross-origin object", property_key)));
|
||||
return throw_completion(WebIDL::SecurityError::create(realm(), String::formatted("Can't delete property '{}' on cross-origin object", property_key)));
|
||||
}
|
||||
|
||||
// 7.10.5.10 [[OwnPropertyKeys]] ( ), https://html.spec.whatwg.org/multipage/history.html#location-ownpropertykeys
|
||||
|
|
|
@ -4,10 +4,9 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/NavigatorConstructor.h>
|
||||
#include <LibWeb/Bindings/NavigatorPrototype.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::Bindings {
|
||||
|
||||
|
@ -31,10 +30,9 @@ JS::ThrowCompletionOr<JS::Object*> NavigatorConstructor::construct(FunctionObjec
|
|||
void NavigatorConstructor::initialize(JS::Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||
|
||||
NativeFunction::initialize(realm);
|
||||
define_direct_property(vm.names.prototype, &window.cached_web_prototype("Navigator"), 0);
|
||||
define_direct_property(vm.names.prototype, &cached_web_prototype(realm, "Navigator"), 0);
|
||||
define_direct_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/NavigatorObject.h>
|
||||
#include <LibWeb/Bindings/NavigatorPrototype.h>
|
||||
#include <LibWeb/Loader/ResourceLoader.h>
|
||||
|
@ -14,7 +14,7 @@ namespace Web {
|
|||
namespace Bindings {
|
||||
|
||||
NavigatorObject::NavigatorObject(JS::Realm& realm)
|
||||
: Object(verify_cast<HTML::Window>(realm.global_object()).cached_web_prototype("Navigator"))
|
||||
: Object(cached_web_prototype(realm, "Navigator"))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -23,10 +23,9 @@ OptionConstructor::OptionConstructor(JS::Realm& realm)
|
|||
void OptionConstructor::initialize(JS::Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||
NativeFunction::initialize(realm);
|
||||
|
||||
define_direct_property(vm.names.prototype, &window.cached_web_prototype("HTMLOptionElement"), 0);
|
||||
NativeFunction::initialize(realm);
|
||||
define_direct_property(vm.names.prototype, &cached_web_prototype(realm, "HTMLOptionElement"), 0);
|
||||
define_direct_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
HTML::Window& global_object() const;
|
||||
|
||||
protected:
|
||||
PlatformObject(JS::Realm&);
|
||||
explicit PlatformObject(JS::Realm&);
|
||||
explicit PlatformObject(JS::Object& prototype);
|
||||
};
|
||||
|
||||
|
|
|
@ -4,10 +4,9 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/WindowConstructor.h>
|
||||
#include <LibWeb/Bindings/WindowPrototype.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::Bindings {
|
||||
|
||||
|
@ -31,10 +30,9 @@ JS::ThrowCompletionOr<JS::Object*> WindowConstructor::construct(FunctionObject&)
|
|||
void WindowConstructor::initialize(JS::Realm& realm)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||
|
||||
NativeFunction::initialize(realm);
|
||||
define_direct_property(vm.names.prototype, &window.cached_web_prototype("Window"), 0);
|
||||
define_direct_property(vm.names.prototype, &cached_web_prototype(realm, "Window"), 0);
|
||||
define_direct_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,12 +6,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibWeb/Bindings/EventTargetPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::Bindings {
|
||||
|
||||
|
@ -20,7 +17,7 @@ class WindowPrototype final : public JS::Object {
|
|||
|
||||
public:
|
||||
explicit WindowPrototype(JS::Realm& realm)
|
||||
: JS::Object(verify_cast<HTML::Window>(realm.global_object()).cached_web_prototype("EventTarget"))
|
||||
: JS::Object(cached_web_prototype(realm, "EventTarget"))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue