v0.27.1 c78ce83

webkit_context.go RawHistoryFolder

1// Package port defines interfaces for external dependencies.
2package port
3
4import "context"
5
6// WebKitCookiePolicy controls cookie acceptance behavior for NetworkSession.
7type WebKitCookiePolicy string
8
9const (
10	WebKitCookiePolicyAlways       WebKitCookiePolicy = "always"
11	WebKitCookiePolicyNoThirdParty WebKitCookiePolicy = "no_third_party"
12	WebKitCookiePolicyNever        WebKitCookiePolicy = "never"
13)
14
15// MemoryPressureConfig holds memory pressure settings for a WebKit process.
16// Zero values mean "use WebKit defaults".
17type MemoryPressureConfig struct {
18	// MemoryLimitMB sets the memory limit in megabytes.
19	// 0 means unset (uses WebKit default: system RAM capped at 3GB).
20	MemoryLimitMB int
21
22	// PollIntervalSec sets the interval for memory usage checks.
23	// 0 means unset (uses WebKit default: 30 seconds).
24	PollIntervalSec float64
25
26	// ConservativeThreshold sets threshold for conservative memory release.
27	// Must be in (0, 1). 0 means unset (uses WebKit default: 0.33).
28	ConservativeThreshold float64
29
30	// StrictThreshold sets threshold for strict memory release.
31	// Must be in (0, 1). 0 means unset (uses WebKit default: 0.5).
32	StrictThreshold float64
33}
34
35// IsConfigured returns true if any memory pressure setting is configured.
36func (c *MemoryPressureConfig) IsConfigured() bool {
37	if c == nil {
38		return false
39	}
40	return c.MemoryLimitMB > 0 ||
41		c.PollIntervalSec > 0 ||
42		c.ConservativeThreshold > 0 ||
43		c.StrictThreshold > 0
44}
45
46// WebKitContextOptions configures WebKitContext creation.
47type WebKitContextOptions struct {
48	// DataDir is the directory for persistent data (cookies, storage, etc.).
49	DataDir string
50
51	// CacheDir is the directory for cache data.
52	CacheDir string
53
54	// CookiePolicy controls cookie acceptance behavior.
55	// Empty value means runtime defaults are used.
56	CookiePolicy WebKitCookiePolicy
57
58	// ITPEnabled controls Intelligent Tracking Prevention for NetworkSession.
59	// False means ITP remains disabled unless enabled explicitly.
60	ITPEnabled bool
61
62	// WebProcessMemory configures memory pressure for web processes.
63	// nil means use WebKit defaults.
64	WebProcessMemory *MemoryPressureConfig
65
66	// NetworkProcessMemory configures memory pressure for the network process.
67	// nil means use WebKit defaults.
68	NetworkProcessMemory *MemoryPressureConfig
69}
70
71// IsWebProcessMemoryConfigured returns true if web process memory settings are configured.
72func (o *WebKitContextOptions) IsWebProcessMemoryConfigured() bool {
73	if o == nil {
74		return false
75	}
76	return o.WebProcessMemory.IsConfigured()
77}
78
79// IsNetworkProcessMemoryConfigured returns true if network process memory settings are configured.
80func (o *WebKitContextOptions) IsNetworkProcessMemoryConfigured() bool {
81	if o == nil {
82		return false
83	}
84	return o.NetworkProcessMemory.IsConfigured()
85}
86
87// MemoryPressureApplier applies memory pressure settings to WebKit processes.
88// This interface abstracts the WebKit-specific memory pressure configuration
89// to allow testing without WebKit dependencies.
90type MemoryPressureApplier interface {
91	// ApplyNetworkProcessSettings applies memory pressure settings to the network process.
92	// Must be called BEFORE creating any NetworkSession.
93	ApplyNetworkProcessSettings(ctx context.Context, cfg *MemoryPressureConfig) error
94
95	// ApplyWebProcessSettings applies memory pressure settings to web processes.
96	// Returns an opaque settings object that should be passed to WebContext creation.
97	// Returns nil if no settings are configured.
98	ApplyWebProcessSettings(ctx context.Context, cfg *MemoryPressureConfig) (any, error)
99}
100
101// WebKitContextProvider creates and manages WebKit contexts.
102// This interface abstracts WebKit context creation for testability.
103type WebKitContextProvider interface {
104	// Initialize sets up the WebKit context with the given options.
105	// Must be called before any other methods.
106	Initialize(ctx context.Context, opts WebKitContextOptions) error
107
108	// DataDir returns the data directory path.
109	DataDir() string
110
111	// CacheDir returns the cache directory path.
112	CacheDir() string
113
114	// PrefetchDNS prefetches DNS for the given hostname.
115	PrefetchDNS(hostname string)
116
117	// Close releases resources held by the context.
118	Close() error
119}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close