LibWeb/HTML: Port Window.self to IDL
This commit is contained in:
parent
d57876306c
commit
437a7c977e
Notes:
sideshowbarker
2024-07-17 02:06:40 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/437a7c977e Pull-request: https://github.com/SerenityOS/serenity/pull/17752 Reviewed-by: https://github.com/awesomekling
3 changed files with 9 additions and 10 deletions
Userland/Libraries/LibWeb/HTML
|
@ -1093,7 +1093,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, "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);
|
||||
define_native_accessor(realm, "document", document_getter, {}, JS::Attribute::Enumerable);
|
||||
define_native_accessor(realm, "frameElement", frame_element_getter, {}, JS::Attribute::Enumerable);
|
||||
|
@ -1210,6 +1209,13 @@ JS::NonnullGCPtr<WindowProxy> Window::window() const
|
|||
return verify_cast<WindowProxy>(relevant_realm(*this).global_environment().global_this_value());
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/window-object.html#dom-self
|
||||
JS::NonnullGCPtr<WindowProxy> Window::self() 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
|
||||
{
|
||||
|
@ -1530,14 +1536,6 @@ JS_DEFINE_NATIVE_FUNCTION(Window::top_getter)
|
|||
return browsing_context->top_level_browsing_context().window_proxy();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/window-object.html#dom-self
|
||||
JS_DEFINE_NATIVE_FUNCTION(Window::self_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)
|
||||
{
|
||||
|
|
|
@ -141,6 +141,7 @@ public:
|
|||
|
||||
// JS API functions
|
||||
JS::NonnullGCPtr<WindowProxy> window() const;
|
||||
JS::NonnullGCPtr<WindowProxy> self() const;
|
||||
|
||||
JS::NonnullGCPtr<Navigator> navigator() const;
|
||||
|
||||
|
@ -243,7 +244,6 @@ private:
|
|||
JS_DECLARE_NATIVE_FUNCTION(inner_height_getter);
|
||||
|
||||
JS_DECLARE_NATIVE_FUNCTION(frames_getter);
|
||||
JS_DECLARE_NATIVE_FUNCTION(self_getter);
|
||||
|
||||
JS_DECLARE_NATIVE_FUNCTION(parent_getter);
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
interface Window : EventTarget {
|
||||
// the current browsing context
|
||||
[LegacyUnforgeable] readonly attribute WindowProxy window;
|
||||
[Replaceable] readonly attribute WindowProxy self;
|
||||
|
||||
// the user agent
|
||||
readonly attribute Navigator navigator;
|
||||
|
|
Loading…
Add table
Reference in a new issue