ladybird/Libraries/LibWeb/HTML/NavigationObserver.cpp
Shannon Booth f87041bf3a LibGC+Everywhere: Factor out a LibGC from LibJS
Resulting in a massive rename across almost everywhere! Alongside the
namespace change, we now have the following names:

 * JS::NonnullGCPtr -> GC::Ref
 * JS::GCPtr -> GC::Ptr
 * JS::HeapFunction -> GC::Function
 * JS::CellImpl -> GC::Cell
 * JS::Handle -> GC::Root
2024-11-15 14:49:20 +01:00

43 lines
1 KiB
C++

/*
* Copyright (c) 2024, Tim Flynn <trflynn89@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Runtime/Realm.h>
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/NavigationObserver.h>
namespace Web::HTML {
GC_DEFINE_ALLOCATOR(NavigationObserver);
NavigationObserver::NavigationObserver(JS::Realm& realm, Navigable& navigable)
: Bindings::PlatformObject(realm)
, m_navigable(navigable)
{
m_navigable->register_navigation_observer({}, *this);
}
void NavigationObserver::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_navigable);
visitor.visit(m_navigation_complete);
}
void NavigationObserver::finalize()
{
Base::finalize();
m_navigable->unregister_navigation_observer({}, *this);
}
void NavigationObserver::set_navigation_complete(Function<void()> callback)
{
if (callback)
m_navigation_complete = GC::create_function(vm().heap(), move(callback));
else
m_navigation_complete = nullptr;
}
}