mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:07:36 +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) 2020, Andreas Kling <kling@serenityos.org>
|
||||||
|
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* 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
|
// https://html.spec.whatwg.org/multipage/history.html#dom-location-href
|
||||||
JS_DEFINE_NATIVE_FUNCTION(LocationObject::href_getter)
|
JS_DEFINE_NATIVE_FUNCTION(LocationObject::href_getter)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||||
|
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -29,6 +30,8 @@ public:
|
||||||
// but we don't have the infrastructure in place to implement them yet.
|
// but we don't have the infrastructure in place to implement them yet.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
DOM::Document const* relevant_document() const;
|
||||||
|
|
||||||
JS_DECLARE_NATIVE_FUNCTION(reload);
|
JS_DECLARE_NATIVE_FUNCTION(reload);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(replace);
|
JS_DECLARE_NATIVE_FUNCTION(replace);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue