mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:37:45 +00:00
LibWeb: Add an interface to be notified of Document state changes
Some HTML elements, e.g. HTMLMediaElement, need to take action when the document becomes inactive.
This commit is contained in:
parent
88b8969443
commit
f78eadf00f
6 changed files with 92 additions and 1 deletions
31
Userland/Libraries/LibWeb/DOM/DocumentObserver.h
Normal file
31
Userland/Libraries/LibWeb/DOM/DocumentObserver.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/SafeFunction.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
class DocumentObserver final : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(DocumentObserver, Bindings::PlatformObject);
|
||||
|
||||
public:
|
||||
JS::SafeFunction<void()> document_became_inactive;
|
||||
|
||||
private:
|
||||
explicit DocumentObserver(JS::Realm&, DOM::Document&);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
virtual void finalize() override;
|
||||
|
||||
JS::NonnullGCPtr<DOM::Document> m_document;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue