// Copyright © 2014 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using System;
using CefSharp.Enums;
using CefSharp.Structs;
namespace CefSharp.Internals
{
///
/// IRenderWebBrowser is an internal interface used by CefSharp for the WPF/Offscreen implementation
/// The ChromiumWebBrowser instances implement this interface
///
public interface IRenderWebBrowser : IWebBrowserInternal
{
///
/// Implement to handle events related to accessibility.
///
/// The accessibility handler.
IAccessibilityHandler AccessibilityHandler { get; set; }
///
/// Called to allow the client to return a ScreenInfo object with appropriate values.
/// If null is returned then the rectangle from GetViewRect will be used.
/// If the rectangle is still empty or invalid popups may not be drawn correctly.
///
/// Return null if no screenInfo structure is provided.
ScreenInfo? GetScreenInfo();
///
/// Called to retrieve the view rectangle which is relative to screen coordinates.
///
/// Return a ViewRect strict containing the rectangle or null. If the rectangle is
/// still empty or invalid popups may not be drawn correctly.
Rect GetViewRect();
///
/// Called to retrieve the translation from view coordinates to actual screen coordinates.
///
/// x
/// y
/// screen x
/// screen y
/// Return true if the screen coordinates were provided.
bool GetScreenPoint(int viewX, int viewY, out int screenX, out int screenY);
///
/// Called when an element has been rendered to the shared texture handle.
/// This method is only called when is set to true
///
/// indicates whether the element is the view or the popup widget.
/// contains the set of rectangles in pixel coordinates that need to be repainted
/// is the handle for a D3D11 Texture2D that can be accessed via ID3D11Device using the OpenSharedResource method.
void OnAcceleratedPaint(PaintElementType type, Rect dirtyRect, IntPtr sharedHandle);
///
/// Called when an element should be painted. Pixel values passed to this method are scaled relative to view coordinates based on the
/// value of returned from .
/// Called on the CEF UI Thread
///
/// indicates whether the element is the view or the popup widget.
/// contains the set of rectangles in pixel coordinates that need to be repainted
/// The bitmap will be will be width * height *4 bytes in size and represents a BGRA image with an upper-left origin
/// width
/// height
void OnPaint(PaintElementType type, Rect dirtyRect, IntPtr buffer, int width, int height);
///
/// Called when the browser's cursor has changed. .
///
/// If type is Custom then customCursorInfo will be populated with the custom cursor information
/// cursor type
/// custom cursor Information
void OnCursorChange(IntPtr cursor, CursorType type, CursorInfo customCursorInfo);
///
/// Called when the user starts dragging content in the web view. Contextual information about the dragged content is
/// supplied by dragData. (|x|, |y|) is the drag start location in screen coordinates. OS APIs that run a system message
/// loop may be used within the StartDragging call. Return false to abort the drag operation. Don't call any of
/// CefBrowserHost::DragSource*Ended* methods after returning false. Return true to handle the drag operation.
/// Call IBrowserHost::DragSourceEndedAt and DragSourceSystemDragEnded either synchronously or asynchronously to inform
/// the web view that the drag operation has ended.
///
/// drag data
/// operation mask
/// x coordinate
/// y coordinate
/// Return false to abort the drag operation.
bool StartDragging(IDragData dragData, DragOperationsMask mask, int x, int y);
///
/// Called when the web view wants to update the mouse cursor during a drag & drop operation.
///
/// describes the allowed operation (none, move, copy, link).
void UpdateDragCursor(DragOperationsMask operation);
///
/// Called when the browser wants to show or hide the popup widget.
///
/// The popup should be shown if show is true and hidden if show is false.
void OnPopupShow(bool show);
///
/// Called when the browser wants to move or resize the popup widget.
///
/// contains the new location and size in view coordinates.
void OnPopupSize(Rect rect);
///
/// Called when the IME composition range has changed.
///
/// is the range of characters that have been selected
/// is the bounds of each character in view coordinates.
void OnImeCompositionRangeChanged(Range selectedRange, Rect[] characterBounds);
///
/// Called when an on-screen keyboard should be shown or hidden for the specified browser.
///
/// the browser
/// specifies what kind of keyboard should be opened. If , any existing keyboard for this browser should be hidden.
void OnVirtualKeyboardRequested(IBrowser browser, TextInputMode inputMode);
};
}