detached 2d5276a

feat(cef): add CEF handler implementations wiring to port callbacks

Single handlerSet struct implements Client, RenderHandler,
DisplayHandler, LoadHandler, LifeSpanHandler, and RequestHandler.
Active handlers wire CEF events to WebView state cache updates and
port.WebViewCallbacks dispatch. Phase 1: popups blocked, accelerated
paint unused.
commit
2d5276abbe373ecad6693752b4352ad9454c0f78
author
brice · · 2026-03-19 15:36 UTC
committer
brice · · 2026-03-28 04:35 UTC
parent
96ceffb
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +355 -0
A internal/infrastructure/cef/webview_handlers.go +355 -0
@@ -0,0 +1,355 @@
1+package cef
2+
3+import (
4+ "unsafe"
5+
6+ purecef "github.com/bnema/purego-cef/cef"
7+
8+ "github.com/bnema/dumber/internal/application/port"
9+)
10+
11+// handlerSet implements all CEF handler interfaces and dispatches events to the
12+// owning WebView. A single struct is used so that the Client's Get*Handler
13+// methods can return the same receiver, avoiding extra allocations.
14+type handlerSet struct {
15+ wv *WebView
16+}
17+
18+// Compile-time interface checks.
19+var (
20+ _ purecef.Client = (*handlerSet)(nil)
21+ _ purecef.RenderHandler = (*handlerSet)(nil)
22+ _ purecef.DisplayHandler = (*handlerSet)(nil)
23+ _ purecef.LoadHandler = (*handlerSet)(nil)
24+ _ purecef.LifeSpanHandler = (*handlerSet)(nil)
25+ _ purecef.RequestHandler = (*handlerSet)(nil)
26+)
27+
28+// ===========================================================================
29+// Client
30+// ===========================================================================
31+
32+func (h *handlerSet) GetAudioHandler() purecef.AudioHandler { return nil }
33+func (h *handlerSet) GetCommandHandler() purecef.CommandHandler { return nil }
34+func (h *handlerSet) GetContextMenuHandler() purecef.ContextMenuHandler { return nil }
35+func (h *handlerSet) GetDialogHandler() purecef.DialogHandler { return nil }
36+func (h *handlerSet) GetDisplayHandler() purecef.DisplayHandler { return h }
37+func (h *handlerSet) GetDownloadHandler() purecef.DownloadHandler { return nil }
38+func (h *handlerSet) GetDragHandler() purecef.DragHandler { return nil }
39+func (h *handlerSet) GetFindHandler() purecef.FindHandler { return nil }
40+func (h *handlerSet) GetFocusHandler() purecef.FocusHandler { return nil }
41+func (h *handlerSet) GetFrameHandler() purecef.FrameHandler { return nil }
42+func (h *handlerSet) GetPermissionHandler() purecef.PermissionHandler { return nil }
43+func (h *handlerSet) GetJsdialogHandler() purecef.JsdialogHandler { return nil }
44+func (h *handlerSet) GetKeyboardHandler() purecef.KeyboardHandler { return nil }
45+func (h *handlerSet) GetLifeSpanHandler() purecef.LifeSpanHandler { return h }
46+func (h *handlerSet) GetLoadHandler() purecef.LoadHandler { return h }
47+func (h *handlerSet) GetPrintHandler() purecef.PrintHandler { return nil }
48+func (h *handlerSet) GetRenderHandler() purecef.RenderHandler { return h }
49+func (h *handlerSet) GetRequestHandler() purecef.RequestHandler { return h }
50+
51+func (h *handlerSet) OnProcessMessageReceived(_ purecef.Browser, _ purecef.Frame, _ purecef.ProcessID, _ purecef.ProcessMessage) int32 {
52+ return 0
53+}
54+
55+// ===========================================================================
56+// RenderHandler (17 methods)
57+// ===========================================================================
58+
59+func (h *handlerSet) GetAccessibilityHandler() purecef.AccessibilityHandler { return nil }
60+
61+func (h *handlerSet) GetRootScreenRect(_ purecef.Browser, _ uintptr) int32 { return 0 }
62+
63+// GetViewRect fills the rect struct with the pipeline dimensions.
64+// The rect pointer points to a cef_rect_t: {HostLayout padding, X, Y, Width, Height} all int32.
65+// The HostLayout field occupies 0 bytes on most platforms but we use the Rect type alias to be safe.
66+func (h *handlerSet) GetViewRect(_ purecef.Browser, rect uintptr) {
67+ if rect == 0 {
68+ return
69+ }
70+ h.wv.pipeline.mu.Lock()
71+ w := h.wv.pipeline.width
72+ ht := h.wv.pipeline.height
73+ h.wv.pipeline.mu.Unlock()
74+
75+ r := (*purecef.Rect)(unsafe.Pointer(rect))
76+ r.X = 0
77+ r.Y = 0
78+ r.Width = w
79+ r.Height = ht
80+}
81+
82+func (h *handlerSet) GetScreenPoint(_ purecef.Browser, _ int32, _ int32, _ unsafe.Pointer, _ unsafe.Pointer) int32 {
83+ return 0
84+}
85+
86+func (h *handlerSet) GetScreenInfo(_ purecef.Browser, _ uintptr) int32 { return 0 }
87+
88+func (h *handlerSet) OnPopupShow(_ purecef.Browser, _ int32) {}
89+
90+func (h *handlerSet) OnPopupSize(_ purecef.Browser, _ uintptr) {}
91+
92+// OnPaint receives the BGRA pixel buffer from CEF and forwards dirty rects
93+// to the render pipeline for GPU upload.
94+func (h *handlerSet) OnPaint(_ purecef.Browser, _ purecef.PaintElementType, dirtyRects []purecef.Rect, buffer unsafe.Pointer, width int32, height int32) {
95+ // Convert purecef.Rect (which has HostLayout padding) to our local rect type.
96+ rects := make([]rect, len(dirtyRects))
97+ for i, dr := range dirtyRects {
98+ rects[i] = rect{X: dr.X, Y: dr.Y, Width: dr.Width, Height: dr.Height}
99+ }
100+ h.wv.pipeline.handlePaint(buffer, width, height, rects)
101+}
102+
103+func (h *handlerSet) OnAcceleratedPaint(_ purecef.Browser, _ purecef.PaintElementType, _ int, _ uintptr, _ uintptr) {
104+}
105+
106+func (h *handlerSet) GetTouchHandleSize(_ purecef.Browser, _ purecef.HorizontalAlignment, _ uintptr) {
107+}
108+
109+func (h *handlerSet) OnTouchHandleStateChanged(_ purecef.Browser, _ uintptr) {}
110+
111+func (h *handlerSet) StartDragging(_ purecef.Browser, _ purecef.DragData, _ purecef.DragOperationsMask, _ int32, _ int32) int32 {
112+ return 0
113+}
114+
115+func (h *handlerSet) UpdateDragCursor(_ purecef.Browser, _ purecef.DragOperationsMask) {}
116+
117+func (h *handlerSet) OnScrollOffsetChanged(_ purecef.Browser, _ float64, _ float64) {}
118+
119+func (h *handlerSet) OnImeCompositionRangeChanged(_ purecef.Browser, _ uintptr, _ int, _ uintptr) {
120+}
121+
122+func (h *handlerSet) OnTextSelectionChanged(_ purecef.Browser, _ string, _ uintptr) {}
123+
124+func (h *handlerSet) OnVirtualKeyboardRequested(_ purecef.Browser, _ purecef.TextInputMode) {}
125+
126+// ===========================================================================
127+// DisplayHandler (13 methods)
128+// ===========================================================================
129+
130+// OnAddressChange updates the cached URI when the main frame navigates.
131+func (h *handlerSet) OnAddressChange(_ purecef.Browser, frame purecef.Frame, url string) {
132+ if frame != nil && frame.IsMain() {
133+ h.wv.updateURI(url)
134+ }
135+}
136+
137+// OnTitleChange updates the cached title.
138+func (h *handlerSet) OnTitleChange(_ purecef.Browser, title string) {
139+ h.wv.updateTitle(title)
140+}
141+
142+func (h *handlerSet) OnFaviconUrlchange(_ purecef.Browser, _ uintptr) {}
143+
144+// OnFullscreenModeChange toggles the fullscreen atomic and fires callbacks.
145+func (h *handlerSet) OnFullscreenModeChange(_ purecef.Browser, fullscreen int32) {
146+ entering := fullscreen != 0
147+ h.wv.fullscreen.Store(entering)
148+
149+ h.wv.mu.RLock()
150+ cb := h.wv.callbacks
151+ h.wv.mu.RUnlock()
152+ if cb == nil {
153+ return
154+ }
155+ if entering && cb.OnEnterFullscreen != nil {
156+ cb.OnEnterFullscreen()
157+ }
158+ if !entering && cb.OnLeaveFullscreen != nil {
159+ cb.OnLeaveFullscreen()
160+ }
161+}
162+
163+func (h *handlerSet) OnTooltip(_ purecef.Browser, _ uintptr) int32 { return 0 }
164+
165+// OnStatusMessage fires the OnLinkHover callback with the status text.
166+func (h *handlerSet) OnStatusMessage(_ purecef.Browser, value string) {
167+ h.wv.mu.RLock()
168+ cb := h.wv.callbacks
169+ h.wv.mu.RUnlock()
170+ if cb != nil && cb.OnLinkHover != nil {
171+ cb.OnLinkHover(value)
172+ }
173+}
174+
175+func (h *handlerSet) OnConsoleMessage(_ purecef.Browser, _ purecef.LogSeverity, _ string, _ string, _ int32) int32 {
176+ return 0
177+}
178+
179+func (h *handlerSet) OnAutoResize(_ purecef.Browser, _ uintptr) int32 { return 0 }
180+
181+// OnLoadingProgressChange updates the cached progress value.
182+func (h *handlerSet) OnLoadingProgressChange(_ purecef.Browser, progress float64) {
183+ h.wv.updateProgress(progress)
184+}
185+
186+func (h *handlerSet) OnCursorChange(_ purecef.Browser, _ uintptr, _ purecef.CursorType, _ uintptr) int32 {
187+ return 0
188+}
189+
190+func (h *handlerSet) OnMediaAccessChange(_ purecef.Browser, _ int32, _ int32) {}
191+
192+func (h *handlerSet) OnContentsBoundsChange(_ purecef.Browser, _ uintptr) int32 { return 0 }
193+
194+func (h *handlerSet) GetRootWindowScreenRect(_ purecef.Browser, _ uintptr) int32 { return 0 }
195+
196+// ===========================================================================
197+// LoadHandler (4 methods)
198+// ===========================================================================
199+
200+// OnLoadingStateChange updates the loading/navigation state cache and fires callbacks.
201+func (h *handlerSet) OnLoadingStateChange(_ purecef.Browser, isloading int32, cangoback int32, cangoforward int32) {
202+ loading := isloading != 0
203+ h.wv.updateLoadState(loading, cangoback != 0, cangoforward != 0)
204+
205+ h.wv.mu.RLock()
206+ cb := h.wv.callbacks
207+ h.wv.mu.RUnlock()
208+ if cb != nil && cb.OnLoadChanged != nil {
209+ if loading {
210+ cb.OnLoadChanged(port.LoadStarted)
211+ } else {
212+ cb.OnLoadChanged(port.LoadFinished)
213+ }
214+ }
215+}
216+
217+// OnLoadStart fires LoadStarted for main frame navigations.
218+func (h *handlerSet) OnLoadStart(_ purecef.Browser, frame purecef.Frame, _ purecef.TransitionType) {
219+ if frame == nil || !frame.IsMain() {
220+ return
221+ }
222+ h.wv.mu.RLock()
223+ cb := h.wv.callbacks
224+ h.wv.mu.RUnlock()
225+ if cb != nil && cb.OnLoadChanged != nil {
226+ cb.OnLoadChanged(port.LoadStarted)
227+ }
228+}
229+
230+// OnLoadEnd fires LoadFinished and sets progress to 1.0 for the main frame.
231+func (h *handlerSet) OnLoadEnd(_ purecef.Browser, frame purecef.Frame, _ int32) {
232+ if frame == nil || !frame.IsMain() {
233+ return
234+ }
235+ h.wv.mu.RLock()
236+ cb := h.wv.callbacks
237+ h.wv.mu.RUnlock()
238+ if cb != nil {
239+ if cb.OnLoadChanged != nil {
240+ cb.OnLoadChanged(port.LoadFinished)
241+ }
242+ if cb.OnProgressChanged != nil {
243+ cb.OnProgressChanged(1.0)
244+ }
245+ }
246+}
247+
248+// OnLoadError is a no-op in Phase 1.
249+func (h *handlerSet) OnLoadError(_ purecef.Browser, _ purecef.Frame, _ purecef.Errorcode, _ string, _ string) {
250+}
251+
252+// ===========================================================================
253+// LifeSpanHandler (6 methods)
254+// ===========================================================================
255+
256+// OnBeforePopup blocks all popups in Phase 1.
257+func (h *handlerSet) OnBeforePopup(_ purecef.Browser, _ purecef.Frame, _ int32, _ string, _ string, _ purecef.WindowOpenDisposition, _ int32, _ uintptr, _ *purecef.WindowInfo, _ unsafe.Pointer, _ *purecef.BrowserSettings, _ unsafe.Pointer, _ unsafe.Pointer) bool {
258+ return true // block
259+}
260+
261+func (h *handlerSet) OnBeforePopupAborted(_ purecef.Browser, _ int32) {}
262+
263+func (h *handlerSet) OnBeforeDevToolsPopup(_ purecef.Browser, _ *purecef.WindowInfo, _ unsafe.Pointer, _ *purecef.BrowserSettings, _ unsafe.Pointer, _ unsafe.Pointer) {
264+}
265+
266+// OnAfterCreated stores the browser and host references and enables input.
267+func (h *handlerSet) OnAfterCreated(browser purecef.Browser) {
268+ h.wv.browser = browser
269+ h.wv.host = browser.GetHost()
270+ h.wv.input.setHost(h.wv.host)
271+}
272+
273+// DoClose returns false to allow the default close behavior.
274+func (h *handlerSet) DoClose(_ purecef.Browser) bool {
275+ return false
276+}
277+
278+// OnBeforeClose fires the OnClose callback.
279+func (h *handlerSet) OnBeforeClose(_ purecef.Browser) {
280+ h.wv.mu.RLock()
281+ cb := h.wv.callbacks
282+ h.wv.mu.RUnlock()
283+ if cb != nil && cb.OnClose != nil {
284+ cb.OnClose()
285+ }
286+}
287+
288+// ===========================================================================
289+// RequestHandler (11 methods)
290+// ===========================================================================
291+
292+func (h *handlerSet) OnBeforeBrowse(_ purecef.Browser, _ purecef.Frame, _ purecef.Request, _ int32, _ int32) bool {
293+ return false
294+}
295+
296+func (h *handlerSet) OnOpenUrlfromTab(_ purecef.Browser, _ purecef.Frame, _ string, _ purecef.WindowOpenDisposition, _ int32) int32 {
297+ return 0
298+}
299+
300+func (h *handlerSet) GetResourceRequestHandler(_ purecef.Browser, _ purecef.Frame, _ purecef.Request, _ int32, _ int32, _ string, _ unsafe.Pointer) purecef.ResourceRequestHandler {
301+ return nil
302+}
303+
304+func (h *handlerSet) GetAuthCredentials(_ purecef.Browser, _ string, _ int32, _ string, _ int32, _ string, _ string, _ purecef.AuthCallback) int32 {
305+ return 0
306+}
307+
308+func (h *handlerSet) OnCertificateError(_ purecef.Browser, _ purecef.Errorcode, _ string, _ purecef.Sslinfo, _ purecef.Callback) int32 {
309+ return 0
310+}
311+
312+func (h *handlerSet) OnSelectClientCertificate(_ purecef.Browser, _ int32, _ string, _ int32, _ int, _ unsafe.Pointer, _ purecef.SelectClientCertificateCallback) int32 {
313+ return 0
314+}
315+
316+func (h *handlerSet) OnRenderViewReady(_ purecef.Browser) {}
317+
318+func (h *handlerSet) OnRenderProcessUnresponsive(_ purecef.Browser, _ purecef.UnresponsiveProcessCallback) int32 {
319+ return 0
320+}
321+
322+func (h *handlerSet) OnRenderProcessResponsive(_ purecef.Browser) {}
323+
324+// OnRenderProcessTerminated fires the OnWebProcessTerminated callback with a mapped reason.
325+func (h *handlerSet) OnRenderProcessTerminated(_ purecef.Browser, status purecef.TerminationStatus, _ int32, _ string) {
326+ var reason port.WebProcessTerminationReason
327+ var label string
328+ switch status {
329+ case purecef.TerminationStatusTsAbnormalTermination:
330+ reason = port.WebProcessTerminationCrashed
331+ label = "abnormal termination"
332+ case purecef.TerminationStatusTsProcessWasKilled:
333+ reason = port.WebProcessTerminationByAPI
334+ label = "killed"
335+ case purecef.TerminationStatusTsProcessCrashed:
336+ reason = port.WebProcessTerminationCrashed
337+ label = "crashed"
338+ case purecef.TerminationStatusTsProcessOom:
339+ reason = port.WebProcessTerminationExceededMemory
340+ label = "out of memory"
341+ default:
342+ reason = port.WebProcessTerminationUnknown
343+ label = "unknown"
344+ }
345+
346+ h.wv.mu.RLock()
347+ cb := h.wv.callbacks
348+ uri := h.wv.uri
349+ h.wv.mu.RUnlock()
350+ if cb != nil && cb.OnWebProcessTerminated != nil {
351+ cb.OnWebProcessTerminated(reason, label, uri)
352+ }
353+}
354+
355+func (h *handlerSet) OnDocumentAvailableInMainFrame(_ purecef.Browser) {}
@@ -0,0 +1,355 @@
1+package cef
2+
3+import (
4+ "unsafe"
5+
6+ purecef "github.com/bnema/purego-cef/cef"
7+
8+ "github.com/bnema/dumber/internal/application/port"
9+)
10+
11+// handlerSet implements all CEF handler interfaces and dispatches events to the
12+// owning WebView. A single struct is used so that the Client's Get*Handler
13+// methods can return the same receiver, avoiding extra allocations.
14+type handlerSet struct {
15+ wv *WebView
16+}
17+
18+// Compile-time interface checks.
19+var (
20+ _ purecef.Client = (*handlerSet)(nil)
21+ _ purecef.RenderHandler = (*handlerSet)(nil)
22+ _ purecef.DisplayHandler = (*handlerSet)(nil)
23+ _ purecef.LoadHandler = (*handlerSet)(nil)
24+ _ purecef.LifeSpanHandler = (*handlerSet)(nil)
25+ _ purecef.RequestHandler = (*handlerSet)(nil)
26+)
27+
28+// ===========================================================================
29+// Client
30+// ===========================================================================
31+
32+func (h *handlerSet) GetAudioHandler() purecef.AudioHandler { return nil }
33+func (h *handlerSet) GetCommandHandler() purecef.CommandHandler { return nil }
34+func (h *handlerSet) GetContextMenuHandler() purecef.ContextMenuHandler { return nil }
35+func (h *handlerSet) GetDialogHandler() purecef.DialogHandler { return nil }
36+func (h *handlerSet) GetDisplayHandler() purecef.DisplayHandler { return h }
37+func (h *handlerSet) GetDownloadHandler() purecef.DownloadHandler { return nil }
38+func (h *handlerSet) GetDragHandler() purecef.DragHandler { return nil }
39+func (h *handlerSet) GetFindHandler() purecef.FindHandler { return nil }
40+func (h *handlerSet) GetFocusHandler() purecef.FocusHandler { return nil }
41+func (h *handlerSet) GetFrameHandler() purecef.FrameHandler { return nil }
42+func (h *handlerSet) GetPermissionHandler() purecef.PermissionHandler { return nil }
43+func (h *handlerSet) GetJsdialogHandler() purecef.JsdialogHandler { return nil }
44+func (h *handlerSet) GetKeyboardHandler() purecef.KeyboardHandler { return nil }
45+func (h *handlerSet) GetLifeSpanHandler() purecef.LifeSpanHandler { return h }
46+func (h *handlerSet) GetLoadHandler() purecef.LoadHandler { return h }
47+func (h *handlerSet) GetPrintHandler() purecef.PrintHandler { return nil }
48+func (h *handlerSet) GetRenderHandler() purecef.RenderHandler { return h }
49+func (h *handlerSet) GetRequestHandler() purecef.RequestHandler { return h }
50+
51+func (h *handlerSet) OnProcessMessageReceived(_ purecef.Browser, _ purecef.Frame, _ purecef.ProcessID, _ purecef.ProcessMessage) int32 {
52+ return 0
53+}
54+
55+// ===========================================================================
56+// RenderHandler (17 methods)
57+// ===========================================================================
58+
59+func (h *handlerSet) GetAccessibilityHandler() purecef.AccessibilityHandler { return nil }
60+
61+func (h *handlerSet) GetRootScreenRect(_ purecef.Browser, _ uintptr) int32 { return 0 }
62+
63+// GetViewRect fills the rect struct with the pipeline dimensions.
64+// The rect pointer points to a cef_rect_t: {HostLayout padding, X, Y, Width, Height} all int32.
65+// The HostLayout field occupies 0 bytes on most platforms but we use the Rect type alias to be safe.
66+func (h *handlerSet) GetViewRect(_ purecef.Browser, rect uintptr) {
67+ if rect == 0 {
68+ return
69+ }
70+ h.wv.pipeline.mu.Lock()
71+ w := h.wv.pipeline.width
72+ ht := h.wv.pipeline.height
73+ h.wv.pipeline.mu.Unlock()
74+
75+ r := (*purecef.Rect)(unsafe.Pointer(rect))
76+ r.X = 0
77+ r.Y = 0
78+ r.Width = w
79+ r.Height = ht
80+}
81+
82+func (h *handlerSet) GetScreenPoint(_ purecef.Browser, _ int32, _ int32, _ unsafe.Pointer, _ unsafe.Pointer) int32 {
83+ return 0
84+}
85+
86+func (h *handlerSet) GetScreenInfo(_ purecef.Browser, _ uintptr) int32 { return 0 }
87+
88+func (h *handlerSet) OnPopupShow(_ purecef.Browser, _ int32) {}
89+
90+func (h *handlerSet) OnPopupSize(_ purecef.Browser, _ uintptr) {}
91+
92+// OnPaint receives the BGRA pixel buffer from CEF and forwards dirty rects
93+// to the render pipeline for GPU upload.
94+func (h *handlerSet) OnPaint(_ purecef.Browser, _ purecef.PaintElementType, dirtyRects []purecef.Rect, buffer unsafe.Pointer, width int32, height int32) {
95+ // Convert purecef.Rect (which has HostLayout padding) to our local rect type.
96+ rects := make([]rect, len(dirtyRects))
97+ for i, dr := range dirtyRects {
98+ rects[i] = rect{X: dr.X, Y: dr.Y, Width: dr.Width, Height: dr.Height}
99+ }
100+ h.wv.pipeline.handlePaint(buffer, width, height, rects)
101+}
102+
103+func (h *handlerSet) OnAcceleratedPaint(_ purecef.Browser, _ purecef.PaintElementType, _ int, _ uintptr, _ uintptr) {
104+}
105+
106+func (h *handlerSet) GetTouchHandleSize(_ purecef.Browser, _ purecef.HorizontalAlignment, _ uintptr) {
107+}
108+
109+func (h *handlerSet) OnTouchHandleStateChanged(_ purecef.Browser, _ uintptr) {}
110+
111+func (h *handlerSet) StartDragging(_ purecef.Browser, _ purecef.DragData, _ purecef.DragOperationsMask, _ int32, _ int32) int32 {
112+ return 0
113+}
114+
115+func (h *handlerSet) UpdateDragCursor(_ purecef.Browser, _ purecef.DragOperationsMask) {}
116+
117+func (h *handlerSet) OnScrollOffsetChanged(_ purecef.Browser, _ float64, _ float64) {}
118+
119+func (h *handlerSet) OnImeCompositionRangeChanged(_ purecef.Browser, _ uintptr, _ int, _ uintptr) {
120+}
121+
122+func (h *handlerSet) OnTextSelectionChanged(_ purecef.Browser, _ string, _ uintptr) {}
123+
124+func (h *handlerSet) OnVirtualKeyboardRequested(_ purecef.Browser, _ purecef.TextInputMode) {}
125+
126+// ===========================================================================
127+// DisplayHandler (13 methods)
128+// ===========================================================================
129+
130+// OnAddressChange updates the cached URI when the main frame navigates.
131+func (h *handlerSet) OnAddressChange(_ purecef.Browser, frame purecef.Frame, url string) {
132+ if frame != nil && frame.IsMain() {
133+ h.wv.updateURI(url)
134+ }
135+}
136+
137+// OnTitleChange updates the cached title.
138+func (h *handlerSet) OnTitleChange(_ purecef.Browser, title string) {
139+ h.wv.updateTitle(title)
140+}
141+
142+func (h *handlerSet) OnFaviconUrlchange(_ purecef.Browser, _ uintptr) {}
143+
144+// OnFullscreenModeChange toggles the fullscreen atomic and fires callbacks.
145+func (h *handlerSet) OnFullscreenModeChange(_ purecef.Browser, fullscreen int32) {
146+ entering := fullscreen != 0
147+ h.wv.fullscreen.Store(entering)
148+
149+ h.wv.mu.RLock()
150+ cb := h.wv.callbacks
151+ h.wv.mu.RUnlock()
152+ if cb == nil {
153+ return
154+ }
155+ if entering && cb.OnEnterFullscreen != nil {
156+ cb.OnEnterFullscreen()
157+ }
158+ if !entering && cb.OnLeaveFullscreen != nil {
159+ cb.OnLeaveFullscreen()
160+ }
161+}
162+
163+func (h *handlerSet) OnTooltip(_ purecef.Browser, _ uintptr) int32 { return 0 }
164+
165+// OnStatusMessage fires the OnLinkHover callback with the status text.
166+func (h *handlerSet) OnStatusMessage(_ purecef.Browser, value string) {
167+ h.wv.mu.RLock()
168+ cb := h.wv.callbacks
169+ h.wv.mu.RUnlock()
170+ if cb != nil && cb.OnLinkHover != nil {
171+ cb.OnLinkHover(value)
172+ }
173+}
174+
175+func (h *handlerSet) OnConsoleMessage(_ purecef.Browser, _ purecef.LogSeverity, _ string, _ string, _ int32) int32 {
176+ return 0
177+}
178+
179+func (h *handlerSet) OnAutoResize(_ purecef.Browser, _ uintptr) int32 { return 0 }
180+
181+// OnLoadingProgressChange updates the cached progress value.
182+func (h *handlerSet) OnLoadingProgressChange(_ purecef.Browser, progress float64) {
183+ h.wv.updateProgress(progress)
184+}
185+
186+func (h *handlerSet) OnCursorChange(_ purecef.Browser, _ uintptr, _ purecef.CursorType, _ uintptr) int32 {
187+ return 0
188+}
189+
190+func (h *handlerSet) OnMediaAccessChange(_ purecef.Browser, _ int32, _ int32) {}
191+
192+func (h *handlerSet) OnContentsBoundsChange(_ purecef.Browser, _ uintptr) int32 { return 0 }
193+
194+func (h *handlerSet) GetRootWindowScreenRect(_ purecef.Browser, _ uintptr) int32 { return 0 }
195+
196+// ===========================================================================
197+// LoadHandler (4 methods)
198+// ===========================================================================
199+
200+// OnLoadingStateChange updates the loading/navigation state cache and fires callbacks.
201+func (h *handlerSet) OnLoadingStateChange(_ purecef.Browser, isloading int32, cangoback int32, cangoforward int32) {
202+ loading := isloading != 0
203+ h.wv.updateLoadState(loading, cangoback != 0, cangoforward != 0)
204+
205+ h.wv.mu.RLock()
206+ cb := h.wv.callbacks
207+ h.wv.mu.RUnlock()
208+ if cb != nil && cb.OnLoadChanged != nil {
209+ if loading {
210+ cb.OnLoadChanged(port.LoadStarted)
211+ } else {
212+ cb.OnLoadChanged(port.LoadFinished)
213+ }
214+ }
215+}
216+
217+// OnLoadStart fires LoadStarted for main frame navigations.
218+func (h *handlerSet) OnLoadStart(_ purecef.Browser, frame purecef.Frame, _ purecef.TransitionType) {
219+ if frame == nil || !frame.IsMain() {
220+ return
221+ }
222+ h.wv.mu.RLock()
223+ cb := h.wv.callbacks
224+ h.wv.mu.RUnlock()
225+ if cb != nil && cb.OnLoadChanged != nil {
226+ cb.OnLoadChanged(port.LoadStarted)
227+ }
228+}
229+
230+// OnLoadEnd fires LoadFinished and sets progress to 1.0 for the main frame.
231+func (h *handlerSet) OnLoadEnd(_ purecef.Browser, frame purecef.Frame, _ int32) {
232+ if frame == nil || !frame.IsMain() {
233+ return
234+ }
235+ h.wv.mu.RLock()
236+ cb := h.wv.callbacks
237+ h.wv.mu.RUnlock()
238+ if cb != nil {
239+ if cb.OnLoadChanged != nil {
240+ cb.OnLoadChanged(port.LoadFinished)
241+ }
242+ if cb.OnProgressChanged != nil {
243+ cb.OnProgressChanged(1.0)
244+ }
245+ }
246+}
247+
248+// OnLoadError is a no-op in Phase 1.
249+func (h *handlerSet) OnLoadError(_ purecef.Browser, _ purecef.Frame, _ purecef.Errorcode, _ string, _ string) {
250+}
251+
252+// ===========================================================================
253+// LifeSpanHandler (6 methods)
254+// ===========================================================================
255+
256+// OnBeforePopup blocks all popups in Phase 1.
257+func (h *handlerSet) OnBeforePopup(_ purecef.Browser, _ purecef.Frame, _ int32, _ string, _ string, _ purecef.WindowOpenDisposition, _ int32, _ uintptr, _ *purecef.WindowInfo, _ unsafe.Pointer, _ *purecef.BrowserSettings, _ unsafe.Pointer, _ unsafe.Pointer) bool {
258+ return true // block
259+}
260+
261+func (h *handlerSet) OnBeforePopupAborted(_ purecef.Browser, _ int32) {}
262+
263+func (h *handlerSet) OnBeforeDevToolsPopup(_ purecef.Browser, _ *purecef.WindowInfo, _ unsafe.Pointer, _ *purecef.BrowserSettings, _ unsafe.Pointer, _ unsafe.Pointer) {
264+}
265+
266+// OnAfterCreated stores the browser and host references and enables input.
267+func (h *handlerSet) OnAfterCreated(browser purecef.Browser) {
268+ h.wv.browser = browser
269+ h.wv.host = browser.GetHost()
270+ h.wv.input.setHost(h.wv.host)
271+}
272+
273+// DoClose returns false to allow the default close behavior.
274+func (h *handlerSet) DoClose(_ purecef.Browser) bool {
275+ return false
276+}
277+
278+// OnBeforeClose fires the OnClose callback.
279+func (h *handlerSet) OnBeforeClose(_ purecef.Browser) {
280+ h.wv.mu.RLock()
281+ cb := h.wv.callbacks
282+ h.wv.mu.RUnlock()
283+ if cb != nil && cb.OnClose != nil {
284+ cb.OnClose()
285+ }
286+}
287+
288+// ===========================================================================
289+// RequestHandler (11 methods)
290+// ===========================================================================
291+
292+func (h *handlerSet) OnBeforeBrowse(_ purecef.Browser, _ purecef.Frame, _ purecef.Request, _ int32, _ int32) bool {
293+ return false
294+}
295+
296+func (h *handlerSet) OnOpenUrlfromTab(_ purecef.Browser, _ purecef.Frame, _ string, _ purecef.WindowOpenDisposition, _ int32) int32 {
297+ return 0
298+}
299+
300+func (h *handlerSet) GetResourceRequestHandler(_ purecef.Browser, _ purecef.Frame, _ purecef.Request, _ int32, _ int32, _ string, _ unsafe.Pointer) purecef.ResourceRequestHandler {
301+ return nil
302+}
303+
304+func (h *handlerSet) GetAuthCredentials(_ purecef.Browser, _ string, _ int32, _ string, _ int32, _ string, _ string, _ purecef.AuthCallback) int32 {
305+ return 0
306+}
307+
308+func (h *handlerSet) OnCertificateError(_ purecef.Browser, _ purecef.Errorcode, _ string, _ purecef.Sslinfo, _ purecef.Callback) int32 {
309+ return 0
310+}
311+
312+func (h *handlerSet) OnSelectClientCertificate(_ purecef.Browser, _ int32, _ string, _ int32, _ int, _ unsafe.Pointer, _ purecef.SelectClientCertificateCallback) int32 {
313+ return 0
314+}
315+
316+func (h *handlerSet) OnRenderViewReady(_ purecef.Browser) {}
317+
318+func (h *handlerSet) OnRenderProcessUnresponsive(_ purecef.Browser, _ purecef.UnresponsiveProcessCallback) int32 {
319+ return 0
320+}
321+
322+func (h *handlerSet) OnRenderProcessResponsive(_ purecef.Browser) {}
323+
324+// OnRenderProcessTerminated fires the OnWebProcessTerminated callback with a mapped reason.
325+func (h *handlerSet) OnRenderProcessTerminated(_ purecef.Browser, status purecef.TerminationStatus, _ int32, _ string) {
326+ var reason port.WebProcessTerminationReason
327+ var label string
328+ switch status {
329+ case purecef.TerminationStatusTsAbnormalTermination:
330+ reason = port.WebProcessTerminationCrashed
331+ label = "abnormal termination"
332+ case purecef.TerminationStatusTsProcessWasKilled:
333+ reason = port.WebProcessTerminationByAPI
334+ label = "killed"
335+ case purecef.TerminationStatusTsProcessCrashed:
336+ reason = port.WebProcessTerminationCrashed
337+ label = "crashed"
338+ case purecef.TerminationStatusTsProcessOom:
339+ reason = port.WebProcessTerminationExceededMemory
340+ label = "out of memory"
341+ default:
342+ reason = port.WebProcessTerminationUnknown
343+ label = "unknown"
344+ }
345+
346+ h.wv.mu.RLock()
347+ cb := h.wv.callbacks
348+ uri := h.wv.uri
349+ h.wv.mu.RUnlock()
350+ if cb != nil && cb.OnWebProcessTerminated != nil {
351+ cb.OnWebProcessTerminated(reason, label, uri)
352+ }
353+}
354+
355+func (h *handlerSet) OnDocumentAvailableInMainFrame(_ purecef.Browser) {}

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