mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
LibWeb: Add Window.innerWidth and Window.innerHeight
This commit is contained in:
parent
72501775a7
commit
906cccbf7f
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -84,6 +84,9 @@ private:
|
|||
|
||||
JS_DECLARE_NATIVE_GETTER(event_getter);
|
||||
|
||||
JS_DECLARE_NATIVE_GETTER(inner_width_getter);
|
||||
JS_DECLARE_NATIVE_GETTER(inner_height_getter);
|
||||
|
||||
JS_DECLARE_NATIVE_FUNCTION(alert);
|
||||
JS_DECLARE_NATIVE_FUNCTION(confirm);
|
||||
JS_DECLARE_NATIVE_FUNCTION(prompt);
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <LibWeb/DOM/Window.h>
|
||||
#include <LibWeb/HighResolutionTime/Performance.h>
|
||||
#include <LibWeb/InProcessWebView.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
@ -181,4 +182,18 @@ JS::Object* Window::create_wrapper(JS::GlobalObject& global_object)
|
|||
return &global_object;
|
||||
}
|
||||
|
||||
int Window::inner_width() const
|
||||
{
|
||||
if (!document().layout_node())
|
||||
return 0;
|
||||
return document().layout_node()->width();
|
||||
}
|
||||
|
||||
int Window::inner_height() const
|
||||
{
|
||||
if (!document().layout_node())
|
||||
return 0;
|
||||
return document().layout_node()->height();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -66,6 +66,9 @@ public:
|
|||
void clear_timeout(i32);
|
||||
void clear_interval(i32);
|
||||
|
||||
int inner_width() const;
|
||||
int inner_height() const;
|
||||
|
||||
void did_set_location_href(Badge<Bindings::LocationObject>, const URL& new_href);
|
||||
void did_call_location_reload(Badge<Bindings::LocationObject>);
|
||||
|
||||
|
|
Loading…
Reference in a new issue