diff --git a/Libraries/LibWeb/Painting/PaintableBox.cpp b/Libraries/LibWeb/Painting/PaintableBox.cpp index a57665399d66..6e4d6dbd0c8e 100644 --- a/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -31,6 +31,8 @@ namespace Web::Painting { +bool g_paint_viewport_scrollbars = true; + GC::Ref PaintableWithLines::create(Layout::BlockContainer const& block_container) { return block_container.heap().allocate(block_container); @@ -381,13 +383,15 @@ void PaintableBox::paint(PaintContext& context, PaintPhase phase) const } } - auto scrollbar_width = computed_values().scrollbar_width(); - if (phase == PaintPhase::Overlay && scrollbar_width != CSS::ScrollbarWidth::None) { - if (auto scrollbar_data = compute_scrollbar_data(ScrollDirection::Vertical); scrollbar_data.has_value()) { - context.display_list_recorder().paint_scrollbar(own_scroll_frame_id().value(), context.rounded_device_rect(scrollbar_data->thumb_rect).to_type(), scrollbar_data->scroll_length, true); - } - if (auto scrollbar_data = compute_scrollbar_data(ScrollDirection::Horizontal); scrollbar_data.has_value()) { - context.display_list_recorder().paint_scrollbar(own_scroll_frame_id().value(), context.rounded_device_rect(scrollbar_data->thumb_rect).to_type(), scrollbar_data->scroll_length, false); + if (g_paint_viewport_scrollbars || !is_viewport()) { + auto scrollbar_width = computed_values().scrollbar_width(); + if (phase == PaintPhase::Overlay && scrollbar_width != CSS::ScrollbarWidth::None) { + if (auto scrollbar_data = compute_scrollbar_data(ScrollDirection::Vertical); scrollbar_data.has_value()) { + context.display_list_recorder().paint_scrollbar(own_scroll_frame_id().value(), context.rounded_device_rect(scrollbar_data->thumb_rect).to_type(), scrollbar_data->scroll_length, true); + } + if (auto scrollbar_data = compute_scrollbar_data(ScrollDirection::Horizontal); scrollbar_data.has_value()) { + context.display_list_recorder().paint_scrollbar(own_scroll_frame_id().value(), context.rounded_device_rect(scrollbar_data->thumb_rect).to_type(), scrollbar_data->scroll_length, false); + } } } diff --git a/Libraries/LibWeb/Painting/PaintableBox.h b/Libraries/LibWeb/Painting/PaintableBox.h index 8b3c8437649f..40e35e649907 100644 --- a/Libraries/LibWeb/Painting/PaintableBox.h +++ b/Libraries/LibWeb/Painting/PaintableBox.h @@ -21,6 +21,8 @@ namespace Web::Painting { +extern bool g_paint_viewport_scrollbars; + class PaintableBox : public Paintable , public ClippableAndScrollable { GC_CELL(PaintableBox, Paintable); diff --git a/Services/WebContent/main.cpp b/Services/WebContent/main.cpp index 44a73194e680..9d49a803a246 100644 --- a/Services/WebContent/main.cpp +++ b/Services/WebContent/main.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -105,6 +106,7 @@ ErrorOr serenity_main(Main::Arguments arguments) bool force_fontconfig = false; bool collect_garbage_on_every_allocation = false; bool is_headless = false; + bool disable_scrollbar_painting = false; StringView echo_server_port_string_view {}; Core::ArgsParser args_parser; @@ -124,6 +126,7 @@ ErrorOr serenity_main(Main::Arguments arguments) 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"); + args_parser.add_option(disable_scrollbar_painting, "Don't paint horizontal or vertical viewport scrollbars", "disable-scrollbar-painting"); args_parser.add_option(echo_server_port_string_view, "Echo server port used in test internals", "echo-server-port", 0, "echo_server_port"); args_parser.add_option(is_headless, "Report that the browser is running in headless mode", "headless"); @@ -157,6 +160,8 @@ ErrorOr serenity_main(Main::Arguments arguments) Web::Fetch::Fetching::g_http_cache_enabled = true; } + Web::Painting::g_paint_viewport_scrollbars = !disable_scrollbar_painting; + if (!echo_server_port_string_view.is_empty()) { if (auto maybe_echo_server_port = echo_server_port_string_view.to_number(); maybe_echo_server_port.has_value()) Web::Internals::Internals::set_echo_server_port(maybe_echo_server_port.value());