Commit Graph

862 Commits

Author SHA1 Message Date
Alex Maitland 3d39238a93 Core - Code cleanup
- Make more classes sealed
- Add xml doc
- Add serializable constructor
2022-02-22 11:33:18 +10:00
Alex Maitland 597e54fc11 IBrowserHost.Find remove identifier param
Resolves #4013
2022-02-22 11:17:56 +10:00
Alex Maitland 3b1c46aab9 Code Cleanup - Minor code cleanup
- Add Microsoft.CodeAnalysis.NetAnalyzers package
- Make some classes sealed
- Fix/Add xml doc
2022-02-01 14:07:01 +10:00
Alex Maitland 137a4bbe6f WPF - Update CleanupElement when PresentationSource changes
- If the CleanupElement is a Window then move it to the new Window
2022-01-15 11:20:07 +10:00
Alex Maitland 27816d54b8 Core - Change from using GetBrowser() method to BrowserHost
- BrowserHost will return null if not set where GetBrowser() will throw an exception
2022-01-05 10:14:24 +10:00
Alex Maitland f90271fb14 WPF - Improve Mouse Click Count
Chromium only supports values of 1,2,3 for clickCount so we
set click count to 1 if greater than 3

Resolves #3940
2022-01-04 10:44:31 +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 6e211bcc7f Wpf - Context Menu improvements/fixes
- Fix separator not showing
- Remove unused code
- Add consts for devtools menu command id's
2021-11-30 13:47:42 +10:00
EmilyPaek 6f73ea1bba WPF - Korean IME fix cursor displayed at the left side of current character (#3912)
Co-authored-by: agrina1008 <noely1008@naver.com>
2021-11-30 13:47:16 +10:00
Alex Maitland 89b66f58d7 WPF - Use WPF specific menu handler by default
Resolves #1767
2021-11-25 11:09:38 +10:00
Alex Maitland 6fcfb66cbb WPF - OnWindowStateChanged only set browser to visible if IsVisible = true
Previously all browser instances were set to visible when the window was restored from minimized state
2021-11-05 10:39:11 +10:00
Alex Maitland aa8403a5d6 WPF - Add ChromiumWebBrowser.OnBrowserWasHidden
Can be overridden to keep the browser in a visible state even when it's not displayed
on screen.
2021-11-05 10:29:36 +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 0e242a8706 Upgrade to CEF 95.7.10+g00d4ad5+chromium-95.0.4638.54 / Chromium 95.0.4638.54
Remove CefBrowserSettings.universal_access_from_file_urls and CefBrowserSettings.file_access_from_file_urls.
https://bitbucket.org/chromiumembedded/cef/commits/ff33d7f72144

Remove CefBrowserSettings.application_cache
https://bitbucket.org/chromiumembedded/cef/commits/370a7749e950ef6784c29a666d07a0b67148dd5f

Remove ignore_certificate_errors setting
https://bitbucket.org/chromiumembedded/cef/commits/aabe4ce466766f8bd9907e7fa30546a3afada214

RequestContextSettings.IgnoreCertificateErrors was removed, the CefSettings.IgnoreCertificateErrors property
now set the command line arg

Use CefRect for CefWindowInfo bounds
https://bitbucket.org/chromiumembedded/cef/commits/8587cc4e4bbc187aa989152e521318818b3f41d3

Additional overload has been added to pass in a Rect directly to SetAsChild

Rename SendFocusEvent to SetFocus
https://bitbucket.org/chromiumembedded/cef/commits/49a4611e28d7bbc221cff816d7c4a96c55ba2721

SendFocusEvent will now call SetFocus internally, the project internally has been updated to use SetFocus for WPF

Replace CefRequestCallback with CefCallback
https://bitbucket.org/chromiumembedded/cef/commits/3e7f1bb529442a6c7674262d9219df57964e9524

No changes to the API for this, I've kept the same interface and just mapped internally

Resolves #3857, #3667, #3668
2021-10-22 14:45:12 +10:00
Andrew Smith bfa8ccf24c WPF - IME Only use GCS_CURSORPOS if an adjacent character is new input (#3846)
* Change Wpf IME handling to only use the cursor pos when an adjacent character is new input

* Meant to change both character before and after

* Ensure the cursor pos is > 0 when checking the character before
2021-10-11 10:16:07 +10:00
Alex Maitland 8bbe6a45ef WPF - Fix Address Load being called multiple times after browser created 2021-10-11 10:14:31 +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 6ce9958d2d WPF - Add System.Windows.Controls.ContextMenu based ContextMenuHandler (#3815)
* WPF - Add System.Windows.Controls.ContextMenu based ContextMenuHandler

Based of https://github.com/chromiumembedded/cef/blob/ba46b8c53ed0f46cec82a1aebaec173784deb6e4/libcef/browser/menu_manager.cc#L385

* Add model class instead of passing in params
2021-09-23 13:43:28 +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 138d6e94cd WPF - Support DPI change notification for .Net 4.6.2 or higher 2021-09-05 15:22:00 +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 90b631a5ad WPF - Add TODO regarding shutdown support for multiple dispatchers 2021-09-03 14:51:17 +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
campersau aae39fc1e5 WPF - Check for "ax_tree_id" and avoid referencing IValue in class member (#3770) 2021-08-25 09:13:41 +10:00
Alex Maitland 6cf756f25a WPF - WritableBitmapRenderHandler ArgumentOutofRange
Resolves #3474
2021-07-30 10:29:52 +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 66cd9ef4b8 WPF - Improve WpfIMEKeyboardHandler browserHost null checks
CancelComposition is now private as it's not used outside the scope of the class. Technically this is a breaking change
though it's incredibly unlikely this method was used outside the scope of WpfImeKeyboardHandler as it requires
the Hwnd which is obtained from the SourceHook which is private.

We can and probably should make most of the private methods protected virtual to allow for overriding of just a small
portion of the class, you currently can copy and paste the whole class into your own code base if small changes are required.

#3690
2021-07-22 10:33:32 +10:00
Shaojun Li d9a7a398cb WPF - Fix WpfIMEKeyboardHandler crash when browser is not initalized. (#3690)
GetBrowserHost will throw exception when browser is not initalized.
2021-07-22 10:17:21 +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 7dfead360e WPF - IWpfWebBrowser implement IInputElement
Simplify setting Focus from View model as now possible to call Keyboard.Focus(IWpfWebBrowser);

Resolves #3546
2021-06-04 15:10:41 +10:00
Alex Maitland f6ea0de783 WPF - Update NotifyDpiChange xml doc to clarify allowed values.
Resolves #3561
2021-06-01 15:42:53 +10:00
Alex Maitland 9b4d68b5aa WPF - Allow overriding of IRenderWebBrowser implementation methods
- Add additional protected virtual methods so deriving classes can override
2021-05-12 10:39:38 +10:00
Alex Maitland a48cf807e6 WPF - Allow setting Focus before the underlying browser has been initialized.
- Remove hacks from the ViewModel as Focus can now be set on Go().
- Creating a new viewmodel also sets focus

Changing tabs doesn't set focus currently.
2021-05-10 15:39:32 +10:00
Alex Maitland aabdb68e99 WPF - Pass 0 to SendKeyEvent as lparam instead of modifiers
Resolves #3462
2021-04-01 17:17:40 +10:00
Alex Maitland 047f8b838c WPF/WinForms/OffScreen - Reduce code duplication
Issue #3082
2021-04-01 16:28:20 +10:00
billshinji 516de14af6 WPF - Japanese IME unable to enter space (#3455)
This is a fix in response to the issue of not emitting spaces in Japanese IME (from @karthikeyancdm).
After all, it turns out that ImeSetComposition() and ImeFinishComposingText() should be invoked regardless of the current language.
2021-03-22 14:07:54 +10:00
Alex Maitland 207172efe3 WPF - Add OnDpiChanged for NetCore builds
Automatically deals with DPI Change

Issue #3388
2021-03-16 15:58:25 +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 12e583d2ef Core - PublicApi remove references to CefSharp.Core.Runtime
- Add an UnWrap method to the interfaces (should be hidden from IntelliSense)
- For .Net 4.5.2 projects they're  not a decorator class which an inner instance of the CefSharp.Core.Runtime Type
- For Net Core we have a ref assembly which allows us to reference the CefSharp.Core.Runtime without issues
  We can potentially remove the ref assembly now and forgo any direct reference.
2021-01-13 16:56:57 +10:00
TMOONLIGHT bf8893a58f Update WpfIMEKeyboardHandler.cs (#3346)
fix chinese IMEs ( such as "sogou pinyin", "qq pinyin" etc. ) input window position.
2021-01-11 20:30:38 +10:00
Alex Maitland 2a80b71161 WinForms/WPF - Fix BrowserSettings/RequestContext type checking
- When settings BrowserSettings/RequestContext properties the type checking needs to make sure the
CefSharp.Core.BrowserSettings and CefSharp.BrowserSettings objects are acceptable
- In WPF only the RequestContext was updated as there's no check for BrowserSettings property yet (probably should be)

https://github.com/cefsharp/CefSharp/issues/3343#issuecomment-757581368
2021-01-11 20:29:54 +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
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 049172fbba WPF - CompositionTargetRenderHandler improve Dispose 2020-10-31 09:25:07 +10:00