1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:27:35 +00:00

LibWeb: Add Window.innerWidth and Window.innerHeight

This commit is contained in:
Andreas Kling 2021-03-16 17:22:01 +01:00
parent 72501775a7
commit 906cccbf7f
4 changed files with 39 additions and 0 deletions

View file

@ -67,6 +67,8 @@ void WindowObject::initialize()
define_property("self", this, JS::Attribute::Enumerable);
define_native_property("document", document_getter, document_setter, JS::Attribute::Enumerable);
define_native_property("performance", performance_getter, nullptr, JS::Attribute::Enumerable);
define_native_property("innerWidth", inner_width_getter, nullptr, JS::Attribute::Enumerable);
define_native_property("innerHeight", inner_height_getter, nullptr, JS::Attribute::Enumerable);
define_native_function("alert", alert);
define_native_function("confirm", confirm);
define_native_function("prompt", prompt);
@ -379,4 +381,20 @@ JS_DEFINE_NATIVE_GETTER(WindowObject::event_getter)
return wrap(global_object, const_cast<DOM::Event&>(*impl->current_event()));
}
JS_DEFINE_NATIVE_GETTER(WindowObject::inner_width_getter)
{
auto* impl = impl_from(vm, global_object);
if (!impl)
return {};
return JS::Value(impl->inner_width());
}
JS_DEFINE_NATIVE_GETTER(WindowObject::inner_height_getter)
{
auto* impl = impl_from(vm, global_object);
if (!impl)
return {};
return JS::Value(impl->inner_height());
}
}