Skip to content

Commit 4f2e721

Browse files
committed
Rect - Change to use Math.Ceiling as that appears to match what CEF uses
cefclient uses Math.Floor though when I examine the values returned they're always one less use use Math.Ceiling appears to match
1 parent 30ba69d commit 4f2e721

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

CefSharp.Wpf/ChromiumWebBrowser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ public IRequestContext RequestContext
459459
/// you must manually call IBrowserHost.NotifyScreenInfoChanged for the
460460
/// browser to be notified of the change.
461461
/// </summary>
462-
public double DpiScaleFactor { get; set; }
462+
public float DpiScaleFactor { get; set; }
463463

464464
/// <summary>
465465
/// Initializes static members of the <see cref="ChromiumWebBrowser"/> class.
@@ -1672,7 +1672,7 @@ private void PresentationSourceChangedHandler(object sender, SourceChangedEventA
16721672
var matrix = source.CompositionTarget.TransformToDevice;
16731673
var notifyDpiChanged = DpiScaleFactor > 0 && !DpiScaleFactor.Equals(matrix.M11);
16741674

1675-
DpiScaleFactor = source.CompositionTarget.TransformToDevice.M11;
1675+
DpiScaleFactor = (float)source.CompositionTarget.TransformToDevice.M11;
16761676

16771677
WpfKeyboardHandler.Setup(source);
16781678

CefSharp/Structs/Rect.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ public Rect(int x, int y, int width, int height)
5454
/// </summary>
5555
/// <param name="dpi">Dpi to scale by</param>
5656
/// <returns>New rect with scaled values</returns>
57-
public Rect ScaleByDpi(double dpi)
57+
public Rect ScaleByDpi(float dpi)
5858
{
59-
var x = (int)Math.Floor(X / dpi);
60-
var y = (int)Math.Floor(Y / dpi);
61-
var width = (int)Math.Floor(Width / dpi);
62-
var height = (int)Math.Floor(Height / dpi);
59+
var x = (int)Math.Ceiling(X / dpi);
60+
var y = (int)Math.Ceiling(Y / dpi);
61+
var width = (int)Math.Ceiling(Width / dpi);
62+
var height = (int)Math.Ceiling(Height / dpi);
6363

6464
return new Rect(x, y, width, height);
6565
}

0 commit comments

Comments
 (0)