Skip to content

Commit

Permalink
Ladybird/Qt: Resize the viewport when window resize is requested
Browse files Browse the repository at this point in the history
Previously, when a window resize was programatically requested
through WebDriver, we would update the size of the entire window. We
now ensure that the portion of the window containing the WebView is
set to the size requested.

This fixes some WPT tests where a specific viewport size is required.
  • Loading branch information
tcl3 committed Jul 15, 2024
1 parent f17f559 commit 3f49f7d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions Ladybird/Qt/BrowserWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,7 @@ void BrowserWindow::resizeEvent(QResizeEvent* event)
QWidget::resizeEvent(event);

for_each_tab([&](auto& tab) {
tab.view().set_viewport_size({ static_cast<int>(tab.view().width() * m_device_pixel_ratio), static_cast<int>(tab.view().height() * m_device_pixel_ratio) });
tab.view().set_window_size({ frameSize().width() * m_device_pixel_ratio, frameSize().height() * m_device_pixel_ratio });
});
}
Expand Down
5 changes: 3 additions & 2 deletions Ladybird/Qt/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,9 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St
};

view().on_resize_window = [this](auto const& size) {
m_window->resize(size.width(), size.height());
return Gfx::IntSize { m_window->width(), m_window->height() };
auto new_window_size = m_window->size() - m_view->size() + QSize { size.width(), size.height() };
m_window->resize(new_window_size);
return Gfx::IntSize { m_view->width(), m_view->height() };
};

view().on_maximize_window = [this]() {
Expand Down

0 comments on commit 3f49f7d

Please sign in to comment.