mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 22:38:13 +00:00
LibJS+LibWeb: Replace GlobalObject with Realm in object constructors
No functional changes - we can still very easily get to the global object via `Realm::global_object()`. This is in preparation of moving the intrinsics to the realm and no longer having to pass a global object when allocating any object. In a few (now, and many more in subsequent commits) places we get a realm using `GlobalObject::associated_realm()`, this is intended to be temporary. For example, create() functions will later receive the same treatment and are passed a realm instead of a global object.
This commit is contained in:
parent
4c300cc5e8
commit
ecd163bdf1
315 changed files with 592 additions and 554 deletions
|
@ -63,6 +63,8 @@ void WindowObject::initialize_global_object()
|
|||
|
||||
Object::set_prototype(&ensure_web_prototype<WindowPrototype>("Window"));
|
||||
|
||||
auto& realm = *associated_realm();
|
||||
|
||||
// FIXME: These should be native accessors, not properties
|
||||
define_direct_property("window", this, JS::Attribute::Enumerable);
|
||||
define_direct_property("frames", this, JS::Attribute::Enumerable);
|
||||
|
@ -117,7 +119,7 @@ void WindowObject::initialize_global_object()
|
|||
define_native_accessor("screenLeft", screen_left_getter, {}, attr);
|
||||
define_native_accessor("screenTop", screen_top_getter, {}, attr);
|
||||
|
||||
define_direct_property("CSS", heap().allocate<CSSNamespace>(*this, *this), 0);
|
||||
define_direct_property("CSS", heap().allocate<CSSNamespace>(*this, realm), 0);
|
||||
|
||||
define_native_accessor("localStorage", local_storage_getter, {}, attr);
|
||||
define_native_accessor("sessionStorage", session_storage_getter, {}, attr);
|
||||
|
@ -126,9 +128,9 @@ void WindowObject::initialize_global_object()
|
|||
// Legacy
|
||||
define_native_accessor("event", event_getter, event_setter, JS::Attribute::Enumerable);
|
||||
|
||||
m_location_object = heap().allocate<LocationObject>(*this, *this);
|
||||
m_location_object = heap().allocate<LocationObject>(*this, realm);
|
||||
|
||||
auto* m_navigator_object = heap().allocate<NavigatorObject>(*this, *this);
|
||||
auto* m_navigator_object = heap().allocate<NavigatorObject>(*this, realm);
|
||||
define_direct_property("navigator", m_navigator_object, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_direct_property("clientInformation", m_navigator_object, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
|
||||
|
@ -136,7 +138,7 @@ void WindowObject::initialize_global_object()
|
|||
define_native_accessor("location", location_getter, location_setter, JS::Attribute::Enumerable);
|
||||
|
||||
// WebAssembly "namespace"
|
||||
define_direct_property("WebAssembly", heap().allocate<WebAssemblyObject>(*this, *this), JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_direct_property("WebAssembly", heap().allocate<WebAssemblyObject>(*this, realm), JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
|
||||
// HTML::GlobalEventHandlers and HTML::WindowEventHandlers
|
||||
#define __ENUMERATE(attribute, event_name) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue