From 1423a9741a29162b9f4a7db11de064a8ffa4f9ff Mon Sep 17 00:00:00 2001 From: amaitland Date: Fri, 26 Jul 2019 17:51:13 +1000 Subject: [PATCH] WPF - store width/height in local variable upon size change Do this so it's easier to implement a workaround for #2779 --- CefSharp.Wpf/ChromiumWebBrowser.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/CefSharp.Wpf/ChromiumWebBrowser.cs b/CefSharp.Wpf/ChromiumWebBrowser.cs index 5ebed29738..4e42faf65f 100644 --- a/CefSharp.Wpf/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf/ChromiumWebBrowser.cs @@ -39,6 +39,11 @@ public class ChromiumWebBrowser : Control, IRenderWebBrowser, IWpfWebBrowser public const string PartImageName = "PART_image"; public const string PartPopupImageName = "PART_popupImage"; + /// + /// View Rectangle used by + /// + private Rect viewRect; + /// /// The source /// @@ -754,11 +759,6 @@ Rect IRenderWebBrowser.GetViewRect() /// View Rectangle protected virtual Rect GetViewRect() { - //NOTE: Previous we used Math.Ceiling to round the sizing up, we - //now set UseLayoutRounding = true; on the control so the sizes are - //already rounded to a whole number for us. - var viewRect = new Rect(0, 0, (int)ActualWidth, (int)ActualHeight); - return viewRect; } @@ -1856,6 +1856,11 @@ private void OnActualSizeChanged(object sender, SizeChangedEventArgs e) // Initialize RenderClientAdapter when WPF has calculated the actual size of current content. CreateOffscreenBrowser(e.NewSize); + //NOTE: Previous we used Math.Ceiling to round the sizing up, we + //now set UseLayoutRounding = true; on the control so the sizes are + //already rounded to a whole number for us. + viewRect = new Rect(0, 0, (int)e.NewSize.Width, (int)e.NewSize.Height); + if (browser != null) { browser.GetHost().WasResized();