Skip to content

Commit

Permalink
LibWebView: Add an option to disable painting viewport scrollbars
Browse files Browse the repository at this point in the history
  • Loading branch information
tcl3 committed Jan 14, 2025
1 parent 0c1be60 commit edd713a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Libraries/LibWebView/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ void Application::initialize(Main::Arguments const& arguments, URL::URL new_tab_
bool force_cpu_painting = false;
bool force_fontconfig = false;
bool collect_garbage_on_every_allocation = false;
bool disable_scrollbar_painting = false;

Core::ArgsParser args_parser;
args_parser.set_general_help("The Ladybird web browser :^)");
Expand All @@ -104,6 +105,7 @@ void Application::initialize(Main::Arguments const& arguments, URL::URL new_tab_
args_parser.add_option(force_cpu_painting, "Force CPU painting", "force-cpu-painting");
args_parser.add_option(force_fontconfig, "Force using fontconfig for font loading", "force-fontconfig");
args_parser.add_option(collect_garbage_on_every_allocation, "Collect garbage after every JS heap allocation", "collect-garbage-on-every-allocation", 'g');
args_parser.add_option(disable_scrollbar_painting, "Don't paint horizontal or vertical scrollbars on the main viewport", "disable-scrollbar-painting");
args_parser.add_option(dns_server_address, "Set the DNS server address", "dns-server", 0, "host|address");
args_parser.add_option(dns_server_port, "Set the DNS server port", "dns-port", 0, "port (default: 53 or 853 if --dot)");
args_parser.add_option(use_dns_over_tls, "Use DNS over TLS", "dot");
Expand Down Expand Up @@ -171,6 +173,7 @@ void Application::initialize(Main::Arguments const& arguments, URL::URL new_tab_
.force_fontconfig = force_fontconfig ? ForceFontconfig::Yes : ForceFontconfig::No,
.enable_autoplay = enable_autoplay ? EnableAutoplay::Yes : EnableAutoplay::No,
.collect_garbage_on_every_allocation = collect_garbage_on_every_allocation ? CollectGarbageOnEveryAllocation::Yes : CollectGarbageOnEveryAllocation::No,
.paint_viewport_scrollbars = disable_scrollbar_painting ? PaintViewportScrollbars::No : PaintViewportScrollbars::Yes,
};

create_platform_options(m_chrome_options, m_web_content_options);
Expand Down
2 changes: 2 additions & 0 deletions Libraries/LibWebView/HelperProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(
arguments.append("--collect-garbage-on-every-allocation"sv);
if (web_content_options.is_headless == WebView::IsHeadless::Yes)
arguments.append("--headless"sv);
if (web_content_options.paint_viewport_scrollbars == PaintViewportScrollbars::No)
arguments.append("--disable-scrollbar-painting"sv);

if (auto const maybe_echo_server_port = web_content_options.echo_server_port; maybe_echo_server_port.has_value()) {
arguments.append("--echo-server-port"sv);
Expand Down
6 changes: 6 additions & 0 deletions Libraries/LibWebView/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ enum class IsHeadless {
Yes,
};

enum class PaintViewportScrollbars {
Yes,
No,
};

struct WebContentOptions {
String command_line;
String executable_path;
Expand All @@ -134,6 +139,7 @@ struct WebContentOptions {
CollectGarbageOnEveryAllocation collect_garbage_on_every_allocation { CollectGarbageOnEveryAllocation::No };
Optional<u16> echo_server_port {};
IsHeadless is_headless { IsHeadless::No };
PaintViewportScrollbars paint_viewport_scrollbars { PaintViewportScrollbars::Yes };
};

}

0 comments on commit edd713a

Please sign in to comment.