Skip to content

Commit

Permalink
WPF - store width/height in local variable upon size change
Browse files Browse the repository at this point in the history
Do this so it's easier to implement a workaround for #2779
  • Loading branch information
amaitland committed Jul 26, 2019
1 parent cc1f1e4 commit 1423a97
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions CefSharp.Wpf/ChromiumWebBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public class ChromiumWebBrowser : Control, IRenderWebBrowser, IWpfWebBrowser
public const string PartImageName = "PART_image";
public const string PartPopupImageName = "PART_popupImage";

/// <summary>
/// View Rectangle used by <see cref="GetViewRect"/>
/// </summary>
private Rect viewRect;

/// <summary>
/// The source
/// </summary>
Expand Down Expand Up @@ -754,11 +759,6 @@ Rect IRenderWebBrowser.GetViewRect()
/// <returns>View Rectangle</returns>
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;
}

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 1423a97

Please sign in to comment.