mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-06 04:00:07 +00:00
Revert "sizes passed to the CefRenderHandler OnPaint and OnPopupSize methods are now already DPI scaled"
This reverts commit d173f28e09.
This commit is contained in:
@@ -34,11 +34,12 @@ namespace CefSharp.Wpf
|
||||
private readonly ToolTip toolTip;
|
||||
private ManagedCefBrowserAdapter managedCefBrowserAdapter;
|
||||
private bool ignoreUriChange;
|
||||
private Matrix matrix;
|
||||
|
||||
private Image image;
|
||||
private Image popupImage;
|
||||
private Popup popup;
|
||||
|
||||
private ScaleTransform dpiTransform;
|
||||
private readonly List<IDisposable> disposables = new List<IDisposable>();
|
||||
|
||||
public BrowserSettings BrowserSettings { get; set; }
|
||||
@@ -104,14 +105,14 @@ namespace CefSharp.Wpf
|
||||
get { return PixelFormat.BitsPerPixel / 8; }
|
||||
}
|
||||
|
||||
double IRenderWebBrowser.Width
|
||||
int IRenderWebBrowser.Width
|
||||
{
|
||||
get { return ActualWidth; }
|
||||
get { return (int)matrix.Transform(new Point(ActualWidth, ActualHeight)).X; }
|
||||
}
|
||||
|
||||
double IRenderWebBrowser.Height
|
||||
int IRenderWebBrowser.Height
|
||||
{
|
||||
get { return ActualHeight; }
|
||||
get { return (int)matrix.Transform(new Point(ActualWidth, ActualHeight)).Y; }
|
||||
}
|
||||
|
||||
private static PixelFormat PixelFormat
|
||||
@@ -509,11 +510,14 @@ namespace CefSharp.Wpf
|
||||
|
||||
AddSourceHookIfNotAlreadyPresent();
|
||||
|
||||
CheckIsNonStandardDpi();
|
||||
|
||||
// Create main window
|
||||
Content = image = CreateImage();
|
||||
Transform(image);
|
||||
|
||||
// Create popup
|
||||
popup = CreatePopup();
|
||||
Transform(popup);
|
||||
}
|
||||
|
||||
private static Image CreateImage()
|
||||
@@ -543,6 +547,22 @@ namespace CefSharp.Wpf
|
||||
return newPopup;
|
||||
}
|
||||
|
||||
private void Transform(FrameworkElement element)
|
||||
{
|
||||
if (dpiTransform != null)
|
||||
{
|
||||
element.LayoutTransform = dpiTransform;
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckIsNonStandardDpi()
|
||||
{
|
||||
dpiTransform = new ScaleTransform(
|
||||
1 / matrix.M11,
|
||||
1 / matrix.M22
|
||||
);
|
||||
}
|
||||
|
||||
private void AddSourceHookIfNotAlreadyPresent()
|
||||
{
|
||||
if (source != null)
|
||||
@@ -554,6 +574,7 @@ namespace CefSharp.Wpf
|
||||
|
||||
if (source != null)
|
||||
{
|
||||
matrix = source.CompositionTarget.TransformToDevice;
|
||||
sourceHook = SourceHook;
|
||||
source.AddHook(sourceHook);
|
||||
}
|
||||
@@ -714,6 +735,10 @@ namespace CefSharp.Wpf
|
||||
{
|
||||
popup.Width = width;
|
||||
popup.Height = height;
|
||||
|
||||
var popupOffset = new Point(x, y);
|
||||
popup.HorizontalOffset = popupOffset.X / matrix.M11;
|
||||
popup.VerticalOffset = popupOffset.Y / matrix.M22;
|
||||
}
|
||||
|
||||
private void OnTooltipTimerTick(object sender, EventArgs e)
|
||||
@@ -1155,7 +1180,10 @@ namespace CefSharp.Wpf
|
||||
|
||||
private Point GetPixelPosition(MouseEventArgs e)
|
||||
{
|
||||
return e.GetPosition(this);
|
||||
var deviceIndependentPosition = e.GetPosition(this);
|
||||
var pixelPosition = matrix.Transform(deviceIndependentPosition);
|
||||
|
||||
return pixelPosition;
|
||||
}
|
||||
|
||||
private object SetBitmapHelper(BitmapInfo bitmapInfo, InteropBitmap bitmap, Action<InteropBitmap> imageSourceSetter)
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace CefSharp.Internals
|
||||
{
|
||||
int BytesPerPixel { get; }
|
||||
|
||||
double Width { get; }
|
||||
double Height { get; }
|
||||
int Width { get; }
|
||||
int Height { get; }
|
||||
|
||||
void InvokeRenderAsync(BitmapInfo bitmapInfo);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user