mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-05 16:41:52 +00:00
LibWeb: Implement BarProp properties for Window
This commit is contained in:
parent
ad634897b8
commit
b66e7ac1ba
Notes:
github-actions[bot]
2025-03-29 02:36:35 +00:00
Author: https://github.com/Totto16
Commit: b66e7ac1ba
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3810
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/tcl3 ✅
13 changed files with 201 additions and 0 deletions
47
Libraries/LibWeb/HTML/BarProp.cpp
Normal file
47
Libraries/LibWeb/HTML/BarProp.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2025, the Ladybird developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/BarPropPrototype.h>
|
||||
#include <LibWeb/HTML/BarProp.h>
|
||||
#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);
|
||||
auto* browsing_context = as<HTML::Window>(global_object).associated_document().browsing_context();
|
||||
|
||||
// 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.
|
||||
return browsing_context->top_level_browsing_context()->is_popup() != TokenizedFeature::Popup::Yes;
|
||||
}
|
||||
|
||||
void BarProp::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(BarProp);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue