diff --git a/CefSharp.Wpf/WebView.cs b/CefSharp.Wpf/WebView.cs index fc4169ca0..bfa3d0591 100644 --- a/CefSharp.Wpf/WebView.cs +++ b/CefSharp.Wpf/WebView.cs @@ -25,7 +25,6 @@ namespace CefSharp.Wpf private RenderClientAdapter renderClientAdapter; private Image image; - private int width, height; private InteropBitmap interopBitmap; private InteropBitmap popupInteropBitmap; @@ -53,6 +52,16 @@ namespace CefSharp.Wpf get { return PixelFormats.Bgr32.BitsPerPixel / 8; } } + int IRenderWebBrowser.Width + { + get { return (int) ActualWidth; } + } + + int IRenderWebBrowser.Height + { + get { return (int) ActualWidth; } + } + public Uri Uri { get { return (Uri) GetValue(UriProperty); } @@ -107,10 +116,6 @@ namespace CefSharp.Wpf sync = new Object(); - // FIXME: Fix this to be done correctly. - width = 500; - height = 500; - //_scriptCore = new ScriptCore(); //_paintPopupDelegate = gcnew ActionHandler(this, &WebView::SetPopupBitmap); //_resizePopupDelegate = gcnew ActionHandler(this, &WebView::SetPopupSizeAndPositionImpl); @@ -502,9 +507,9 @@ namespace CefSharp.Wpf image.Source = null; GC.Collect(1); - var stride = width * BytesPerPixel; - var bitmap = (InteropBitmap) Imaging.CreateBitmapSourceFromMemorySection(FileMappingHandle, width, height, - PixelFormats.Bgr32, stride, 0); + var stride = (int) ActualWidth * BytesPerPixel; + var bitmap = (InteropBitmap) Imaging.CreateBitmapSourceFromMemorySection(FileMappingHandle, (int) ActualWidth, + (int) ActualHeight, PixelFormats.Bgr32, stride, 0); image.Source = bitmap; interopBitmap = bitmap; } diff --git a/CefSharp/IRenderWebBrowser.h b/CefSharp/IRenderWebBrowser.h index 6d65f356f..5d0730263 100644 --- a/CefSharp/IRenderWebBrowser.h +++ b/CefSharp/IRenderWebBrowser.h @@ -15,6 +15,9 @@ namespace CefSharp property IntPtr PopupFileMappingHandle; property int BytesPerPixel { int get(); }; + property int Width { int get(); }; + property int Height { int get(); }; + void InvokeRenderAsync(Action^ callback); void SetCursor(IntPtr cursor); diff --git a/CefSharp/Internals/RenderClientAdapterInternal.h b/CefSharp/Internals/RenderClientAdapterInternal.h index a897ca47d..c4e6b1b81 100644 --- a/CefSharp/Internals/RenderClientAdapterInternal.h +++ b/CefSharp/Internals/RenderClientAdapterInternal.h @@ -53,8 +53,7 @@ namespace CefSharp // CefRenderHandler virtual DECL bool GetViewRect(CefRefPtr browser, CefRect& rect) OVERRIDE { - // TODO: add a real implementation... :) - rect = CefRect(0, 0, _width, _height); + rect = CefRect(0, 0, _renderWebBrowser->Width, _renderWebBrowser->Height); return true; }