From 227151b881b57a23ae5f799ddc235c5d4d15dc8f Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Sat, 25 May 2024 12:34:17 +0100 Subject: [PATCH] LibWeb: Add getter for sticky activation --- Userland/Libraries/LibWeb/HTML/Window.cpp | 15 +++++++++++++++ Userland/Libraries/LibWeb/HTML/Window.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index 7850264d83d..28667ca2be5 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -594,6 +594,21 @@ WebIDL::ExceptionOr> Window::session_storage() return JS::NonnullGCPtr { *storage }; } +// https://html.spec.whatwg.org/multipage/interaction.html#sticky-activation +bool Window::has_sticky_activation() const +{ + // When the current high resolution time given W + auto current_time = HighResolutionTime::current_high_resolution_time(*this); + + // is greater than or equal to the last activation timestamp in W + if (current_time >= m_last_activation_timestamp) { + // W is said to have sticky activation. + return true; + } + + return false; +} + // https://html.spec.whatwg.org/multipage/interaction.html#transient-activation bool Window::has_transient_activation() const { diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h index 1b4b23534b1..1ac16f4dbef 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.h +++ b/Userland/Libraries/LibWeb/HTML/Window.h @@ -116,6 +116,9 @@ public: AnimationFrameCallbackDriver& animation_frame_callback_driver() { return m_animation_frame_callback_driver; } + // https://html.spec.whatwg.org/multipage/interaction.html#sticky-activation + bool has_sticky_activation() const; + // https://html.spec.whatwg.org/multipage/interaction.html#transient-activation bool has_transient_activation() const;