mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:57:44 +00:00
LibJS: Add define_direct_property and remove the define_property helper
This removes all usages of the non-standard define_property helper method and replaces all it's usages with the specification required alternative or with define_direct_property where appropriate.
This commit is contained in:
parent
e915155ca4
commit
a6b8291a9b
81 changed files with 246 additions and 275 deletions
|
@ -25,8 +25,8 @@ void ImageConstructor::initialize(JS::GlobalObject& global_object)
|
|||
auto& window = static_cast<WindowObject&>(global_object);
|
||||
NativeFunction::initialize(global_object);
|
||||
|
||||
define_property(vm.names.prototype, &window.ensure_web_prototype<HTMLImageElementPrototype>("HTMLImageElement"), 0);
|
||||
define_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable);
|
||||
define_direct_property(vm.names.prototype, &window.ensure_web_prototype<HTMLImageElementPrototype>("HTMLImageElement"), 0);
|
||||
define_direct_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
ImageConstructor::~ImageConstructor()
|
||||
|
|
|
@ -24,13 +24,14 @@ void NavigatorObject::initialize(JS::GlobalObject& global_object)
|
|||
languages->indexed_properties().append(js_string(heap, "en-US"));
|
||||
|
||||
// FIXME: All of these should be in Navigator's prototype and be native accessors
|
||||
define_property("appCodeName", js_string(heap, "Mozilla"));
|
||||
define_property("appName", js_string(heap, "Netscape"));
|
||||
define_property("appVersion", js_string(heap, "4.0"));
|
||||
define_property("language", languages->get(0));
|
||||
define_property("languages", languages);
|
||||
define_property("platform", js_string(heap, "SerenityOS"));
|
||||
define_property("product", js_string(heap, "Gecko"));
|
||||
u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable;
|
||||
define_direct_property("appCodeName", js_string(heap, "Mozilla"), attr);
|
||||
define_direct_property("appName", js_string(heap, "Netscape"), attr);
|
||||
define_direct_property("appVersion", js_string(heap, "4.0"), attr);
|
||||
define_direct_property("language", languages->get(0), attr);
|
||||
define_direct_property("languages", languages, attr);
|
||||
define_direct_property("platform", js_string(heap, "SerenityOS"), attr);
|
||||
define_direct_property("product", js_string(heap, "Gecko"), attr);
|
||||
|
||||
define_native_accessor("userAgent", user_agent_getter, {});
|
||||
}
|
||||
|
|
|
@ -47,9 +47,9 @@ void WindowObject::initialize_global_object()
|
|||
VERIFY(success);
|
||||
|
||||
// FIXME: These should be native accessors, not properties
|
||||
define_property("window", this, JS::Attribute::Enumerable);
|
||||
define_property("frames", this, JS::Attribute::Enumerable);
|
||||
define_property("self", this, JS::Attribute::Enumerable);
|
||||
define_direct_property("window", this, JS::Attribute::Enumerable);
|
||||
define_direct_property("frames", this, JS::Attribute::Enumerable);
|
||||
define_direct_property("self", this, JS::Attribute::Enumerable);
|
||||
define_native_accessor("top", top_getter, nullptr, JS::Attribute::Enumerable);
|
||||
define_native_accessor("parent", parent_getter, {}, JS::Attribute::Enumerable);
|
||||
define_native_accessor("document", document_getter, {}, JS::Attribute::Enumerable);
|
||||
|
@ -72,11 +72,11 @@ void WindowObject::initialize_global_object()
|
|||
// Legacy
|
||||
define_native_accessor("event", event_getter, {}, JS::Attribute::Enumerable);
|
||||
|
||||
define_property("navigator", heap().allocate<NavigatorObject>(*this, *this), JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_property("location", heap().allocate<LocationObject>(*this, *this), JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_direct_property("navigator", heap().allocate<NavigatorObject>(*this, *this), JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_direct_property("location", heap().allocate<LocationObject>(*this, *this), JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
|
||||
// WebAssembly "namespace"
|
||||
define_property("WebAssembly", heap().allocate<WebAssemblyObject>(*this, *this), JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_direct_property("WebAssembly", heap().allocate<WebAssemblyObject>(*this, *this), JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
|
||||
ADD_WINDOW_OBJECT_INTERFACES;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
return *it->value;
|
||||
auto* constructor = heap().allocate<T>(*this, *this);
|
||||
m_constructors.set(class_name, constructor);
|
||||
define_property(class_name, JS::Value(constructor), JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||
define_direct_property(class_name, JS::Value(constructor), JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||
return *constructor;
|
||||
}
|
||||
|
||||
|
|
|
@ -226,12 +226,12 @@
|
|||
#include <LibWeb/Bindings/XMLHttpRequestEventTargetPrototype.h>
|
||||
#include <LibWeb/Bindings/XMLHttpRequestPrototype.h>
|
||||
|
||||
#define ADD_WINDOW_OBJECT_CONSTRUCTOR_AND_PROTOTYPE(interface_name, constructor_name, prototype_name) \
|
||||
{ \
|
||||
auto& constructor = ensure_web_constructor<constructor_name>(#interface_name); \
|
||||
constructor.define_property(vm.names.name, js_string(vm, #interface_name), JS::Attribute::Configurable); \
|
||||
auto& prototype = ensure_web_prototype<prototype_name>(#interface_name); \
|
||||
prototype.define_property(vm.names.constructor, &constructor, JS::Attribute::Writable | JS::Attribute::Configurable); \
|
||||
#define ADD_WINDOW_OBJECT_CONSTRUCTOR_AND_PROTOTYPE(interface_name, constructor_name, prototype_name) \
|
||||
{ \
|
||||
auto& constructor = ensure_web_constructor<constructor_name>(#interface_name); \
|
||||
constructor.define_direct_property(vm.names.name, js_string(vm, #interface_name), JS::Attribute::Configurable); \
|
||||
auto& prototype = ensure_web_prototype<prototype_name>(#interface_name); \
|
||||
prototype.define_direct_property(vm.names.constructor, &constructor, JS::Attribute::Writable | JS::Attribute::Configurable); \
|
||||
}
|
||||
|
||||
#define ADD_WINDOW_OBJECT_INTERFACE(interface_name) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue