LibWebView+UI: Do not create a QApplication in headless mode

This is causing errors on the WPT runner, which does not have a display
output. To do this requires shuffling around the Main::Arguments struct,
as we now need access to it from overridden WebView::Application methods
after construction.
This commit is contained in:
Timothy Flynn 2025-06-10 14:56:24 -04:00 committed by Tim Ledbetter
commit fa164083fd
Notes: github-actions[bot] 2025-06-10 22:11:59 +00:00
6 changed files with 64 additions and 49 deletions

View file

@ -72,9 +72,9 @@ public:
protected:
template<DerivedFrom<Application> ApplicationType>
static NonnullOwnPtr<ApplicationType> create(Main::Arguments& arguments)
static NonnullOwnPtr<ApplicationType> create(Main::Arguments const& arguments)
{
auto app = adopt_own(*new ApplicationType { {}, arguments });
auto app = adopt_own(*new ApplicationType { {} });
app->initialize(arguments);
return app;
@ -90,6 +90,8 @@ protected:
virtual Optional<ByteString> ask_user_for_download_folder() const { return {}; }
Main::Arguments& arguments() { return m_arguments; }
private:
void initialize(Main::Arguments const& arguments);
@ -134,6 +136,7 @@ private:
Settings m_settings;
OwnPtr<ApplicationSettingsObserver> m_settings_observer;
Main::Arguments m_arguments;
BrowserOptions m_browser_options;
WebContentOptions m_web_content_options;
@ -157,16 +160,16 @@ private:
}
#define WEB_VIEW_APPLICATION(ApplicationType) \
public: \
static NonnullOwnPtr<ApplicationType> create(Main::Arguments& arguments) \
{ \
return WebView::Application::create<ApplicationType>(arguments); \
} \
\
static ApplicationType& the() \
{ \
return static_cast<ApplicationType&>(WebView::Application::the()); \
} \
\
ApplicationType(Badge<WebView::Application>, Main::Arguments&);
#define WEB_VIEW_APPLICATION(ApplicationType) \
public: \
static NonnullOwnPtr<ApplicationType> create(Main::Arguments const& arguments) \
{ \
return WebView::Application::create<ApplicationType>(arguments); \
} \
\
static ApplicationType& the() \
{ \
return static_cast<ApplicationType&>(WebView::Application::the()); \
} \
\
ApplicationType(Badge<WebView::Application>);