1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:57:43 +00:00

LibWeb/HTML: Port Window.document to IDL

This commit is contained in:
Linus Groh 2023-03-05 18:54:33 +00:00
parent dcff775ab1
commit 0e587420a8
3 changed files with 10 additions and 9 deletions

View file

@ -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, "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);
define_native_accessor(realm, "name", name_getter, name_setter, JS::Attribute::Enumerable);
define_native_accessor(realm, "history", history_getter, {}, JS::Attribute::Enumerable);
@ -1215,6 +1214,13 @@ JS::NonnullGCPtr<WindowProxy> Window::self() const
return verify_cast<WindowProxy>(relevant_realm(*this).global_environment().global_this_value());
}
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-document-2
JS::NonnullGCPtr<DOM::Document const> Window::document() const
{
// The document getter steps are to return this's associated Document.
return associated_document();
}
// https://html.spec.whatwg.org/multipage/window-object.html#dom-frames
JS::NonnullGCPtr<WindowProxy> Window::frames() const
{
@ -1551,12 +1557,6 @@ JS_DEFINE_NATIVE_FUNCTION(Window::parent_getter)
return parent;
}
JS_DEFINE_NATIVE_FUNCTION(Window::document_getter)
{
auto* impl = TRY(impl_from(vm));
return &impl->associated_document();
}
// https://html.spec.whatwg.org/multipage/browsers.html#dom-frameelement
JS_DEFINE_NATIVE_FUNCTION(Window::frame_element_getter)
{

View file

@ -142,6 +142,7 @@ public:
// JS API functions
JS::NonnullGCPtr<WindowProxy> window() const;
JS::NonnullGCPtr<WindowProxy> self() const;
JS::NonnullGCPtr<DOM::Document const> document() const;
JS::NonnullGCPtr<WindowProxy> frames() const;
@ -221,8 +222,6 @@ private:
JS_DECLARE_NATIVE_FUNCTION(length_getter);
JS_DECLARE_NATIVE_FUNCTION(top_getter);
JS_DECLARE_NATIVE_FUNCTION(document_getter);
JS_DECLARE_NATIVE_FUNCTION(frame_element_getter);
JS_DECLARE_NATIVE_FUNCTION(location_getter);

View file

@ -1,3 +1,4 @@
#import <DOM/Document.idl>
#import <DOM/EventHandler.idl>
#import <DOM/EventTarget.idl>
#import <HTML/Navigator.idl>
@ -8,6 +9,7 @@ interface Window : EventTarget {
// the current browsing context
[LegacyUnforgeable] readonly attribute WindowProxy window;
[Replaceable] readonly attribute WindowProxy self;
[LegacyUnforgeable] readonly attribute Document document;
// other browsing contexts
[Replaceable] readonly attribute WindowProxy frames;