mirror of
https://github.com/RGBCube/serenity
synced 2025-07-02 19:52:07 +00:00
LibWeb: Define window.outerWidth and window.outerHeight
This commit is contained in:
parent
8cc1997f33
commit
5eeb6bbee3
2 changed files with 39 additions and 0 deletions
|
@ -524,6 +524,24 @@ int Window::screen_y() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-window-outerwidth
|
||||
int Window::outer_width() const
|
||||
{
|
||||
// The outerWidth attribute must return the width of the client window. If there is no client window this attribute must return zero.
|
||||
if (auto* page = this->page())
|
||||
return page->window_size().width();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-window-screeny
|
||||
int Window::outer_height() const
|
||||
{
|
||||
// The outerHeight attribute must return the height of the client window. If there is no client window this attribute must return zero.
|
||||
if (auto* page = this->page())
|
||||
return page->window_size().height();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webstorage.html#dom-localstorage
|
||||
JS::NonnullGCPtr<HTML::Storage> Window::local_storage()
|
||||
{
|
||||
|
@ -787,6 +805,9 @@ void Window::initialize_web_interfaces(Badge<WindowEnvironmentSettingsObject>)
|
|||
define_native_accessor(realm, "screenLeft", screen_left_getter, {}, attr);
|
||||
define_native_accessor(realm, "screenTop", screen_top_getter, {}, attr);
|
||||
|
||||
define_native_accessor(realm, "outerWidth", outer_width_getter, {}, attr);
|
||||
define_native_accessor(realm, "outerHeight", outer_height_getter, {}, attr);
|
||||
|
||||
define_direct_property("CSS", heap().allocate<Bindings::CSSNamespace>(realm, realm), 0);
|
||||
|
||||
define_native_accessor(realm, "localStorage", local_storage_getter, {}, attr);
|
||||
|
@ -1423,6 +1444,18 @@ JS_DEFINE_NATIVE_FUNCTION(Window::screen_y_getter)
|
|||
return JS::Value(impl->screen_y());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(Window::outer_width_getter)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
return JS::Value(impl->outer_width());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(Window::outer_height_getter)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
return JS::Value(impl->outer_height());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(Window::post_message)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue