Skip to content

Commit

Permalink
OffScreen - Check if browser is not null in GetScreenInfo/GetViewRect (
Browse files Browse the repository at this point in the history
  • Loading branch information
campersau authored and amaitland committed Jan 13, 2024
1 parent cda78d0 commit 1d69295
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions CefSharp.OffScreen/DefaultRenderHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,14 @@ public void Dispose()
/// <returns>Return null if no screenInfo structure is provided.</returns>
public virtual ScreenInfo? GetScreenInfo()
{
var screenInfo = new ScreenInfo { DeviceScaleFactor = browser.DeviceScaleFactor };
var deviceScaleFactor = browser?.DeviceScaleFactor;

if (deviceScaleFactor == null)
{
return null;
}

var screenInfo = new ScreenInfo { DeviceScaleFactor = deviceScaleFactor.Value };

return screenInfo;
}
Expand All @@ -111,9 +118,14 @@ public void Dispose()
public virtual Rect GetViewRect()
{
//TODO: See if this can be refactored and remove browser reference
var size = browser.Size;
var size = browser?.Size;

if (size == null)
{
return new Rect(0, 0, 1, 1);
}

var viewRect = new Rect(0, 0, size.Width, size.Height);
var viewRect = new Rect(0, 0, size.Value.Width, size.Value.Height);

return viewRect;
}
Expand Down

0 comments on commit 1d69295

Please sign in to comment.