diff --git a/CefSharp.Core/Internals/CefBrowserHostWrapper.cpp b/CefSharp.Core/Internals/CefBrowserHostWrapper.cpp index 7643e660d..7a4a48d2e 100644 --- a/CefSharp.Core/Internals/CefBrowserHostWrapper.cpp +++ b/CefSharp.Core/Internals/CefBrowserHostWrapper.cpp @@ -229,12 +229,79 @@ void CefBrowserHostWrapper::SendMouseMoveEvent(int x, int y, bool mouseLeave, Ce _browserHost->SendMouseMoveEvent(mouseEvent, mouseLeave); } +void CefBrowserHostWrapper::WasResized() +{ + ThrowIfDisposed(); + + _browserHost->WasResized(); +} + +void CefBrowserHostWrapper::WasHidden(bool hidden) +{ + ThrowIfDisposed(); + + _browserHost->WasHidden(hidden); +} + +void CefBrowserHostWrapper::NotifyMoveOrResizeStarted() +{ + ThrowIfDisposed(); + + _browserHost->NotifyMoveOrResizeStarted(); +} + +void CefBrowserHostWrapper::NotifyScreenInfoChanged() +{ + ThrowIfDisposed(); + + _browserHost->NotifyScreenInfoChanged(); +} + int CefBrowserHostWrapper::WindowlessFrameRate::get() { + ThrowIfDisposed(); + return _browserHost->GetWindowlessFrameRate(); } void CefBrowserHostWrapper::WindowlessFrameRate::set(int val) { + ThrowIfDisposed(); + _browserHost->SetWindowlessFrameRate(val); +} + +bool CefBrowserHostWrapper::MouseCursorChangeDisabled::get() +{ + ThrowIfDisposed(); + + return _browserHost->IsMouseCursorChangeDisabled(); +} + +void CefBrowserHostWrapper::MouseCursorChangeDisabled::set(bool val) +{ + ThrowIfDisposed(); + + _browserHost->SetMouseCursorChangeDisabled(val); +} + +bool CefBrowserHostWrapper::WindowRenderingDisabled::get() +{ + ThrowIfDisposed(); + + return _browserHost->IsWindowRenderingDisabled(); +} + +IntPtr CefBrowserHostWrapper::GetOpenerWindowHandle() +{ + ThrowIfDisposed(); + + return IntPtr(_browserHost->GetOpenerWindowHandle()); +} + +void CefBrowserHostWrapper::SendCaptureLostEvent() +{ + ThrowIfDisposed(); + + _browserHost->SendCaptureLostEvent(); } \ No newline at end of file diff --git a/CefSharp.Core/Internals/CefBrowserHostWrapper.h b/CefSharp.Core/Internals/CefBrowserHostWrapper.h index cbeab76d8..eb3cebace 100644 --- a/CefSharp.Core/Internals/CefBrowserHostWrapper.h +++ b/CefSharp.Core/Internals/CefBrowserHostWrapper.h @@ -68,11 +68,34 @@ namespace CefSharp virtual void SendMouseMoveEvent(int x, int y, bool mouseLeave, CefEventFlags modifiers); + virtual void NotifyMoveOrResizeStarted(); + + virtual void NotifyScreenInfoChanged(); + + virtual void WasResized(); + + virtual void WasHidden(bool hidden); + virtual property int WindowlessFrameRate { int get(); void set(int val); } + + virtual property bool MouseCursorChangeDisabled + { + bool get(); + void set(bool val); + } + + virtual property bool WindowRenderingDisabled + { + bool get(); + } + + virtual IntPtr GetOpenerWindowHandle(); + + virtual void SendCaptureLostEvent(); }; } } diff --git a/CefSharp/IBrowserHost.cs b/CefSharp/IBrowserHost.cs index 9f43dfa46..fa3d49180 100644 --- a/CefSharp/IBrowserHost.cs +++ b/CefSharp/IBrowserHost.cs @@ -9,7 +9,86 @@ namespace CefSharp { public interface IBrowserHost : IDisposable { - void StartDownload(string url); + /// + /// Add the specified word to the spelling dictionary. + /// + /// + void AddWordToDictionary(string word); + + /// + /// Request that the browser close. The JavaScript 'onbeforeunload' event will be fired. + /// + /// + /// If forceClose is false the event handler, if any, will be allowed to prompt the user and the + /// user can optionally cancel the close. If forceClose is true the prompt will not be displayed + /// and the close will proceed. Results in a call to if + /// the event handler allows the close or if forceClose is true + /// See documentation for additional usage information. + /// + void CloseBrowser(bool forceClose); + + /// + /// Explicitly close the developer tools window if one exists for this browser instance. + /// + void CloseDevTools(); + + /// + /// Search for text + /// + /// can be used to have multiple searches running simultaniously + /// text to search for + /// indicates whether to search forward or backward within the page + /// indicates whether the search should be case-sensitive + /// indicates whether this is the first request or a follow-up + /// The IFindHandler instance, if any, will be called to report find results. + void Find(int identifier, string searchText, bool forward, bool matchCase, bool findNext); + + /// + /// Retrieve the window handle of the browser that opened this browser. + /// + /// The handler + IntPtr GetOpenerWindowHandle(); + + /// + /// Retrieve the window handle for this browser. + /// + /// The handler + IntPtr GetWindowHandle(); + + /// + /// Get the current zoom level. The default zoom level is 0.0. This method can only be called on the CEF UI thread. + /// + /// a that when executed returns the zoom level as a double. + Task GetZoomLevelAsync(); + + /// + /// Invalidate the view. The browser will call CefRenderHandler::OnPaint asynchronously. + /// This method is only used when window rendering is disabled (OSR). + /// + /// indicates which surface to re-paint either View or Popup. + void Invalidate(PaintElementType type); + + /// + /// Get/Set Mouse cursor change disabled + /// + bool MouseCursorChangeDisabled { get; set; } + + /// + /// Notify the browser that the window hosting it is about to be moved or resized. + /// + void NotifyMoveOrResizeStarted(); + + /// + /// Send a notification to the browser that the screen info has changed. + /// The browser will then call CefRenderHandler::GetScreenInfo to update the screen information with the new values. + /// This simulates moving the webview window from one display to another, or changing the properties of the current display. + /// This method is only used when window rendering is disabled. + /// + void NotifyScreenInfoChanged(); + + /// + /// Print the current browser contents. + /// void Print(); /// @@ -22,25 +101,16 @@ namespace CefSharp /// The result is true on success or false on failure to generate the Pdf. Task PrintToPdfAsync(string path, PdfPrintSettings settings = null); - void SetZoomLevel(double zoomLevel); - Task GetZoomLevelAsync(); - IntPtr GetWindowHandle(); - void CloseBrowser(bool forceClose); - - void ShowDevTools(IWindowInfo windowInfo = null, int inspectElementAtX = 0, int inspectElementAtY = 0); - void CloseDevTools(); - - void AddWordToDictionary(string word); + /// + /// If a misspelled word is currently selected in an editable node calling this method will replace it with the specified word. + /// + /// word to be replaced void ReplaceMisspelling(string word); - void Find(int identifier, string searchText, bool forward, bool matchCase, bool findNext); - void StopFinding(bool clearSelection); - /// - /// Set whether the browser is focused. (Used for Normal Rendering e.g. WinForms) + /// Send a capture lost event to the browser. /// - /// set focus - void SetFocus(bool focus); + void SendCaptureLostEvent(); /// /// Send a focus event to the browser. . (Used for OSR Rendering e.g. WPF or OffScreen) @@ -54,23 +124,6 @@ namespace CefSharp /// represents keyboard event void SendKeyEvent(KeyEvent keyEvent); - /// - /// Send a mouse wheel event to the browser. - /// - /// X-Axis coordinate relative to the upper-left corner of the view. - /// Y-Axis coordinate relative to the upper-left corner of the view. - /// Movement delta for X direction. - /// movement delta for Y direction. - /// /// click modifiers e.g. Ctrl - void SendMouseWheelEvent(int x, int y, int deltaX, int deltaY, CefEventFlags modifiers); - - /// - /// Invalidate the view. The browser will call CefRenderHandler::OnPaint asynchronously. - /// This method is only used when window rendering is disabled (OSR). - /// - /// indicates which surface to re-paint either View or Popup. - void Invalidate(PaintElementType type); - /// /// Send a mouse click event to the browser. /// @@ -82,6 +135,51 @@ namespace CefSharp /// click modifiers e.g. Ctrl void SendMouseClickEvent(int x, int y, MouseButtonType mouseButtonType, bool mouseUp, int clickCount, CefEventFlags modifiers); + /// + /// Send a mouse wheel event to the browser. + /// + /// X-Axis coordinate relative to the upper-left corner of the view. + /// Y-Axis coordinate relative to the upper-left corner of the view. + /// Movement delta for X direction. + /// movement delta for Y direction. + /// /// click modifiers e.g. Ctrl + void SendMouseWheelEvent(int x, int y, int deltaX, int deltaY, CefEventFlags modifiers); + + /// + /// Set whether the browser is focused. (Used for Normal Rendering e.g. WinForms) + /// + /// set focus + void SetFocus(bool focus); + + /// + /// Change the zoom level to the specified value. Specify 0.0 to reset the zoom level. + /// If called on the CEF UI thread the change will be applied immediately. + /// Otherwise, the change will be applied asynchronously on the UI thread. + /// + /// zoom level + void SetZoomLevel(double zoomLevel); + + /// + /// Open developer tools in its own window. If inspectElementAtX and/or inspectElementAtY are specified then + /// the element at the specified (x,y) location will be inspected. + /// + /// window info used for showing dev tools + /// x coordinate (used for inspectElement) + /// y coordinate (used for inspectElement) + void ShowDevTools(IWindowInfo windowInfo = null, int inspectElementAtX = 0, int inspectElementAtY = 0); + + /// + /// Download the file at url using IDownloadHandler. + /// + /// url to download + void StartDownload(string url); + + /// + /// Cancel all searches that are currently going on. + /// + /// clear the selection + void StopFinding(bool clearSelection); + /// /// Send a mouse move event to the browser /// @@ -91,6 +189,21 @@ namespace CefSharp /// click modifiers .e.g Ctrl void SendMouseMoveEvent(int x, int y, bool mouseLeave, CefEventFlags modifiers); + /// + /// Notify the browser that it has been hidden or shown. + /// Layouting and rendering notification will stop when the browser is hidden. + /// This method is only used when window rendering is disabled (WPF/OffScreen). + /// + /// + void WasHidden(bool hidden); + + /// + /// Notify the browser that the widget has been resized. + /// The browser will first call CefRenderHandler::GetViewRect to get the new size and then call CefRenderHandler::OnPaint asynchronously with the updated regions. + /// This method is only used when window rendering is disabled. + /// + void WasResized(); + /// /// Gets/sets the maximum rate in frames per second (fps) that CefRenderHandler:: /// OnPaint will be called for a windowless browser. The actual fps may be @@ -99,7 +212,12 @@ namespace CefSharp /// can only be called on the UI thread. Can also be set at browser creation /// via BrowserSettings.WindowlessFrameRate. /// - int WindowlessFrameRate { get; set;} + int WindowlessFrameRate { get; set; } + + /// + /// Returns true if window rendering is disabled. + /// + bool WindowRenderingDisabled { get; } /// /// Gets a value indicating whether the browserHost has been disposed of. diff --git a/CefSharp/IJsDialogHandler.cs b/CefSharp/IJsDialogHandler.cs index 34b1b5cc5..438ec7f1a 100644 --- a/CefSharp/IJsDialogHandler.cs +++ b/CefSharp/IJsDialogHandler.cs @@ -17,7 +17,7 @@ namespace CefSharp /// Message Text /// value will be specified for prompt dialogs only /// Callback can be executed inline or in an async fashion - /// Set |suppress_message| to true and return false to suppress the message (suppressing messages is preferable to immediately executing the callback as this is used to detect presumably malicious behavior like spamming alert messages in onbeforeunload). Set |suppress_message| to false and return false to use the default implementation (the default implementation will show one modal dialog at a time and suppress any additional dialog requests until the displayed dialog is dismissed). + /// Set suppressMessage to true and return false to suppress the message (suppressing messages is preferable to immediately executing the callback as this is used to detect presumably malicious behavior like spamming alert messages in onbeforeunload). Set suppressMessage to false and return false to use the default implementation (the default implementation will show one modal dialog at a time and suppress any additional dialog requests until the displayed dialog is dismissed). /// Return true if the application will use a custom dialog or if the callback has been executed immediately. Custom dialogs may be either modal or modeless. If a custom dialog is used the application must execute |callback| once the custom dialog is dismissed. bool OnJSDialog(IWebBrowser browserControl, IBrowser browser, string originUrl, string acceptLang, CefJsDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback, ref bool suppressMessage);