Ladybird: Specify window size in layout dump mode

This commit is contained in:
Aliaksandr Kalenik 2023-01-30 23:38:19 +03:00 committed by Andreas Kling
parent e249d751c8
commit 12eca612bc
Notes: sideshowbarker 2024-07-17 03:27:40 +09:00
4 changed files with 14 additions and 6 deletions

View file

@ -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();
}

View file

@ -96,6 +96,8 @@ public:
ErrorOr<String> dump_layout_tree();
void set_viewport_rect(Gfx::IntRect);
Gfx::IntPoint to_content(Gfx::IntPoint) const;
Gfx::IntPoint to_widget(Gfx::IntPoint) const;

View file

@ -88,6 +88,7 @@ ErrorOr<int> 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);

View file

@ -1,6 +1,6 @@
InitialContainingBlock <#document> at (0,0) content-size 0x0 children: not-inline
BlockContainer <html> 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 <html> at (0,0) content-size 800x16 children: not-inline
BlockContainer <(anonymous)> at (0,0) content-size 800x0 children: inline
TextNode <#text>
BlockContainer <body> at (8,8) content-size 0x0 children: inline
BlockContainer <body> at (8,8) content-size 784x0 children: inline
TextNode <#text>