1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 21:35:06 +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)