fix(cef): sync purego-cef vendor and fix lint issues
- Add LogFile and InitTraceFile fields to purego-cef Settings - Remove Go 1.22+ redundant loop var copies (copyloopvar) - Extract file permission constants (mnd) - Simplify Widget selector (staticcheck) - Use InEpsilon for float comparison in test (testifylint)
- commit
- c5aba1b1e6e189cbef3362aa11882cbe6fe2eb53
- author
- brice · · 2026-03-21 20:13 UTC
- committer
- brice · · 2026-03-28 04:37 UTC
- parent
- fcafef6
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
4 files · +12 -10
M internal/infrastructure/cef/engine_init.go +9 -4
| @@ -243,10 +243,15 @@ func findHelperBinary() string { | |||
| 243 | 243 | return "" | |
| 244 | 244 | } | |
| 245 | 245 | ||
| 246 | + | const ( | |
| 247 | + | dirPerm = 0o755 | |
| 248 | + | filePerm = 0o644 | |
| 249 | + | ) | |
| 250 | + | ||
| 246 | 251 | func prepareCEFLogFile(cfg config.CEFEngineConfig) (string, error) { | |
| 247 | 252 | if cfg.LogFile != "" { | |
| 248 | 253 | runtimeLogFile := filepath.Clean(cfg.LogFile) | |
| 249 | - | if err := os.MkdirAll(filepath.Dir(runtimeLogFile), 0o755); err != nil { | |
| 254 | + | if err := os.MkdirAll(filepath.Dir(runtimeLogFile), dirPerm); err != nil { | |
| 250 | 255 | return "", fmt.Errorf("mkdir %s: %w", filepath.Dir(runtimeLogFile), err) | |
| 251 | 256 | } | |
| 252 | 257 | return runtimeLogFile, nil | |
| @@ -257,7 +262,7 @@ func prepareCEFLogFile(cfg config.CEFEngineConfig) (string, error) { | |||
| 257 | 262 | return "", fmt.Errorf("getwd: %w", cwdErr) | |
| 258 | 263 | } | |
| 259 | 264 | runtimeLogFile := filepath.Join(cwd, ".dev", "dumber", "logs", "cef_runtime.log") | |
| 260 | - | if err := os.MkdirAll(filepath.Dir(runtimeLogFile), 0o755); err != nil { | |
| 265 | + | if err := os.MkdirAll(filepath.Dir(runtimeLogFile), dirPerm); err != nil { | |
| 261 | 266 | return "", fmt.Errorf("mkdir %s: %w", filepath.Dir(runtimeLogFile), err) | |
| 262 | 267 | } | |
| 263 | 268 | return runtimeLogFile, nil | |
| @@ -279,10 +284,10 @@ func prepareCEFInitTraceFile(cfg config.CEFEngineConfig) (string, error) { | |||
| 279 | 284 | runtimeLogFile = filepath.Join(cwd, ".dev", "dumber", "logs", "cef_runtime.log") | |
| 280 | 285 | } | |
| 281 | 286 | bootstrapLogFile := strings.TrimSuffix(runtimeLogFile, filepath.Ext(runtimeLogFile)) + ".bootstrap.log" | |
| 282 | - | if err := os.MkdirAll(filepath.Dir(bootstrapLogFile), 0o755); err != nil { | |
| 287 | + | if err := os.MkdirAll(filepath.Dir(bootstrapLogFile), dirPerm); err != nil { | |
| 283 | 288 | return "", fmt.Errorf("mkdir %s: %w", filepath.Dir(bootstrapLogFile), err) | |
| 284 | 289 | } | |
| 285 | - | if err := os.WriteFile(bootstrapLogFile, nil, 0o644); err != nil { | |
| 290 | + | if err := os.WriteFile(bootstrapLogFile, nil, filePerm); err != nil { | |
| 286 | 291 | return "", fmt.Errorf("reset %s: %w", bootstrapLogFile, err) | |
| 287 | 292 | } | |
| 288 | 293 | return bootstrapLogFile, nil | |
| @@ -243,10 +243,15 @@ func findHelperBinary() string { | |||||
| 243 | return "" | 243 | return "" | ||
| 244 | } | 244 | } | ||
| 245 | 245 | ||||
| 246 | + | const ( | |||
| 247 | + | dirPerm = 0o755 | |||
| 248 | + | filePerm = 0o644 | |||
| 249 | + | ) | |||
| 250 | + | ||||
| 246 | func prepareCEFLogFile(cfg config.CEFEngineConfig) (string, error) { | 251 | func prepareCEFLogFile(cfg config.CEFEngineConfig) (string, error) { | ||
| 247 | if cfg.LogFile != "" { | 252 | if cfg.LogFile != "" { | ||
| 248 | runtimeLogFile := filepath.Clean(cfg.LogFile) | 253 | runtimeLogFile := filepath.Clean(cfg.LogFile) | ||
| 249 | - | if err := os.MkdirAll(filepath.Dir(runtimeLogFile), 0o755); err != nil { | 254 | + | if err := os.MkdirAll(filepath.Dir(runtimeLogFile), dirPerm); err != nil { |
| 250 | return "", fmt.Errorf("mkdir %s: %w", filepath.Dir(runtimeLogFile), err) | 255 | return "", fmt.Errorf("mkdir %s: %w", filepath.Dir(runtimeLogFile), err) | ||
| 251 | } | 256 | } | ||
| 252 | return runtimeLogFile, nil | 257 | return runtimeLogFile, nil | ||
| @@ -257,7 +262,7 @@ func prepareCEFLogFile(cfg config.CEFEngineConfig) (string, error) { | |||||
| 257 | return "", fmt.Errorf("getwd: %w", cwdErr) | 262 | return "", fmt.Errorf("getwd: %w", cwdErr) | ||
| 258 | } | 263 | } | ||
| 259 | runtimeLogFile := filepath.Join(cwd, ".dev", "dumber", "logs", "cef_runtime.log") | 264 | runtimeLogFile := filepath.Join(cwd, ".dev", "dumber", "logs", "cef_runtime.log") | ||
| 260 | - | if err := os.MkdirAll(filepath.Dir(runtimeLogFile), 0o755); err != nil { | 265 | + | if err := os.MkdirAll(filepath.Dir(runtimeLogFile), dirPerm); err != nil { |
| 261 | return "", fmt.Errorf("mkdir %s: %w", filepath.Dir(runtimeLogFile), err) | 266 | return "", fmt.Errorf("mkdir %s: %w", filepath.Dir(runtimeLogFile), err) | ||
| 262 | } | 267 | } | ||
| 263 | return runtimeLogFile, nil | 268 | return runtimeLogFile, nil | ||
| @@ -279,10 +284,10 @@ func prepareCEFInitTraceFile(cfg config.CEFEngineConfig) (string, error) { | |||||
| 279 | runtimeLogFile = filepath.Join(cwd, ".dev", "dumber", "logs", "cef_runtime.log") | 284 | runtimeLogFile = filepath.Join(cwd, ".dev", "dumber", "logs", "cef_runtime.log") | ||
| 280 | } | 285 | } | ||
| 281 | bootstrapLogFile := strings.TrimSuffix(runtimeLogFile, filepath.Ext(runtimeLogFile)) + ".bootstrap.log" | 286 | bootstrapLogFile := strings.TrimSuffix(runtimeLogFile, filepath.Ext(runtimeLogFile)) + ".bootstrap.log" | ||
| 282 | - | if err := os.MkdirAll(filepath.Dir(bootstrapLogFile), 0o755); err != nil { | 287 | + | if err := os.MkdirAll(filepath.Dir(bootstrapLogFile), dirPerm); err != nil { |
| 283 | return "", fmt.Errorf("mkdir %s: %w", filepath.Dir(bootstrapLogFile), err) | 288 | return "", fmt.Errorf("mkdir %s: %w", filepath.Dir(bootstrapLogFile), err) | ||
| 284 | } | 289 | } | ||
| 285 | - | if err := os.WriteFile(bootstrapLogFile, nil, 0o644); err != nil { | 290 | + | if err := os.WriteFile(bootstrapLogFile, nil, filePerm); err != nil { |
| 286 | return "", fmt.Errorf("reset %s: %w", bootstrapLogFile, err) | 291 | return "", fmt.Errorf("reset %s: %w", bootstrapLogFile, err) | ||
| 287 | } | 292 | } | ||
| 288 | return bootstrapLogFile, nil | 293 | return bootstrapLogFile, nil | ||
M internal/infrastructure/cef/webview.go +2 -4
| @@ -555,7 +555,6 @@ func (f cefTaskFunc) Execute() { | |||
| 555 | 555 | ||
| 556 | 556 | func (wv *WebView) scheduleZoomRefresh() { | |
| 557 | 557 | for _, delayMs := range [...]int64{16, 48} { | |
| 558 | - | delayMs := delayMs | |
| 559 | 558 | purecef.PostDelayedTask(purecef.ThreadIDTidUi, purecef.NewTask(cefTaskFunc(func() { | |
| 560 | 559 | if wv.destroyed.Load() { | |
| 561 | 560 | return | |
| @@ -573,7 +572,6 @@ func (wv *WebView) scheduleZoomRefresh() { | |||
| 573 | 572 | ||
| 574 | 573 | func (wv *WebView) scheduleZoomReadback(expectedFactor, expectedLevel float64) { | |
| 575 | 574 | for _, delayMs := range [...]int64{0, 64} { | |
| 576 | - | delayMs := delayMs | |
| 577 | 575 | purecef.PostDelayedTask(purecef.ThreadIDTidUi, purecef.NewTask(cefTaskFunc(func() { | |
| 578 | 576 | if wv.destroyed.Load() { | |
| 579 | 577 | return | |
| @@ -635,7 +633,7 @@ func (wv *WebView) startBeginFrameLoop() { | |||
| 635 | 633 | return true | |
| 636 | 634 | } | |
| 637 | 635 | wv.beginFrameTick = cb | |
| 638 | - | wv.beginFrameTickID = glArea.Widget.AddTickCallback(cb, 0, nil) | |
| 636 | + | wv.beginFrameTickID = glArea.AddTickCallback(cb, 0, nil) | |
| 639 | 637 | host := wv.host | |
| 640 | 638 | wv.mu.Unlock() | |
| 641 | 639 | ||
| @@ -657,7 +655,7 @@ func (wv *WebView) stopBeginFrameLoop() { | |||
| 657 | 655 | wv.mu.Unlock() | |
| 658 | 656 | ||
| 659 | 657 | if tickID != 0 { | |
| 660 | - | glArea.Widget.RemoveTickCallback(tickID) | |
| 658 | + | glArea.RemoveTickCallback(tickID) | |
| 661 | 659 | } | |
| 662 | 660 | } | |
| 663 | 661 | ||
| @@ -555,7 +555,6 @@ func (f cefTaskFunc) Execute() { | |||||
| 555 | 555 | ||||
| 556 | func (wv *WebView) scheduleZoomRefresh() { | 556 | func (wv *WebView) scheduleZoomRefresh() { | ||
| 557 | for _, delayMs := range [...]int64{16, 48} { | 557 | for _, delayMs := range [...]int64{16, 48} { | ||
| 558 | - | delayMs := delayMs | |||
| 559 | purecef.PostDelayedTask(purecef.ThreadIDTidUi, purecef.NewTask(cefTaskFunc(func() { | 558 | purecef.PostDelayedTask(purecef.ThreadIDTidUi, purecef.NewTask(cefTaskFunc(func() { | ||
| 560 | if wv.destroyed.Load() { | 559 | if wv.destroyed.Load() { | ||
| 561 | return | 560 | return | ||
| @@ -573,7 +572,6 @@ func (wv *WebView) scheduleZoomRefresh() { | |||||
| 573 | 572 | ||||
| 574 | func (wv *WebView) scheduleZoomReadback(expectedFactor, expectedLevel float64) { | 573 | func (wv *WebView) scheduleZoomReadback(expectedFactor, expectedLevel float64) { | ||
| 575 | for _, delayMs := range [...]int64{0, 64} { | 574 | for _, delayMs := range [...]int64{0, 64} { | ||
| 576 | - | delayMs := delayMs | |||
| 577 | purecef.PostDelayedTask(purecef.ThreadIDTidUi, purecef.NewTask(cefTaskFunc(func() { | 575 | purecef.PostDelayedTask(purecef.ThreadIDTidUi, purecef.NewTask(cefTaskFunc(func() { | ||
| 578 | if wv.destroyed.Load() { | 576 | if wv.destroyed.Load() { | ||
| 579 | return | 577 | return | ||
| @@ -635,7 +633,7 @@ func (wv *WebView) startBeginFrameLoop() { | |||||
| 635 | return true | 633 | return true | ||
| 636 | } | 634 | } | ||
| 637 | wv.beginFrameTick = cb | 635 | wv.beginFrameTick = cb | ||
| 638 | - | wv.beginFrameTickID = glArea.Widget.AddTickCallback(cb, 0, nil) | 636 | + | wv.beginFrameTickID = glArea.AddTickCallback(cb, 0, nil) |
| 639 | host := wv.host | 637 | host := wv.host | ||
| 640 | wv.mu.Unlock() | 638 | wv.mu.Unlock() | ||
| 641 | 639 | ||||
| @@ -657,7 +655,7 @@ func (wv *WebView) stopBeginFrameLoop() { | |||||
| 657 | wv.mu.Unlock() | 655 | wv.mu.Unlock() | ||
| 658 | 656 | ||||
| 659 | if tickID != 0 { | 657 | if tickID != 0 { | ||
| 660 | - | glArea.Widget.RemoveTickCallback(tickID) | 658 | + | glArea.RemoveTickCallback(tickID) |
| 661 | } | 659 | } | ||
| 662 | } | 660 | } | ||
| 663 | 661 | ||||
M internal/infrastructure/cef/webview_handlers_test.go +1 -1
| @@ -95,7 +95,7 @@ func TestGetScreenInfoUsesDIPRectAndScale(t *testing.T) { | |||
| 95 | 95 | ok := h.GetScreenInfo(nil, info) | |
| 96 | 96 | ||
| 97 | 97 | require.Equal(t, int32(1), ok) | |
| 98 | - | require.Equal(t, float32(3), info.DeviceScaleFactor) | |
| 98 | + | require.InEpsilon(t, float32(3), info.DeviceScaleFactor, 0.001) | |
| 99 | 99 | require.Equal(t, int32(500), info.Rect.Width) | |
| 100 | 100 | require.Equal(t, int32(300), info.Rect.Height) | |
| 101 | 101 | require.Equal(t, int32(500), info.AvailableRect.Width) | |
| @@ -95,7 +95,7 @@ func TestGetScreenInfoUsesDIPRectAndScale(t *testing.T) { | |||||
| 95 | ok := h.GetScreenInfo(nil, info) | 95 | ok := h.GetScreenInfo(nil, info) | ||
| 96 | 96 | ||||
| 97 | require.Equal(t, int32(1), ok) | 97 | require.Equal(t, int32(1), ok) | ||
| 98 | - | require.Equal(t, float32(3), info.DeviceScaleFactor) | 98 | + | require.InEpsilon(t, float32(3), info.DeviceScaleFactor, 0.001) |
| 99 | require.Equal(t, int32(500), info.Rect.Width) | 99 | require.Equal(t, int32(500), info.Rect.Width) | ||
| 100 | require.Equal(t, int32(300), info.Rect.Height) | 100 | require.Equal(t, int32(300), info.Rect.Height) | ||
| 101 | require.Equal(t, int32(500), info.AvailableRect.Width) | 101 | require.Equal(t, int32(500), info.AvailableRect.Width) | ||
M internal/infrastructure/cef/webview_zoom_test.go +0 -1
| @@ -16,4 +16,3 @@ func TestZoomConversionsRoundTrip(t *testing.T) { | |||
| 16 | 16 | } | |
| 17 | 17 | } | |
| 18 | 18 | } | |
| 19 | - | ||
| @@ -16,4 +16,3 @@ func TestZoomConversionsRoundTrip(t *testing.T) { | |||||
| 16 | } | 16 | } | ||
| 17 | } | 17 | } | ||
| 18 | } | 18 | } | ||
| 19 | - | ||||