mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +00:00
LibWeb: Add LocationObject::relevant_document()
https://html.spec.whatwg.org/multipage/history.html#relevant-document > A Location object has an associated relevant Document, which is this > Location object's relevant global object's browsing context's active > document, if this Location object's relevant global object's browsing > context is non-null, and null otherwise.
This commit is contained in:
parent
2f021e92a5
commit
da8525279e
2 changed files with 14 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -45,6 +46,16 @@ LocationObject::~LocationObject()
|
|||
{
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/history.html#relevant-document
|
||||
DOM::Document const* LocationObject::relevant_document() const
|
||||
{
|
||||
// A Location object has an associated relevant Document, which is this Location object's
|
||||
// relevant global object's browsing context's active document, if this Location object's
|
||||
// relevant global object's browsing context is non-null, and null otherwise.
|
||||
auto* browsing_context = static_cast<WindowObject&>(global_object()).impl().browsing_context();
|
||||
return browsing_context ? browsing_context->active_document() : nullptr;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/history.html#dom-location-href
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocationObject::href_getter)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue