mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:17:35 +00:00
LibWeb+WebContent: Move Serenity EventLoop and Font plugins into LibWeb
These are exactly what's wanted by headless-browser too, so this saves us some duplication. LibWeb already links LibCore so it should not cause any issues for Ladybird.
This commit is contained in:
parent
69dd158f91
commit
6b2a916069
9 changed files with 30 additions and 30 deletions
|
@ -356,9 +356,12 @@ set(SOURCES
|
||||||
Painting/StackingContext.cpp
|
Painting/StackingContext.cpp
|
||||||
Painting/TextPaintable.cpp
|
Painting/TextPaintable.cpp
|
||||||
Platform/EventLoopPlugin.cpp
|
Platform/EventLoopPlugin.cpp
|
||||||
|
Platform/EventLoopPluginSerenity.cpp
|
||||||
Platform/FontPlugin.cpp
|
Platform/FontPlugin.cpp
|
||||||
|
Platform/FontPluginSerenity.cpp
|
||||||
Platform/ImageCodecPlugin.cpp
|
Platform/ImageCodecPlugin.cpp
|
||||||
Platform/Timer.cpp
|
Platform/Timer.cpp
|
||||||
|
Platform/TimerSerenity.cpp
|
||||||
RequestIdleCallback/IdleDeadline.cpp
|
RequestIdleCallback/IdleDeadline.cpp
|
||||||
ResizeObserver/ResizeObserver.cpp
|
ResizeObserver/ResizeObserver.cpp
|
||||||
SVG/AttributeNames.cpp
|
SVG/AttributeNames.cpp
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "EventLoopPluginSerenity.h"
|
#include "EventLoopPluginSerenity.h"
|
||||||
#include "TimerSerenity.h"
|
|
||||||
#include <AK/Function.h>
|
#include <AK/Function.h>
|
||||||
#include <AK/NonnullRefPtr.h>
|
#include <AK/NonnullRefPtr.h>
|
||||||
#include <LibCore/EventLoop.h>
|
#include <LibCore/EventLoop.h>
|
||||||
|
#include <LibWeb/Platform/TimerSerenity.h>
|
||||||
|
|
||||||
namespace WebContent {
|
namespace Web::Platform {
|
||||||
|
|
||||||
EventLoopPluginSerenity::EventLoopPluginSerenity() = default;
|
EventLoopPluginSerenity::EventLoopPluginSerenity() = default;
|
||||||
EventLoopPluginSerenity::~EventLoopPluginSerenity() = default;
|
EventLoopPluginSerenity::~EventLoopPluginSerenity() = default;
|
||||||
|
@ -26,7 +26,7 @@ void EventLoopPluginSerenity::deferred_invoke(Function<void()> function)
|
||||||
Core::deferred_invoke(move(function));
|
Core::deferred_invoke(move(function));
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Web::Platform::Timer> EventLoopPluginSerenity::create_timer()
|
NonnullRefPtr<Timer> EventLoopPluginSerenity::create_timer()
|
||||||
{
|
{
|
||||||
return TimerSerenity::create();
|
return TimerSerenity::create();
|
||||||
}
|
}
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#include <LibWeb/Platform/EventLoopPlugin.h>
|
#include <LibWeb/Platform/EventLoopPlugin.h>
|
||||||
|
|
||||||
namespace WebContent {
|
namespace Web::Platform {
|
||||||
|
|
||||||
class EventLoopPluginSerenity final : public Web::Platform::EventLoopPlugin {
|
class EventLoopPluginSerenity final : public Web::Platform::EventLoopPlugin {
|
||||||
public:
|
public:
|
||||||
|
@ -17,7 +17,7 @@ public:
|
||||||
|
|
||||||
virtual void spin_until(Function<bool()> goal_condition) override;
|
virtual void spin_until(Function<bool()> goal_condition) override;
|
||||||
virtual void deferred_invoke(Function<void()>) override;
|
virtual void deferred_invoke(Function<void()>) override;
|
||||||
virtual NonnullRefPtr<Web::Platform::Timer> create_timer() override;
|
virtual NonnullRefPtr<Timer> create_timer() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -8,7 +8,7 @@
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <LibGfx/Font/FontDatabase.h>
|
#include <LibGfx/Font/FontDatabase.h>
|
||||||
|
|
||||||
namespace WebContent {
|
namespace Web::Platform {
|
||||||
|
|
||||||
FontPluginSerenity::FontPluginSerenity()
|
FontPluginSerenity::FontPluginSerenity()
|
||||||
{
|
{
|
||||||
|
@ -26,26 +26,26 @@ Gfx::Font& FontPluginSerenity::default_fixed_width_font()
|
||||||
return Gfx::FontDatabase::default_fixed_width_font();
|
return Gfx::FontDatabase::default_fixed_width_font();
|
||||||
}
|
}
|
||||||
|
|
||||||
String FontPluginSerenity::generic_font_name(Web::Platform::GenericFont generic_font)
|
String FontPluginSerenity::generic_font_name(GenericFont generic_font)
|
||||||
{
|
{
|
||||||
// FIXME: Replace hard-coded font names with a relevant call to FontDatabase.
|
// FIXME: Replace hard-coded font names with a relevant call to FontDatabase.
|
||||||
// Currently, we cannot request the default font's name, or request it at a specific size and weight.
|
// Currently, we cannot request the default font's name, or request it at a specific size and weight.
|
||||||
// So, hard-coded font names it is.
|
// So, hard-coded font names it is.
|
||||||
switch (generic_font) {
|
switch (generic_font) {
|
||||||
case Web::Platform::GenericFont::SansSerif:
|
case GenericFont::SansSerif:
|
||||||
case Web::Platform::GenericFont::UiSansSerif:
|
case GenericFont::UiSansSerif:
|
||||||
case Web::Platform::GenericFont::Cursive:
|
case GenericFont::Cursive:
|
||||||
case Web::Platform::GenericFont::UiRounded:
|
case GenericFont::UiRounded:
|
||||||
return "Katica";
|
return "Katica";
|
||||||
case Web::Platform::GenericFont::Monospace:
|
case GenericFont::Monospace:
|
||||||
case Web::Platform::GenericFont::UiMonospace:
|
case GenericFont::UiMonospace:
|
||||||
return "Csilla";
|
return "Csilla";
|
||||||
case Web::Platform::GenericFont::Serif:
|
case GenericFont::Serif:
|
||||||
case Web::Platform::GenericFont::UiSerif:
|
case GenericFont::UiSerif:
|
||||||
return "Roman";
|
return "Roman";
|
||||||
case Web::Platform::GenericFont::Fantasy:
|
case GenericFont::Fantasy:
|
||||||
return "Comic Book";
|
return "Comic Book";
|
||||||
case Web::Platform::GenericFont::__Count:
|
case GenericFont::__Count:
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
|
@ -9,16 +9,16 @@
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibWeb/Platform/FontPlugin.h>
|
#include <LibWeb/Platform/FontPlugin.h>
|
||||||
|
|
||||||
namespace WebContent {
|
namespace Web::Platform {
|
||||||
|
|
||||||
class FontPluginSerenity final : public Web::Platform::FontPlugin {
|
class FontPluginSerenity final : public FontPlugin {
|
||||||
public:
|
public:
|
||||||
FontPluginSerenity();
|
FontPluginSerenity();
|
||||||
virtual ~FontPluginSerenity();
|
virtual ~FontPluginSerenity();
|
||||||
|
|
||||||
virtual Gfx::Font& default_font() override;
|
virtual Gfx::Font& default_font() override;
|
||||||
virtual Gfx::Font& default_fixed_width_font() override;
|
virtual Gfx::Font& default_fixed_width_font() override;
|
||||||
virtual String generic_font_name(Web::Platform::GenericFont) override;
|
virtual String generic_font_name(GenericFont) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -8,7 +8,7 @@
|
||||||
#include <AK/NonnullRefPtr.h>
|
#include <AK/NonnullRefPtr.h>
|
||||||
#include <LibCore/Timer.h>
|
#include <LibCore/Timer.h>
|
||||||
|
|
||||||
namespace WebContent {
|
namespace Web::Platform {
|
||||||
|
|
||||||
NonnullRefPtr<TimerSerenity> TimerSerenity::create()
|
NonnullRefPtr<TimerSerenity> TimerSerenity::create()
|
||||||
{
|
{
|
|
@ -10,9 +10,9 @@
|
||||||
#include <LibCore/Forward.h>
|
#include <LibCore/Forward.h>
|
||||||
#include <LibWeb/Platform/Timer.h>
|
#include <LibWeb/Platform/Timer.h>
|
||||||
|
|
||||||
namespace WebContent {
|
namespace Web::Platform {
|
||||||
|
|
||||||
class TimerSerenity final : public Web::Platform::Timer {
|
class TimerSerenity final : public Timer {
|
||||||
public:
|
public:
|
||||||
static NonnullRefPtr<TimerSerenity> create();
|
static NonnullRefPtr<TimerSerenity> create();
|
||||||
|
|
|
@ -10,11 +10,8 @@ compile_ipc(WebContentClient.ipc WebContentClientEndpoint.h)
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
ConnectionFromClient.cpp
|
ConnectionFromClient.cpp
|
||||||
ConsoleGlobalObject.cpp
|
ConsoleGlobalObject.cpp
|
||||||
EventLoopPluginSerenity.cpp
|
|
||||||
FontPluginSerenity.cpp
|
|
||||||
ImageCodecPluginSerenity.cpp
|
ImageCodecPluginSerenity.cpp
|
||||||
PageHost.cpp
|
PageHost.cpp
|
||||||
TimerSerenity.cpp
|
|
||||||
WebContentClientEndpoint.h
|
WebContentClientEndpoint.h
|
||||||
WebContentConsoleClient.cpp
|
WebContentConsoleClient.cpp
|
||||||
WebContentServerEndpoint.h
|
WebContentServerEndpoint.h
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "EventLoopPluginSerenity.h"
|
|
||||||
#include "FontPluginSerenity.h"
|
|
||||||
#include "ImageCodecPluginSerenity.h"
|
#include "ImageCodecPluginSerenity.h"
|
||||||
#include <LibCore/EventLoop.h>
|
#include <LibCore/EventLoop.h>
|
||||||
#include <LibCore/LocalServer.h>
|
#include <LibCore/LocalServer.h>
|
||||||
|
@ -14,6 +12,8 @@
|
||||||
#include <LibMain/Main.h>
|
#include <LibMain/Main.h>
|
||||||
#include <LibWeb/Loader/ResourceLoader.h>
|
#include <LibWeb/Loader/ResourceLoader.h>
|
||||||
#include <LibWeb/Platform/EventLoopPlugin.h>
|
#include <LibWeb/Platform/EventLoopPlugin.h>
|
||||||
|
#include <LibWeb/Platform/EventLoopPluginSerenity.h>
|
||||||
|
#include <LibWeb/Platform/FontPluginSerenity.h>
|
||||||
#include <LibWeb/WebSockets/WebSocket.h>
|
#include <LibWeb/WebSockets/WebSocket.h>
|
||||||
#include <LibWebView/RequestServerAdapter.h>
|
#include <LibWebView/RequestServerAdapter.h>
|
||||||
#include <LibWebView/WebSocketClientAdapter.h>
|
#include <LibWebView/WebSocketClientAdapter.h>
|
||||||
|
@ -30,9 +30,9 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
||||||
TRY(Core::System::unveil("/tmp/user/%uid/portal/websocket", "rw"));
|
TRY(Core::System::unveil("/tmp/user/%uid/portal/websocket", "rw"));
|
||||||
TRY(Core::System::unveil(nullptr, nullptr));
|
TRY(Core::System::unveil(nullptr, nullptr));
|
||||||
|
|
||||||
Web::Platform::EventLoopPlugin::install(*new WebContent::EventLoopPluginSerenity);
|
Web::Platform::EventLoopPlugin::install(*new Web::Platform::EventLoopPluginSerenity);
|
||||||
Web::Platform::ImageCodecPlugin::install(*new WebContent::ImageCodecPluginSerenity);
|
Web::Platform::ImageCodecPlugin::install(*new WebContent::ImageCodecPluginSerenity);
|
||||||
Web::Platform::FontPlugin::install(*new WebContent::FontPluginSerenity);
|
Web::Platform::FontPlugin::install(*new Web::Platform::FontPluginSerenity);
|
||||||
|
|
||||||
Web::WebSockets::WebSocketClientManager::initialize(TRY(WebView::WebSocketClientManagerAdapter::try_create()));
|
Web::WebSockets::WebSocketClientManager::initialize(TRY(WebView::WebSocketClientManagerAdapter::try_create()));
|
||||||
Web::ResourceLoader::initialize(TRY(WebView::RequestServerAdapter::try_create()));
|
Web::ResourceLoader::initialize(TRY(WebView::RequestServerAdapter::try_create()));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue