mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
LibWeb: Don't attempt to create new bitmap for zero-size OOPWV
It's not possible to construct a Gfx::Bitmap with empty size. Let the client know the new viewport rect and return before even attempting to create new front and back bitmaps. Also consider that we might have to paint the widget but not have a front/back bitmap available (e.g. when only part of a scrollbar is visible, and the inner rect is empty).
This commit is contained in:
parent
5c9d7d8026
commit
b97a900595
1 changed files with 9 additions and 1 deletions
|
@ -71,6 +71,10 @@ void OutOfProcessWebView::paint_event(GUI::PaintEvent& event)
|
|||
{
|
||||
GUI::ScrollableWidget::paint_event(event);
|
||||
|
||||
// If the available size is empty, we don't have a front or back bitmap to draw.
|
||||
if (available_size().is_empty())
|
||||
return;
|
||||
|
||||
GUI::Painter painter(*this);
|
||||
painter.add_clip_rect(frame_inner_rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
@ -84,9 +88,14 @@ void OutOfProcessWebView::resize_event(GUI::ResizeEvent& event)
|
|||
{
|
||||
GUI::ScrollableWidget::resize_event(event);
|
||||
|
||||
client().post_message(Messages::WebContentServer::SetViewportRect(Gfx::IntRect({ horizontal_scrollbar().value(), vertical_scrollbar().value() }, available_size())));
|
||||
|
||||
m_front_bitmap = nullptr;
|
||||
m_back_bitmap = nullptr;
|
||||
|
||||
if (available_size().is_empty())
|
||||
return;
|
||||
|
||||
// FIXME: Don't create a temporary bitmap just to convert it to one backed by a shared buffer.
|
||||
if (auto helper = Gfx::Bitmap::create(Gfx::BitmapFormat::RGB32, available_size())) {
|
||||
m_front_bitmap = helper->to_bitmap_backed_by_shared_buffer();
|
||||
|
@ -101,7 +110,6 @@ void OutOfProcessWebView::resize_event(GUI::ResizeEvent& event)
|
|||
m_back_bitmap->shared_buffer()->share_with(client().server_pid());
|
||||
}
|
||||
|
||||
client().post_message(Messages::WebContentServer::SetViewportRect(Gfx::IntRect({ horizontal_scrollbar().value(), vertical_scrollbar().value() }, available_size())));
|
||||
request_repaint();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue