From 12eca612bc146e50beb8107e893e05b92a5c1234 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Mon, 30 Jan 2023 23:38:19 +0300 Subject: Ladybird: Specify window size in layout dump mode --- Ladybird/WebContentView.cpp | 9 +++++++-- Ladybird/WebContentView.h | 2 ++ Ladybird/main.cpp | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) (limited to 'Ladybird') diff --git a/Ladybird/WebContentView.cpp b/Ladybird/WebContentView.cpp index 71666bf510..df7dab4ea3 100644 --- a/Ladybird/WebContentView.cpp +++ b/Ladybird/WebContentView.cpp @@ -448,14 +448,19 @@ void WebContentView::handle_resize() request_repaint(); } +void WebContentView::set_viewport_rect(Gfx::IntRect rect) +{ + m_viewport_rect = rect; + client().async_set_viewport_rect(rect); +} + void WebContentView::update_viewport_rect() { auto scaled_width = int(viewport()->width() / m_inverse_pixel_scaling_ratio); auto scaled_height = int(viewport()->height() / m_inverse_pixel_scaling_ratio); Gfx::IntRect rect(horizontalScrollBar()->value(), verticalScrollBar()->value(), scaled_width, scaled_height); - m_viewport_rect = rect; - client().async_set_viewport_rect(rect); + set_viewport_rect(rect); request_repaint(); } diff --git a/Ladybird/WebContentView.h b/Ladybird/WebContentView.h index 008e51b44a..7b81f64c7e 100644 --- a/Ladybird/WebContentView.h +++ b/Ladybird/WebContentView.h @@ -96,6 +96,8 @@ public: ErrorOr dump_layout_tree(); + void set_viewport_rect(Gfx::IntRect); + Gfx::IntPoint to_content(Gfx::IntPoint) const; Gfx::IntPoint to_widget(Gfx::IntPoint) const; diff --git a/Ladybird/main.cpp b/Ladybird/main.cpp index 1e8c0aa5e6..b6fa18b614 100644 --- a/Ladybird/main.cpp +++ b/Ladybird/main.cpp @@ -88,6 +88,7 @@ ErrorOr serenity_main(Main::Arguments arguments) if (dump_layout_tree) { WebContentView view({}); + view.set_viewport_rect(Gfx::IntRect({}, { 800, 600 })); view.on_load_finish = [&](auto&) { auto dump = view.dump_layout_tree().release_value_but_fixme_should_propagate_errors(); outln("{}", dump); -- cgit v1.2.3