From 274411db9756a9dffe44e21b4da09c7808e9f465 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 8 Oct 2024 16:27:40 +0200 Subject: [PATCH] LibWeb: Support Document.onvisibilitychange We don't have a way to trigger this from a test, but the fix is so simple that we might as well get it in. :^) --- Userland/Libraries/LibWeb/DOM/Document.cpp | 10 ++++++++++ Userland/Libraries/LibWeb/DOM/Document.h | 3 +++ Userland/Libraries/LibWeb/DOM/Document.idl | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 3fbe3f1ba86..feea781db74 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -5676,4 +5676,14 @@ void Document::set_onreadystatechange(WebIDL::CallbackType* value) set_event_handler_attribute(HTML::EventNames::readystatechange, value); } +WebIDL::CallbackType* Document::onvisibilitychange() +{ + return event_handler_attribute(HTML::EventNames::visibilitychange); +} + +void Document::set_onvisibilitychange(WebIDL::CallbackType* value) +{ + set_event_handler_attribute(HTML::EventNames::visibilitychange, value); +} + } diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index a81fb8d70fe..dc4466681ee 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -734,6 +734,9 @@ public: [[nodiscard]] WebIDL::CallbackType* onreadystatechange(); void set_onreadystatechange(WebIDL::CallbackType*); + [[nodiscard]] WebIDL::CallbackType* onvisibilitychange(); + void set_onvisibilitychange(WebIDL::CallbackType*); + protected: virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; diff --git a/Userland/Libraries/LibWeb/DOM/Document.idl b/Userland/Libraries/LibWeb/DOM/Document.idl index 19fb2a7b7d5..10b5b1dc545 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.idl +++ b/Userland/Libraries/LibWeb/DOM/Document.idl @@ -152,7 +152,7 @@ interface Document : Node { // special event handler IDL attributes that only apply to Document objects [LegacyLenientThis] attribute EventHandler onreadystatechange; - [FIXME] attribute EventHandler onvisibilitychange; + attribute EventHandler onvisibilitychange; }; dictionary ElementCreationOptions {