mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWebView+UI: Migrate some UI process init to LibWebView
No need to do this setup in every UI's main().
This commit is contained in:
Notes:
github-actions[bot]
2025-06-11 11:27:28 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/39da2d9a2fb Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5054
@@ -24,6 +24,10 @@
|
||||
#include <LibWebView/Utilities.h>
|
||||
#include <LibWebView/WebContentClient.h>
|
||||
|
||||
#if defined(AK_OS_MACOS)
|
||||
# include <LibWebView/MachPortServer.h>
|
||||
#endif
|
||||
|
||||
namespace WebView {
|
||||
|
||||
Application* Application::s_the = nullptr;
|
||||
@@ -46,7 +50,7 @@ struct ApplicationSettingsObserver : public SettingsObserver {
|
||||
}
|
||||
};
|
||||
|
||||
Application::Application()
|
||||
Application::Application(Optional<ByteString> ladybird_binary_path)
|
||||
: m_settings(Settings::create({}))
|
||||
{
|
||||
VERIFY(!s_the);
|
||||
@@ -73,6 +77,8 @@ Application::Application()
|
||||
m_process_manager.on_process_exited = [this](Process&& process) {
|
||||
process_did_exit(move(process));
|
||||
};
|
||||
|
||||
platform_init(move(ladybird_binary_path));
|
||||
}
|
||||
|
||||
Application::~Application()
|
||||
@@ -83,16 +89,30 @@ Application::~Application()
|
||||
s_the = nullptr;
|
||||
}
|
||||
|
||||
void Application::initialize(Main::Arguments const& arguments)
|
||||
ErrorOr<void> Application::initialize(Main::Arguments const& arguments)
|
||||
{
|
||||
TRY(handle_attached_debugger());
|
||||
m_arguments = arguments;
|
||||
|
||||
#ifndef AK_OS_WINDOWS
|
||||
#if !defined(AK_OS_WINDOWS)
|
||||
// Increase the open file limit, as the default limits on Linux cause us to run out of file descriptors with around 15 tabs open.
|
||||
if (auto result = Core::System::set_resource_limits(RLIMIT_NOFILE, 8192); result.is_error())
|
||||
warnln("Unable to increase open file limit: {}", result.error());
|
||||
#endif
|
||||
|
||||
#if defined(AK_OS_MACOS)
|
||||
m_mach_port_server = make<MachPortServer>();
|
||||
set_mach_server_name(m_mach_port_server->server_port_name());
|
||||
|
||||
m_mach_port_server->on_receive_child_mach_port = [this](auto pid, auto port) {
|
||||
set_process_mach_port(pid, move(port));
|
||||
};
|
||||
m_mach_port_server->on_receive_backing_stores = [](MachPortServer::BackingStoresMessage message) {
|
||||
if (auto view = WebContentClient::view_for_pid_and_page_id(message.pid, message.page_id); view.has_value())
|
||||
view->did_allocate_iosurface_backing_stores(message.front_backing_store_id, move(message.front_backing_store_port), message.back_backing_store_id, move(message.back_backing_store_port));
|
||||
};
|
||||
#endif
|
||||
|
||||
Vector<ByteString> raw_urls;
|
||||
Vector<ByteString> certificates;
|
||||
Optional<HeadlessMode> headless_mode;
|
||||
@@ -256,6 +276,9 @@ void Application::initialize(Main::Arguments const& arguments)
|
||||
create_platform_options(m_browser_options, m_web_content_options);
|
||||
|
||||
m_event_loop = create_platform_event_loop();
|
||||
TRY(launch_services());
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<NonnullRefPtr<WebContentClient>> create_web_content_client(Optional<ViewImplementation&> view)
|
||||
|
||||
Reference in New Issue
Block a user