WebContent: Use available size for bitmap (#2701)

After adding the scrolling feature, content available space reduced and
thus the bitmap size was always larger, than the inner size.
This lead to the horizontal scrollbar always beeing engaged.
This commit is contained in:
Kevin Meyer 2020-07-05 12:45:56 +02:00 committed by GitHub
parent a8489967a3
commit 0f6c5783d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
Notes: sideshowbarker 2024-07-19 05:09:51 +09:00

View File

@ -48,7 +48,7 @@ void WebContentView::load(const URL& url)
void WebContentView::paint_event(GUI::PaintEvent& event)
{
GUI::Frame::paint_event(event);
GUI::ScrollableWidget::paint_event(event);
GUI::Painter painter(*this);
painter.add_clip_rect(frame_inner_rect());
@ -61,11 +61,12 @@ void WebContentView::paint_event(GUI::PaintEvent& event)
void WebContentView::resize_event(GUI::ResizeEvent& event)
{
GUI::Widget::resize_event(event);
auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::RGB32, event.size());
GUI::ScrollableWidget::resize_event(event);
auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::RGB32, available_size());
m_bitmap = bitmap->to_bitmap_backed_by_shared_buffer();
m_bitmap->shared_buffer()->share_with(client().server_pid());
client().post_message(Messages::WebContentServer::SetViewportRect(Gfx::IntRect({ horizontal_scrollbar().value(), vertical_scrollbar().value() }, event.size())));
client().post_message(Messages::WebContentServer::SetViewportRect(Gfx::IntRect({ horizontal_scrollbar().value(), vertical_scrollbar().value() }, m_bitmap->size())));
request_repaint();
}
@ -116,7 +117,7 @@ void WebContentView::notify_server_did_change_title(Badge<WebContentClient>, con
void WebContentView::did_scroll()
{
client().post_message(Messages::WebContentServer::SetViewportRect(Gfx::IntRect({ horizontal_scrollbar().value(), vertical_scrollbar().value() }, size())));
client().post_message(Messages::WebContentServer::SetViewportRect(visible_content_rect()));
request_repaint();
}