mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
26a7ea0e0f
This patch brings over the WebContent process over from SerenityOS to Ladybird, along with a new WebContentView widget that renders web content in a separate process. There's a lot of jank and FIXME material here, notably I had to re-add manually pumped Core::EventLoop instances on both sides, in order to get the IPC protocol running. This introduces a lot of latency and we should work towards replacing those loops with improved abstractions. The WebContent process is built separately here (not part of Lagom) and we provide our own main.cpp for it. Like everything, this can be better architected, it's just a starting point. :^)
56 lines
1.6 KiB
C++
56 lines
1.6 KiB
C++
/*
|
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include "BrowserWindow.h"
|
|
#include "Settings.h"
|
|
#include "Utilities.h"
|
|
#include "WebContentView.h"
|
|
#include <AK/LexicalPath.h>
|
|
#include <LibCore/ArgsParser.h>
|
|
#include <LibCore/EventLoop.h>
|
|
#include <LibCore/File.h>
|
|
#include <LibCore/Timer.h>
|
|
#include <LibGfx/Font/FontDatabase.h>
|
|
#include <LibMain/Main.h>
|
|
#include <QApplication>
|
|
#include <QTimer>
|
|
#include <QWidget>
|
|
|
|
Browser::Settings* s_settings;
|
|
extern String s_serenity_resource_root;
|
|
|
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|
{
|
|
platform_init();
|
|
|
|
// NOTE: We only instantiate this to ensure that Gfx::FontDatabase has its default queries initialized.
|
|
Gfx::FontDatabase::set_default_font_query("Katica 10 400 0");
|
|
Gfx::FontDatabase::set_fixed_width_font_query("Csilla 10 400 0");
|
|
|
|
// NOTE: This is only used for the Core::Socket inside the IPC connections.
|
|
// FIXME: Refactor things so we can get rid of this somehow.
|
|
Core::EventLoop event_loop;
|
|
|
|
QApplication app(arguments.argc, arguments.argv);
|
|
|
|
String url;
|
|
Core::ArgsParser args_parser;
|
|
args_parser.set_general_help("The Ladybird web browser :^)");
|
|
args_parser.add_positional_argument(url, "URL to open", "url", Core::ArgsParser::Required::No);
|
|
args_parser.parse(arguments);
|
|
|
|
BrowserWindow window;
|
|
s_settings = new Browser::Settings(&window);
|
|
window.setWindowTitle("Ladybird");
|
|
window.resize(800, 600);
|
|
window.show();
|
|
|
|
if (!url.is_empty()) {
|
|
window.view().load(url);
|
|
}
|
|
|
|
return app.exec();
|
|
}
|