mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-30 19:47:17 +02: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:
committed by
Andreas Kling
parent
88b8969443
commit
f78eadf00f
Notes:
sideshowbarker
2024-07-16 20:42:33 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/f78eadf00f Pull-request: https://github.com/SerenityOS/serenity/pull/18638 Reviewed-by: https://github.com/awesomekling
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;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user