Skip to content

Commit c7f61d3

Browse files
committed
Allow creating BWebView with null size
- In this case, we don't create the fOffscreenBitmap immediately, and do it only when the view is resized. - Add some missing NULL checks and initialization to make this work (all drawing attempts are of course ignored)
1 parent 19e37d4 commit c7f61d3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Source/WebKit/haiku/API/WebPage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ void BWebPage::paint(BRect rect, bool immediate)
732732
// window locked. This cannot deadlock and makes sure
733733
// the window is not deleting the offscreen view right
734734
// after we unlock it and before locking the bitmap.
735-
if (!offscreenView->LockLooper()) {
735+
if (offscreenView == NULL || !offscreenView->LockLooper()) {
736736
fWebView->UnlockLooper();
737737
return;
738738
}

Source/WebKit/haiku/API/WebView.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ BWebView::BWebView(const char* name, BUrlContext* urlContext)
7171
, fLastMousePos(0, 0)
7272
, fAutoHidePointer(false)
7373
, fOffscreenBitmap(nullptr)
74+
, fOffscreenView(nullptr)
7475
, fWebPage(new BWebPage(this, urlContext))
7576
, fUserData(nullptr)
7677
{
@@ -246,7 +247,7 @@ void BWebView::Hide()
246247
void BWebView::Draw(BRect rect)
247248
{
248249
// Draw the page that was already rendered as an offscreen bitmap
249-
if (!fOffscreenBitmap->Lock()) {
250+
if (fOffscreenBitmap == NULL || !fOffscreenBitmap->Lock()) {
250251
SetHighColor(255, 255, 255);
251252
FillRect(rect);
252253
return;
@@ -544,6 +545,9 @@ bool BWebView::IsComposited()
544545

545546
void BWebView::_ResizeOffscreenView(int width, int height)
546547
{
548+
if (width <= 1 || height <= 1)
549+
return;
550+
547551
BRect bounds(0, 0, width - 1, height - 1);
548552

549553
if (fOffscreenBitmap) {

0 commit comments

Comments
 (0)