diff --git a/Ladybird/WebContentView.cpp b/Ladybird/WebContentView.cpp index 71666bf510b..df7dab4ea3d 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 008e51b44ad..7b81f64c7ef 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 1e8c0aa5e6e..b6fa18b6141 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); diff --git a/Tests/LibWeb/Layout/expected/blank.txt b/Tests/LibWeb/Layout/expected/blank.txt index 2d4ca4d59db..ee749da44c0 100644 --- a/Tests/LibWeb/Layout/expected/blank.txt +++ b/Tests/LibWeb/Layout/expected/blank.txt @@ -1,6 +1,6 @@ -InitialContainingBlock <#document> at (0,0) content-size 0x0 children: not-inline - BlockContainer at (0,0) content-size 0x16 children: not-inline - BlockContainer <(anonymous)> at (0,0) content-size 0x0 children: inline +InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x16 children: not-inline + BlockContainer <(anonymous)> at (0,0) content-size 800x0 children: inline TextNode <#text> - BlockContainer at (8,8) content-size 0x0 children: inline + BlockContainer at (8,8) content-size 784x0 children: inline TextNode <#text>