mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 00:47:45 +00:00
LibJS: Remove GlobalObject parameter from native functions
This commit is contained in:
parent
7b990c27a1
commit
b465f46e00
77 changed files with 240 additions and 215 deletions
|
@ -126,7 +126,7 @@ Optional<JS::PropertyDescriptor> cross_origin_get_own_property_helper(Variant<Lo
|
|||
// 2. If IsCallable(value) is true, then set value to an anonymous built-in function, created in the current Realm Record, that performs the same steps as the IDL operation P on object O.
|
||||
if (value->is_function()) {
|
||||
value = JS::NativeFunction::create(
|
||||
realm, [function = JS::make_handle(*value)](auto& vm, auto&) {
|
||||
realm, [function = JS::make_handle(*value)](auto& vm) {
|
||||
return JS::call(vm, function.value(), JS::js_undefined());
|
||||
},
|
||||
0, "");
|
||||
|
@ -143,7 +143,7 @@ Optional<JS::PropertyDescriptor> cross_origin_get_own_property_helper(Variant<Lo
|
|||
// 2. If e.[[NeedsGet]] is true, then set crossOriginGet to an anonymous built-in function, created in the current Realm Record, that performs the same steps as the getter of the IDL attribute P on object O.
|
||||
if (*entry.needs_get) {
|
||||
cross_origin_get = JS::NativeFunction::create(
|
||||
realm, [object_ptr, getter = JS::make_handle(*original_descriptor->get)](auto& vm, auto&) {
|
||||
realm, [object_ptr, getter = JS::make_handle(*original_descriptor->get)](auto& vm) {
|
||||
return JS::call(vm, getter.cell(), object_ptr);
|
||||
},
|
||||
0, "");
|
||||
|
@ -155,7 +155,7 @@ Optional<JS::PropertyDescriptor> cross_origin_get_own_property_helper(Variant<Lo
|
|||
// If e.[[NeedsSet]] is true, then set crossOriginSet to an anonymous built-in function, created in the current Realm Record, that performs the same steps as the setter of the IDL attribute P on object O.
|
||||
if (*entry.needs_set) {
|
||||
cross_origin_set = JS::NativeFunction::create(
|
||||
realm, [object_ptr, setter = JS::make_handle(*original_descriptor->set)](auto& vm, auto&) {
|
||||
realm, [object_ptr, setter = JS::make_handle(*original_descriptor->set)](auto& vm) {
|
||||
return JS::call(vm, setter.cell(), object_ptr);
|
||||
},
|
||||
0, "");
|
||||
|
|
|
@ -95,6 +95,8 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::href_getter)
|
|||
// https://html.spec.whatwg.org/multipage/history.html#the-location-interface:dom-location-href-2
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocationObject::href_setter)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto& global_object = realm.global_object();
|
||||
auto& window = static_cast<WindowObject&>(global_object);
|
||||
|
||||
// FIXME: 1. If this's relevant Document is null, then return.
|
||||
|
@ -218,6 +220,8 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::port_getter)
|
|||
// https://html.spec.whatwg.org/multipage/history.html#dom-location-reload
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocationObject::reload)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto& global_object = realm.global_object();
|
||||
auto& window = static_cast<WindowObject&>(global_object);
|
||||
window.impl().did_call_location_reload({});
|
||||
return JS::js_undefined();
|
||||
|
@ -226,6 +230,8 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::reload)
|
|||
// https://html.spec.whatwg.org/multipage/history.html#dom-location-replace
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocationObject::replace)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto& global_object = realm.global_object();
|
||||
auto& window = static_cast<WindowObject&>(global_object);
|
||||
auto url = TRY(vm.argument(0).to_string(vm));
|
||||
// FIXME: This needs spec compliance work.
|
||||
|
|
|
@ -626,7 +626,7 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::scroll)
|
|||
// https://www.w3.org/TR/cssom-view/#dom-window-scrollby
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::scroll_by)
|
||||
{
|
||||
auto& realm = *global_object.associated_realm();
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
if (!impl->page())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue