Commit Graph

881 Commits

Author SHA1 Message Date
amaitland 41813c390e WPF - Rename WindowStateChanged to OnWindowStateChanged
Also tweak some of the comments
2018-06-14 22:45:19 +10:00
Henrik Heggelund-Berg ff2665444b Release window event handlers on Dispose (#2416)
* Release window event handlers on Dispose

Make sure event handlers related to `Window`, e.g. `WindowStateChanged`, is released during Dispose.

* Clear reference to `Window`
2018-06-12 21:24:59 +10:00
amaitland 93fdd63525 WPF - Fix incorrect param ordering of IRenderHandler.OnPaint
Param order now matches CEF interface
2018-04-23 13:06:05 +10:00
amaitland 61033e66c8 WPF/OffScreen cleanup
- More code cleanup, use null-propagating operator
- WPF Add protected virtual UpdateDragCursor
2018-04-23 12:42:00 +10:00
amaitland c1b89c62e9 WPF/OffScreen - Code cleanup and minor refactor
IRenderWebBrowser - Method naming now matches CEF, xmldoc updated to be more accurate

CefSharp.Wpf.ChromiumWebBrowser and CefSharp.OffScreen.ChromiumWebBrowser both updated as a result of IRenderWebBrowser changes
Should be minimal public API changes, should only require changes for those that are implementing their own rendering, who will have a major rewrite on their hands regardless of this.
2018-04-20 14:49:25 +10:00
amaitland 11564becca WPF - Improve DragDrop implementation
Improved for when drag/drop both originate and end within the browser. Reuse the CEF IDragData for DragTargetDragEnter call

No improvement has been made to dragging external items
2018-04-16 17:26:23 +10:00
amaitland d99d6d87fe Set event handlers to null in Dispose
Not all event handlers were set to null on Dispose in ChromiumWebBrowser instances and JavascriptObjectRepository

Resolves #2307
2018-04-13 16:18:57 +10:00
amaitland b97c0c54b5 WPF - Add ByteArrayWritableBitmapRenderHandler
Copies every bitmap into a unique byte[], no locking is used.
Will use lots of memory
2018-04-05 16:53:55 +10:00
amaitland 447cce66bb WPF - Update ZoomLevelProperty when browser becomes visible.
Resolves #1778
2018-03-27 12:08:46 +10:00
amaitland c3746d3115 WPF - Expose GetBrowserScreenLocation as protected virtual
Allow for custom implementation
2018-03-23 15:01:04 +10:00
amaitland c843317e33 WPF - Capture mouse when left button down so scrollbar works correctly outside of browser
Quick fix for #2258
2018-03-23 14:53:38 +10:00
Marinko edb0bc9983 check if the visual is connected (#2321) 2018-03-21 15:45:15 +10:00
amaitland 895ad8d94f WPF OSR - Rename IBitmapFactory to IRenderHandler
At some point it would be nice to expose the whole of the CefRenderHandler API, this should at some point make that easier.

Issue #2237
2018-03-21 14:36:30 +10:00
amaitland 59c6da399c WPF OSR - WritableBitmapFactory Add checks for a valid sourceBuffer 2018-03-21 14:11:21 +10:00
amaitland 73894a592d WPF OSR Rendering - InteropBitmapFactory split the experimental resize on increase option into IncreaseBufferInteropBitmapFactory
Also some minor threading improvements and buffer validation (check if closed and invalid)
2018-03-18 00:07:37 +10:00
amaitland c37dbcd06a Remove Geolocation API and Upgrade version numbers to 65 2018-03-17 21:31:25 +10:00
amaitland 9c62fa4d46 InteropBitmapFactory and WritableBitmapFactory - Add ability to customise the dispatcherPriority 2018-03-06 10:59:06 +10:00
amaitland e7002a7874 WPF - Fix exception in WritableBitmapFactory
WritableBitmapFactory now works as expected
Add option to invalidate whole bitmap in response to #2035 (default is to invalidate only the dirty rect still)
2018-02-06 11:03:38 +10:00
campersau 7802653fb1 add missing space in exception message (#2263)
https://github.com/cefsharp/CefSharp/commit/a086b4b7802da4d8ddc60a38e309968ba8d4cce6
2018-02-05 19:16:54 +10:00
amaitland a086b4b780 WPF - Throw exception if Load called before browser initialized
Follow up to #2260
2018-02-05 10:46:16 +10:00
amaitland dd4b7d630b WPF - OnMouseLeave send actual x,y coordinates not just the -1 and call SendMouseClickEvent when left mouse button pressed
Resolves #2060

# Conflicts:
#	CefSharp.Wpf/ChromiumWebBrowser.cs
2018-01-22 11:07:42 +10:00
amaitland 738635d38c Hide tooltip if already open when textchanged
Follow up to #2232
2018-01-22 11:06:24 +10:00
Daniel Bretzigheimer f98fb858c7 tooltip updates it position when the tooltip text is changed (#2232)
* tooltip updates it position when the tooltip text is changed

* encoding fixed
2018-01-22 11:04:59 +10:00
amaitland efc77d4fcc Fix typo 2018-01-22 11:03:49 +10:00
Alex Maitland 9b01b69d2f Implement Javascript Binding v2 (#2247)
* JSB Rewrite - Add CefSharp.RegisterBoundObject javascript method

To get around the problem of IPC timing, I've reversed the communication, now it's the render process requesting
the bound objects, the implementation is incomplete at this stage, more just a basic proof of concept

Rewrite BindingTest.html using QUnit
One of the tests doesn't map correctly as it requires def user interaction

TODO:

- Get objects by name
- Rename Messages.h values that relate to this change so they are more descriptive
- Better error handling
- Caching of objects within a render process
- Investigate global context options, don't think it's possible to call an async method directly in the global context

# Conflicts:
#	CefSharp.Example/Resources/BindingTest.html

* JSB Improve Request/Response message names

* BindingTest.html - Output stress test results

* Remove JavascriptRootObject was leftover from time we used WCF to transmit objects

* JavascriptObjectRepository - Objects are now sent in the same list with an IsAsync flag

Separation when sending over IPC with two unique lists isn't necessary

* JavascriptObjectRepository - Return objects by name or return all by default

Untabify CefAppUnmanagedWrapper.cpp
Add minor comment to CefBrowserWrapper for a reminder that we use Frame Identifier as dictionary key

* Add //TODO: JSB comments for work that's left to be done

Ideally within a render process we cache bound objects once they've been communicated,
It would also be nice to make multiple binding requests so objects can later be added dynamically

* JSB Allow multiple calls to CefSharp.RegisterBoundObject

Update BindingTest.html to name two distinct calls to different bound objects

* JSB - Add some notes about caching, no working implementation yet

* JSB - Dynamically Register object on Request

* JSB Add ability to unbind an object and rename RegisterBoundObject to BindObjectAsync

# Conflicts:
#	CefSharp.Example/Resources/BindingTest.html

* JSB BindObjectAsync - if objects already bound then return false

* JSB - Ignore Indexer properties

Were previously throwing an exception

* JSB - Add LegacyJavascriptBindingEnabled option so preserve existing behaviour

This is only useful for SPA application and those that only navigate to pages
hosting within a single domain. Any sort of cross-site navigation and a new
render process will be spawned and objects won't be bound automatically
(You can use the new methods to request they're bound yourself, at least in theory,
more testing required on this)

* Add LegacyBindingTest.html

Current disabled by default. To enable uncomment CefSharpSettings.LegacyJavascriptBindingEnabled = true;
in CefExample.cs

* RegisterJsObject and RegisterAsyncJsObject can now only be used when CefSharpSettings.LegacyJavascriptBindingEnabled = true

See https://github.com/cefsharp/CefSharp/issues/2246 for details
2018-01-22 10:24:25 +10:00
amaitland a2451960d3 WPF IWpfKeyboardHandler Changes
- Make public so users can implement their own handler (the OSR IME patch can be rewritten as a IWpfKeyboardHandler)
- Formatting for consistency
- Make methods virtual

Follow up to #2056
2018-01-18 16:28:53 +10:00
João Neves a845e75432 Prevent accelerator keys to work when typing text (#2056)
* Call correct base method and handle text input in case event wasn't handled
* Removed SourceHook method
* Added previous keyboard handling logic and ability to use it through a property
2018-01-18 16:25:24 +10:00
amaitland 199aee55a2 WPF Incorrect Type Checking for InteropBitmapFactory
Followup to #2237
2018-01-18 14:13:07 +10:00
amaitland c18c6e7b1f WPF Popup bind layout transform to parent
Popup needs to allow transparency or only ScaleTrasnform will work (comment in reference source see https://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/Controls/Primitives/Popup.cs,1713)
Bind the parent LayoutTransformProperty to the popup LayoutTransformProperty

Resolves #2151
2018-01-18 13:36:01 +10:00
amaitland c021be6c8d WPF - ChromiumWebBrowser inherits from Control rather than UserControl
Based on #1499

Popup is created in xaml
Canvas used to absolute position the two images, one on top of the other
No Mouse.Capture required
2018-01-18 13:24:29 +10:00
amaitland 127c00554f Rewrite WPF/OffScreen OnPaint
OffScreen
  - Now maintains a raw Byte[] buffer that is used to create the GDI bitmaps
can be overridden and raw buffer access granted (eliminates the forced memory copy to the memory mapped view)

WPF
  - MemoryMappedFile.CreateNew is now used to create the in memory view and copy the buffer
  - InteropBitmapFactory only create new MemoryMappedFile selectively. If the MemoryMappedFile is larger than we require then just reuse it rather than
    releasing then allocating a smaller section of memory that's used for double buffering with InteropBitmap and WritableBitmap
  - Removed CefDirtyRect and used existing Rect class
  - Rename rendering event to Paint, still preferable to implement IBitmapFactory or subclass ChromiumWebBrowser
  - Update ChromiumWebBrowserWithScreenshotSupport to support new rendering method - not very well tested.

Resolves #2237
2018-01-18 11:29:12 +10:00
amaitland 86774ef0bf WPF - Layout rounding has been changed to UseLayoutRounding so values for ActualWidth and ActualHeight are scaled by the framework
This reverts the change from #1962 where we manually rounded up - it's still possible to do this by inheriting from ChromiumWebBrowser and overriding GetViewRect should you choose to

Easy way to test the rounding changes is to add Margin="0.5,0.5,0,0" to a ChromiumWebBrowser instance in xaml
You can manually disable layout rounding of course UseLayoutRounding="False" in xaml on the control
2018-01-18 10:25:50 +10:00
amaitland cc5a92f307 WPF - Add protected virtual void OnImeCompositionRangeChanged
Was previously unimplemented, and user was unable to implement, so added protected virtual method
2017-12-21 08:58:20 +10:00
amaitland 4f48dbd49a WPF Add event handled checks in mouse overrides
Allow user to override and then specify their own behaviour
Call base methods in overrides - reference source shows the protected methods are empty,
we're just doing this for correctness (compiler should optimise the calls away)
2017-12-20 12:26:50 +10:00
amaitland 93a329bc7a WinForms/WPF Fix incorrect type check when setting RequestContext 2017-12-20 12:26:50 +10:00
amaitland d585348887 Add RequestContext getter property to IWebBrowser
WPF - Add checks so if RequestContext is set after browser created an exception is thrown
WinForms - Add checks so if RequestContext is set after browser created an exception is thrown
2017-12-20 12:26:49 +10:00
amaitland e4dbc51635 WPF - rename updateBrowserScreenLocation to UpdateBrowserScreenLocation (inconsistent naming)
Remove call to PresentationSource.FromVisual(this) as it's very expensive, walks up the tree, it's also unnecessary as we keep a reference to the visual HwndSource
2017-12-20 12:26:49 +10:00
amaitland 98f31c0a5b CefSharp.Wpf/ChromiumWebBrowser.cs - Simplify OnTooltipTimerTick Disposed check 2017-12-14 15:24:27 +10:00
Per Lundberg 8dd46377be Fixed typos + whitespace cleanups. 2017-11-28 00:07:47 +02:00
Chris 8a144050ee WPF: Possible fix for NullReferenceException in OnTooltipTimerTick
Resolves #2134
2017-08-31 18:13:01 +02:00
Chris bad729ee0d WPF: Added support for back and forward mouse buttons
Resolves #2133
2017-08-31 15:19:34 +02:00
Chris 2cb368016a WPF: Removed debug code for mouse events 2017-08-25 17:20:22 +02:00
James Pearce 2c14ac6919 Prevent unhandled exception in PointToScreen when not yet visible (#2107)
* Fix exception when PresentationSource not set

Prevent PointToScreen() being called if the visual is not yet connected
to a presentation source

* Fix typo

Fix typo
2017-08-11 13:31:06 +02:00
amaitland d1681162a6 WPF - Manually calculate GetScreenPoint
Using PointToScreen(point) on the UI thread (had to be called in a sync fashion) made it easy for users to cause a deadlock
Resolve #1915
2017-06-02 11:47:24 +10:00
amaitland e94f063b47 WPF - Change from storing a reference to the Matrix to having a DpiScaleFactor property, can be used to manually set the scale factor.
If the scale factor is set after the browser has been created then it's necessary to manually call IBrowserHost.NotifyScreenInfoChanged
2017-05-30 14:19:13 +10:00
amaitland c2891c5d1e Add protected virtual methods for the most common IRenderWebBrowser methods that users would need to override.
Still maintain the explicit interface methods - prefer the additional compiler checks and readability
Rename IRenderWebBrowser.InvokeRenderAsync to OnPaint - keeps inline with CEF naming
Added better comments to IRenderWebBrowser.OnPaint
2017-05-29 13:33:50 +10:00
amaitland d8520e8166 WPF - Hook the parent Window.StateChanged event and call IBrowserHost.WasHidden depending on visibility.
Seems like the only reliable way to determine when the window was minimized/restored
Should improve performance when browser is hidden
2017-05-22 16:17:32 +10:00
amaitland ef27fb5cf0 Enable implementation of GetScreenPoint (was commented out)
Looks like the Point returned from PointToScreen is pre-scaled, so no need to perform a Transform
2017-04-19 12:23:13 +10:00
amaitland eecf3aded9 Add IWebBrowser.CanExecuteJavascriptInMainFrame property, set to true/false when V8Context is created/released
Added checks in the execute/eval javscript methods in WebBrowserExtensions
Made possibly by the addition of OnContextReleased IPC message being added
2017-03-28 09:43:59 +10:00
amaitland b432d5aa38 Change IBrowserHost.SendMouse* to use the MouseEvent struct (added some extension methods to maintain API compatibility)
Review classes and structs
Added constructor to structs where all fields were required
Made some classes sealed, mostly those that are passed into the framework where subclassing and adding methods/properties wouldn't make sense
2017-03-27 15:46:34 +10:00