webkit

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package webkit provides a WebKit2GTK-backed browser view and window.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotImplemented = errors.New("webkit: not implemented")

ErrNotImplemented is returned by stub implementations pending WebKit2GTK migration.

Functions

func IsNativeAvailable

func IsNativeAvailable() bool

IsNativeAvailable reports whether the native WebKit2GTK backend is compiled in. In non-CGO builds, this returns false and WebView methods are logical no-ops.

func QuitMainLoop

func QuitMainLoop()

QuitMainLoop is a no-op in non-CGO builds.

func RunMainLoop

func RunMainLoop()

RunMainLoop is a no-op in non-CGO builds.

func SetURISchemeResolver

func SetURISchemeResolver(r SchemeResolver)

SetURISchemeResolver is a no-op in non-CGO builds.

Types

type Config

type Config struct {
	// InitialURL is the first URL to load when creating a WebView.
	InitialURL string

	// UserAgent allows overriding the default user agent string.
	UserAgent string

	// EnableDeveloperExtras enables devtools/inspector.
	EnableDeveloperExtras bool

	// ZoomDefault sets an initial zoom factor (1.0 = 100%).
	ZoomDefault float64

	// DataDir is the base directory for persistent website data (cookies, localStorage, etc.).
	DataDir string
	// CacheDir is the base directory for cache data.
	CacheDir string

	// Fonts apply to pages that don't specify fonts (browser defaults).
	DefaultSansFont      string
	DefaultSerifFont     string
	DefaultMonospaceFont string
	DefaultFontSize      int // CSS px (~points)

	// Rendering controls GPU/CPU selection and debug options
	Rendering RenderingConfig
}

Config holds initialization settings for the WebKit-based browser components. This will map to WebKit2GTK and GTK settings in the real implementation.

type RenderingConfig

type RenderingConfig struct {
	Mode     string
	DebugGPU bool
}

RenderingConfig controls hardware acceleration preferences. Mode accepts: "auto" (default), "gpu", or "cpu". DebugGPU enables compositing indicators if supported.

type SchemeResolver

type SchemeResolver func(uri string) (mime string, data []byte, ok bool)

SchemeResolver provides bytes and mime for a given custom URI.

type WebView

type WebView struct {
	// contains filtered or unexported fields
}

WebView represents a browser view powered by WebKit2GTK. Methods are currently stubs returning ErrNotImplemented to satisfy TDD ordering.

func NewWebView

func NewWebView(cfg *Config) (*WebView, error)

NewWebView constructs a new WebView instance.

func (*WebView) CloseDevTools

func (w *WebView) CloseDevTools() error

CloseDevTools is a no-op in the non-CGO build.

func (*WebView) Destroy

func (w *WebView) Destroy() error

Destroy releases native resources.

func (*WebView) GetCurrentURL

func (w *WebView) GetCurrentURL() string

GetCurrentURL returns the last requested URL (non-CGO build approximation).

func (*WebView) GetZoom

func (w *WebView) GetZoom() (float64, error)

GetZoom returns the current zoom factor.

func (*WebView) GoBack

func (w *WebView) GoBack() error

GoBack is not supported in the non-CGO stub.

func (*WebView) GoForward

func (w *WebView) GoForward() error

GoForward is not supported in the non-CGO stub.

func (*WebView) Hide

func (w *WebView) Hide() error

Hide hides the WebView window.

func (*WebView) InjectScript

func (w *WebView) InjectScript(js string) error

InjectScript evaluates JavaScript in the active WebView context.

func (*WebView) LoadURL

func (w *WebView) LoadURL(rawURL string) error

LoadURL navigates the webview to the specified URL.

func (*WebView) RegisterKeyboardShortcut

func (w *WebView) RegisterKeyboardShortcut(accel string, callback func()) error

RegisterKeyboardShortcut binds a global or window-scoped accelerator to a callback.

func (*WebView) RegisterScriptMessageHandler

func (w *WebView) RegisterScriptMessageHandler(cb func(payload string))

RegisterScriptMessageHandler registers a callback invoked when the content script posts a message.

func (*WebView) RegisterTitleChangedHandler

func (w *WebView) RegisterTitleChangedHandler(cb func(title string))

RegisterTitleChangedHandler registers a callback invoked when the page title changes.

func (*WebView) RegisterURIChangedHandler

func (w *WebView) RegisterURIChangedHandler(cb func(uri string))

RegisterURIChangedHandler registers a callback invoked when the current page URI changes.

func (*WebView) SetZoom

func (w *WebView) SetZoom(level float64) error

SetZoom sets the current zoom factor for the WebView.

func (*WebView) Show

func (w *WebView) Show() error

Show makes the WebView visible.

func (*WebView) ShowDevTools

func (w *WebView) ShowDevTools() error

ShowDevTools is a no-op in the non-CGO build.

func (*WebView) Window

func (w *WebView) Window() *Window

Window returns the associated native window wrapper (non-nil).

type Window

type Window struct {
	Title string
}

Window represents a top-level application window hosting a WebView. Stub for future GTK application window management.

func NewWindow

func NewWindow(title string) (*Window, error)

NewWindow constructs a Window. In real implementation, this would create a GTK window.

func (*Window) SetTitle

func (w *Window) SetTitle(title string)

SetTitle updates the window title (no-op in non-CGO build).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL