namespace XFESystem.Desktop; /// Each browser window owns a page runtime; no DOM or globals are shared across windows. public interface IInteractiveBrowserFactory { IInteractiveBrowserSession CreatePageSession(); } public interface IInteractiveBrowserSession { BrowserPage CurrentPage { get; } long Revision { get; } BrowserPage Navigate(string address); BrowserPage NavigateDocument(string source, string path, bool dark = true) => throw new NotSupportedException("Document web previews are unavailable."); /// Show the real sanitized document before running its packaged enhancement scripts. BrowserPage BeginDocumentPreview(string source, string path, bool dark = true) => NavigateDocument(source, path, dark); BrowserPage NavigateEditor(string source, string path) => throw new NotSupportedException("The web editor is unavailable."); string? ReadEditorText() => null; void SetCanvas(IDesktopCanvas canvas) { } /// The platform has exclusively transferred and verified the prepared font caches. void CompleteEditorPreparationHandoff(IDesktopCanvas canvas, bool equivalentTextMetrics) => SetCanvas(canvas); void ResizeViewport(int width, int height) { } void Paint(IDesktopCanvas canvas, DesktopBounds viewport, double scrollY); bool Pointer(BrowserPointerInput input); bool Key(BrowserKeyboardInput input); bool AdvanceTime(long monotonicMilliseconds); /// Called only after the desktop successfully presents a complete frame. void FramePresented() { } double DocumentHeight { get; } bool TextCursor => false; } public readonly record struct BrowserPointerInput(string Type, double X, double Y, int Button = 0, int Buttons = 0, double DeltaY = 0, bool Shift = false, bool Control = false, bool Alt = false); public readonly record struct BrowserKeyboardInput(string Type, string Key, string Code = "", string Text = "", bool Shift = false, bool Control = false, bool Alt = false, bool Repeat = false); /// Native raster/font operations required by laid-out web content. Clipping nests inside scene damage. public interface IDesktopWebCanvas : IDesktopCanvas { void PushClip(DesktopBounds bounds); void PopClip(); double MeasureWebText(string text, double fontSize, string fontFamily, int fontWeight); double MeasureWebLineHeight(double fontSize,string fontFamily,int fontWeight)=>fontSize*1.2; (int Width, int Height, byte[] Alpha) RasterizeWebText(string text, double fontSize, string fontFamily, int fontWeight); void WebText(string text, uint color, double x, double y, double fontSize, string fontFamily, int fontWeight, double opacity = 1); }