2024-05-25 12:40:44 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
|
|
|
#include <LibWeb/Bindings/UserActivationPrototype.h>
|
|
|
|
#include <LibWeb/HTML/UserActivation.h>
|
|
|
|
#include <LibWeb/HTML/Window.h>
|
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DEFINE_ALLOCATOR(UserActivation);
|
2024-05-25 12:40:44 +01:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
WebIDL::ExceptionOr<GC::Ref<UserActivation>> UserActivation::construct_impl(JS::Realm& realm)
|
2024-05-25 12:40:44 +01:00
|
|
|
{
|
2024-11-14 05:50:17 +13:00
|
|
|
return realm.create<UserActivation>(realm);
|
2024-05-25 12:40:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
UserActivation::UserActivation(JS::Realm& realm)
|
|
|
|
: PlatformObject(realm)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void UserActivation::initialize(JS::Realm& realm)
|
|
|
|
{
|
|
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(UserActivation);
|
2025-04-20 16:22:57 +02:00
|
|
|
Base::initialize(realm);
|
2024-05-25 12:40:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/interaction.html#dom-useractivation-hasbeenactive
|
|
|
|
bool UserActivation::has_been_active() const
|
|
|
|
{
|
|
|
|
// The hasBeenActive getter steps are to return true if this's relevant global object has sticky activation, and false otherwise.
|
2025-01-21 09:12:05 -05:00
|
|
|
return as<HTML::Window>(relevant_global_object(*this)).has_sticky_activation();
|
2024-05-25 12:40:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/interaction.html#dom-useractivation-isactive
|
|
|
|
bool UserActivation::is_active() const
|
|
|
|
{
|
|
|
|
// The isActive getter steps are to return true if this's relevant global object has transient activation, and false otherwise.
|
2025-01-21 09:12:05 -05:00
|
|
|
return as<HTML::Window>(relevant_global_object(*this)).has_transient_activation();
|
2024-05-25 12:40:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|