summaryrefslogtreecommitdiff
path: root/Ladybird
diff options
context:
space:
mode:
Diffstat (limited to 'Ladybird')
-rw-r--r--Ladybird/EventLoopPluginQt.cpp43
-rw-r--r--Ladybird/EventLoopPluginQt.h24
-rw-r--r--Ladybird/TimerQt.cpp92
-rw-r--r--Ladybird/TimerQt.h42
-rw-r--r--Ladybird/WebContent/CMakeLists.txt2
-rw-r--r--Ladybird/WebContent/main.cpp37
-rw-r--r--Ladybird/WebContentView.cpp20
-rw-r--r--Ladybird/WebContentView.h2
8 files changed, 4 insertions, 258 deletions
diff --git a/Ladybird/EventLoopPluginQt.cpp b/Ladybird/EventLoopPluginQt.cpp
deleted file mode 100644
index fe5b28de70..0000000000
--- a/Ladybird/EventLoopPluginQt.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include "EventLoopPluginQt.h"
-#include "TimerQt.h"
-#include <AK/Function.h>
-#include <AK/NonnullRefPtr.h>
-#include <QCoreApplication>
-#include <QTimer>
-
-namespace Ladybird {
-
-EventLoopPluginQt::EventLoopPluginQt() = default;
-EventLoopPluginQt::~EventLoopPluginQt() = default;
-
-void EventLoopPluginQt::spin_until(JS::SafeFunction<bool()> goal_condition)
-{
- while (!goal_condition())
- QCoreApplication::processEvents(QEventLoop::ProcessEventsFlag::AllEvents | QEventLoop::ProcessEventsFlag::WaitForMoreEvents);
-}
-
-void EventLoopPluginQt::deferred_invoke(JS::SafeFunction<void()> function)
-{
- VERIFY(function);
- QTimer::singleShot(0, [function = move(function)] {
- function();
- });
-}
-
-NonnullRefPtr<Web::Platform::Timer> EventLoopPluginQt::create_timer()
-{
- return TimerQt::create();
-}
-
-void EventLoopPluginQt::quit()
-{
- QCoreApplication::quit();
-}
-
-}
diff --git a/Ladybird/EventLoopPluginQt.h b/Ladybird/EventLoopPluginQt.h
deleted file mode 100644
index db3c0300b9..0000000000
--- a/Ladybird/EventLoopPluginQt.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <LibWeb/Platform/EventLoopPlugin.h>
-
-namespace Ladybird {
-
-class EventLoopPluginQt final : public Web::Platform::EventLoopPlugin {
-public:
- EventLoopPluginQt();
- virtual ~EventLoopPluginQt() override;
-
- virtual void spin_until(JS::SafeFunction<bool()> goal_condition) override;
- virtual void deferred_invoke(JS::SafeFunction<void()>) override;
- virtual NonnullRefPtr<Web::Platform::Timer> create_timer() override;
- virtual void quit() override;
-};
-
-}
diff --git a/Ladybird/TimerQt.cpp b/Ladybird/TimerQt.cpp
deleted file mode 100644
index 39d6520dd2..0000000000
--- a/Ladybird/TimerQt.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include "TimerQt.h"
-#include <AK/NonnullRefPtr.h>
-#include <QTimer>
-
-namespace Ladybird {
-
-NonnullRefPtr<TimerQt> TimerQt::create()
-{
- return adopt_ref(*new TimerQt);
-}
-
-TimerQt::TimerQt()
-{
- m_timer = new QTimer;
- QObject::connect(m_timer, &QTimer::timeout, [this] {
- if (on_timeout)
- on_timeout();
- });
-}
-
-TimerQt::~TimerQt()
-{
- delete m_timer;
-}
-
-void TimerQt::start()
-{
- m_timer->start();
-}
-
-void TimerQt::start(int interval_ms)
-{
- m_timer->start(interval_ms);
-}
-
-void TimerQt::restart()
-{
- restart(interval());
-}
-
-void TimerQt::restart(int interval_ms)
-{
- if (is_active())
- stop();
- start(interval_ms);
-}
-
-void TimerQt::stop()
-{
- m_timer->stop();
-}
-
-void TimerQt::set_active(bool active)
-{
- if (active)
- m_timer->start();
- else
- m_timer->stop();
-}
-
-bool TimerQt::is_active() const
-{
- return m_timer->isActive();
-}
-
-int TimerQt::interval() const
-{
- return m_timer->interval();
-}
-
-void TimerQt::set_interval(int interval_ms)
-{
- m_timer->setInterval(interval_ms);
-}
-
-bool TimerQt::is_single_shot() const
-{
- return m_timer->isSingleShot();
-}
-
-void TimerQt::set_single_shot(bool single_shot)
-{
- m_timer->setSingleShot(single_shot);
-}
-
-}
diff --git a/Ladybird/TimerQt.h b/Ladybird/TimerQt.h
deleted file mode 100644
index 2057cf38b4..0000000000
--- a/Ladybird/TimerQt.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <LibWeb/Platform/Timer.h>
-
-class QTimer;
-
-namespace Ladybird {
-
-class TimerQt final : public Web::Platform::Timer {
-public:
- static NonnullRefPtr<TimerQt> create();
-
- virtual ~TimerQt();
-
- virtual void start() override;
- virtual void start(int interval_ms) override;
- virtual void restart() override;
- virtual void restart(int interval_ms) override;
- virtual void stop() override;
-
- virtual void set_active(bool) override;
-
- virtual bool is_active() const override;
- virtual int interval() const override;
- virtual void set_interval(int interval_ms) override;
-
- virtual bool is_single_shot() const override;
- virtual void set_single_shot(bool) override;
-
-private:
- TimerQt();
-
- QTimer* m_timer { nullptr };
-};
-
-}
diff --git a/Ladybird/WebContent/CMakeLists.txt b/Ladybird/WebContent/CMakeLists.txt
index e553a105da..d8c9c1b780 100644
--- a/Ladybird/WebContent/CMakeLists.txt
+++ b/Ladybird/WebContent/CMakeLists.txt
@@ -7,11 +7,9 @@ set(WEBCONTENT_SOURCES
${WEBCONTENT_SOURCE_DIR}/WebContentConsoleClient.cpp
${WEBCONTENT_SOURCE_DIR}/WebDriverConnection.cpp
../EventLoopImplementationQt.cpp
- ../EventLoopPluginQt.cpp
../FontPluginQt.cpp
../ImageCodecPluginLadybird.cpp
../RequestManagerQt.cpp
- ../TimerQt.cpp
../Utilities.cpp
../WebSocketClientManagerLadybird.cpp
../WebSocketLadybird.cpp
diff --git a/Ladybird/WebContent/main.cpp b/Ladybird/WebContent/main.cpp
index 1b1f2fe2b5..72b8e7326c 100644
--- a/Ladybird/WebContent/main.cpp
+++ b/Ladybird/WebContent/main.cpp
@@ -1,12 +1,10 @@
/*
- * Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2020-2023, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
-
#include "../EventLoopImplementationQt.h"
-#include "../EventLoopPluginQt.h"
#include "../FontPluginQt.h"
#include "../ImageCodecPluginLadybird.h"
#include "../RequestManagerQt.h"
@@ -25,9 +23,9 @@
#include <LibWeb/Loader/FrameLoader.h>
#include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/PermissionsPolicy/AutoplayAllowlist.h>
+#include <LibWeb/Platform/EventLoopPluginSerenity.h>
#include <LibWeb/WebSockets/WebSocket.h>
#include <QGuiApplication>
-#include <QSocketNotifier>
#include <QTimer>
#include <WebContent/ConnectionFromClient.h>
#include <WebContent/PageHost.h>
@@ -38,27 +36,6 @@ static ErrorOr<void> load_autoplay_allowlist();
extern DeprecatedString s_serenity_resource_root;
-struct DeferredInvokerQt final : IPC::DeferredInvoker {
- virtual ~DeferredInvokerQt() = default;
- virtual void schedule(Function<void()> callback) override
- {
- QTimer::singleShot(0, move(callback));
- }
-};
-
-template<typename ClientType>
-static void proxy_socket_through_notifier(ClientType& client, QSocketNotifier& notifier)
-{
- notifier.setSocket(client.socket().fd().value());
- notifier.setEnabled(true);
-
- QObject::connect(&notifier, &QSocketNotifier::activated, [&client]() mutable {
- client.socket().notifier()->on_activation();
- });
-
- client.set_deferred_invoker(make<DeferredInvokerQt>());
-}
-
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
QGuiApplication app(arguments.argc, arguments.argv);
@@ -68,7 +45,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
platform_init();
- Web::Platform::EventLoopPlugin::install(*new Ladybird::EventLoopPluginQt);
+ Web::Platform::EventLoopPlugin::install(*new Web::Platform::EventLoopPluginSerenity);
Web::Platform::ImageCodecPlugin::install(*new Ladybird::ImageCodecPluginLadybird);
Web::ResourceLoader::initialize(RequestManagerQt::create());
@@ -102,14 +79,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto webcontent_client = TRY(WebContent::ConnectionFromClient::try_create(move(webcontent_socket)));
webcontent_client->set_fd_passing_socket(TRY(Core::LocalSocket::adopt_fd(webcontent_fd_passing_socket)));
- QSocketNotifier webcontent_notifier(QSocketNotifier::Type::Read);
- proxy_socket_through_notifier(*webcontent_client, webcontent_notifier);
-
- QSocketNotifier webdriver_notifier(QSocketNotifier::Type::Read);
- webcontent_client->page_host().on_webdriver_connection = [&](auto& webdriver) {
- proxy_socket_through_notifier(webdriver, webdriver_notifier);
- };
-
return event_loop.exec();
}
diff --git a/Ladybird/WebContentView.cpp b/Ladybird/WebContentView.cpp
index 0c3e3948d7..84ca46ee62 100644
--- a/Ladybird/WebContentView.cpp
+++ b/Ladybird/WebContentView.cpp
@@ -605,27 +605,9 @@ void WebContentView::create_client(WebView::EnableCallgrindProfiling enable_call
auto candidate_web_content_paths = get_paths_for_helper_process("WebContent"sv).release_value_but_fixme_should_propagate_errors();
auto new_client = launch_web_content_process(candidate_web_content_paths, enable_callgrind_profiling).release_value_but_fixme_should_propagate_errors();
- m_web_content_notifier.setSocket(new_client->socket().fd().value());
- m_web_content_notifier.setEnabled(true);
-
- QObject::connect(&m_web_content_notifier, &QSocketNotifier::activated, [new_client = new_client.ptr()] {
- if (auto notifier = new_client->socket().notifier())
- notifier->on_activation();
- });
-
- struct DeferredInvokerQt final : IPC::DeferredInvoker {
- virtual ~DeferredInvokerQt() = default;
- virtual void schedule(Function<void()> callback) override
- {
- QTimer::singleShot(0, std::move(callback));
- }
- };
-
- new_client->set_deferred_invoker(make<DeferredInvokerQt>());
-
m_client_state.client = new_client;
m_client_state.client->on_web_content_process_crash = [this] {
- QTimer::singleShot(0, [this] {
+ Core::deferred_invoke([this] {
handle_web_content_process_crash();
});
};
diff --git a/Ladybird/WebContentView.h b/Ladybird/WebContentView.h
index 9b24cfe518..107db9195b 100644
--- a/Ladybird/WebContentView.h
+++ b/Ladybird/WebContentView.h
@@ -22,7 +22,6 @@
#include <LibWebView/ViewImplementation.h>
#include <QAbstractScrollArea>
#include <QPointer>
-#include <QSocketNotifier>
class QTextEdit;
class QLineEdit;
@@ -215,7 +214,6 @@ private:
Gfx::IntRect m_viewport_rect;
void handle_web_content_process_crash();
- QSocketNotifier m_web_content_notifier { QSocketNotifier::Type::Read };
RefPtr<Gfx::Bitmap> m_backup_bitmap;