From 65b74684dd06e3dad4326a7a5fcc49c4a9837891 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Tue, 7 Oct 2014 21:20:55 +0200 Subject: [PATCH 01/27] nuked --- CefSharp.Core/BrowserSettings.h | 5 ----- CefSharp.Core/CefSettings.h | 4 ---- CefSharp/LogSeverity.cs | 5 ----- 3 files changed, 14 deletions(-) diff --git a/CefSharp.Core/BrowserSettings.h b/CefSharp.Core/BrowserSettings.h index dcd6be4e9..bd47ec32a 100644 --- a/CefSharp.Core/BrowserSettings.h +++ b/CefSharp.Core/BrowserSettings.h @@ -272,10 +272,5 @@ namespace CefSharp void set(Nullable^ value) { _browserSettings->webgl = CefStateFromDisabledSetting(value); } } - property Nullable^ AcceleratedCompositingDisabled - { - Nullable^ get() { return CefStateToDisabledSetting(_browserSettings->accelerated_compositing); } - void set(Nullable^ value) { _browserSettings->accelerated_compositing = CefStateFromDisabledSetting(value); } - } }; } \ No newline at end of file diff --git a/CefSharp.Core/CefSettings.h b/CefSharp.Core/CefSettings.h index 8b421a677..e8153b21d 100644 --- a/CefSharp.Core/CefSettings.h +++ b/CefSharp.Core/CefSettings.h @@ -30,8 +30,6 @@ namespace CefSharp return LOGSEVERITY_WARNING; case CefSharp::LogSeverity::Error: return LOGSEVERITY_ERROR; - case CefSharp::LogSeverity::ErrorReport: - return LOGSEVERITY_ERROR_REPORT; case CefSharp::LogSeverity::Disable: default: return LOGSEVERITY_DISABLE; @@ -50,8 +48,6 @@ namespace CefSharp return CefSharp::LogSeverity::Warning; case LOGSEVERITY_ERROR: return CefSharp::LogSeverity::Error; - case LOGSEVERITY_ERROR_REPORT: - return CefSharp::LogSeverity::ErrorReport; case LOGSEVERITY_DISABLE: default: return CefSharp::LogSeverity::Disable; diff --git a/CefSharp/LogSeverity.cs b/CefSharp/LogSeverity.cs index b25fa7ec7..0974cc197 100644 --- a/CefSharp/LogSeverity.cs +++ b/CefSharp/LogSeverity.cs @@ -31,11 +31,6 @@ namespace CefSharp /// Error, - /// - /// ErrorReport logging - /// - ErrorReport, - /// /// Completely disable logging /// From 97f91176464f331e6ebf064ad4b6c9e229d3df22 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Tue, 7 Oct 2014 21:35:57 +0200 Subject: [PATCH 02/27] nullptr is gone, use NULL instead --- CefSharp.Core/Internals/ClientAdapter.cpp | 2 +- CefSharp.Core/Internals/ClientAdapter.h | 2 +- CefSharp.Core/Wrappers/CefSubprocessWrapper.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CefSharp.Core/Internals/ClientAdapter.cpp b/CefSharp.Core/Internals/ClientAdapter.cpp index c6e752993..5366d9ae9 100644 --- a/CefSharp.Core/Internals/ClientAdapter.cpp +++ b/CefSharp.Core/Internals/ClientAdapter.cpp @@ -56,7 +56,7 @@ namespace CefSharp handler->OnBeforeClose(_browserControl); } - _cefBrowser = nullptr; + _cefBrowser = NULL; } } diff --git a/CefSharp.Core/Internals/ClientAdapter.h b/CefSharp.Core/Internals/ClientAdapter.h index 518deb3b6..c77cc8a88 100644 --- a/CefSharp.Core/Internals/ClientAdapter.h +++ b/CefSharp.Core/Internals/ClientAdapter.h @@ -49,7 +49,7 @@ namespace CefSharp _browserControl = nullptr; _managedCefBrowserAdapter = nullptr; _browserHwnd = nullptr; - _cefBrowser = nullptr; + _cefBrowser = NULL; _tooltip = nullptr; } diff --git a/CefSharp.Core/Wrappers/CefSubprocessWrapper.h b/CefSharp.Core/Wrappers/CefSubprocessWrapper.h index c17005a41..d1912affe 100644 --- a/CefSharp.Core/Wrappers/CefSubprocessWrapper.h +++ b/CefSharp.Core/Wrappers/CefSubprocessWrapper.h @@ -28,7 +28,7 @@ namespace CefSharp ~CefBrowserUnmanagedWrapper() { - _cefBrowser = nullptr; + _cefBrowser = NULL; EvaluateScriptResult = nullptr; EvaluateScriptExceptionMessage = nullptr; From 86657617bb1b1026c04691a33cc48370eec2f361 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Tue, 7 Oct 2014 21:36:41 +0200 Subject: [PATCH 03/27] CefCompletionHandler has been renamed to CefCompletionCallback --- CefSharp.Core/Cef.h | 2 +- CefSharp.Core/Internals/CompletionHandler.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CefSharp.Core/Cef.h b/CefSharp.Core/Cef.h index e16fd10a3..a2d4effbc 100644 --- a/CefSharp.Core/Cef.h +++ b/CefSharp.Core/Cef.h @@ -348,7 +348,7 @@ namespace CefSharp auto wrapper = new CompletionHandler(handler); - return manager->FlushStore(static_cast>(wrapper)); + return manager->FlushStore(static_cast>(wrapper)); } /// Shuts down CefSharp and the underlying CEF infrastructure. This method is safe to call multiple times; it will only diff --git a/CefSharp.Core/Internals/CompletionHandler.h b/CefSharp.Core/Internals/CompletionHandler.h index a1d4d851d..6982d907b 100644 --- a/CefSharp.Core/Internals/CompletionHandler.h +++ b/CefSharp.Core/Internals/CompletionHandler.h @@ -9,7 +9,7 @@ namespace CefSharp { - private class CompletionHandler : public CefCompletionHandler + private class CompletionHandler : public CefCompletionCallback { private: gcroot _handler; From d5ebb2aa01427afefa821e516b8bc9ab43982f61 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Tue, 7 Oct 2014 21:37:15 +0200 Subject: [PATCH 04/27] SetAsOffScreen & SetTransparentPainting has been merged into a single method called SetAsWindowless --- CefSharp.Core/ManagedCefBrowserAdapter.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CefSharp.Core/ManagedCefBrowserAdapter.h b/CefSharp.Core/ManagedCefBrowserAdapter.h index 0b8860efe..0fb06276a 100644 --- a/CefSharp.Core/ManagedCefBrowserAdapter.h +++ b/CefSharp.Core/ManagedCefBrowserAdapter.h @@ -48,8 +48,7 @@ namespace CefSharp { HWND hwnd = HWND(); CefWindowInfo window; - window.SetAsOffScreen(hwnd); - window.SetTransparentPainting(true); + window.SetAsWindowless(hwnd, TRUE); CefString addressNative = StringUtils::ToNative("about:blank"); if (!CefBrowserHost::CreateBrowser(window, _renderClientAdapter.get(), addressNative, From 09f7fd08d5e19e0c3f8bb3371bea371f9a2024c1 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Tue, 7 Oct 2014 21:38:24 +0200 Subject: [PATCH 05/27] upgrade cef.redist to 3.2062.1856 --- .nuget/packages.config | 4 ---- CefSharp.Core/CefSharp.Core.vcxproj | 5 +++-- CefSharp.Core/packages.config | 2 +- CefSharp.Test/CefSharp.Test.csproj | 5 +++-- CefSharp.Test/packages.config | 2 +- CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj | 5 +++-- CefSharp.WinForms.Example/packages.config | 2 +- CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj | 5 +++-- CefSharp.Wpf.Example/packages.config | 2 +- CefSharp3.sln | 2 ++ NuGet/CefSharp.Common.nuspec | 2 +- 11 files changed, 19 insertions(+), 17 deletions(-) delete mode 100644 .nuget/packages.config diff --git a/.nuget/packages.config b/.nuget/packages.config deleted file mode 100644 index a05271e70..000000000 --- a/.nuget/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/CefSharp.Core/CefSharp.Core.vcxproj b/CefSharp.Core/CefSharp.Core.vcxproj index 7a327f27a..8d42e7696 100644 --- a/CefSharp.Core/CefSharp.Core.vcxproj +++ b/CefSharp.Core/CefSharp.Core.vcxproj @@ -1,6 +1,6 @@  - + Debug @@ -66,6 +66,7 @@ <_ProjectFileVersion>11.0.51106.1 + 692f35e4 bin\$(Configuration)\ @@ -283,6 +284,6 @@ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/CefSharp.Core/packages.config b/CefSharp.Core/packages.config index bbef23d17..114e1bcdb 100644 --- a/CefSharp.Core/packages.config +++ b/CefSharp.Core/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/CefSharp.Test/CefSharp.Test.csproj b/CefSharp.Test/CefSharp.Test.csproj index 0aa234944..7754ea041 100644 --- a/CefSharp.Test/CefSharp.Test.csproj +++ b/CefSharp.Test/CefSharp.Test.csproj @@ -18,6 +18,7 @@ 3.5 + 4c628f79 true @@ -135,11 +136,11 @@ --> - + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/CefSharp.Test/packages.config b/CefSharp.Test/packages.config index 742fc0821..d3dc7e5a0 100644 --- a/CefSharp.Test/packages.config +++ b/CefSharp.Test/packages.config @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj b/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj index c34e16f1f..5a98a1c34 100644 --- a/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj +++ b/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj @@ -20,6 +20,7 @@ 3.5 + 5cbe48da x64 @@ -125,11 +126,11 @@ - + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/CefSharp.WinForms.Example/packages.config b/CefSharp.WinForms.Example/packages.config index b519c7ce7..c934865b9 100644 --- a/CefSharp.WinForms.Example/packages.config +++ b/CefSharp.WinForms.Example/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj b/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj index 0b0e6b6b4..29d5d05f1 100644 --- a/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj +++ b/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj @@ -20,6 +20,7 @@ 3.5 + b0235bb6 true @@ -162,11 +163,11 @@ - + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/CefSharp.Wpf.Example/packages.config b/CefSharp.Wpf.Example/packages.config index b519c7ce7..c934865b9 100644 --- a/CefSharp.Wpf.Example/packages.config +++ b/CefSharp.Wpf.Example/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/CefSharp3.sln b/CefSharp3.sln index da3664619..08485a58e 100644 --- a/CefSharp3.sln +++ b/CefSharp3.sln @@ -52,6 +52,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CefSharp.Core", "CefSharp.C EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp", "CefSharp\CefSharp.csproj", "{A55848CC-10E7-40CB-ADDB-04740B16DD43}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{D62CBBCA-9C35-4CB4-BA62-ADC79C9045DF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 diff --git a/NuGet/CefSharp.Common.nuspec b/NuGet/CefSharp.Common.nuspec index 5b12baa62..db7668a43 100644 --- a/NuGet/CefSharp.Common.nuspec +++ b/NuGet/CefSharp.Common.nuspec @@ -12,7 +12,7 @@ chrome browser Copyright © 2010-2014 The CefSharp Authors - + From a6117fd4c20449dff6fd960e82fe3b1a11028f3d Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Tue, 7 Oct 2014 21:46:06 +0200 Subject: [PATCH 06/27] nullptr -> null --- CefSharp.Core/SchemeHandlerWrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CefSharp.Core/SchemeHandlerWrapper.cpp b/CefSharp.Core/SchemeHandlerWrapper.cpp index 5d44aaa2b..f98a5449b 100644 --- a/CefSharp.Core/SchemeHandlerWrapper.cpp +++ b/CefSharp.Core/SchemeHandlerWrapper.cpp @@ -123,7 +123,7 @@ namespace CefSharp _stream->Close(); } _stream = nullptr; - _callback = nullptr; + _callback = NULL; } int SchemeHandlerWrapper::SizeFromStream() From 3cb15a905bcd05b12bca3bfa4c447cc2c426d1c7 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Tue, 7 Oct 2014 21:46:49 +0200 Subject: [PATCH 07/27] check if initialized --- CefSharp.Core/SchemeHandlerWrapper.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CefSharp.Core/SchemeHandlerWrapper.cpp b/CefSharp.Core/SchemeHandlerWrapper.cpp index f98a5449b..aa52710d1 100644 --- a/CefSharp.Core/SchemeHandlerWrapper.cpp +++ b/CefSharp.Core/SchemeHandlerWrapper.cpp @@ -94,7 +94,7 @@ namespace CefSharp AutoLock lock_scope(this); - if (!_stream) + if (static_cast(_stream) == nullptr) { bytes_read = 0; } @@ -118,7 +118,7 @@ namespace CefSharp void SchemeHandlerWrapper::Cancel() { - if (!!_stream && _closeStream) + if (static_cast(_stream) != nullptr && _closeStream) { _stream->Close(); } @@ -128,7 +128,7 @@ namespace CefSharp int SchemeHandlerWrapper::SizeFromStream() { - if (!_stream) + if (static_cast(_stream) == nullptr) { return 0; } From 6591c4e4cfabf6e2bff5a5d421d7da8d9ffeebe1 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Tue, 7 Oct 2014 21:47:03 +0200 Subject: [PATCH 08/27] bump --- NuGet/pack.bat | 2 +- build.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet/pack.bat b/NuGet/pack.bat index 1afa6de1b..8358fc925 100644 --- a/NuGet/pack.bat +++ b/NuGet/pack.bat @@ -1,4 +1,4 @@ -set version=33.0.0 +set version=37.0.0 NuGet pack CefSharp.Common.nuspec -NoPackageAnalysis -Version %version% NuGet pack CefSharp.Wpf.nuspec -NoPackageAnalysis -Version %version% NuGet pack CefSharp.WinForms.nuspec -NoPackageAnalysis -Version %version% diff --git a/build.ps1 b/build.ps1 index 1bdd3d458..42566584a 100644 --- a/build.ps1 +++ b/build.ps1 @@ -3,7 +3,7 @@ param( [Parameter(Position = 0)] [string] $Target = "nupkg", [Parameter(Position = 1)] - [string] $Version = "33.0.0" + [string] $Version = "37.0.0" ) $WorkingDir = split-path -parent $MyInvocation.MyCommand.Definition From fa74a333db3d4213dba2313b75e5447d3d0f6180 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Tue, 7 Oct 2014 21:47:21 +0200 Subject: [PATCH 09/27] enable building for vc110 --- build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index 42566584a..081935358 100644 --- a/build.ps1 +++ b/build.ps1 @@ -240,7 +240,7 @@ switch -Exact ($Target) { "nupkg" { VSX v120 - #VSX v110 + VSX v110 Nupkg } "nupkg-only" From 6338b72e8adfc76ec7e2f1d825420a2815afd0f5 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Wed, 8 Oct 2014 08:42:06 +0200 Subject: [PATCH 10/27] handle debugging both x86/x64 --- CefSharp.Example/CefExample.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CefSharp.Example/CefExample.cs b/CefSharp.Example/CefExample.cs index 7d2b4cbc8..d5cbc1e46 100644 --- a/CefSharp.Example/CefExample.cs +++ b/CefSharp.Example/CefExample.cs @@ -18,7 +18,9 @@ namespace CefSharp.Example if (debuggingSubProcess) { - settings.BrowserSubprocessPath = "..\\..\\..\\..\\CefSharp.BrowserSubprocess\\bin\\x86\\Debug\\CefSharp.BrowserSubprocess.exe"; + var platform = IntPtr.Size == 4 ? "x86" : "x64"; + settings.BrowserSubprocessPath = string.Format( + "..\\..\\..\\..\\CefSharp.BrowserSubprocess\\bin\\{0}\\Debug\\CefSharp.BrowserSubprocess.exe", platform); } settings.RegisterScheme(new CefCustomScheme From 46f248488be1259ac5787dab7d92f1a41d0f39f0 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Wed, 8 Oct 2014 08:42:24 +0200 Subject: [PATCH 11/27] bump --- CefSharp/Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CefSharp/Properties/AssemblyInfo.cs b/CefSharp/Properties/AssemblyInfo.cs index 6a9cb7ff4..afbe14223 100644 --- a/CefSharp/Properties/AssemblyInfo.cs +++ b/CefSharp/Properties/AssemblyInfo.cs @@ -32,8 +32,8 @@ namespace CefSharp public const bool ComVisible = false; public const string AssemblyCompany = "The CefSharp Authors"; public const string AssemblyProduct = "CefSharp"; - public const string AssemblyVersion = "33.0.0.0"; - public const string AssemblyFileVersion = "33.0.0.0"; + public const string AssemblyVersion = "37.0.0.0"; + public const string AssemblyFileVersion = "37.0.0.0"; public const string AssemblyCopyright = "Copyright © The CefSharp Authors 2010-2014"; public const string CefSharpCoreProject = "CefSharp.Core, PublicKey=" + PublicKey; public const string CefSharpBrowserSubprocessProject = "CefSharp.BrowserSubprocess, PublicKey=" + PublicKey; From 0d5cc48096d26e7017d5e47662f9f91ca9e60795 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Wed, 8 Oct 2014 11:32:21 +0200 Subject: [PATCH 12/27] IMPLEMENT_LOCKING is gone, see: https://code.google.com/p/chromiumembedded/source/detail?r=1769&path=/trunk/cef3/libcef_dll/base/cef_lock.cc --- CefSharp.Core/Internals/ClientAdapter.cpp | 10 ++++++++-- CefSharp.Core/Internals/ClientAdapter.h | 2 +- CefSharp.Core/Internals/StreamAdapter.cpp | 5 ++++- CefSharp.Core/Internals/StreamAdapter.h | 2 +- CefSharp.Core/SchemeHandlerWrapper.cpp | 8 ++++++-- CefSharp.Core/SchemeHandlerWrapper.h | 2 +- 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CefSharp.Core/Internals/ClientAdapter.cpp b/CefSharp.Core/Internals/ClientAdapter.cpp index 5366d9ae9..70b2bbabc 100644 --- a/CefSharp.Core/Internals/ClientAdapter.cpp +++ b/CefSharp.Core/Internals/ClientAdapter.cpp @@ -159,7 +159,8 @@ namespace CefSharp return; } - AutoLock lock_scope(this); + _sync.Lock(); + if (frame->IsMain()) { _browserControl->SetIsLoading(true); @@ -167,6 +168,8 @@ namespace CefSharp } _browserControl->OnFrameLoadStart(StringUtils::ToClr(frame->GetURL()), frame->IsMain()); + + _sync.Unlock(); } void ClientAdapter::OnLoadEnd(CefRefPtr browser, CefRefPtr frame, int httpStatusCode) @@ -176,13 +179,16 @@ namespace CefSharp return; } - AutoLock lock_scope(this); + _sync.Lock(); + if (frame->IsMain()) { _browserControl->SetIsLoading(false); } _browserControl->OnFrameLoadEnd(StringUtils::ToClr(frame->GetURL()), frame->IsMain(), httpStatusCode); + + _sync.Unlock(); } void ClientAdapter::OnLoadError(CefRefPtr browser, CefRefPtr frame, ErrorCode errorCode, const CefString& errorText, const CefString& failedUrl) diff --git a/CefSharp.Core/Internals/ClientAdapter.h b/CefSharp.Core/Internals/ClientAdapter.h index c77cc8a88..17ed362c2 100644 --- a/CefSharp.Core/Internals/ClientAdapter.h +++ b/CefSharp.Core/Internals/ClientAdapter.h @@ -30,6 +30,7 @@ namespace CefSharp public CefDialogHandler { private: + base::internal::LockImpl _sync; gcroot _browserControl; gcroot _managedCefBrowserAdapter; HWND _browserHwnd; @@ -121,7 +122,6 @@ namespace CefSharp const CefString& default_file_name, const std::vector& accept_types, CefRefPtr callback) OVERRIDE; - IMPLEMENT_LOCKING(ClientAdapter); IMPLEMENT_REFCOUNTING(ClientAdapter); }; } diff --git a/CefSharp.Core/Internals/StreamAdapter.cpp b/CefSharp.Core/Internals/StreamAdapter.cpp index adc1be635..7b056eb30 100644 --- a/CefSharp.Core/Internals/StreamAdapter.cpp +++ b/CefSharp.Core/Internals/StreamAdapter.cpp @@ -16,7 +16,7 @@ namespace CefSharp size_t StreamAdapter::Read(void* ptr, size_t size, size_t n) { - AutoLock lock_scope(this); + _sync.Lock(); try { array^ buffer = gcnew array(n * size); @@ -29,6 +29,9 @@ namespace CefSharp { return -1; } + finally { + _sync.Unlock(); + } } int StreamAdapter::Seek(int64 offset, int whence) diff --git a/CefSharp.Core/Internals/StreamAdapter.h b/CefSharp.Core/Internals/StreamAdapter.h index 7f7bc3b7f..2a9a10e41 100644 --- a/CefSharp.Core/Internals/StreamAdapter.h +++ b/CefSharp.Core/Internals/StreamAdapter.h @@ -14,6 +14,7 @@ namespace CefSharp { private class StreamAdapter : public CefReadHandler { + base::internal::LockImpl _sync; gcroot _stream; public: @@ -25,7 +26,6 @@ namespace CefSharp virtual int64 Tell(); virtual int Eof(); - IMPLEMENT_LOCKING(StreamAdapter); IMPLEMENT_REFCOUNTING(StreamAdapter); }; } diff --git a/CefSharp.Core/SchemeHandlerWrapper.cpp b/CefSharp.Core/SchemeHandlerWrapper.cpp index aa52710d1..5f7e92d47 100644 --- a/CefSharp.Core/SchemeHandlerWrapper.cpp +++ b/CefSharp.Core/SchemeHandlerWrapper.cpp @@ -36,7 +36,7 @@ namespace CefSharp bool handled = false; - AutoLock lock_scope(this); + _sync.Lock(); auto schemeResponse = gcnew SchemeHandlerResponse(this); auto onRequestCompleted = gcnew OnRequestCompletedHandler(schemeResponse, &SchemeHandlerResponse::OnRequestCompleted); @@ -47,6 +47,8 @@ namespace CefSharp handled = true; } + _sync.Unlock(); + return handled; } @@ -92,7 +94,7 @@ namespace CefSharp { bool has_data = false; - AutoLock lock_scope(this); + _sync.Lock(); if (static_cast(_stream) == nullptr) { @@ -113,6 +115,8 @@ namespace CefSharp } } + _sync.Unlock(); + return has_data; } diff --git a/CefSharp.Core/SchemeHandlerWrapper.h b/CefSharp.Core/SchemeHandlerWrapper.h index 4f0939ba5..31802d059 100644 --- a/CefSharp.Core/SchemeHandlerWrapper.h +++ b/CefSharp.Core/SchemeHandlerWrapper.h @@ -17,6 +17,7 @@ namespace CefSharp public class SchemeHandlerWrapper : public CefResourceHandler { + base::internal::LockImpl _sync; gcroot _handler; gcroot _stream; CefRefPtr _callback; @@ -45,7 +46,6 @@ namespace CefSharp virtual bool ReadResponse(void* data_out, int bytes_to_read, int& bytes_read, CefRefPtr callback); virtual void Cancel(); - IMPLEMENT_LOCKING(SchemeHandlerWrapper); IMPLEMENT_REFCOUNTING(SchemeHandlerWrapper); }; From a24d9a023bc8157f6b48ad2af16c65ec052cec82 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Wed, 8 Oct 2014 11:32:34 +0200 Subject: [PATCH 13/27] check for nullptr --- CefSharp.Core/SchemeHandlerWrapper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CefSharp.Core/SchemeHandlerWrapper.h b/CefSharp.Core/SchemeHandlerWrapper.h index 31802d059..64f2c2d57 100644 --- a/CefSharp.Core/SchemeHandlerWrapper.h +++ b/CefSharp.Core/SchemeHandlerWrapper.h @@ -34,7 +34,7 @@ namespace CefSharp SchemeHandlerWrapper(ISchemeHandler^ handler) : _handler(handler) { - if (!_handler) + if (static_cast(_handler) == nullptr) { throw gcnew ArgumentException("handler must not be null"); } From daf27076a0d68e181eb304cc510edbc9dc22376a Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Wed, 8 Oct 2014 11:37:00 +0200 Subject: [PATCH 14/27] install x86/x64 nupkg variants into cefsharp.wpf.example, cefsharp.winforms.example and cefsharp.test --- CefSharp.Test/CefSharp.Test.csproj | 12 +++++++++--- CefSharp.Test/packages.config | 5 ++++- .../CefSharp.WinForms.Example.csproj | 12 +++++++++--- CefSharp.WinForms.Example/packages.config | 5 ++++- CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj | 12 +++++++++--- CefSharp.Wpf.Example/packages.config | 5 ++++- 6 files changed, 39 insertions(+), 12 deletions(-) diff --git a/CefSharp.Test/CefSharp.Test.csproj b/CefSharp.Test/CefSharp.Test.csproj index 7754ea041..9a1ae8da9 100644 --- a/CefSharp.Test/CefSharp.Test.csproj +++ b/CefSharp.Test/CefSharp.Test.csproj @@ -18,7 +18,7 @@ 3.5 - 4c628f79 + 64eeb8eb true @@ -136,11 +136,17 @@ --> - + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + + + + + + + \ No newline at end of file diff --git a/CefSharp.Test/packages.config b/CefSharp.Test/packages.config index d3dc7e5a0..1f691904c 100644 --- a/CefSharp.Test/packages.config +++ b/CefSharp.Test/packages.config @@ -2,7 +2,10 @@ - + + + + \ No newline at end of file diff --git a/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj b/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj index 5a98a1c34..680effe14 100644 --- a/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj +++ b/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj @@ -20,7 +20,7 @@ 3.5 - 5cbe48da + 251f73ac x64 @@ -126,11 +126,17 @@ - + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + + + + + + + \ No newline at end of file diff --git a/CefSharp.WinForms.Example/packages.config b/CefSharp.WinForms.Example/packages.config index c934865b9..0f2091c4a 100644 --- a/CefSharp.WinForms.Example/packages.config +++ b/CefSharp.WinForms.Example/packages.config @@ -1,4 +1,7 @@  - + + + + \ No newline at end of file diff --git a/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj b/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj index 29d5d05f1..6bdab9748 100644 --- a/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj +++ b/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj @@ -20,7 +20,7 @@ 3.5 - b0235bb6 + 04d545b3 true @@ -163,11 +163,17 @@ - + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + + + + + + + \ No newline at end of file diff --git a/CefSharp.Wpf.Example/packages.config b/CefSharp.Wpf.Example/packages.config index c934865b9..0f2091c4a 100644 --- a/CefSharp.Wpf.Example/packages.config +++ b/CefSharp.Wpf.Example/packages.config @@ -1,4 +1,7 @@  - + + + + \ No newline at end of file From 75d4606a50162449ec7f98f6627800449317c86c Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Wed, 8 Oct 2014 12:24:55 +0200 Subject: [PATCH 15/27] redist version should always match package version --- NuGet/CefSharp.Common.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet/CefSharp.Common.nuspec b/NuGet/CefSharp.Common.nuspec index db7668a43..c2e97d14b 100644 --- a/NuGet/CefSharp.Common.nuspec +++ b/NuGet/CefSharp.Common.nuspec @@ -12,7 +12,7 @@ chrome browser Copyright © 2010-2014 The CefSharp Authors - + From 27c61fad28a9c0f49b0ed5e3de354dbcd78d6edd Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Wed, 8 Oct 2014 12:51:01 +0200 Subject: [PATCH 16/27] depend on redist for entire build matrix --- NuGet/CefSharp.Common.nuspec | 7 +++++-- build.ps1 | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/NuGet/CefSharp.Common.nuspec b/NuGet/CefSharp.Common.nuspec index c2e97d14b..7e9fb1312 100644 --- a/NuGet/CefSharp.Common.nuspec +++ b/NuGet/CefSharp.Common.nuspec @@ -12,9 +12,12 @@ chrome browser Copyright © 2010-2014 The CefSharp Authors - + + + + - + diff --git a/build.ps1 b/build.ps1 index 081935358..aefe9793e 100644 --- a/build.ps1 +++ b/build.ps1 @@ -3,7 +3,9 @@ param( [Parameter(Position = 0)] [string] $Target = "nupkg", [Parameter(Position = 1)] - [string] $Version = "37.0.0" + [string] $Version = "37.0.0", + [Parameter(Position = 2)] + [string] $RedistVersion = "3.2062.1856" ) $WorkingDir = split-path -parent $MyInvocation.MyCommand.Definition @@ -217,7 +219,7 @@ function Nupkg Write-Diagnostic "Building nuget package" # Build packages - . $nuget pack nuget\CefSharp.Common.nuspec -NoPackageAnalysis -Version $Version -OutputDirectory nuget + . $nuget pack nuget\CefSharp.Common.nuspec -NoPackageAnalysis -Version $Version -OutputDirectory nuget -Properties "RedistVersion=$RedistVersion" . $nuget pack nuget\CefSharp.Wpf.nuspec -NoPackageAnalysis -Version $Version -OutputDirectory nuget . $nuget pack nuget\CefSharp.WinForms.nuspec -NoPackageAnalysis -Version $Version -OutputDirectory nuget } From ea2fbf6dcf7645149c80cde48c8afbfd40bd95a4 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Thu, 9 Oct 2014 10:16:04 +0200 Subject: [PATCH 17/27] oh la la! dirty, dirty dirty.. temp fix for getting stuff working so we can continue development until a proper fix can be devised --- CefSharp.Core/Internals/RenderClientAdapter.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CefSharp.Core/Internals/RenderClientAdapter.h b/CefSharp.Core/Internals/RenderClientAdapter.h index 74b6743a0..48eb49f0f 100644 --- a/CefSharp.Core/Internals/RenderClientAdapter.h +++ b/CefSharp.Core/Internals/RenderClientAdapter.h @@ -58,11 +58,13 @@ namespace CefSharp { return false; } - else - { - rect = CefRect(0, 0, _renderWebBrowser->Width, _renderWebBrowser->Height); - return true; + + while (_renderWebBrowser->Width == 0 && _renderWebBrowser->Height == 0) { + // block until the source window is ready } + + rect = CefRect(0, 0, _renderWebBrowser->Width, _renderWebBrowser->Height); + return true; }; /// From b804243201544e3ccefc29c83e2c1483934a8422 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Thu, 9 Oct 2014 11:38:26 +0200 Subject: [PATCH 18/27] implement block scope locking --- CefSharp.Core/CefSharp.Core.vcxproj | 1 + CefSharp.Core/CefSharp.Core.vcxproj.filters | 3 ++ CefSharp.Core/Internals/AutoLock.h | 58 +++++++++++++++++++++ CefSharp.Core/Internals/ClientAdapter.cpp | 8 +-- CefSharp.Core/Internals/ClientAdapter.h | 3 +- CefSharp.Core/Internals/StreamAdapter.cpp | 5 +- CefSharp.Core/Internals/StreamAdapter.h | 3 +- CefSharp.Core/SchemeHandlerWrapper.cpp | 8 +-- CefSharp.Core/SchemeHandlerWrapper.h | 3 +- 9 files changed, 73 insertions(+), 19 deletions(-) create mode 100644 CefSharp.Core/Internals/AutoLock.h diff --git a/CefSharp.Core/CefSharp.Core.vcxproj b/CefSharp.Core/CefSharp.Core.vcxproj index 8d42e7696..2f541e9f9 100644 --- a/CefSharp.Core/CefSharp.Core.vcxproj +++ b/CefSharp.Core/CefSharp.Core.vcxproj @@ -241,6 +241,7 @@ + diff --git a/CefSharp.Core/CefSharp.Core.vcxproj.filters b/CefSharp.Core/CefSharp.Core.vcxproj.filters index 4449bd366..90dc924bf 100644 --- a/CefSharp.Core/CefSharp.Core.vcxproj.filters +++ b/CefSharp.Core/CefSharp.Core.vcxproj.filters @@ -136,6 +136,9 @@ Header Files + + Header Files + diff --git a/CefSharp.Core/Internals/AutoLock.h b/CefSharp.Core/Internals/AutoLock.h new file mode 100644 index 000000000..659f8a306 --- /dev/null +++ b/CefSharp.Core/Internals/AutoLock.h @@ -0,0 +1,58 @@ +#pragma once + +#include + +namespace CefSharp +{ + namespace Internals + { + private class CriticalSection + { + public: + CriticalSection() + { + ::InitializeCriticalSection(&_cs); + } + + ~CriticalSection() + { + ::DeleteCriticalSection(&_cs); + } + + void Enter() + { + ::EnterCriticalSection(&_cs); + } + void Leave() + { + ::LeaveCriticalSection(&_cs); + } + + private: + CriticalSection(const CriticalSection&); + CriticalSection& operator=(const CriticalSection&); + + CRITICAL_SECTION _cs; + }; + + private class AutoLock + { + public: + AutoLock(CriticalSection& cs) : _cs(cs) + { + _cs.Enter(); + } + + ~AutoLock() + { + _cs.Leave(); + } + + private: + AutoLock(const AutoLock&); + AutoLock& operator=(const AutoLock&); + + CriticalSection& _cs; + }; + }; +}; \ No newline at end of file diff --git a/CefSharp.Core/Internals/ClientAdapter.cpp b/CefSharp.Core/Internals/ClientAdapter.cpp index 70b2bbabc..6754e5bed 100644 --- a/CefSharp.Core/Internals/ClientAdapter.cpp +++ b/CefSharp.Core/Internals/ClientAdapter.cpp @@ -159,7 +159,7 @@ namespace CefSharp return; } - _sync.Lock(); + AutoLock lock_scope(_syncRoot); if (frame->IsMain()) { @@ -168,8 +168,6 @@ namespace CefSharp } _browserControl->OnFrameLoadStart(StringUtils::ToClr(frame->GetURL()), frame->IsMain()); - - _sync.Unlock(); } void ClientAdapter::OnLoadEnd(CefRefPtr browser, CefRefPtr frame, int httpStatusCode) @@ -179,7 +177,7 @@ namespace CefSharp return; } - _sync.Lock(); + AutoLock lock_scope(_syncRoot); if (frame->IsMain()) { @@ -187,8 +185,6 @@ namespace CefSharp } _browserControl->OnFrameLoadEnd(StringUtils::ToClr(frame->GetURL()), frame->IsMain(), httpStatusCode); - - _sync.Unlock(); } void ClientAdapter::OnLoadError(CefRefPtr browser, CefRefPtr frame, ErrorCode errorCode, const CefString& errorText, const CefString& failedUrl) diff --git a/CefSharp.Core/Internals/ClientAdapter.h b/CefSharp.Core/Internals/ClientAdapter.h index 17ed362c2..f937a0c9c 100644 --- a/CefSharp.Core/Internals/ClientAdapter.h +++ b/CefSharp.Core/Internals/ClientAdapter.h @@ -8,6 +8,7 @@ #include "include/cef_app.h" #include "include/cef_client.h" #include "include/cef_render_process_handler.h" +#include "AutoLock.h" using namespace System; @@ -30,7 +31,7 @@ namespace CefSharp public CefDialogHandler { private: - base::internal::LockImpl _sync; + CriticalSection _syncRoot; gcroot _browserControl; gcroot _managedCefBrowserAdapter; HWND _browserHwnd; diff --git a/CefSharp.Core/Internals/StreamAdapter.cpp b/CefSharp.Core/Internals/StreamAdapter.cpp index 7b056eb30..d17553d91 100644 --- a/CefSharp.Core/Internals/StreamAdapter.cpp +++ b/CefSharp.Core/Internals/StreamAdapter.cpp @@ -16,7 +16,7 @@ namespace CefSharp size_t StreamAdapter::Read(void* ptr, size_t size, size_t n) { - _sync.Lock(); + AutoLock lock_scope(_syncRoot); try { array^ buffer = gcnew array(n * size); @@ -29,9 +29,6 @@ namespace CefSharp { return -1; } - finally { - _sync.Unlock(); - } } int StreamAdapter::Seek(int64 offset, int whence) diff --git a/CefSharp.Core/Internals/StreamAdapter.h b/CefSharp.Core/Internals/StreamAdapter.h index 2a9a10e41..70c882389 100644 --- a/CefSharp.Core/Internals/StreamAdapter.h +++ b/CefSharp.Core/Internals/StreamAdapter.h @@ -3,6 +3,7 @@ // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. #include "Stdafx.h" +#include "AutoLock.h" #pragma once using namespace System; @@ -14,7 +15,7 @@ namespace CefSharp { private class StreamAdapter : public CefReadHandler { - base::internal::LockImpl _sync; + CriticalSection _syncRoot; gcroot _stream; public: diff --git a/CefSharp.Core/SchemeHandlerWrapper.cpp b/CefSharp.Core/SchemeHandlerWrapper.cpp index 5f7e92d47..d7902fa60 100644 --- a/CefSharp.Core/SchemeHandlerWrapper.cpp +++ b/CefSharp.Core/SchemeHandlerWrapper.cpp @@ -36,7 +36,7 @@ namespace CefSharp bool handled = false; - _sync.Lock(); + AutoLock lock_scope(_syncRoot); auto schemeResponse = gcnew SchemeHandlerResponse(this); auto onRequestCompleted = gcnew OnRequestCompletedHandler(schemeResponse, &SchemeHandlerResponse::OnRequestCompleted); @@ -47,8 +47,6 @@ namespace CefSharp handled = true; } - _sync.Unlock(); - return handled; } @@ -94,7 +92,7 @@ namespace CefSharp { bool has_data = false; - _sync.Lock(); + AutoLock lock_scope(_syncRoot); if (static_cast(_stream) == nullptr) { @@ -115,8 +113,6 @@ namespace CefSharp } } - _sync.Unlock(); - return has_data; } diff --git a/CefSharp.Core/SchemeHandlerWrapper.h b/CefSharp.Core/SchemeHandlerWrapper.h index 64f2c2d57..b1f349651 100644 --- a/CefSharp.Core/SchemeHandlerWrapper.h +++ b/CefSharp.Core/SchemeHandlerWrapper.h @@ -6,6 +6,7 @@ #include "Stdafx.h" #include "include/cef_scheme.h" +#include "Internals/AutoLock.h" using namespace System; using namespace System::IO; @@ -17,7 +18,7 @@ namespace CefSharp public class SchemeHandlerWrapper : public CefResourceHandler { - base::internal::LockImpl _sync; + CriticalSection _syncRoot; gcroot _handler; gcroot _stream; CefRefPtr _callback; From d173f28e0900840ef6466ccf22808467faa23b10 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Fri, 10 Oct 2014 08:30:59 +0200 Subject: [PATCH 19/27] sizes passed to the CefRenderHandler OnPaint and OnPopupSize methods are now already DPI scaled --- CefSharp.Wpf/ChromiumWebBrowser.cs | 42 +++++-------------------- CefSharp/Internals/IRenderWebBrowser.cs | 4 +-- 2 files changed, 9 insertions(+), 37 deletions(-) diff --git a/CefSharp.Wpf/ChromiumWebBrowser.cs b/CefSharp.Wpf/ChromiumWebBrowser.cs index 4e07c0483..64b44bb20 100644 --- a/CefSharp.Wpf/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf/ChromiumWebBrowser.cs @@ -34,12 +34,11 @@ 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 disposables = new List(); public BrowserSettings BrowserSettings { get; set; } @@ -105,14 +104,14 @@ namespace CefSharp.Wpf get { return PixelFormat.BitsPerPixel / 8; } } - int IRenderWebBrowser.Width + double IRenderWebBrowser.Width { - get { return (int)matrix.Transform(new Point(ActualWidth, ActualHeight)).X; } + get { return ActualWidth; } } - int IRenderWebBrowser.Height + double IRenderWebBrowser.Height { - get { return (int)matrix.Transform(new Point(ActualWidth, ActualHeight)).Y; } + get { return ActualHeight; } } private static PixelFormat PixelFormat @@ -501,14 +500,11 @@ namespace CefSharp.Wpf AddSourceHookIfNotAlreadyPresent(); - CheckIsNonStandardDpi(); - // Create main window Content = image = CreateImage(); - Transform(image); + // Create popup popup = CreatePopup(); - Transform(popup); } private static Image CreateImage() @@ -538,22 +534,6 @@ 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) @@ -565,7 +545,6 @@ namespace CefSharp.Wpf if (source != null) { - matrix = source.CompositionTarget.TransformToDevice; sourceHook = SourceHook; source.AddHook(sourceHook); } @@ -726,10 +705,6 @@ 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) @@ -1171,10 +1146,7 @@ namespace CefSharp.Wpf private Point GetPixelPosition(MouseEventArgs e) { - var deviceIndependentPosition = e.GetPosition(this); - var pixelPosition = matrix.Transform(deviceIndependentPosition); - - return pixelPosition; + return e.GetPosition(this); } private object SetBitmapHelper(BitmapInfo bitmapInfo, InteropBitmap bitmap, Action imageSourceSetter) diff --git a/CefSharp/Internals/IRenderWebBrowser.cs b/CefSharp/Internals/IRenderWebBrowser.cs index ef7e6f718..abda8b1d9 100644 --- a/CefSharp/Internals/IRenderWebBrowser.cs +++ b/CefSharp/Internals/IRenderWebBrowser.cs @@ -10,8 +10,8 @@ namespace CefSharp.Internals { int BytesPerPixel { get; } - int Width { get; } - int Height { get; } + double Width { get; } + double Height { get; } void InvokeRenderAsync(BitmapInfo bitmapInfo); From 4e090ce54db343bbd5260872315f416fd63cbead Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Fri, 10 Oct 2014 08:49:38 +0200 Subject: [PATCH 20/27] this and that, see: https://github.com/peters/CefSharp/commit/ea2fbf6dcf7645149c80cde48c8afbfd40bd95a4#commitcomment-8110807 --- CefSharp.Core/Internals/RenderClientAdapter.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CefSharp.Core/Internals/RenderClientAdapter.h b/CefSharp.Core/Internals/RenderClientAdapter.h index 48eb49f0f..bcd9db14e 100644 --- a/CefSharp.Core/Internals/RenderClientAdapter.h +++ b/CefSharp.Core/Internals/RenderClientAdapter.h @@ -59,8 +59,9 @@ namespace CefSharp return false; } + // Block until the source window is ready while (_renderWebBrowser->Width == 0 && _renderWebBrowser->Height == 0) { - // block until the source window is ready + ::Sleep(50); } rect = CefRect(0, 0, _renderWebBrowser->Width, _renderWebBrowser->Height); From 4a477d181c4a788934697b76be7d7d50e70a5bf5 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Tue, 14 Oct 2014 09:01:44 +0200 Subject: [PATCH 21/27] bugfix: initialize RenderClientAdapter when WPF has calculated the actual size of current content. --- CefSharp.Core/Internals/RenderClientAdapter.h | 5 ----- CefSharp.Wpf/ChromiumWebBrowser.cs | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CefSharp.Core/Internals/RenderClientAdapter.h b/CefSharp.Core/Internals/RenderClientAdapter.h index bcd9db14e..c55247475 100644 --- a/CefSharp.Core/Internals/RenderClientAdapter.h +++ b/CefSharp.Core/Internals/RenderClientAdapter.h @@ -59,11 +59,6 @@ namespace CefSharp return false; } - // Block until the source window is ready - while (_renderWebBrowser->Width == 0 && _renderWebBrowser->Height == 0) { - ::Sleep(50); - } - rect = CefRect(0, 0, _renderWebBrowser->Width, _renderWebBrowser->Height); return true; }; diff --git a/CefSharp.Wpf/ChromiumWebBrowser.cs b/CefSharp.Wpf/ChromiumWebBrowser.cs index 64b44bb20..6eb761674 100644 --- a/CefSharp.Wpf/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf/ChromiumWebBrowser.cs @@ -436,11 +436,6 @@ namespace CefSharp.Wpf CleanupCommand = new DelegateCommand(Dispose); StopCommand = new DelegateCommand(Stop); - managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this); - managedCefBrowserAdapter.CreateOffscreenBrowser(BrowserSettings ?? new BrowserSettings()); - - disposables.Add(managedCefBrowserAdapter); - disposables.Add(new DisposableEventWrapper(this, ActualHeightProperty, OnActualSizeChanged)); disposables.Add(new DisposableEventWrapper(this, ActualWidthProperty, OnActualSizeChanged)); } @@ -450,6 +445,18 @@ namespace CefSharp.Wpf Dispose(false); } + private void CreateOffscreenBrowserWhenActualSizeChanged() + { + if (managedCefBrowserAdapter != null) + { + return; + } + managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this); + managedCefBrowserAdapter.CreateOffscreenBrowser(BrowserSettings ?? new BrowserSettings()); + + disposables.Add(managedCefBrowserAdapter); + } + private void DoInUi(Action action, DispatcherPriority priority = DispatcherPriority.DataBind) { if (Dispatcher.CheckAccess()) @@ -464,6 +471,8 @@ namespace CefSharp.Wpf private void OnActualSizeChanged(object sender, EventArgs e) { + // Initialize RenderClientAdapter when WPF has calculated the actual size of current content. + CreateOffscreenBrowserWhenActualSizeChanged(); managedCefBrowserAdapter.WasResized(); } From 105f5c49c2aa04d34ccff35fb136c2e1705a4bbe Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Tue, 14 Oct 2014 09:38:21 +0200 Subject: [PATCH 22/27] Revert "sizes passed to the CefRenderHandler OnPaint and OnPopupSize methods are now already DPI scaled" This reverts commit d173f28e0900840ef6466ccf22808467faa23b10. --- CefSharp.Wpf/ChromiumWebBrowser.cs | 42 ++++++++++++++++++++----- CefSharp/Internals/IRenderWebBrowser.cs | 4 +-- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/CefSharp.Wpf/ChromiumWebBrowser.cs b/CefSharp.Wpf/ChromiumWebBrowser.cs index 6eb761674..43e009e66 100644 --- a/CefSharp.Wpf/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf/ChromiumWebBrowser.cs @@ -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 disposables = new List(); 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 imageSourceSetter) diff --git a/CefSharp/Internals/IRenderWebBrowser.cs b/CefSharp/Internals/IRenderWebBrowser.cs index abda8b1d9..ef7e6f718 100644 --- a/CefSharp/Internals/IRenderWebBrowser.cs +++ b/CefSharp/Internals/IRenderWebBrowser.cs @@ -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); From b01f8013075858392462f156adf8b07002047d00 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Tue, 14 Oct 2014 10:10:37 +0200 Subject: [PATCH 23/27] automatically bump assembly version --- build.ps1 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/build.ps1 b/build.ps1 index aefe9793e..4db0a8523 100644 --- a/build.ps1 +++ b/build.ps1 @@ -234,10 +234,25 @@ function DownloadNuget() } } +function WriteAssemblyVersion +{ + param() + + $Filename = Join-Path $WorkingDir CefSharp\Properties\AssemblyInfo.cs + $Regex = 'public const string AssemblyVersion = "(.*)"'; + + $AssemblyInfo = Get-Content $Filename + $NewString = $AssemblyInfo -replace $Regex, "public const string AssemblyVersion = ""$Version""" + + $NewString | Set-Content $Filename -Encoding UTF8 +} + DownloadNuget NugetPackageRestore +WriteAssemblyVersion + switch -Exact ($Target) { "nupkg" { From 4c7e4a6b2121e64e73caba5a3fb03d4ebe051dc1 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Tue, 14 Oct 2014 10:15:51 +0200 Subject: [PATCH 24/27] include build.ps1 in solution so that we can use powershell tools inside visual studio --- CefSharp3.sln | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CefSharp3.sln b/CefSharp3.sln index 08485a58e..bb31481ad 100644 --- a/CefSharp3.sln +++ b/CefSharp3.sln @@ -54,6 +54,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp", "CefSharp\CefSha EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{D62CBBCA-9C35-4CB4-BA62-ADC79C9045DF}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{9AD9C469-B121-47BB-9B9F-30D1B96B52B0}" + ProjectSection(SolutionItems) = preProject + build.ps1 = build.ps1 + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -140,5 +145,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {A23AA466-1903-44F2-946D-25AD0500D56B} = {47D0DC8C-D707-4D8A-A578-7737AA9CE79B} + {9AD9C469-B121-47BB-9B9F-30D1B96B52B0} = {47D0DC8C-D707-4D8A-A578-7737AA9CE79B} EndGlobalSection EndGlobal From bd56578df0d39dde9feb8d509c900b084e07abce Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Tue, 14 Oct 2014 10:58:16 +0200 Subject: [PATCH 25/27] add after build script example that shows how to automatically upload packages to myget which is useful for automated builds --- afterbuild.example.ps1 | 32 ++++++++++++++++++++++++++++++++ build.ps1 | 7 +++++++ 2 files changed, 39 insertions(+) create mode 100644 afterbuild.example.ps1 diff --git a/afterbuild.example.ps1 b/afterbuild.example.ps1 new file mode 100644 index 000000000..a862e42d9 --- /dev/null +++ b/afterbuild.example.ps1 @@ -0,0 +1,32 @@ +param( + [Parameter(Position = 0, Mandatory = $true)] + [string] $Version +) + +$WorkingDir = Split-Path -Parent $MyInvocation.MyCommand.Definition +$Nuget = Join-Path $env:LOCALAPPDATA .\nuget\NuGet.exe +$PackagePath = Join-Path $WorkingDir\nuget + +function Write-Diagnostic +{ + param( + [Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)] + [string] $Message + ) + + Write-Host + Write-Host $Message -ForegroundColor Green + Write-Host +} + +Write-Diagnostic "Uploading packages to myget" + +$Packages = @( + "$PackagePath\CefSharp.Common.$Version.nupkg", + "$PackagePath\CefSharp.WinForms.$Version.nupkg", + "$PackagePath\CefSharp.Wpf.$Version.nupkg" +) + +$Packages | ForEach-Object { + . $Nuget push $_ -Source https://myget.org/F/X +} \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index 4db0a8523..d1121d51c 100644 --- a/build.ps1 +++ b/build.ps1 @@ -222,6 +222,13 @@ function Nupkg . $nuget pack nuget\CefSharp.Common.nuspec -NoPackageAnalysis -Version $Version -OutputDirectory nuget -Properties "RedistVersion=$RedistVersion" . $nuget pack nuget\CefSharp.Wpf.nuspec -NoPackageAnalysis -Version $Version -OutputDirectory nuget . $nuget pack nuget\CefSharp.WinForms.nuspec -NoPackageAnalysis -Version $Version -OutputDirectory nuget + + # Invoke `AfterBuild` script if available (ie. upload packages to myget) + if(-not (Test-Path $WorkingDir\AfterBuild.ps1)) { + return + } + + . $WorkingDir\AfterBuild.ps1 -Version $Version } function DownloadNuget() From 9bbeff703b822979652120b56f31b229f279fd9c Mon Sep 17 00:00:00 2001 From: amaitland Date: Fri, 24 Oct 2014 17:10:14 +1000 Subject: [PATCH 26/27] Update to 2062.1876 packages on staging --- CefSharp.Core/CefSharp.Core.vcxproj | 4 ++-- CefSharp.Core/packages.config | 2 +- CefSharp.Test/CefSharp.Test.csproj | 12 ++++-------- CefSharp.Test/packages.config | 6 ++---- .../CefSharp.WinForms.Example.csproj | 16 +++++++--------- CefSharp.WinForms.Example/packages.config | 6 ++---- CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj | 12 ++++-------- CefSharp.Wpf.Example/packages.config | 6 ++---- 8 files changed, 24 insertions(+), 40 deletions(-) diff --git a/CefSharp.Core/CefSharp.Core.vcxproj b/CefSharp.Core/CefSharp.Core.vcxproj index 2f541e9f9..0b71f7874 100644 --- a/CefSharp.Core/CefSharp.Core.vcxproj +++ b/CefSharp.Core/CefSharp.Core.vcxproj @@ -1,6 +1,6 @@  - + Debug @@ -285,6 +285,6 @@ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/CefSharp.Core/packages.config b/CefSharp.Core/packages.config index 114e1bcdb..5536533e9 100644 --- a/CefSharp.Core/packages.config +++ b/CefSharp.Core/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/CefSharp.Test/CefSharp.Test.csproj b/CefSharp.Test/CefSharp.Test.csproj index f2591227d..f24312825 100644 --- a/CefSharp.Test/CefSharp.Test.csproj +++ b/CefSharp.Test/CefSharp.Test.csproj @@ -137,17 +137,13 @@ --> - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - + + - - - + + \ No newline at end of file diff --git a/CefSharp.Test/packages.config b/CefSharp.Test/packages.config index 1f691904c..0f1da6083 100644 --- a/CefSharp.Test/packages.config +++ b/CefSharp.Test/packages.config @@ -2,10 +2,8 @@ - - - - + + \ No newline at end of file diff --git a/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj b/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj index de05ec328..b46a2bc08 100644 --- a/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj +++ b/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj @@ -71,7 +71,9 @@ BrowserTabUserControl.cs - + + Form + SimpleBrowserForm.cs @@ -144,17 +146,13 @@ - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - + + - - - + + \ No newline at end of file diff --git a/CefSharp.WinForms.Example/packages.config b/CefSharp.WinForms.Example/packages.config index 0f2091c4a..711f25de0 100644 --- a/CefSharp.WinForms.Example/packages.config +++ b/CefSharp.WinForms.Example/packages.config @@ -1,7 +1,5 @@  - - - - + + \ No newline at end of file diff --git a/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj b/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj index 35f1f5a9b..6a94d60af 100644 --- a/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj +++ b/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj @@ -164,17 +164,13 @@ - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - + + - - - + + \ No newline at end of file diff --git a/CefSharp.Wpf.Example/packages.config b/CefSharp.Wpf.Example/packages.config index 0f2091c4a..711f25de0 100644 --- a/CefSharp.Wpf.Example/packages.config +++ b/CefSharp.Wpf.Example/packages.config @@ -1,7 +1,5 @@  - - - - + + \ No newline at end of file From ff7ef547b3a5aa4118555d0c4d0f0cd4e702c7b8 Mon Sep 17 00:00:00 2001 From: jornh Date: Sun, 26 Oct 2014 13:06:24 +0100 Subject: [PATCH 27/27] Bump `cef.sdk` package to 3.2062.1876-pre1 which has VS2013 specific lib files too --- CefSharp.Core/CefSharp.Core.vcxproj | 6 +++--- CefSharp.Core/packages.config | 2 +- build.ps1 | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CefSharp.Core/CefSharp.Core.vcxproj b/CefSharp.Core/CefSharp.Core.vcxproj index 0b71f7874..c49046cb7 100644 --- a/CefSharp.Core/CefSharp.Core.vcxproj +++ b/CefSharp.Core/CefSharp.Core.vcxproj @@ -1,6 +1,6 @@  - + Debug @@ -66,7 +66,7 @@ <_ProjectFileVersion>11.0.51106.1 - 692f35e4 + 9aa99f24 bin\$(Configuration)\ @@ -285,6 +285,6 @@ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/CefSharp.Core/packages.config b/CefSharp.Core/packages.config index 5536533e9..03ee03d3d 100644 --- a/CefSharp.Core/packages.config +++ b/CefSharp.Core/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index d1121d51c..63ca6c512 100644 --- a/build.ps1 +++ b/build.ps1 @@ -5,7 +5,7 @@ param( [Parameter(Position = 1)] [string] $Version = "37.0.0", [Parameter(Position = 2)] - [string] $RedistVersion = "3.2062.1856" + [string] $RedistVersion = "3.2062.1876" ) $WorkingDir = split-path -parent $MyInvocation.MyCommand.Definition