mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 08:07:44 +00:00
LibWeb: Add --layout-test-mode
flag to HeadlessBrowser
The `layout-test-mode` flag changes the font to be SerenitySans as this is the font used for layout tests for cross-platform compatibility of tests.
This commit is contained in:
parent
af26b76e0a
commit
c719a542c5
6 changed files with 27 additions and 8 deletions
|
@ -18,7 +18,8 @@ extern DeprecatedString s_serenity_resource_root;
|
|||
|
||||
namespace Ladybird {
|
||||
|
||||
FontPluginQt::FontPluginQt()
|
||||
FontPluginQt::FontPluginQt(bool is_layout_test_mode)
|
||||
: m_is_layout_test_mode(is_layout_test_mode)
|
||||
{
|
||||
// Load the default SerenityOS fonts...
|
||||
Gfx::FontDatabase::set_default_fonts_lookup_path(DeprecatedString::formatted("{}/res/fonts", s_serenity_resource_root));
|
||||
|
@ -69,6 +70,11 @@ void FontPluginQt::update_generic_fonts()
|
|||
m_generic_font_names.resize(static_cast<size_t>(Web::Platform::GenericFont::__Count));
|
||||
|
||||
auto update_mapping = [&](Web::Platform::GenericFont generic_font, QFont::StyleHint qfont_style_hint, ReadonlySpan<DeprecatedString> fallbacks) {
|
||||
if (m_is_layout_test_mode) {
|
||||
m_generic_font_names[static_cast<size_t>(generic_font)] = "SerenitySans";
|
||||
return;
|
||||
}
|
||||
|
||||
QFont qt_font;
|
||||
qt_font.setStyleHint(qfont_style_hint);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Ladybird {
|
|||
|
||||
class FontPluginQt final : public Web::Platform::FontPlugin {
|
||||
public:
|
||||
FontPluginQt();
|
||||
FontPluginQt(bool is_layout_test_mode);
|
||||
virtual ~FontPluginQt();
|
||||
|
||||
virtual Gfx::Font& default_font() override;
|
||||
|
@ -27,6 +27,7 @@ private:
|
|||
Vector<DeprecatedString> m_generic_font_names;
|
||||
RefPtr<Gfx::Font> m_default_font;
|
||||
RefPtr<Gfx::Font> m_default_fixed_width_font;
|
||||
bool m_is_layout_test_mode { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -63,14 +63,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
Web::FrameLoader::set_default_favicon_path(DeprecatedString::formatted("{}/res/icons/16x16/app-browser.png", s_serenity_resource_root));
|
||||
|
||||
int webcontent_fd_passing_socket { -1 };
|
||||
bool is_layout_test_mode = false;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_option(webcontent_fd_passing_socket, "File descriptor of the passing socket for the WebContent connection", "webcontent-fd-passing-socket", 'c', "webcontent_fd_passing_socket");
|
||||
args_parser.add_option(is_layout_test_mode, "Is layout test mode", "layout-test-mode", 0);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
VERIFY(webcontent_fd_passing_socket >= 0);
|
||||
|
||||
Web::Platform::FontPlugin::install(*new Ladybird::FontPluginQt);
|
||||
Web::Platform::FontPlugin::install(*new Ladybird::FontPluginQt(is_layout_test_mode));
|
||||
|
||||
Web::FrameLoader::set_error_page_url(DeprecatedString::formatted("file://{}/res/html/error.html", s_serenity_resource_root));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue