1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:18:11 +00:00

LibWeb/HTML: Port Window.window to IDL

This commit is contained in:
Linus Groh 2023-03-05 18:36:43 +00:00
parent eb2425040b
commit d57876306c
3 changed files with 12 additions and 10 deletions

View file

@ -1092,7 +1092,6 @@ WebIDL::ExceptionOr<void> Window::initialize_web_interfaces(Badge<WindowEnvironm
// FIXME: These should be native accessors, not properties
define_native_accessor(realm, "top", top_getter, nullptr, JS::Attribute::Enumerable);
define_native_accessor(realm, "window", window_getter, {}, JS::Attribute::Enumerable);
define_native_accessor(realm, "frames", frames_getter, {}, JS::Attribute::Enumerable);
define_native_accessor(realm, "self", self_getter, {}, JS::Attribute::Enumerable);
define_native_accessor(realm, "parent", parent_getter, {}, JS::Attribute::Enumerable);
@ -1204,6 +1203,13 @@ static JS::ThrowCompletionOr<HTML::Window*> impl_from(JS::VM& vm)
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "Window");
}
// https://html.spec.whatwg.org/multipage/window-object.html#dom-window
JS::NonnullGCPtr<WindowProxy> Window::window() const
{
// The window, frames, and self getter steps are to return this's relevant realm.[[GlobalEnv]].[[GlobalThisValue]].
return verify_cast<WindowProxy>(relevant_realm(*this).global_environment().global_this_value());
}
// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator
JS::NonnullGCPtr<Navigator> Window::navigator() const
{
@ -1532,14 +1538,6 @@ JS_DEFINE_NATIVE_FUNCTION(Window::self_getter)
return &relevant_realm(*impl).global_environment().global_this_value();
}
// https://html.spec.whatwg.org/multipage/window-object.html#dom-window
JS_DEFINE_NATIVE_FUNCTION(Window::window_getter)
{
auto* impl = TRY(impl_from(vm));
// The window, frames, and self getter steps are to return this's relevant realm.[[GlobalEnv]].[[GlobalThisValue]].
return &relevant_realm(*impl).global_environment().global_this_value();
}
// https://html.spec.whatwg.org/multipage/window-object.html#dom-frames
JS_DEFINE_NATIVE_FUNCTION(Window::frames_getter)
{