diff --git a/Ladybird/WebView.cpp b/Ladybird/WebView.cpp index 36a30b9a727..ac4048fb2b0 100644 --- a/Ladybird/WebView.cpp +++ b/Ladybird/WebView.cpp @@ -363,6 +363,13 @@ WebView::WebView() verticalScrollBar()->setSingleStep(24); horizontalScrollBar()->setSingleStep(24); + + QObject::connect(verticalScrollBar(), &QScrollBar::valueChanged, [this](int) { + update_viewport_rect(); + }); + QObject::connect(horizontalScrollBar(), &QScrollBar::valueChanged, [this](int) { + update_viewport_rect(); + }); } WebView::~WebView() @@ -648,8 +655,14 @@ void WebView::paintEvent(QPaintEvent* event) void WebView::resizeEvent(QResizeEvent* event) { - auto scaled_width = int(event->size().width() / m_inverse_pixel_scaling_ratio); - auto scaled_height = int(event->size().height() / m_inverse_pixel_scaling_ratio); + QAbstractScrollArea::resizeEvent(event); + update_viewport_rect(); +} + +void WebView::update_viewport_rect() +{ + auto scaled_width = int(size().width() / m_inverse_pixel_scaling_ratio); + auto scaled_height = int(size().height() / m_inverse_pixel_scaling_ratio); Gfx::IntRect rect(horizontalScrollBar()->value(), verticalScrollBar()->value(), scaled_width, scaled_height); m_page_client->set_viewport_rect(rect); } diff --git a/Ladybird/WebView.h b/Ladybird/WebView.h index 2af499be196..52cc45bfb3f 100644 --- a/Ladybird/WebView.h +++ b/Ladybird/WebView.h @@ -57,6 +57,8 @@ signals: void favicon_changed(QIcon); private: + void update_viewport_rect(); + OwnPtr m_page_client; qreal m_inverse_pixel_scaling_ratio { 1.0 };