2025-03-04 18:51:08 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2025, the Ladybird developers.
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <LibJS/Runtime/Realm.h>
|
2026-04-18 05:54:06 -03:00
|
|
|
#include <LibWeb/Bindings/BarProp.h>
|
2026-02-11 03:33:58 -03:00
|
|
|
#include <LibWeb/DOM/Document.h>
|
2025-03-04 18:51:08 -03:00
|
|
|
#include <LibWeb/HTML/BarProp.h>
|
2026-02-11 03:33:58 -03:00
|
|
|
#include <LibWeb/HTML/BrowsingContext.h>
|
2025-03-04 18:51:08 -03:00
|
|
|
#include <LibWeb/HTML/Window.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
|
|
|
|
|
GC_DEFINE_ALLOCATOR(BarProp);
|
|
|
|
|
|
|
|
|
|
GC::Ref<BarProp> BarProp::create(JS::Realm& realm)
|
|
|
|
|
{
|
|
|
|
|
return realm.create<BarProp>(realm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BarProp::BarProp(JS::Realm& realm)
|
|
|
|
|
: Bindings::PlatformObject(realm)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-barprop-visible
|
|
|
|
|
bool BarProp::visible() const
|
|
|
|
|
{
|
|
|
|
|
// 1. Let browsingContext be this's relevant global object's browsing context.
|
|
|
|
|
auto& global_object = HTML::relevant_global_object(*this);
|
2025-07-17 11:26:59 -03:00
|
|
|
auto browsing_context = as<HTML::Window>(global_object).associated_document().browsing_context();
|
2025-03-04 18:51:08 -03:00
|
|
|
|
|
|
|
|
// 2. If browsingContext is null, then return true.
|
|
|
|
|
if (!browsing_context) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 3. Return the negation of browsingContext's top-level browsing context's is popup.
|
2026-06-06 16:32:28 -03:00
|
|
|
auto top_level_browsing_context = browsing_context->top_level_browsing_context();
|
|
|
|
|
if (!top_level_browsing_context)
|
|
|
|
|
return true;
|
|
|
|
|
return top_level_browsing_context->is_popup() != TokenizedFeature::Popup::Yes;
|
2025-03-04 18:51:08 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BarProp::initialize(JS::Realm& realm)
|
|
|
|
|
{
|
|
|
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(BarProp);
|
2025-04-20 11:22:57 -03:00
|
|
|
Base::initialize(realm);
|
2025-03-04 18:51:08 -03:00
|
|
|
}
|
2025-05-13 08:06:33 -03:00
|
|
|
|
2025-03-04 18:51:08 -03:00
|
|
|
}
|