ladybird/Libraries/LibWeb/HTML/NavigationObserver.h
Shannon Booth 4d64f21fa5 LibWeb: Give IDL exposed PlatformObjects an InterfaceName
By making use of the WEB_PLATFORM_OBJECT macro we can remove
the boilerplate of needing to add this override for every
serializable platform object so that we can check whether they
are exposed or not.
2026-02-14 20:22:40 +01:00

45 lines
1.3 KiB
C++

/*
* Copyright (c) 2024, Tim Flynn <trflynn89@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGC/Function.h>
#include <LibGC/Ptr.h>
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/Export.h>
#include <LibWeb/Forward.h>
namespace Web::HTML {
class WEB_API NavigationObserver final : public Bindings::PlatformObject {
WEB_NON_IDL_PLATFORM_OBJECT(NavigationObserver, Bindings::PlatformObject);
GC_DECLARE_ALLOCATOR(NavigationObserver);
public:
static constexpr bool OVERRIDES_FINALIZE = true;
[[nodiscard]] GC::Ptr<GC::Function<void()>> navigation_complete() const { return m_navigation_complete; }
void set_navigation_complete(Function<void()>);
[[nodiscard]] GC::Ptr<GC::Function<void()>> ongoing_navigation_changed() const { return m_ongoing_navigation_changed; }
void set_ongoing_navigation_changed(Function<void()>);
private:
NavigationObserver(JS::Realm&, Navigable&);
virtual void visit_edges(Cell::Visitor&) override;
virtual void finalize() override;
IntrusiveListNode<NavigationObserver> m_list_node;
GC::Ref<Navigable> m_navigable;
GC::Ptr<GC::Function<void()>> m_navigation_complete;
GC::Ptr<GC::Function<void()>> m_ongoing_navigation_changed;
public:
using NavigationObserversList = IntrusiveList<&NavigationObserver::m_list_node>;
};
}