1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:38:12 +00:00

LibWeb: Make Window.getSelection() forward to Document.getSelection()

(And have document create the Selection object on demand.)
This commit is contained in:
Andreas Kling 2022-10-10 21:23:03 +02:00
parent b945d164e2
commit a2348ebcc0
4 changed files with 24 additions and 10 deletions

View file

@ -525,13 +525,6 @@ int Window::screen_y() const
return 0;
}
// https://w3c.github.io/selection-api/#dom-window-getselection
Selection::Selection* Window::get_selection_impl()
{
// FIXME: Implement.
return nullptr;
}
// https://html.spec.whatwg.org/multipage/webstorage.html#dom-localstorage
JS::NonnullGCPtr<HTML::Storage> Window::local_storage()
{
@ -1241,10 +1234,12 @@ JS_DEFINE_NATIVE_FUNCTION(Window::get_computed_style)
return impl->get_computed_style_impl(*static_cast<DOM::Element*>(object));
}
// https://w3c.github.io/selection-api/#dom-window-getselection
JS_DEFINE_NATIVE_FUNCTION(Window::get_selection)
{
// The method must invoke and return the result of getSelection() on this's Window.document attribute.
auto* impl = TRY(impl_from(vm));
return impl->get_selection_impl();
return impl->associated_document().get_selection();
}
JS_DEFINE_NATIVE_FUNCTION(Window::match_media)

View file

@ -102,8 +102,6 @@ public:
int screen_x() const;
int screen_y() const;
Selection::Selection* get_selection_impl();
JS::NonnullGCPtr<HTML::Storage> local_storage();
JS::NonnullGCPtr<HTML::Storage> session_storage();