LibWeb: Extract some Internals functionality to a base class

This will just allow re-using these definitions on other internal pages.
This commit is contained in:
Timothy Flynn 2025-03-16 09:32:07 -04:00 committed by Tim Flynn
commit 9dcbf5562a
Notes: github-actions[bot] 2025-03-19 14:04:52 +00:00
5 changed files with 87 additions and 37 deletions

View file

@ -0,0 +1,33 @@
/*
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/HTML/Scripting/Environments.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/Internals/InternalsBase.h>
#include <LibWeb/Page/Page.h>
namespace Web::Internals {
GC_DEFINE_ALLOCATOR(InternalsBase);
InternalsBase::InternalsBase(JS::Realm& realm)
: Bindings::PlatformObject(realm)
{
}
InternalsBase::~InternalsBase() = default;
HTML::Window& InternalsBase::window() const
{
return as<HTML::Window>(HTML::relevant_global_object(*this));
}
Page& InternalsBase::page() const
{
return window().page();
}
}