init lserp cs 5.0

This commit is contained in:
cyf
2026-07-10 15:25:05 +08:00
commit 90f3fda86a
3799 changed files with 976868 additions and 0 deletions
@@ -0,0 +1,365 @@
namespace Cef3
{
using System;
using System.Collections.Generic;
using System.Text;
using Cef3.Interop;
/// <summary>
/// Browser initialization settings. Specify <c>null</c> or 0 to get the recommended
/// default values. The consequences of using custom values may not be well
/// tested. Many of these and other settings can also configured using command-
/// line switches.
/// </summary>
public sealed unsafe class CefBrowserSettings
{
private cef_browser_settings_t* _self;
public CefBrowserSettings()
{
_self = cef_browser_settings_t.Alloc();
}
internal CefBrowserSettings(cef_browser_settings_t* ptr)
{
_self = ptr;
}
internal void Dispose()
{
_self = null;
}
internal cef_browser_settings_t* ToNative()
{
return _self;
}
/// <summary>
/// The maximum rate in frames per second (fps) that CefRenderHandler::OnPaint
/// will be called for a windowless browser. The actual fps may be lower if
/// the browser cannot generate frames at the requested rate. The minimum
/// value is 1 and the maximum value is 60 (default 30). This value can also be
/// changed dynamically via CefBrowserHost::SetWindowlessFrameRate.
/// </summary>
public int WindowlessFrameRate
{
get { return _self->windowless_frame_rate; }
set { _self->windowless_frame_rate = value; }
}
// The below values map to WebPreferences settings.
#region Font Settings
public string StandardFontFamily
{
get { return cef_string_t.ToString(&_self->standard_font_family); }
set { cef_string_t.Copy(value, &_self->standard_font_family); }
}
public string FixedFontFamily
{
get { return cef_string_t.ToString(&_self->fixed_font_family); }
set { cef_string_t.Copy(value, &_self->fixed_font_family); }
}
public string SerifFontFamily
{
get { return cef_string_t.ToString(&_self->serif_font_family); }
set { cef_string_t.Copy(value, &_self->serif_font_family); }
}
public string SansSerifFontFamily
{
get { return cef_string_t.ToString(&_self->sans_serif_font_family); }
set { cef_string_t.Copy(value, &_self->sans_serif_font_family); }
}
public string CursiveFontFamily
{
get { return cef_string_t.ToString(&_self->cursive_font_family); }
set { cef_string_t.Copy(value, &_self->cursive_font_family); }
}
public string FantasyFontFamily
{
get { return cef_string_t.ToString(&_self->fantasy_font_family); }
set { cef_string_t.Copy(value, &_self->fantasy_font_family); }
}
public int DefaultFontSize
{
get { return _self->default_font_size; }
set { _self->default_font_size = value; }
}
public int DefaultFixedFontSize
{
get { return _self->default_fixed_font_size; }
set { _self->default_fixed_font_size = value; }
}
public int MinimumFontSize
{
get { return _self->minimum_font_size; }
set { _self->minimum_font_size = value; }
}
public int MinimumLogicalFontSize
{
get { return _self->minimum_logical_font_size; }
set { _self->minimum_logical_font_size = value; }
}
#endregion
/// <summary>
/// Default encoding for Web content. If empty "ISO-8859-1" will be used. Also
/// configurable using the "default-encoding" command-line switch.
/// </summary>
public string DefaultEncoding
{
get { return cef_string_t.ToString(&_self->default_encoding); }
set { cef_string_t.Copy(value, &_self->default_encoding); }
}
/// <summary>
/// Controls the loading of fonts from remote sources. Also configurable using
/// the "disable-remote-fonts" command-line switch.
/// </summary>
public CefState RemoteFonts
{
get { return _self->remote_fonts; }
set { _self->remote_fonts = value; }
}
/// <summary>
/// Controls whether JavaScript can be executed. Also configurable using the
/// "disable-javascript" command-line switch.
/// </summary>
public CefState JavaScript
{
get { return _self->javascript; }
set { _self->javascript = value; }
}
/// <summary>
/// Controls whether JavaScript can be used for opening windows. Also
/// configurable using the "disable-javascript-open-windows" command-line
/// switch.
/// </summary>
public CefState JavaScriptOpenWindows
{
get { return _self->javascript_open_windows; }
set { _self->javascript_open_windows = value; }
}
/// <summary>
/// Controls whether JavaScript can be used to close windows that were not
/// opened via JavaScript. JavaScript can still be used to close windows that
/// were opened via JavaScript or that have no back/forward history. Also
/// configurable using the "disable-javascript-close-windows" command-line
/// switch.
/// </summary>
public CefState JavaScriptCloseWindows
{
get { return _self->javascript_close_windows; }
set { _self->javascript_close_windows = value; }
}
/// <summary>
/// Controls whether JavaScript can access the clipboard. Also configurable
/// using the "disable-javascript-access-clipboard" command-line switch.
/// </summary>
public CefState JavaScriptAccessClipboard
{
get { return _self->javascript_access_clipboard; }
set { _self->javascript_access_clipboard = value; }
}
/// <summary>
/// Controls whether DOM pasting is supported in the editor via
/// execCommand("paste"). The |javascript_access_clipboard| setting must also
/// be enabled. Also configurable using the "disable-javascript-dom-paste"
/// command-line switch.
/// </summary>
public CefState JavaScriptDomPaste
{
get { return _self->javascript_dom_paste; }
set { _self->javascript_dom_paste = value; }
}
/// <summary>
/// Controls whether the caret position will be drawn. Also configurable using
/// the "enable-caret-browsing" command-line switch.
/// </summary>
public CefState CaretBrowsing
{
get { return _self->caret_browsing; }
set { _self->caret_browsing = value; }
}
/// <summary>
/// Controls whether the Java plugin will be loaded. Also configurable using
/// the "disable-java" command-line switch.
/// </summary>
public CefState Java
{
get { return _self->java; }
set { _self->java = value; }
}
/// <summary>
/// Controls whether any plugins will be loaded. Also configurable using the
/// "disable-plugins" command-line switch.
/// </summary>
public CefState Plugins
{
get { return _self->plugins; }
set { _self->plugins = value; }
}
/// <summary>
/// Controls whether file URLs will have access to all URLs. Also configurable
/// using the "allow-universal-access-from-files" command-line switch.
/// </summary>
public CefState UniversalAccessFromFileUrls
{
get { return _self->universal_access_from_file_urls; }
set { _self->universal_access_from_file_urls = value; }
}
/// <summary>
/// Controls whether file URLs will have access to other file URLs. Also
/// configurable using the "allow-access-from-files" command-line switch.
/// </summary>
public CefState FileAccessFromFileUrls
{
get { return _self->file_access_from_file_urls; }
set { _self->file_access_from_file_urls = value; }
}
/// <summary>
/// Controls whether web security restrictions (same-origin policy) will be
/// enforced. Disabling this setting is not recommend as it will allow risky
/// security behavior such as cross-site scripting (XSS). Also configurable
/// using the "disable-web-security" command-line switch.
/// </summary>
public CefState WebSecurity
{
get { return _self->web_security; }
set { _self->web_security = value; }
}
/// <summary>
/// Controls whether image URLs will be loaded from the network. A cached image
/// will still be rendered if requested. Also configurable using the
/// "disable-image-loading" command-line switch.
/// </summary>
public CefState ImageLoading
{
get { return _self->image_loading; }
set { _self->image_loading = value; }
}
/// <summary>
/// Controls whether standalone images will be shrunk to fit the page. Also
/// configurable using the "image-shrink-standalone-to-fit" command-line
/// switch.
/// </summary>
public CefState ImageShrinkStandaloneToFit
{
get { return _self->image_shrink_standalone_to_fit; }
set { _self->image_shrink_standalone_to_fit = value; }
}
/// <summary>
/// Controls whether text areas can be resized. Also configurable using the
/// "disable-text-area-resize" command-line switch.
/// </summary>
public CefState TextAreaResize
{
get { return _self->text_area_resize; }
set { _self->text_area_resize = value; }
}
/// <summary>
/// Controls whether the tab key can advance focus to links. Also configurable
/// using the "disable-tab-to-links" command-line switch.
/// </summary>
public CefState TabToLinks
{
get { return _self->tab_to_links; }
set { _self->tab_to_links = value; }
}
/// <summary>
/// Controls whether local storage can be used. Also configurable using the
/// "disable-local-storage" command-line switch.
/// </summary>
public CefState LocalStorage
{
get { return _self->local_storage; }
set { _self->local_storage = value; }
}
/// <summary>
/// Controls whether databases can be used. Also configurable using the
/// "disable-databases" command-line switch.
/// </summary>
public CefState Databases
{
get { return _self->databases; }
set { _self->databases = value; }
}
/// <summary>
/// Controls whether the application cache can be used. Also configurable using
/// the "disable-application-cache" command-line switch.
/// </summary>
public CefState ApplicationCache
{
get { return _self->application_cache; }
set { _self->application_cache = value; }
}
/// <summary>
/// Controls whether WebGL can be used. Note that WebGL requires hardware
/// support and may not work on all systems even when enabled. Also
/// configurable using the "disable-webgl" command-line switch.
/// </summary>
public CefState WebGL
{
get { return _self->webgl; }
set { _self->webgl = value; }
}
/// <summary>
/// Opaque background color used for the browser before a document is loaded
/// and when no document color is specified. By default the background color
/// will be the same as CefSettings.background_color. Only the RGB compontents
/// of the specified value will be used. The alpha component must greater than
/// 0 to enable use of the background color but will be otherwise ignored.
/// </summary>
public CefColor BackgroundColor
{
get { return new CefColor(_self->background_color); }
set { _self->background_color = value.ToArgb(); }
}
/// <summary>
/// Comma delimited ordered list of language codes without any whitespace that
/// will be used in the "Accept-Language" HTTP header. May be set globally
/// using the CefBrowserSettings.accept_language_list value. If both values are
/// empty then "en-US,en" will be used.
/// </summary>
public string AcceptLanguageList
{
get { return cef_string_t.ToString(&_self->accept_language_list); }
set { cef_string_t.Copy(value, &_self->accept_language_list); }
}
}
}
+32
View File
@@ -0,0 +1,32 @@
namespace Cef3
{
using System;
public struct CefColor
{
private uint _value;
public CefColor(uint argb)
{
_value = argb;
}
public CefColor(byte alpha, byte red, byte green, byte blue)
{
_value = unchecked((uint)((alpha << 24) | (red << 16) | (green << 8) | blue));
}
public byte A { get { return unchecked((byte)(_value >> 24)); } }
public byte R { get { return unchecked((byte)(_value >> 16)); } }
public byte G { get { return unchecked((byte)(_value >> 8)); } }
public byte B { get { return unchecked((byte)(_value)); } }
public uint ToArgb()
{
return _value;
}
}
}
+63
View File
@@ -0,0 +1,63 @@
namespace Cef3
{
using System;
using System.Collections.Generic;
using System.Text;
using Cef3.Interop;
public sealed unsafe class CefCookie
{
public CefCookie()
{ }
public string Name { get; set; }
public string Value { get; set; }
public string Domain { get; set; }
public string Path { get; set; }
public bool Secure { get; set; }
public bool HttpOnly { get; set; }
public DateTime Creation { get; set; }
public DateTime LastAccess { get; set; }
public DateTime? Expires { get; set; }
internal static CefCookie FromNative(cef_cookie_t* ptr)
{
return new CefCookie
{
Name = cef_string_t.ToString(&ptr->name),
Value = cef_string_t.ToString(&ptr->value),
Domain = cef_string_t.ToString(&ptr->domain),
Path = cef_string_t.ToString(&ptr->path),
Secure = ptr->secure != 0,
HttpOnly = ptr->httponly != 0,
Creation = cef_time_t.ToDateTime(&ptr->creation),
LastAccess = cef_time_t.ToDateTime(&ptr->last_access),
Expires = ptr->has_expires != 0 ? (DateTime?)cef_time_t.ToDateTime(&ptr->expires) : null,
};
}
internal cef_cookie_t* ToNative()
{
var ptr = cef_cookie_t.Alloc();
cef_string_t.Copy(Name, &ptr->name);
cef_string_t.Copy(Value, &ptr->value);
cef_string_t.Copy(Domain, &ptr->domain);
cef_string_t.Copy(Path, &ptr->path);
ptr->secure = Secure ? 1 : 0;
ptr->httponly = HttpOnly ? 1 : 0;
ptr->creation = new cef_time_t(Creation);
ptr->last_access = new cef_time_t(LastAccess);
ptr->has_expires = Expires != null ? 1 : 0;
ptr->expires = Expires != null ? new cef_time_t(Expires.Value) : new cef_time_t();
return ptr;
}
internal static void Free(cef_cookie_t* ptr)
{
cef_cookie_t.Clear((cef_cookie_t*)ptr);
cef_cookie_t.Free((cef_cookie_t*)ptr);
}
}
}
@@ -0,0 +1,69 @@
namespace Cef3
{
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using Cef3.Interop;
/// <summary>
/// Structure representing cursor information. |buffer| will be
/// |size.width|*|size.height|*4 bytes in size and represents a BGRA image with
/// an upper-left origin.
/// </summary>
public unsafe sealed class CefCursorInfo
{
private cef_cursor_info_t* _ptr;
internal CefCursorInfo(cef_cursor_info_t* ptr)
{
_ptr = ptr;
}
internal void Dispose()
{
_ptr = null;
}
private void ThrowIfDisposed()
{
if (_ptr == null) throw new ObjectDisposedException("CefCursorInfo");
}
public CefPoint HotSpot
{
get
{
ThrowIfDisposed();
return new CefPoint(_ptr->hotspot.x, _ptr->hotspot.y);
}
}
public float ImageScaleFactor
{
get
{
ThrowIfDisposed();
return _ptr->image_scale_factor;
}
}
public byte[] GetBuffer()
{
ThrowIfDisposed();
var bufferLength = _ptr->size.width * _ptr->size.height * 4;
var bytes = new byte[bufferLength];
Marshal.Copy((IntPtr)_ptr->buffer, bytes, 0, bufferLength);
return bytes;
}
public CefSize Size
{
get
{
ThrowIfDisposed();
return new CefSize(_ptr->size.width, _ptr->size.height);
}
}
}
}
@@ -0,0 +1,33 @@
namespace Cef3
{
using System;
using System.Collections.Generic;
using System.Text;
using Cef3.Interop;
public sealed class CefDraggableRegion
{
internal static unsafe CefDraggableRegion FromNative(cef_draggable_region_t* ptr)
{
return new CefDraggableRegion(ptr);
}
private readonly CefRectangle _bounds;
private readonly bool _draggable;
private unsafe CefDraggableRegion(cef_draggable_region_t* ptr)
{
_bounds = new CefRectangle(
ptr->bounds.x,
ptr->bounds.y,
ptr->bounds.width,
ptr->bounds.height
);
_draggable = ptr->draggable != 0;
}
public CefRectangle Bounds { get { return _bounds; } }
public bool Draggable { get { return _draggable; } }
}
}
@@ -0,0 +1,96 @@
namespace Cef3
{
using System;
using System.Collections.Generic;
using System.Text;
using Cef3.Interop;
/// <summary>
/// Structure representing geoposition information. The properties of this
/// structure correspond to those of the JavaScript Position object although
/// their types may differ.
/// </summary>
public unsafe sealed class CefGeoposition
{
internal static CefGeoposition FromNative(cef_geoposition_t* position)
{
return new CefGeoposition(position);
}
private readonly double _latitude;
private readonly double _longitude;
private readonly double _altitude;
private readonly double _accuracy;
private readonly double _altitudeAccuracy;
private readonly double _heading;
private readonly double _speed;
private readonly DateTime _timestamp;
private readonly CefGeopositionErrorCode _errorCode;
private readonly string _errorMessage;
private CefGeoposition(cef_geoposition_t* position)
{
_latitude = position->latitude;
_longitude = position->longitude;
_altitude = position->altitude;
_accuracy = position->accuracy;
_altitudeAccuracy = position->altitude_accuracy;
_heading = position->heading;
_speed = position->speed;
_timestamp = cef_time_t.ToDateTime(&position->timestamp);
_errorCode = position->error_code;
_errorMessage = cef_string_t.ToString(&position->error_message);
}
/// <summary>
/// Latitude in decimal degrees north (WGS84 coordinate frame).
/// </summary>
public double Latitude { get { return _latitude; } }
/// <summary>
/// Longitude in decimal degrees west (WGS84 coordinate frame).
/// </summary>
public double Longitude { get { return _longitude; } }
/// <summary>
/// Altitude in meters (above WGS84 datum).
/// </summary>
public double Altitude { get { return _altitude; } }
/// <summary>
/// Accuracy of horizontal position in meters.
/// </summary>
public double Accuracy { get { return _accuracy; } }
/// <summary>
/// Accuracy of altitude in meters.
/// </summary>
public double AltitudeAccuracy { get { return _altitudeAccuracy; } }
/// <summary>
/// Heading in decimal degrees clockwise from true north.
/// </summary>
public double Heading { get { return _heading; } }
/// <summary>
/// Horizontal component of device velocity in meters per second.
/// </summary>
public double Speed { get { return _speed; } }
/// <summary>
/// Time of position measurement in milliseconds since Epoch in UTC time. This
/// is taken from the host computer's system clock.
/// </summary>
public DateTime Timestamp { get { return _timestamp; } }
/// <summary>
/// Error code, see enum above.
/// </summary>
public CefGeopositionErrorCode ErrorCode { get { return _errorCode; } }
/// <summary>
/// Human-readable error message.
/// </summary>
public string ErrorMessage { get { return _errorMessage; } }
}
}
+136
View File
@@ -0,0 +1,136 @@
namespace Cef3
{
using System;
using Cef3.Interop;
public sealed class CefKeyEvent
{
private CefKeyEventType _type;
private CefEventFlags _modifiers;
private int _windowsKeyCode;
private int _nativeKeyCode;
private bool _isSystemKey;
private char _character;
private char _unmodifiedCharacter;
private bool _focusOnEditableField;
public CefKeyEvent()
{
}
/// <summary>
/// The type of keyboard event.
/// </summary>
public CefKeyEventType EventType
{
get { return _type; }
set { _type = value; }
}
/// <summary>
/// Bit flags describing any pressed modifier keys. See
/// cef_event_flags_t for values.
/// </summary>
public CefEventFlags Modifiers
{
get { return _modifiers; }
set { _modifiers = value; }
}
/// <summary>
/// The Windows key code for the key event. This value is used by the DOM
/// specification. Sometimes it comes directly from the event (i.e. on
/// Windows) and sometimes it's determined using a mapping function. See
/// WebCore/platform/chromium/KeyboardCodes.h for the list of values.
/// </summary>
public int WindowsKeyCode
{
get { return _windowsKeyCode; }
set { _windowsKeyCode = value; }
}
/// <summary>
/// The actual key code genenerated by the platform.
/// </summary>
public int NativeKeyCode
{
get { return _nativeKeyCode; }
set { _nativeKeyCode = value; }
}
/// <summary>
/// Indicates whether the event is considered a "system key" event (see
/// http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx for details).
/// This value will always be false on non-Windows platforms.
/// </summary>
public bool IsSystemKey
{
get { return _isSystemKey; }
set { _isSystemKey = value; }
}
/// <summary>
/// The character generated by the keystroke.
/// </summary>
public char Character
{
get { return _character; }
set { _character = value; }
}
/// <summary>
/// Same as |character| but unmodified by any concurrently-held modifiers
/// (except shift). This is useful for working out shortcut keys.
/// </summary>
public char UnmodifiedCharacter
{
get { return _unmodifiedCharacter; }
set { _unmodifiedCharacter = value; }
}
/// <summary>
/// True if the focus is currently on an editable field on the page. This is
/// useful for determining if standard key events should be intercepted.
/// </summary>
public bool FocusOnEditableField
{
get { return _focusOnEditableField; }
set { _focusOnEditableField = value; }
}
#region Interop
internal static unsafe CefKeyEvent FromNative(cef_key_event_t* ptr)
{
if (ptr == null) throw new ArgumentNullException("ptr");
return new CefKeyEvent
{
EventType = ptr->type,
Modifiers = ptr->modifiers,
WindowsKeyCode = ptr->windows_key_code,
NativeKeyCode = ptr->native_key_code,
IsSystemKey = ptr->is_system_key != 0,
Character = (char)ptr->character,
UnmodifiedCharacter = (char)ptr->unmodified_character,
FocusOnEditableField = ptr->focus_on_editable_field != 0,
};
}
internal unsafe void ToNative(cef_key_event_t* ptr)
{
if (ptr == null) throw new ArgumentNullException("ptr");
ptr->type = EventType;
ptr->modifiers = Modifiers;
ptr->windows_key_code = WindowsKeyCode;
ptr->native_key_code = NativeKeyCode;
ptr->is_system_key = IsSystemKey ? 1 : 0;
ptr->character = Character;
ptr->unmodified_character = UnmodifiedCharacter;
ptr->focus_on_editable_field = FocusOnEditableField ? 1 : 0;
}
#endregion
}
}
+116
View File
@@ -0,0 +1,116 @@
namespace Cef3
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Reflection;
using System.Runtime.InteropServices;
using Cef3.Interop;
using Windows = Cef3.Platform.Windows;
public sealed unsafe class CefMainArgs
{
private readonly string[] _args;
private IntPtr _argcArgvBlock;
public CefMainArgs(string[] args)
{
_args = args;
_argcArgvBlock = IntPtr.Zero;
}
internal cef_main_args_t* ToNative()
{
switch (CefRuntime.Platform)
{
case CefRuntimePlatform.Windows:
return (cef_main_args_t*)ToNativeWindows();
case CefRuntimePlatform.Linux:
case CefRuntimePlatform.MacOSX:
return (cef_main_args_t*)ToNativePosix();
default:
throw ExceptionBuilder.UnsupportedPlatform();
}
}
private cef_main_args_t_windows* ToNativeWindows()
{
var ptr = cef_main_args_t_windows.Alloc();
ptr->instance = Windows.NativeMethods.GetModuleHandle(null);
return ptr;
}
private cef_main_args_t_posix* ToNativePosix()
{
var ptr = cef_main_args_t_posix.Alloc();
if (_args != null)
{
ptr->argv = MarshallArgcArgvBlock(_args);
ptr->argc = _args.Length;
}
return ptr;
}
// TODO: check this, and reimplement CefMainArgs to do not leak memory
private IntPtr MarshallArgcArgvBlock(string[] args)
{
Debug.Assert(args != null);
var encoding = Encoding.UTF8;
// calculate required block length
var sizeOfArray = sizeof(IntPtr) * (args.Length + 1); // sizeof array of pointers to arguments
var size = sizeOfArray; // size for entire block
foreach (var arg in args)
{
size += 1 + encoding.GetByteCount(arg ?? "");
}
byte** argv = (byte**)Marshal.AllocHGlobal(size);
byte* data = (byte*)argv + sizeOfArray;
for (var i=0; i < args.Length; i++)
{
argv[i] = data;
var bytes = encoding.GetBytes(args[i]);
Marshal.Copy(bytes, 0, (IntPtr)data, bytes.Length);
data += bytes.Length;
data[0] = 0;
data++;
}
argv[args.Length] = (byte*)0;
return (IntPtr)argv;
}
private void FreeArgcArgvBlock(IntPtr ptr)
{
Marshal.FreeHGlobal(ptr);
}
internal static void Free(cef_main_args_t* ptr)
{
switch (CefRuntime.Platform)
{
case CefRuntimePlatform.Windows:
cef_main_args_t_windows.Free((cef_main_args_t_windows*)ptr);
return;
case CefRuntimePlatform.Linux:
case CefRuntimePlatform.MacOSX:
cef_main_args_t_posix.Free((cef_main_args_t_posix*)ptr);
return;
default:
throw ExceptionBuilder.UnsupportedPlatform();
}
}
}
}
@@ -0,0 +1,55 @@
namespace Cef3
{
using System;
using Cef3.Interop;
using System.Diagnostics;
/// <summary>
/// Structure representing mouse event information.
/// </summary>
public unsafe struct CefMouseEvent
{
private int _x;
private int _y;
private CefEventFlags _modifiers;
public CefMouseEvent(int x, int y, CefEventFlags modifiers)
{
_x = x;
_y = y;
_modifiers = modifiers;
}
internal CefMouseEvent(cef_mouse_event_t* ptr)
{
Debug.Assert(ptr != null);
_x = ptr->x;
_y = ptr->y;
_modifiers = ptr->modifiers;
}
internal cef_mouse_event_t ToNative()
{
return new cef_mouse_event_t(_x, _y, _modifiers);
}
public int X
{
get { return _x; }
set { _x = value; }
}
public int Y
{
get { return _y; }
set { _y = value; }
}
public CefEventFlags Modifiers
{
get { return _modifiers; }
set { _modifiers = value; }
}
}
}
+39
View File
@@ -0,0 +1,39 @@
namespace Cef3
{
using System;
using System.Collections.Generic;
using System.Text;
using Cef3.Interop;
public struct CefPageRange
{
internal static unsafe CefPageRange Create(cef_page_range_t* pageRange)
{
return new CefPageRange(
pageRange->from,
pageRange->to
);
}
private int _from;
private int _to;
public CefPageRange(int from, int to)
{
_from = from;
_to = to;
}
public int From
{
get { return _from; }
set { _from = value; }
}
public int To
{
get { return _to; }
set { _to = value; }
}
}
}
@@ -0,0 +1,46 @@
namespace Cef3
{
using System;
using System.Collections.Generic;
using System.Text;
using Cef3.Interop;
[Serializable]
public sealed class CefPdfPrintSettings
{
public string HeaderFooterTitle { get; set; }
public string HeaderFooterUrl { get; set; }
public int PageWidth { get; set; }
public int PageHeight { get; set; }
public double MarginTop { get; set; }
public double MarginRight { get; set; }
public double MarginBottom { get; set; }
public double MarginLeft { get; set; }
public CefPdfPrintMarginType MarginType { get; set; }
public bool HeaderFooterEnabled { get; set; }
public bool SelectionOnly { get; set; }
public bool Landscape { get; set; }
public bool BackgroundsEnabled { get; set; }
internal unsafe cef_pdf_print_settings_t* ToNative()
{
var ptr = cef_pdf_print_settings_t.Alloc();
cef_string_t.Copy(HeaderFooterTitle, &ptr->header_footer_title);
cef_string_t.Copy(HeaderFooterUrl, &ptr->header_footer_url);
ptr->page_width = PageWidth;
ptr->page_height = PageHeight;
ptr->margin_top = MarginTop;
ptr->margin_right = MarginRight;
ptr->margin_bottom = MarginBottom;
ptr->margin_left = MarginLeft;
ptr->margin_type = MarginType;
ptr->header_footer_enabled = HeaderFooterEnabled ? 1 : 0;
ptr->selection_only = SelectionOnly ? 1 : 0;
ptr->landscape = Landscape ? 1 : 0;
ptr->backgrounds_enabled = BackgroundsEnabled ? 1 : 0;
return ptr;
}
}
}
+31
View File
@@ -0,0 +1,31 @@
namespace Cef3
{
using System;
using System.Collections.Generic;
using System.Text;
using Cef3.Interop;
public struct CefPoint
{
private int _x;
private int _y;
public CefPoint(int x, int y)
{
_x = x;
_y = y;
}
public int X
{
get { return _x; }
set { _x = value; }
}
public int Y
{
get { return _y; }
set { _y = value; }
}
}
}
@@ -0,0 +1,144 @@
namespace Cef3
{
using System;
using System.Collections.Generic;
using System.Text;
using Cef3.Interop;
public sealed unsafe class CefPopupFeatures
{
private cef_popup_features_t* _self;
internal CefPopupFeatures(cef_popup_features_t* ptr)
{
_self = ptr;
}
internal void Dispose()
{
_self = null;
}
public int? X
{
get
{
ThrowIfObjectDisposed();
return _self->xSet != 0 ? (int?)_self->x : null;
}
}
public int? Y
{
get
{
ThrowIfObjectDisposed();
return _self->ySet != 0 ? (int?)_self->y : null;
}
}
public int? Width
{
get
{
ThrowIfObjectDisposed();
return _self->widthSet != 0 ? (int?)_self->width : null;
}
}
public int? Height
{
get
{
ThrowIfObjectDisposed();
return _self->heightSet != 0 ? (int?)_self->height : null;
}
}
public bool MenuBarVisible
{
get
{
ThrowIfObjectDisposed();
return _self->menuBarVisible != 0;
}
}
public bool StatusBarVisible
{
get
{
ThrowIfObjectDisposed();
return _self->statusBarVisible != 0;
}
}
public bool ToolBarVisible
{
get
{
ThrowIfObjectDisposed();
return _self->toolBarVisible != 0;
}
}
public bool LocationBarVisible
{
get
{
ThrowIfObjectDisposed();
return _self->locationBarVisible != 0;
}
}
public bool ScrollbarsVisible
{
get
{
ThrowIfObjectDisposed();
return _self->scrollbarsVisible != 0;
}
}
public bool Resizable
{
get
{
ThrowIfObjectDisposed();
return _self->resizable != 0;
}
}
public bool Fullscreen
{
get
{
ThrowIfObjectDisposed();
return _self->fullscreen != 0;
}
}
public bool Dialog
{
get
{
ThrowIfObjectDisposed();
return _self->dialog != 0;
}
}
public string[] AdditionalFeatures
{
get
{
ThrowIfObjectDisposed();
return cef_string_list.ToArray(_self->additionalFeatures);
}
}
private void ThrowIfObjectDisposed()
{
if (_self == null) throw ExceptionBuilder.ObjectDisposed();
}
}
}
+47
View File
@@ -0,0 +1,47 @@
namespace Cef3
{
using System;
using System.Collections.Generic;
using System.Text;
using Cef3.Interop;
public struct CefRectangle
{
private int _x;
private int _y;
private int _width;
private int _height;
public CefRectangle(int x, int y, int width, int height)
{
_x = x;
_y = y;
_width = width;
_height = height;
}
public int X
{
get { return _x; }
set { _x = value; }
}
public int Y
{
get { return _y; }
set { _y = value; }
}
public int Width
{
get { return _width; }
set { _width = value; }
}
public int Height
{
get { return _height; }
set { _height = value; }
}
}
}
@@ -0,0 +1,76 @@
namespace Cef3
{
using System;
using System.Collections.Generic;
using System.Text;
using Cef3.Interop;
/// <summary>
/// Request context initialization settings. Specify NULL or 0 to get the
/// recommended default values.
/// </summary>
public sealed class CefRequestContextSettings
{
/// <summary>
/// The location where cache data will be stored on disk. If empty then
/// browsers will be created in "incognito mode" where in-memory caches are
/// used for storage and no data is persisted to disk. HTML5 databases such as
/// localStorage will only persist across sessions if a cache path is
/// specified. To share the global browser cache and related configuration set
/// this value to match the CefSettings.cache_path value.
/// </summary>
public string CachePath { get; set; }
/// <summary>
/// To persist session cookies (cookies without an expiry date or validity
/// interval) by default when using the global cookie manager set this value to
/// true. Session cookies are generally intended to be transient and most Web
/// browsers do not persist them. Can be set globally using the
/// CefSettings.persist_session_cookies value. This value will be ignored if
/// |cache_path| is empty or if it matches the CefSettings.cache_path value.
/// </summary>
public bool PersistSessionCookies { get; set; }
/// <summary>
/// Set to true (1) to ignore errors related to invalid SSL certificates.
/// Enabling this setting can lead to potential security vulnerabilities like
/// "man in the middle" attacks. Applications that load content from the
/// internet should not enable this setting. Can be set globally using the
/// CefSettings.ignore_certificate_errors value. This value will be ignored if
/// |cache_path| matches the CefSettings.cache_path value.
/// </summary>
public bool IgnoreCertificateErrors { get; set; }
/// <summary>
/// Comma delimited ordered list of language codes without any whitespace that
/// will be used in the "Accept-Language" HTTP header. Can be set globally
/// using the CefSettings.accept_language_list value or overridden on a per-
/// browser basis using the CefBrowserSettings.accept_language_list value. If
/// all values are empty then "en-US,en" will be used. This value will be
/// ignored if |cache_path| matches the CefSettings.cache_path value.
/// </summary>
public string AcceptLanguageList { get; set; }
internal unsafe cef_request_context_settings_t* ToNative()
{
var ptr = cef_request_context_settings_t.Alloc();
cef_string_t.Copy(CachePath, &ptr->cache_path);
ptr->persist_session_cookies = PersistSessionCookies ? 1 : 0;
ptr->ignore_certificate_errors = IgnoreCertificateErrors ? 1 : 0;
cef_string_t.Copy(CachePath, &ptr->accept_language_list);
return ptr;
}
private static unsafe void Clear(cef_request_context_settings_t* ptr)
{
libcef.string_clear(&ptr->cache_path);
libcef.string_clear(&ptr->accept_language_list);
}
internal static unsafe void Free(cef_request_context_settings_t* ptr)
{
Clear(ptr);
cef_request_context_settings_t.Free(ptr);
}
}
}
+112
View File
@@ -0,0 +1,112 @@
namespace Cef3
{
using System;
using Cef3.Interop;
/// <summary>
/// Screen information used when window rendering is disabled. This structure is
/// passed as a parameter to CefRenderHandler::GetScreenInfo and should be filled
/// in by the client.
/// </summary>
public sealed unsafe class CefScreenInfo
{
private cef_screen_info_t* _self;
internal CefScreenInfo(cef_screen_info_t* self)
{
_self = self;
}
internal void Dispose()
{
_self = null;
}
/// <summary>
/// Device scale factor. Specifies the ratio between physical and logical
/// pixels.
/// </summary>
public float DeviceScaleFactor
{
get { return _self->device_scale_factor; }
set { _self->device_scale_factor = value; }
}
/// <summary>
/// The screen depth in bits per pixel.
/// </summary>
public int Depth
{
get { return _self->depth; }
set { _self->depth = value; }
}
/// <summary>
/// The bits per color component. This assumes that the colors are balanced
/// equally.
/// </summary>
public int DepthPerComponent
{
get { return _self->depth_per_component; }
set { _self->depth_per_component = value; }
}
/// <summary>
/// This can be true for black and white printers.
/// </summary>
public bool IsMonochrome
{
get { return _self->is_monochrome != 0; }
set { _self->is_monochrome = value ? 1 : 0; }
}
/// <summary>
/// This is set from the rcMonitor member of MONITORINFOEX, to whit:
/// "A RECT structure that specifies the display monitor rectangle,
/// expressed in virtual-screen coordinates. Note that if the monitor
/// is not the primary display monitor, some of the rectangle's
/// coordinates may be negative values."
///
/// The |rect| and |available_rect| properties are used to determine the
/// available surface for rendering popup views.
/// </summary>
public CefRectangle Rectangle
{
get
{
var n_rect = _self->rect;
return new CefRectangle(n_rect.x, n_rect.y, n_rect.width, n_rect.height);
}
set
{
_self->rect = new cef_rect_t(value.X, value.Y, value.Width, value.Height);
}
}
/// <summary>
/// This is set from the rcWork member of MONITORINFOEX, to whit:
/// "A RECT structure that specifies the work area rectangle of the
/// display monitor that can be used by applications, expressed in
/// virtual-screen coordinates. Windows uses this rectangle to
/// maximize an application on the monitor. The rest of the area in
/// rcMonitor contains system windows such as the task bar and side
/// bars. Note that if the monitor is not the primary display monitor,
/// some of the rectangle's coordinates may be negative values".
///
/// The |rect| and |available_rect| properties are used to determine the
/// available surface for rendering popup views.
/// </summary>
public CefRectangle AvailableRectangle
{
get
{
var n_rect = _self->available_rect;
return new CefRectangle(n_rect.x, n_rect.y, n_rect.width, n_rect.height);
}
set
{
_self->available_rect = new cef_rect_t(value.X, value.Y, value.Width, value.Height);
}
}
}
}
+292
View File
@@ -0,0 +1,292 @@
namespace Cef3
{
using System;
using System.Collections.Generic;
using System.Text;
using Cef3.Interop;
/// <summary>
/// Initialization settings. Specify <c>null</c> or 0 to get the recommended default
/// values. Many of these and other settings can also configured using command-line
/// switches.
/// </summary>
public sealed unsafe class CefSettings
{
public CefSettings()
{
BackgroundColor = new CefColor(255, 255, 255, 255);
}
/// <summary>
/// Set to <c>true</c> to use a single process for the browser and renderer. This
/// run mode is not officially supported by Chromium and is less stable than
/// the multi-process default. Also configurable using the "single-process"
/// command-line switch.
/// </summary>
public bool SingleProcess { get; set; }
/// <summary>
/// Set to <c>true</c> to disable the sandbox for sub-processes. See
/// cef_sandbox_win.h for requirements to enable the sandbox on Windows. Also
/// configurable using the "no-sandbox" command-line switch.
/// </summary>
public bool NoSandbox { get; set; }
/// <summary>
/// The path to a separate executable that will be launched for sub-processes.
/// By default the browser process executable is used. See the comments on
/// CefExecuteProcess() for details. Also configurable using the
/// "browser-subprocess-path" command-line switch.
/// </summary>
public string BrowserSubprocessPath { get; set; }
/// <summary>
/// Set to <c>true</c> to have the browser process message loop run in a separate
/// thread. If <c>false</c> than the CefDoMessageLoopWork() function must be
/// called from your application message loop. This option is only supported on
/// Windows.
/// </summary>
public bool MultiThreadedMessageLoop { get; set; }
/// <summary>
/// Set to true (1) to enable windowless (off-screen) rendering support. Do not
/// enable this value if the application does not use windowless rendering as
/// it may reduce rendering performance on some systems.
/// </summary>
public bool WindowlessRenderingEnabled { get; set; }
/// <summary>
/// Set to <c>true</c> to disable configuration of browser process features using
/// standard CEF and Chromium command-line arguments. Configuration can still
/// be specified using CEF data structures or via the
/// CefApp::OnBeforeCommandLineProcessing() method.
/// </summary>
public bool CommandLineArgsDisabled { get; set; }
/// <summary>
/// The location where cache data will be stored on disk. If empty then
/// browsers will be created in "incognito mode" where in-memory caches are
/// used for storage and no data is persisted to disk. HTML5 databases such as
/// localStorage will only persist across sessions if a cache path is
/// specified. Can be overridden for individual CefRequestContext instances via
/// the CefRequestContextSettings.cache_path value.
/// </summary>
public string CachePath { get; set; }
/// <summary>
/// The location where user data such as spell checking dictionary files will
/// be stored on disk. If empty then the default platform-specific user data
/// directory will be used ("~/.cef_user_data" directory on Linux,
/// "~/Library/Application Support/CEF/User Data" directory on Mac OS X,
/// "Local Settings\Application Data\CEF\User Data" directory under the user
/// profile directory on Windows).
/// </summary>
public string UserDataPath { get; set; }
/// <summary>
/// To persist session cookies (cookies without an expiry date or validity
/// interval) by default when using the global cookie manager set this value to
/// true. Session cookies are generally intended to be transient and most Web
/// browsers do not persist them. A |cache_path| value must also be specified
/// to enable this feature. Also configurable using the
/// "persist-session-cookies" command-line switch. Can be overridden for
/// individual CefRequestContext instances via the
/// CefRequestContextSettings.persist_session_cookies value.
/// </summary>
public bool PersistSessionCookies { get; set; }
/// <summary>
/// Value that will be returned as the User-Agent HTTP header. If empty the
/// default User-Agent string will be used. Also configurable using the
/// "user-agent" command-line switch.
/// </summary>
public string UserAgent { get; set; }
/// <summary>
/// Value that will be inserted as the product portion of the default
/// User-Agent string. If empty the Chromium product version will be used. If
/// |userAgent| is specified this value will be ignored. Also configurable
/// using the "product-version" command-line switch.
/// </summary>
public string ProductVersion { get; set; }
/// <summary>
/// The locale string that will be passed to WebKit. If empty the default
/// locale of "en-US" will be used. This value is ignored on Linux where locale
/// is determined using environment variable parsing with the precedence order:
/// LANGUAGE, LC_ALL, LC_MESSAGES and LANG. Also configurable using the "lang"
/// command-line switch.
/// </summary>
public string Locale { get; set; }
/// <summary>
/// The directory and file name to use for the debug log. If empty, the
/// default name of "debug.log" will be used and the file will be written
/// to the application directory. Also configurable using the "log-file"
/// command-line switch.
/// </summary>
public string LogFile { get; set; }
/// <summary>
/// The log severity. Only messages of this severity level or higher will be
/// logged. Also configurable using the "log-severity" command-line switch with
/// a value of "verbose", "info", "warning", "error", "error-report" or
/// "disable".
/// </summary>
public CefLogSeverity LogSeverity { get; set; }
/// <summary>
/// Custom flags that will be used when initializing the V8 JavaScript engine.
/// The consequences of using custom flags may not be well tested. Also
/// configurable using the "js-flags" command-line switch.
/// </summary>
public string JavaScriptFlags { get; set; }
/// <summary>
/// The fully qualified path for the resources directory. If this value is
/// empty the cef.pak and/or devtools_resources.pak files must be located in
/// the module directory on Windows/Linux or the app bundle Resources directory
/// on Mac OS X. Also configurable using the "resources-dir-path" command-line
/// switch.
/// </summary>
public string ResourcesDirPath { get; set; }
/// <summary>
/// The fully qualified path for the locales directory. If this value is empty
/// the locales directory must be located in the module directory. This value
/// is ignored on Mac OS X where pack files are always loaded from the app
/// bundle resource directory. Also configurable using the "locales-dir-path"
/// command-line switch.
/// </summary>
public string LocalesDirPath { get; set; }
/// <summary>
/// Set to <c>true</c> to disable loading of pack files for resources and locales.
/// A resource bundle handler must be provided for the browser and render
/// processes via CefApp::GetResourceBundleHandler() if loading of pack files
/// is disabled. Also configurable using the "disable-pack-loading" command-
/// line switch.
/// </summary>
public bool PackLoadingDisabled { get; set; }
/// <summary>
/// Set to a value between 1024 and 65535 to enable remote debugging on the
/// specified port. For example, if 8080 is specified the remote debugging URL
/// will be http://localhost:8080. CEF can be remotely debugged from any CEF or
/// Chrome browser window. Also configurable using the "remote-debugging-port"
/// command-line switch.
/// </summary>
public int RemoteDebuggingPort { get; set; }
/// <summary>
/// The number of stack trace frames to capture for uncaught exceptions.
/// Specify a positive value to enable the CefV8ContextHandler::
/// OnUncaughtException() callback. Specify 0 (default value) and
/// OnUncaughtException() will not be called. Also configurable using the
/// "uncaught-exception-stack-size" command-line switch.
/// </summary>
public int UncaughtExceptionStackSize { get; set; }
/// <summary>
/// By default CEF V8 references will be invalidated (the IsValid() method will
/// return false) after the owning context has been released. This reduces the
/// need for external record keeping and avoids crashes due to the use of V8
/// references after the associated context has been released.
///
/// CEF currently offers two context safety implementations with different
/// performance characteristics. The default implementation (value of 0) uses a
/// map of hash values and should provide better performance in situations with
/// a small number contexts. The alternate implementation (value of 1) uses a
/// hidden value attached to each context and should provide better performance
/// in situations with a large number of contexts.
///
/// If you need better performance in the creation of V8 references and you
/// plan to manually track context lifespan you can disable context safety by
/// specifying a value of -1.
///
/// Also configurable using the "context-safety-implementation" command-line
/// switch.
/// </summary>
public CefContextSafetyImplementation ContextSafetyImplementation { get; set; }
/// <summary>
/// Set to true (1) to ignore errors related to invalid SSL certificates.
/// Enabling this setting can lead to potential security vulnerabilities like
/// "man in the middle" attacks. Applications that load content from the
/// internet should not enable this setting. Also configurable using the
/// "ignore-certificate-errors" command-line switch. Can be overridden for
/// individual CefRequestContext instances via the
/// CefRequestContextSettings.ignore_certificate_errors value.
/// </summary>
public bool IgnoreCertificateErrors { get; set; }
/// <summary>
/// Opaque background color used for accelerated content. By default the
/// background color will be white. Only the RGB compontents of the specified
/// value will be used. The alpha component must greater than 0 to enable use
/// of the background color but will be otherwise ignored.
/// </summary>
public CefColor BackgroundColor { get; set; }
/// <summary>
/// Comma delimited ordered list of language codes without any whitespace that
/// will be used in the "Accept-Language" HTTP header. May be overridden on a
/// per-browser basis using the CefBrowserSettings.accept_language_list value.
/// If both values are empty then "en-US,en" will be used. Can be overridden
/// for individual CefRequestContext instances via the
/// CefRequestContextSettings.accept_language_list value.
/// </summary>
public string AcceptLanguageList { get; set; }
internal cef_settings_t* ToNative()
{
var ptr = cef_settings_t.Alloc();
ptr->single_process = SingleProcess ? 1 : 0;
ptr->no_sandbox = NoSandbox ? 1 : 0;
cef_string_t.Copy(BrowserSubprocessPath, &ptr->browser_subprocess_path);
ptr->multi_threaded_message_loop = MultiThreadedMessageLoop ? 1 : 0;
ptr->windowless_rendering_enabled = WindowlessRenderingEnabled ? 1 : 0;
ptr->command_line_args_disabled = CommandLineArgsDisabled ? 1 : 0;
cef_string_t.Copy(CachePath, &ptr->cache_path);
cef_string_t.Copy(UserDataPath, &ptr->user_data_path);
ptr->persist_session_cookies = PersistSessionCookies ? 1 : 0;
cef_string_t.Copy(UserAgent, &ptr->user_agent);
cef_string_t.Copy(ProductVersion, &ptr->product_version);
cef_string_t.Copy(Locale, &ptr->locale);
cef_string_t.Copy(LogFile, &ptr->log_file);
ptr->log_severity = LogSeverity;
cef_string_t.Copy(JavaScriptFlags, &ptr->javascript_flags);
cef_string_t.Copy(ResourcesDirPath, &ptr->resources_dir_path);
cef_string_t.Copy(LocalesDirPath, &ptr->locales_dir_path);
ptr->pack_loading_disabled = PackLoadingDisabled ? 1 : 0;
ptr->remote_debugging_port = RemoteDebuggingPort;
ptr->uncaught_exception_stack_size = UncaughtExceptionStackSize;
ptr->context_safety_implementation = (int)ContextSafetyImplementation;
ptr->ignore_certificate_errors = IgnoreCertificateErrors ? 1 : 0;
ptr->background_color = BackgroundColor.ToArgb();
cef_string_t.Copy(AcceptLanguageList, &ptr->accept_language_list);
return ptr;
}
private static void Clear(cef_settings_t* ptr)
{
libcef.string_clear(&ptr->browser_subprocess_path);
libcef.string_clear(&ptr->cache_path);
libcef.string_clear(&ptr->user_data_path);
libcef.string_clear(&ptr->user_agent);
libcef.string_clear(&ptr->product_version);
libcef.string_clear(&ptr->locale);
libcef.string_clear(&ptr->log_file);
libcef.string_clear(&ptr->javascript_flags);
libcef.string_clear(&ptr->resources_dir_path);
libcef.string_clear(&ptr->locales_dir_path);
libcef.string_clear(&ptr->accept_language_list);
}
internal static void Free(cef_settings_t* ptr)
{
Clear(ptr);
cef_settings_t.Free(ptr);
}
}
}
+31
View File
@@ -0,0 +1,31 @@
namespace Cef3
{
using System;
using System.Collections.Generic;
using System.Text;
using Cef3.Interop;
public struct CefSize
{
private int _width;
private int _height;
public CefSize(int width, int height)
{
_width = width;
_height = height;
}
public int Width
{
get { return _width; }
set { _width = value; }
}
public int Height
{
get { return _height; }
set { _height = value; }
}
}
}
+92
View File
@@ -0,0 +1,92 @@
namespace Cef3
{
using System;
using System.Collections.Generic;
using System.Text;
using Cef3.Interop;
/// <summary>
/// URL component parts.
/// </summary>
public sealed class CefUrlParts
{
/// <summary>
/// The complete URL specification.
/// </summary>
public string Spec { get; set; }
/// <summary>
/// Scheme component not including the colon (e.g., "http").
/// </summary>
public string Scheme { get; set; }
/// <summary>
/// User name component.
/// </summary>
public string UserName { get; set; }
/// <summary>
/// Password component.
/// </summary>
public string Password { get; set; }
/// <summary>
/// Host component. This may be a hostname, an IPv4 address or an IPv6 literal
/// surrounded by square brackets (e.g., "[2001:db8::1]").
/// </summary>
public string Host { get; set; }
/// <summary>
/// Port number component.
/// </summary>
public string Port { get; set; }
/// <summary>
/// Origin contains just the scheme, host, and port from a URL. Equivalent to
/// clearing any username and password, replacing the path with a slash, and
/// clearing everything after that. This value will be empty for non-standard
/// URLs.
/// </summary>
public string Origin { get; set; }
/// <summary>
/// Path component including the first slash following the host.
/// </summary>
public string Path { get; set; }
/// <summary>
/// Query string component (i.e., everything following the '?').
/// </summary>
public string Query { get; set; }
internal static unsafe CefUrlParts FromNative(cef_urlparts_t* n_parts)
{
var result = new CefUrlParts();
result.Spec = cef_string_t.ToString(&n_parts->spec);
result.Scheme = cef_string_t.ToString(&n_parts->scheme);
result.UserName = cef_string_t.ToString(&n_parts->username);
result.Password = cef_string_t.ToString(&n_parts->password);
result.Host = cef_string_t.ToString(&n_parts->host);
result.Port = cef_string_t.ToString(&n_parts->port);
result.Origin = cef_string_t.ToString(&n_parts->origin);
result.Path = cef_string_t.ToString(&n_parts->path);
result.Query = cef_string_t.ToString(&n_parts->query);
return result;
}
internal unsafe cef_urlparts_t ToNative()
{
var result = new cef_urlparts_t();
cef_string_t.Copy(Spec, &result.spec);
cef_string_t.Copy(Scheme, &result.scheme);
cef_string_t.Copy(UserName, &result.username);
cef_string_t.Copy(Password, &result.password);
cef_string_t.Copy(Host, &result.host);
cef_string_t.Copy(Port, &result.port);
cef_string_t.Copy(Origin, &result.origin);
cef_string_t.Copy(Path, &result.path);
cef_string_t.Copy(Query, &result.query);
return result;
}
}
}
+189
View File
@@ -0,0 +1,189 @@
namespace Cef3
{
using System;
using System.Collections.Generic;
using System.Text;
using Cef3.Interop;
using Cef3.Platform;
using Cef3.Platform.Windows;
/// <summary>
/// Class representing window information.
/// </summary>
/// <remarks>
/// Meanings for handles:
/// <list type="table">
/// <listheader>
/// <item>Platform</item>
/// <description>Description</description>
/// </listheader>
/// <item>
/// <item>Windows</item>
/// <description>Window handle (HWND)</description>
/// </item>
/// <item>
/// <item>Mac OS X</item>
/// <description>NSView pointer for the parent view (NSView*)</description>
/// </item>
/// <item>
/// <item>Linux</item>
/// <description>Pointer for the new browser widget (GtkWidget*)</description>
/// </item>
/// </list>
/// </remarks>
public unsafe abstract class CefWindowInfo
{
public static CefWindowInfo Create()
{
switch (CefRuntime.Platform)
{
case CefRuntimePlatform.Windows: return new CefWindowInfoWindowsImpl();
case CefRuntimePlatform.Linux: return new CefWindowInfoLinuxImpl();
case CefRuntimePlatform.MacOSX: return new CefWindowInfoMacImpl();
default: throw new NotSupportedException();
}
}
internal static CefWindowInfo FromNative(cef_window_info_t* ptr)
{
switch (CefRuntime.Platform)
{
case CefRuntimePlatform.Windows: return new CefWindowInfoWindowsImpl(ptr);
case CefRuntimePlatform.Linux: return new CefWindowInfoLinuxImpl(ptr);
case CefRuntimePlatform.MacOSX: return new CefWindowInfoMacImpl(ptr);
default: throw new NotSupportedException();
}
}
private bool _own;
private bool _disposed;
protected internal CefWindowInfo(bool own)
{
_own = own;
}
~CefWindowInfo()
{
Dispose();
}
internal void Dispose()
{
_disposed = true;
if (_own)
{
DisposeNativePointer();
}
GC.SuppressFinalize(this);
}
internal cef_window_info_t* ToNative()
{
var ptr = GetNativePointer();
_own = false;
return ptr;
}
protected internal void ThrowIfDisposed()
{
if (_disposed) throw ExceptionBuilder.ObjectDisposed();
}
public bool Disposed { get { return _disposed; } }
internal abstract cef_window_info_t* GetNativePointer();
protected internal abstract void DisposeNativePointer();
// Common properties for all platforms
/// <summary>
/// Handle for the parent window.
/// </summary>
public abstract IntPtr ParentHandle { get; set; }
/// <summary>
/// Handle for the new browser window.
/// </summary>
public abstract IntPtr Handle { get; set; }
// Common properties for windows & macosx
public abstract string Name { get; set; }
public abstract int X { get; set; }
public abstract int Y { get; set; }
public abstract int Width { get; set; }
public abstract int Height { get; set; }
// Windows-specific
public abstract WindowStyle Style { get; set; }
public abstract WindowStyleEx StyleEx { get; set; }
public abstract IntPtr MenuHandle { get; set; }
// Mac-specific
public abstract bool Hidden { get; set; }
/// <summary>
/// Set to true (1) to create the browser using windowless (off-screen)
/// rendering. No window will be created for the browser and all rendering will
/// occur via the CefRenderHandler interface. The |parent_window| value will be
/// used to identify monitor info and to act as the parent window for dialogs,
/// context menus, etc. If |parent_window| is not provided then the main screen
/// monitor will be used and some functionality that requires a parent window
/// may not function correctly. In order to create windowless browsers the
/// CefSettings.windowless_rendering_enabled value must be set to true.
/// </summary>
public abstract bool WindowlessRenderingEnabled { get; set; }
/// <summary>
/// Set to true (1) to enable transparent painting in combination with
/// windowless rendering. When this value is true a transparent background
/// color will be used (RGBA=0x00000000). When this value is false the
/// background will be white and opaque.
/// </summary>
public abstract bool TransparentPaintingEnabled { get; set; }
public void SetAsChild(IntPtr parentHandle, CefRectangle rect)
{
ThrowIfDisposed();
Style = WindowStyle.WS_CHILD
| WindowStyle.WS_CLIPCHILDREN
| WindowStyle.WS_CLIPSIBLINGS
| WindowStyle.WS_TABSTOP
| WindowStyle.WS_VISIBLE;
ParentHandle = parentHandle;
X = rect.X;
Y = rect.Y;
Width = rect.Width;
Height = rect.Height;
}
public void SetAsPopup(IntPtr parentHandle, string name)
{
ThrowIfDisposed();
Style = WindowStyle.WS_OVERLAPPEDWINDOW
| WindowStyle.WS_CLIPCHILDREN
| WindowStyle.WS_CLIPSIBLINGS
| WindowStyle.WS_VISIBLE;
ParentHandle = parentHandle;
// CW_USEDEFAULT
X = int.MinValue;
Y = int.MinValue;
Width = int.MinValue;
Height = int.MinValue;
Name = name;
}
public void SetAsWindowless(IntPtr parentHandle, bool transparent)
{
WindowlessRenderingEnabled = true;
ParentHandle = parentHandle;
TransparentPaintingEnabled = transparent;
}
}
}