mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibWeb/HTML: Port Window.outer{Width,Height} to IDL
This commit is contained in:
parent
80acf03278
commit
46e547d774
Notes:
sideshowbarker
2024-07-16 23:13:43 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/46e547d774 Pull-request: https://github.com/SerenityOS/serenity/pull/17752 Reviewed-by: https://github.com/awesomekling
3 changed files with 24 additions and 40 deletions
|
@ -750,24 +750,6 @@ float Window::device_pixel_ratio() const
|
|||
return 1.0f;
|
||||
}
|
||||
|
||||
// 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().value();
|
||||
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().value();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webstorage.html#dom-localstorage
|
||||
JS::NonnullGCPtr<HTML::Storage> Window::local_storage()
|
||||
{
|
||||
|
@ -996,10 +978,6 @@ WebIDL::ExceptionOr<void> Window::initialize_web_interfaces(Badge<WindowEnvironm
|
|||
|
||||
define_native_function(realm, "fetch", Bindings::fetch, 1, attr);
|
||||
|
||||
// FIXME: These properties should be [Replaceable] according to the spec, but [Writable+Configurable] is the closest we have.
|
||||
define_native_accessor(realm, "outerWidth", outer_width_getter, {}, attr);
|
||||
define_native_accessor(realm, "outerHeight", outer_height_getter, {}, attr);
|
||||
|
||||
define_direct_property("CSS", MUST_OR_THROW_OOM(heap().allocate<Bindings::CSSNamespace>(realm, realm)), 0);
|
||||
|
||||
define_native_accessor(realm, "localStorage", local_storage_getter, {}, attr);
|
||||
|
@ -1455,6 +1433,26 @@ i32 Window::screen_y() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/csswg-drafts/cssom-view/#dom-window-outerwidth
|
||||
i32 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().value();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/csswg-drafts/cssom-view/#dom-window-outerheight
|
||||
i32 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().value();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/hr-time/#dom-windoworworkerglobalscope-performance
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<HighResolutionTime::Performance>> Window::performance()
|
||||
{
|
||||
|
@ -1675,18 +1673,6 @@ JS_DEFINE_NATIVE_FUNCTION(Window::get_selection)
|
|||
return impl->associated_document().get_selection();
|
||||
}
|
||||
|
||||
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::structured_clone)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
|
|
|
@ -115,9 +115,6 @@ public:
|
|||
|
||||
float device_pixel_ratio() const;
|
||||
|
||||
int outer_width() const;
|
||||
int outer_height() const;
|
||||
|
||||
JS::NonnullGCPtr<HTML::Storage> local_storage();
|
||||
JS::NonnullGCPtr<HTML::Storage> session_storage();
|
||||
|
||||
|
@ -179,6 +176,8 @@ public:
|
|||
|
||||
i32 screen_x() const;
|
||||
i32 screen_y() const;
|
||||
i32 outer_width() const;
|
||||
i32 outer_height() const;
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<HighResolutionTime::Performance>> performance();
|
||||
|
||||
|
@ -248,9 +247,6 @@ private:
|
|||
|
||||
JS_DECLARE_NATIVE_FUNCTION(device_pixel_ratio_getter);
|
||||
|
||||
JS_DECLARE_NATIVE_FUNCTION(outer_width_getter);
|
||||
JS_DECLARE_NATIVE_FUNCTION(outer_height_getter);
|
||||
|
||||
JS_DECLARE_NATIVE_FUNCTION(structured_clone);
|
||||
|
||||
JS_DECLARE_NATIVE_FUNCTION(local_storage_getter);
|
||||
|
|
|
@ -69,6 +69,8 @@ interface Window : EventTarget {
|
|||
[Replaceable, ImplementedAs=screen_x] readonly attribute long screenLeft;
|
||||
[Replaceable] readonly attribute long screenY;
|
||||
[Replaceable, ImplementedAs=screen_y] readonly attribute long screenTop;
|
||||
[Replaceable] readonly attribute long outerWidth;
|
||||
[Replaceable] readonly attribute long outerHeight;
|
||||
|
||||
// FIXME: Everything from here on should be shared through WindowOrWorkerGlobalScope
|
||||
// https://w3c.github.io/hr-time/#the-performance-attribute
|
||||
|
|
Loading…
Reference in a new issue