mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
LibWeb/HTML: Port Window.window to IDL
This commit is contained in:
parent
eb2425040b
commit
d57876306c
3 changed files with 12 additions and 10 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -140,6 +140,8 @@ public:
|
|||
Vector<JS::NonnullGCPtr<MimeType>> pdf_viewer_mime_type_objects();
|
||||
|
||||
// JS API functions
|
||||
JS::NonnullGCPtr<WindowProxy> window() const;
|
||||
|
||||
JS::NonnullGCPtr<Navigator> navigator() const;
|
||||
|
||||
void alert(String const& message = {});
|
||||
|
@ -240,7 +242,6 @@ private:
|
|||
JS_DECLARE_NATIVE_FUNCTION(inner_width_getter);
|
||||
JS_DECLARE_NATIVE_FUNCTION(inner_height_getter);
|
||||
|
||||
JS_DECLARE_NATIVE_FUNCTION(window_getter);
|
||||
JS_DECLARE_NATIVE_FUNCTION(frames_getter);
|
||||
JS_DECLARE_NATIVE_FUNCTION(self_getter);
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#window
|
||||
[Global=Window, Exposed=Window, LegacyUnenumerableNamedProperties, UseNewAKString]
|
||||
interface Window : EventTarget {
|
||||
// the current browsing context
|
||||
[LegacyUnforgeable] readonly attribute WindowProxy window;
|
||||
|
||||
// the user agent
|
||||
readonly attribute Navigator navigator;
|
||||
[ImplementedAs=navigator] readonly attribute Navigator clientInformation; // legacy alias of .navigator
|
||||
|
|
Loading…
Add table
Reference in a new issue