Commit Graph

247 Commits

Author SHA1 Message Date
Alex Maitland b8b27f6885 WPF/OffScreen - Add WaitForRenderIdleAsync (#4080)
* WPF/OffScreen - Add WaitForRenderIdleAsync

- Task resolves when render has been idle for the specified time
- Make TaskTimeoutExtensions public (they're not extension methods as this was expected)
2022-05-30 19:11:17 +10:00
Alex Maitland 7eb6d6f3b7 OffScreen - CaptureScreenshotAsync change to Scale default
- Previously when no Scale was specified, then the previous ChromiumWebBrowser scale was used.
- Now Viewport defaults to a scale of 1, so the behaviour has been changed so the scale passed as
  the param is always used.
- Test updated

This is a minor breaking change.

Resolves #4091
2022-05-05 19:27:29 +10:00
Alex Maitland f201c694c6 WinForms - Add CaptureScreenshotAsync
- Simplification of calling the DevTools method
- Moved GetContentSizeAsync from OffScreen into partial class (now accessible from WinForms/WPF/OffScreen).
- Added menu option

Resolves #4081
2022-05-03 11:29:11 +10:00
campersau 5e16914d9a OffScreen - Fix ResizeAsync with deviceScalingFactor (#3964)
* OffScreen - Fix ResizeAsync with deviceScalingFactor

* OffScreen - Fix CaptureScreenshotAsync Width / Height calculation to include X and Y

Always apply Scale changes
2022-01-18 11:03:44 +10:00
Alex Maitland 4dba51955b OffScreen - CaptureScreenshotAsync only resize if larger and support clip 2022-01-15 11:20:06 +10:00
Alex Maitland b72d41353e WinForms - Improve hosting of popups using ChromiumHostControl
- Add IChromiumWebBrowserBase which is can be used for ChromiumWebBrowser instances and ChromiumHostControl
- Reduce code duplication for extensions methods
- Update WinForms Example
2021-11-30 13:47:42 +10:00
Alex Maitland d8674fd076 OffScreen - Add CaptureScreenshotAsync, GetContentSizeAsync and ResizeAsync
- Simply taking full page screenshots
- Added new methods
- CaptureScreenshotAsync uses Devtools protocol and allows for specifying image format and quality (if jpg)

Cannot use clip param as https://bitbucket.org/chromiumembedded/cef/issues/3103/offscreen-capture-screenshot-with-devtools
2021-11-16 13:41:26 +10:00
Alex Maitland 4a07af26e9 Core - Rename WaitForBrowserInitialLoadAsync to WaitForInitialLoadAsync and simplify
- Initial intention was to have a reusable method that could be used CefSharp.Wpf.HwndHost,
  upon further deliberation I've decided to build the functionality into the ChromiumWebBrowser.Partial.cs
  and will need to duplicate the functionality in CefSharp.Wpf.HwndHost. This guarantees that the
  Task will be resolved in all cases. The previous implementation there was a theoretical change we'd
  miss subscribing to the relevant events
- Remove CancellationToken as it's not possible to cancel

Issue #3842
2021-10-28 10:31:03 +10:00
Alex Maitland 9993aa78e0 OffScreen - Create Browser when Global CefRequestContext initialized.
- GlobalContextInitialized wraps a TaskCompletionSource which is resolved
  when the Global CefRequestContext has been created
- Reduce code duplication

If successful we can apply the same changes to WinForms/WPF though they're less likely to have
issues than the OffScreen implementation as the CreateBrowser doesn't happen until much later

Issue #3850 #3634
2021-10-26 14:31:10 +10:00
Alex Maitland b82fa05291 WinForms/WPF/OffScreen - Update Load(string url) behaviour
- All three implementations updated to include an IsDisposed check which
  will simply return immediately
- OffScreen updated to match the WinForms behaviour
- WPF is more complex because of the initialAddress and Address properties
  initialAddress will be set if the browser hasn't been created, if the browserCreated
  has been created and OnAfterBrowserCreated hasn't been called then we'll set the Address
  dependency property.

NOTE: For WinForms/OffScreen there's a small window
here between CreateBrowser and OnAfterBrowserCreated
where the Address prop will be updated, though LoadUrl
won't be called.
2021-10-08 12:40:54 +10:00
Alex Maitland c226d344b1 WinForms/WPF/OffScreen - Add LoadUrl method (Same as Load(string)).
A more meaningful name for the method, matches the LoadUrlAsync method
that was added recently.
2021-10-08 10:21:31 +10:00
Alex Maitland 65534275b7 Core - Upgrade to newer SDK Style project
- Upgrade CefSharp.Core.csproj
- Upgrade CefSharp.csproj
- Ensure pdbs are generated for release builds with same settings as before

Issue #3791
2021-09-20 11:32:14 +10:00
Alex Maitland 172ee5afe8 Migrate from GitLink to Source link
Resolves #3036
2021-09-07 12:08:56 +10:00
Alex Maitland e4e0f22ca7 WinForms/WPF/OffScreen - Upgrade to SDK style projects and multi-target net452 and net462
Haven't tested the output nuget packages yet, we might still need to change the nuspec files to add a
dependency group.

Issue #3791
2021-09-05 15:09:35 +10:00
Alex Maitland d350cad52a Update to M93 (#3781)
* Upgrade to CEF 93.1.7+g9117d6a+chromium-93.0.4577.42 / Chromium 93.0.4577.42

- Core - Add basic ref counting implementation

IMPLEMENT_REFCOUNTING implementation uses atomic which
forces the VC++ compiler to compile as native which doesn't work for our managed ref classes.

    - Use InterlockedCompareExchange for custom ref count reads
    - Use InterlockedIncrement/InterlockedDecrement directly
    - There's no memory barrier for HasOneRef/HasAtLeastOneRef as the read of a LONG should happen in one operation
on 32/64 bit architectures (at least that's my understanding at this point in time).

    References:
    https://github.com/chromiumembedded/cef/blob/4472/include/base/internal/cef_atomicops_x86_msvc.h#L125
    https://github.com/chromiumembedded/cef/blob/4472/include/base/internal/cef_atomicops_arm64_msvc.h#L107
    https://github.com/chromiumembedded/cef/blob/4472/include/base/cef_atomic_ref_count.h#L114
    https://github.com/chromiumembedded/cef/blob/4472/include/cef_base.h#L91

-  Remove Microsoft.Net.Compilers package from projects
Now that we require a min of VS2019 to build there's no need for a custom compiler package
- Start removing VS2015/VC++2015 references
- Remove RegisterWidevineCdm
This is a breaking change. CEF will now automatically download the Widevine CDM component
Resolves #3767

- RequestContext.LoadExtension now uses managed to code spawn on CEF UI Thread
Avoid having to use cef_callback.h which was causing problems for x86 builds
2021-09-03 10:51:18 +10:00
Alex Maitland e5f2381351 WinForms/WPF/OffScreen - Use custom FocusHandler when disposing to block taking focus
This was added as a workaround for Issue #3715 which is specific to WinForms
and will hopefully be fixed upstream.

I've added the logic to all three implementations as I think the behaviour should be
consistent across all implementations.
2021-07-27 13:13:17 +10:00
Alex Maitland a6ff42ee6f Core - IAudioHandler now implements IDisposable
IAudioHandler.Dispose is called when the ChromiumWebBrowser instance is being Disposed.

This is a breaking change.

Resolves #3598
2021-06-04 15:49:52 +10:00
Alex Maitland 96117f9a47 OffScreen - Add CreateBrowserAsync
Issue #3594
2021-06-02 19:42:04 +10:00
Alex Maitland 4ebe7de1bc OffScreen - Add ChromiumWebBrowser constructor overload with onAfterBrowserCreated delegate
Use the constructor overload as an alternative to the BrowserInitialized event

Follow up to #3552
2021-05-22 13:45:42 +10:00
Alex Maitland 2568236ac1 OffScreen - Clarify BrowserInitialized may not be called if Browser created automatically
Resolves #3552
2021-05-22 13:18:52 +10:00
Alex Maitland 047f8b838c WPF/WinForms/OffScreen - Reduce code duplication
Issue #3082
2021-04-01 16:28:20 +10:00
Alex Maitland 5780aefda3 Net Source - Add SourceLink support
- The Debug PDBs will now use SourceLink
- The C++/CLI projects will use SourceLink
- CefSharp.Core.dll now generates/uses a ref assembly
- The managed (c#) projects still embed sources/symbols for Release builds

At some point we should investigate generating a snupkg to reduce the dll size
2021-03-12 13:15:31 +10:00
Alex Maitland bcc2c91e0a Core - ManagedCefBrowserAdapter::InitializeBrowserProcessServiceHost improve Dispose handling
As the browser is Disposed on a different Thread to OnAfterBrowserCreated is called there's possibility of an ObjectDisposedException.
Instead of locking just catch and ignore the error as it's extremely rare

Resolves #3437
2021-03-11 15:22:30 +10:00
Alex Maitland 30860d66d6 WinForms/WPF/OffScreen - Improve Cef.Initialize failed error message.
Direct user to check log file as the underlying CefInitialize call doesn't return an error message.
Errors are only available through the logs.
2021-02-26 12:16:49 +10:00
Alex Maitland 8a367fbdc4 Refactor CefSharp.Core into CefSharp.Core.Runtime (#3311)
* Net Core - Rename CefSharp.Core.dll to CefSharp.Core.Runtime.dll

Partial rename, only Net Core, folder not renamed

* Net Core - Rename CefSharp.Core.RefAssembly to CefSharp.Core.netcore

Remove GenApi

* Core - Rename CefDragDataWrapper to DragData

Move into CefSharp.Core namespace

* WinForms/WPF/OffScreen - Migrate from GitLink command line to Nuget package

* Net Core - Refactor to have CefSharp.Core.dll contain only public Api

* Net Core - Remove CefSharp.Core.RefAssembly

* Net Core - Change CefSharp.Core.netcore output folder

* Net Core - Restructure nuget packages

* Net Core - Add Cefsharp.Core.Runtime.RefAssembly

* Net Core - Hide CLI/C++ classes from intellisense

Make sure users don't attempt to load them directly

* Rename CefSharp.Core to CefSharp.Core.Runtime

* Core - Restructure Net 4.5.2 packages to use CefSharp.Core.dll anycpu variant

Attempt to load CefSharp.Core.Runtime at runtime rather than having to use msbuild to copy the correct version

* Rename CefSharp.Core.netcore to CefSharp.Core

* WPF/WinForms/OffScreen - Change from x86/64 to AnyCPU

As they are all managed assemblies they can target AnyCPU.
Includes CefSharp.dll

* Convert RequestContextBuilder from C++ to C#

Now part of the CefSharp.Core PublicApi

* Update version number to 87.1.11

* Migrate more of the public Api to C#

* Net Core - Basic restructure complete

* Net Core - ModuleInitializer (Doesn't work yet)

* Remove direct references to BrowserSettings

* Net Core - ModuleInitializer load CefShar.Core.Runtime.dl

* Net Core - Load libcef.dll via CLR Module initializer

If no RID is specified then we can load libcef.dll using the module initializer

* Add version to CefSharp.Core

* Remove dependency on CefSharp.Core.Runtime
Rewrite common targets

* AnyCPU app.config transform

Improve AnyCPU support

* Improve Net Core 3 support
Only delete CefSharp.Core.Runtime.dll when AnyCPU

* Nuget - Add CefSharp.Core.Runtime reference when TargetFramework = NetCore

* Fix Typos

Based on #3306

* Net Core - Rename CefSharp.Core.Runtime RefAssembly source file

* Net Full - Generate CefSharp.Core.Runtime Ref Assembly

For now the powershell build script generates the .cs file based on a x86 release build.ps1
It's not possible to directly install GenApi as it requires a Sdk style project

* Net Core - Old packages copy files to required folders

* Test - Install newer .Net Compiler and set Lang Version to 7.3

* Net Core - Exclude Net 452 Runtime generated reference source

* Core - Add Refactoring TODO

* Ref Assembly - Generate source as part of build

- Move ref assembly source generate into GenerateRefAssemblySource.ps1
- Call before project build

Runs locally, see if Appveyor has a problem with the powershell script execution

* Core - Add more factory methods to create instances of managed wrappers

* Net Core - Make Initialzier properties internal

Not quite sure what the public API should look like as yet, so making internal for now.
2020-12-16 10:47:34 +10:00
GitHubPang 728420ca7f Fix typos (#3305) 2020-12-06 11:24:14 +10:00
GitHubPang facecb1bab Fix typo. (#3282) 2020-11-15 05:13:47 +10:00
Alex Maitland 928bc68ef6 Net Core - Embed PDB and Source
For release builds we embed project source and symbols (at least until https://github.com/dotnet/sdk/issues/1458 is resolved)

Issue #3197
2020-11-06 15:45:36 +10:00
Alex Maitland c0ef404213 Core - VS2019 Invalid option '7.3' for /langversion
When building CefSharp3.sln under VS2019 the Microsoft.Net.Compilers (version 2.4) is passed version 7.3 for c# version
Version 2.4 supports a maximum of version 7.1, the issue doesn't happen on VS2015 or VS2017
Hard code LangVersion in csproj files

CS1617	Invalid option '7.3' for /langversion; must be ISO-1, ISO-2, Default, Latest or a valid version in range 1 to 7.1.

https://stackoverflow.com/questions/46419760/using-c-sharp-7-1-with-msbuild
2020-11-06 13:13:28 +10:00
amaitland 3372ce8a57 Build - Generate Ref Assemblies for .Net 4.5.2 assemblies
Only for Release builds.

This appears to work as expected under VS2017, not sure about VS2015
Roslny .Net compiler upgraded to 2.4 allows for Ref Assembly generation
2020-10-21 18:10:04 +10:00
amaitland 5d4897f4c6 Core - Add Microsoft.Net.Compilers 2.4
This is the last version to support .Net 4.5.2
Set allowedVersions="2.4"  to stop from updating to a newer version which won't compile under VS2015
2020-10-21 17:55:29 +10:00
amaitland 71773424dc Wpf/WinForms/OffScreen - Standardize InternalIsBrowserInitialized
- Add InternalIsBrowserInitialized to partial class
- Move ThrowExceptionIfDisposed/ThrowExceptionIfBrowserNotInitialized to partial class
- Remove checks from DevToolsExtensions.ExecuteDevToolsMethodAsync as the checks were already in GetBrowser

In WPF it's no longer necessary to have a custom implementation, will leave the Dependency property
(won't action #3033 at this point in time)
2020-09-18 13:32:22 +10:00
amaitland 3ccb0f8b10 Core - Reduce ChromiumWebBrowser Code Duplication
- Move events to partial class (where possible)
- Move other explicit interface implementation methods

Issue #3082
2020-09-16 19:44:36 +10:00
amaitland 6d62d188b7 Core - Reduce Code Duplication
Move Handler property decelerations to partial class

Issue #3082
2020-09-16 17:06:57 +10:00
amaitland e1ca2f085b Net Core - Produce reference assemblies for c# projects
- Produce ref assembly for Release builds only

#3197
2020-08-07 15:41:09 +10:00
amaitland 0183c429e0 WPF/WinForms/OffScreen - Reduce Code Duplication Initial
- Add ChromiumWebBrowser.Partial.cs and include in all three projects
- Remove InternalsVisibleTo from Cefsharp.dll start moving code into the partial class
  (We don't want to publish our internals as part of our Ref Assembly so this goings together)

#3082
#3197
2020-08-07 14:24:07 +10:00
amaitland e8cf336bf3 Net Core - Support for compiling with .Net Core 3.1
- Make Wpf/WinForms/OffScreen projects target AnyCPU
Only the VC++ projects are platform specific now.
- Remove BrowserSubProcess project reference
Not needed as we now have a standalone exe
- Add OffScreen example
- Add WPF Example project
- Fix some compile errors for main solution
- Add BrowserSubProcess executable
- JavascriptObjectRepository remove isAsync param
Rather than throw exception remove the option
- BrowserSubprocess Exclude the WCF specific code from the netCore project
- Add some ifdef/ifndef to exclude the WCF specific implementation
- Move WCF implementation into separate namespace
2020-07-23 15:23:45 +10:00
Konstantin Preißer 5e89f71a44 Add new projects targeting .NET Core 3.1 (#3181)
* Add .NET Core 3.1 projects for CefSharp, CefSharp.Core, CefSharp.BrowserSubprocess.Core, CefSharp.WinForms, CefSharp.Wpf, CefSharp.OffScreen.

Contributes to CefSharp#2796

* - Remove dependencies to "opengl32.lib" and "glu32.lib" which aren't available for ARM64 and don't seem to be needed.
- Clean up project files.

* Switch project CefSharp.netcore.csproj to AnyCPU as it doesn't require different builds for each platform.

* Remove WindowsTargetPlatformVersion property as that is declared in CefSharp.props.

* Use "bin.netcore" and "obj.netcore" as [intermediate] output path for the .NET Core projects, to allow side-by-side builds with the .NET Framework projects.

* Output documentation files.

* Add CefSharp.Example.netcore and CefSharp.WinForms.Example.netcore.

* Follow-up: Remove properties from the example projects that are also not used in the corresponding .NET Framework projects.
2020-07-23 15:21:14 +10:00
Alex Maitland 8d25b71490 Core - Re-Add IAudioHandler (#3153)
Resolves #3152
2020-07-08 08:06:16 +10:00
amaitland ea30d88014 OffScreen - Improve constructor xml doc
Issue #2977
2020-05-23 19:46:43 +10:00
amaitland 1824a0334d WPF/WinForms/OffScreen - CanExecuteJavascriptInMainFrame incorrectly false after loading page with different origin
Proof of concept for a workaround. The frameId for the second OnContextReleased that arrives after the OnContextCreated from
the old render process strangely has a frameId greater than the new frameId

TODO: Unit tests

Issue #3021
2020-05-04 12:34:47 +10:00
amaitland 924e7bd457 WPF/OffScreen - Remove disable-gpu-compositing command line arg
Now that https://bitbucket.org/chromiumembedded/cef/issues/2733/viz-osr-might-be-causing-some-graphic
is resolved this shouldn't be required.

There are some glitches with resizing, the CEF OSR engine still needs some improvements. At least
the basics appear to be working now
2020-04-29 08:12:36 +10:00
amaitland 73e7c5de13 Core - Rename AbstractCefSettings to CefSettingsBase
This is a somewhat cosmetic change so the API Doc looks better, the
classes appear next to each other (CefSettings, CefSettingsBase)
when sorted alphabetically.

Resolves #3093
2020-04-06 14:59:33 +10:00
amaitland 270b5c496e WinForms - Dispose of FrameworkCreated BrowserSettings when Control Disposed
If BrowserSettings is FrameworkCreated we dispose of the BrowserSettings object immediately,
this code was in ManagedCefBrowserAdapter::CreateBrowser, now it's duplicated in WPF/OffScreen

The WinForms version has a slightly different behaviour, we keep the browserSettings reference
until the Control is Disposed incase the Control handle is destroyed then Created again.

Issue #2840
2020-04-01 09:42:56 +10:00
amaitland 3ba0290676 WPF - Add IWebBrowser.IsBrowserInitialized explicit interface implementation
Can be called from any Thread, the ChromiumWebBrowser.IsBrowserInitialized property remains
as Dependency property.

Issue #3033
2020-03-26 09:10:36 +10:00
amaitland 38c7941ab6 xml doc - remove seealso internal interface references 2020-01-29 10:22:17 +10:00
amaitland 19a70727f2 WinForms/WPF/OffScreen - Improve Dispose/BrowserInitialized error messaging
- Set CanExecuteJavascriptInMainFrame to false when disposing
- Throw exception if Disposed when calling GetBrowser method
- Improve error messaging
2020-01-15 11:16:06 +10:00
amaitland fe83ba0aa5 OffScreen - Disable GPU Compositing 2020-01-08 16:46:49 +10:00
amaitland 05172d6943 OffScreen - Add HtmlString constructor overload to ChromiumWebBrowser 2019-11-03 09:21:01 +10:00
amaitland 67c05da691 OffScreen - ScreenshotAsync incorrectly returned null on first Paint call
Resolve a sequence issue where the Paint event is called before the buffer is updated, the first call
to ScreenshotAsync would return null incorrectly even when the paint event fired.
Add internal AfterPaint event, this event is called regardless of args.Handled
If args.Handled is true and ScreenshotAsync is called then the TaskCompletionSource returns an Exception
2019-10-29 20:42:04 +10:00