mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:47:34 +00:00
LibWeb: Add Window.innerWidth and Window.innerHeight
This commit is contained in:
parent
72501775a7
commit
906cccbf7f
4 changed files with 39 additions and 0 deletions
|
@ -67,6 +67,8 @@ void WindowObject::initialize()
|
||||||
define_property("self", this, JS::Attribute::Enumerable);
|
define_property("self", this, JS::Attribute::Enumerable);
|
||||||
define_native_property("document", document_getter, document_setter, 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("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("alert", alert);
|
||||||
define_native_function("confirm", confirm);
|
define_native_function("confirm", confirm);
|
||||||
define_native_function("prompt", prompt);
|
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()));
|
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(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(alert);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(confirm);
|
JS_DECLARE_NATIVE_FUNCTION(confirm);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(prompt);
|
JS_DECLARE_NATIVE_FUNCTION(prompt);
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <LibWeb/DOM/Window.h>
|
#include <LibWeb/DOM/Window.h>
|
||||||
#include <LibWeb/HighResolutionTime/Performance.h>
|
#include <LibWeb/HighResolutionTime/Performance.h>
|
||||||
#include <LibWeb/InProcessWebView.h>
|
#include <LibWeb/InProcessWebView.h>
|
||||||
|
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/Frame.h>
|
||||||
|
|
||||||
namespace Web::DOM {
|
namespace Web::DOM {
|
||||||
|
@ -181,4 +182,18 @@ JS::Object* Window::create_wrapper(JS::GlobalObject& global_object)
|
||||||
return &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_timeout(i32);
|
||||||
void clear_interval(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_set_location_href(Badge<Bindings::LocationObject>, const URL& new_href);
|
||||||
void did_call_location_reload(Badge<Bindings::LocationObject>);
|
void did_call_location_reload(Badge<Bindings::LocationObject>);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue