From e094712e3a0ab9e2a3a65635cd758efabd2dc0cf Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Tue, 12 Nov 2024 11:02:06 -0500 Subject: [PATCH] headless-browser: Update the viewport when WebDriver resizes the window When the window resizes, we should also update the viewport to match, rather than remaining at the hard-coded 800x600 size. --- UI/Headless/HeadlessWebView.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/UI/Headless/HeadlessWebView.cpp b/UI/Headless/HeadlessWebView.cpp index df761e4a588..ecc3c133248 100644 --- a/UI/Headless/HeadlessWebView.cpp +++ b/UI/Headless/HeadlessWebView.cpp @@ -45,21 +45,30 @@ HeadlessWebView::HeadlessWebView(Core::AnonymousBuffer theme, Web::DevicePixelSi }; on_resize_window = [this](auto size) { - client().async_set_window_size(m_client_state.page_index, size.template to_type()); + m_viewport_size = size.template to_type(); + + client().async_set_window_size(m_client_state.page_index, m_viewport_size); + client().async_set_viewport_size(m_client_state.page_index, m_viewport_size); client().async_did_update_window_rect(m_client_state.page_index); }; on_maximize_window = [this]() { + m_viewport_size = screen_rect.size(); + client().async_set_window_position(m_client_state.page_index, screen_rect.location()); client().async_set_window_size(m_client_state.page_index, screen_rect.size()); + client().async_set_viewport_size(m_client_state.page_index, screen_rect.size()); client().async_did_update_window_rect(m_client_state.page_index); }; on_fullscreen_window = [this]() { + m_viewport_size = screen_rect.size(); + client().async_set_window_position(m_client_state.page_index, screen_rect.location()); client().async_set_window_size(m_client_state.page_index, screen_rect.size()); + client().async_set_viewport_size(m_client_state.page_index, screen_rect.size()); client().async_did_update_window_rect(m_client_state.page_index); };