mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
LibWebView+UI: Don't declare a magic ctor for Application subclasses
You would have to just know that you need to define the constructor with this declaration. Let's allow subclasses to define constructors as they see fit.
This commit is contained in:
parent
3a4f2faf2e
commit
b425ce93b1
Notes:
github-actions[bot]
2025-06-11 11:27:40 +00:00
Author: https://github.com/trflynn89
Commit: b425ce93b1
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5054
7 changed files with 24 additions and 33 deletions
|
@ -6,7 +6,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/Optional.h>
|
||||
|
@ -71,17 +70,10 @@ public:
|
|||
void refresh_tab_list();
|
||||
|
||||
protected:
|
||||
template<DerivedFrom<Application> ApplicationType>
|
||||
static NonnullOwnPtr<ApplicationType> create(Main::Arguments const& arguments)
|
||||
{
|
||||
auto app = adopt_own(*new ApplicationType { {} });
|
||||
app->initialize(arguments);
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
Application();
|
||||
|
||||
void initialize(Main::Arguments const&);
|
||||
|
||||
virtual void process_did_exit(Process&&);
|
||||
|
||||
virtual void create_platform_arguments(Core::ArgsParser&) { }
|
||||
|
@ -93,8 +85,6 @@ protected:
|
|||
Main::Arguments& arguments() { return m_arguments; }
|
||||
|
||||
private:
|
||||
void initialize(Main::Arguments const& arguments);
|
||||
|
||||
void launch_spare_web_content_process();
|
||||
ErrorOr<void> launch_request_server();
|
||||
ErrorOr<void> launch_image_decoder_server();
|
||||
|
@ -162,14 +152,15 @@ private:
|
|||
|
||||
#define WEB_VIEW_APPLICATION(ApplicationType) \
|
||||
public: \
|
||||
static NonnullOwnPtr<ApplicationType> create(Main::Arguments const& arguments) \
|
||||
template<typename... ApplicationArguments> \
|
||||
static NonnullOwnPtr<ApplicationType> create(Main::Arguments const& arguments, ApplicationArguments&&... application_arguments) \
|
||||
{ \
|
||||
return WebView::Application::create<ApplicationType>(arguments); \
|
||||
auto app = adopt_own(*new ApplicationType { forward<ApplicationArguments>(application_arguments)... }); \
|
||||
app->initialize(arguments); \
|
||||
return app; \
|
||||
} \
|
||||
\
|
||||
static ApplicationType& the() \
|
||||
{ \
|
||||
return static_cast<ApplicationType&>(WebView::Application::the()); \
|
||||
} \
|
||||
\
|
||||
ApplicationType(Badge<WebView::Application>);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
namespace TestWeb {
|
||||
|
||||
Application::Application(Badge<WebView::Application>)
|
||||
Application::Application()
|
||||
: test_concurrency(Core::System::hardware_concurrency())
|
||||
, python_executable_path("python3")
|
||||
{
|
||||
|
|
|
@ -17,6 +17,7 @@ class Application : public WebView::Application {
|
|||
WEB_VIEW_APPLICATION(Application)
|
||||
|
||||
public:
|
||||
explicit Application();
|
||||
~Application();
|
||||
|
||||
virtual void create_platform_arguments(Core::ArgsParser&) override;
|
||||
|
|
|
@ -16,6 +16,8 @@ class Application final : public WebView::Application {
|
|||
WEB_VIEW_APPLICATION(Application)
|
||||
|
||||
private:
|
||||
explicit Application();
|
||||
|
||||
virtual Optional<ByteString> ask_user_for_download_folder() const override;
|
||||
virtual NonnullOwnPtr<Core::EventLoop> create_platform_event_loop() override;
|
||||
};
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
|
||||
namespace Ladybird {
|
||||
|
||||
Application::Application(Badge<WebView::Application>)
|
||||
{
|
||||
}
|
||||
Application::Application() = default;
|
||||
|
||||
Optional<ByteString> Application::ask_user_for_download_folder() const
|
||||
{
|
||||
|
|
|
@ -48,10 +48,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
Application::Application(Badge<WebView::Application>)
|
||||
{
|
||||
}
|
||||
|
||||
Application::Application() = default;
|
||||
Application::~Application() = default;
|
||||
|
||||
void Application::create_platform_options(WebView::BrowserOptions&, WebView::WebContentOptions& web_content_options)
|
||||
|
|
|
@ -29,6 +29,8 @@ public:
|
|||
void set_active_window(BrowserWindow& w) { m_active_window = &w; }
|
||||
|
||||
private:
|
||||
explicit Application();
|
||||
|
||||
virtual void create_platform_options(WebView::BrowserOptions&, WebView::WebContentOptions&) override;
|
||||
virtual NonnullOwnPtr<Core::EventLoop> create_platform_event_loop() override;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue