fix(cef): satisfy touchpad scroll lint
- commit
- 5af6b41c7340d24cc93ef905e1a001bc1a91c585
- author
- brice · · 2026-06-17 21:27 UTC
- parent
- 01d791b
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
3 files · +17 -13
M internal/infrastructure/config/schema_provider.go +7 -6
| @@ -1056,12 +1056,13 @@ func (*SchemaProvider) getPerformanceKeys(defaults *Config) []entity.ConfigKeyIn | |||
| 1056 | 1056 | Section: SectionPerformance, | |
| 1057 | 1057 | }, | |
| 1058 | 1058 | { | |
| 1059 | - | Key: "engine.cef.input.touchpad_navigation_max_vertical_ratio", | |
| 1060 | - | Type: "float64", | |
| 1061 | - | Default: fmt.Sprintf("%.2f", defaults.Engine.CEF.Input.TouchpadNavigationMaxVerticalRatio), | |
| 1062 | - | Description: "Maximum vertical-to-horizontal delta ratio allowed for CEF touchpad back/forward swipes; does not affect vertical scroll speed", | |
| 1063 | - | Range: ">0", | |
| 1064 | - | Section: SectionPerformance, | |
| 1059 | + | Key: "engine.cef.input.touchpad_navigation_max_vertical_ratio", | |
| 1060 | + | Type: "float64", | |
| 1061 | + | Default: fmt.Sprintf("%.2f", defaults.Engine.CEF.Input.TouchpadNavigationMaxVerticalRatio), | |
| 1062 | + | Description: "Maximum vertical-to-horizontal delta ratio allowed for CEF touchpad back/forward swipes; " + | |
| 1063 | + | "does not affect vertical scroll speed", | |
| 1064 | + | Range: ">0", | |
| 1065 | + | Section: SectionPerformance, | |
| 1065 | 1066 | }, | |
| 1066 | 1067 | { | |
| 1067 | 1068 | Key: "engine.webkit.skia_cpu_painting_threads", | |
| @@ -1056,12 +1056,13 @@ func (*SchemaProvider) getPerformanceKeys(defaults *Config) []entity.ConfigKeyIn | |||||
| 1056 | Section: SectionPerformance, | 1056 | Section: SectionPerformance, | ||
| 1057 | }, | 1057 | }, | ||
| 1058 | { | 1058 | { | ||
| 1059 | - | Key: "engine.cef.input.touchpad_navigation_max_vertical_ratio", | 1059 | + | Key: "engine.cef.input.touchpad_navigation_max_vertical_ratio", |
| 1060 | - | Type: "float64", | 1060 | + | Type: "float64", |
| 1061 | - | Default: fmt.Sprintf("%.2f", defaults.Engine.CEF.Input.TouchpadNavigationMaxVerticalRatio), | 1061 | + | Default: fmt.Sprintf("%.2f", defaults.Engine.CEF.Input.TouchpadNavigationMaxVerticalRatio), |
| 1062 | - | Description: "Maximum vertical-to-horizontal delta ratio allowed for CEF touchpad back/forward swipes; does not affect vertical scroll speed", | 1062 | + | Description: "Maximum vertical-to-horizontal delta ratio allowed for CEF touchpad back/forward swipes; " + |
| 1063 | - | Range: ">0", | 1063 | + | "does not affect vertical scroll speed", |
| 1064 | - | Section: SectionPerformance, | 1064 | + | Range: ">0", |
| 1065 | + | Section: SectionPerformance, | |||
| 1065 | }, | 1066 | }, | ||
| 1066 | { | 1067 | { | ||
| 1067 | Key: "engine.webkit.skia_cpu_painting_threads", | 1068 | Key: "engine.webkit.skia_cpu_painting_threads", | ||
M internal/infrastructure/config/transform_legacy.go +5 -2
| @@ -72,7 +72,10 @@ func (*LegacyConfigTransformer) transformLegacyEngineConfig(rawConfig map[string | |||
| 72 | 72 | migrateLegacyCEFInputScrollDefaults(cef) | |
| 73 | 73 | } | |
| 74 | 74 | ||
| 75 | - | const legacyCEFScrollTouchpadMultiplierDefault = 0.35 | |
| 75 | + | const ( | |
| 76 | + | legacyCEFScrollTouchpadMultiplierDefault = 0.35 | |
| 77 | + | configFloatTolerance = 0.000001 | |
| 78 | + | ) | |
| 76 | 79 | ||
| 77 | 80 | func migrateLegacyCEFInputScrollDefaults(cef map[string]any) { | |
| 78 | 81 | input, ok := cef["input"].(map[string]any) | |
| @@ -114,7 +117,7 @@ func migratedCEFPreciseScrollMultiplier(value any) any { | |||
| 114 | 117 | } | |
| 115 | 118 | ||
| 116 | 119 | func sameConfigFloat(a, b float64) bool { | |
| 117 | - | return math.Abs(a-b) <= 0.000001 | |
| 120 | + | return math.Abs(a-b) <= configFloatTolerance | |
| 118 | 121 | } | |
| 119 | 122 | ||
| 120 | 123 | func migrateLegacyCEFWindowlessFrameRateDefault(cef map[string]any, hasAdaptive, adaptiveEnabled bool) { | |
| @@ -72,7 +72,10 @@ func (*LegacyConfigTransformer) transformLegacyEngineConfig(rawConfig map[string | |||||
| 72 | migrateLegacyCEFInputScrollDefaults(cef) | 72 | migrateLegacyCEFInputScrollDefaults(cef) | ||
| 73 | } | 73 | } | ||
| 74 | 74 | ||||
| 75 | - | const legacyCEFScrollTouchpadMultiplierDefault = 0.35 | 75 | + | const ( |
| 76 | + | legacyCEFScrollTouchpadMultiplierDefault = 0.35 | |||
| 77 | + | configFloatTolerance = 0.000001 | |||
| 78 | + | ) | |||
| 76 | 79 | ||||
| 77 | func migrateLegacyCEFInputScrollDefaults(cef map[string]any) { | 80 | func migrateLegacyCEFInputScrollDefaults(cef map[string]any) { | ||
| 78 | input, ok := cef["input"].(map[string]any) | 81 | input, ok := cef["input"].(map[string]any) | ||
| @@ -114,7 +117,7 @@ func migratedCEFPreciseScrollMultiplier(value any) any { | |||||
| 114 | } | 117 | } | ||
| 115 | 118 | ||||
| 116 | func sameConfigFloat(a, b float64) bool { | 119 | func sameConfigFloat(a, b float64) bool { | ||
| 117 | - | return math.Abs(a-b) <= 0.000001 | 120 | + | return math.Abs(a-b) <= configFloatTolerance |
| 118 | } | 121 | } | ||
| 119 | 122 | ||||
| 120 | func migrateLegacyCEFWindowlessFrameRateDefault(cef map[string]any, hasAdaptive, adaptiveEnabled bool) { | 123 | func migrateLegacyCEFWindowlessFrameRateDefault(cef map[string]any, hasAdaptive, adaptiveEnabled bool) { | ||
M internal/infrastructure/config/transform_legacy_test.go +5 -5
| @@ -221,7 +221,7 @@ func TestTransformLegacyEngineConfig_UpgradesObsoletePreciseScrollDefault(t *tes | |||
| 221 | 221 | transformer.TransformLegacyEngineConfig(rawConfig) | |
| 222 | 222 | ||
| 223 | 223 | input := rawConfig["engine"].(map[string]any)["cef"].(map[string]any)["input"].(map[string]any) | |
| 224 | - | assert.Equal(t, defaultCEFScrollPreciseMultiplier, input["scroll_precise_multiplier"]) | |
| 224 | + | assert.InDelta(t, defaultCEFScrollPreciseMultiplier, input["scroll_precise_multiplier"], 0.001) | |
| 225 | 225 | } | |
| 226 | 226 | ||
| 227 | 227 | func TestTransformLegacyEngineConfig_MigratesLegacyTouchpadScrollKey(t *testing.T) { | |
| @@ -239,7 +239,7 @@ func TestTransformLegacyEngineConfig_MigratesLegacyTouchpadScrollKey(t *testing. | |||
| 239 | 239 | transformer.TransformLegacyEngineConfig(rawConfig) | |
| 240 | 240 | ||
| 241 | 241 | input := rawConfig["engine"].(map[string]any)["cef"].(map[string]any)["input"].(map[string]any) | |
| 242 | - | assert.Equal(t, defaultCEFScrollPreciseMultiplier, input["scroll_precise_multiplier"]) | |
| 242 | + | assert.InDelta(t, defaultCEFScrollPreciseMultiplier, input["scroll_precise_multiplier"], 0.001) | |
| 243 | 243 | assert.NotContains(t, input, "scroll_touchpad_multiplier") | |
| 244 | 244 | } | |
| 245 | 245 | ||
| @@ -258,7 +258,7 @@ func TestTransformLegacyEngineConfig_PreservesCustomPreciseScrollMultiplier(t *t | |||
| 258 | 258 | transformer.TransformLegacyEngineConfig(rawConfig) | |
| 259 | 259 | ||
| 260 | 260 | input := rawConfig["engine"].(map[string]any)["cef"].(map[string]any)["input"].(map[string]any) | |
| 261 | - | assert.Equal(t, 4.0, input["scroll_precise_multiplier"]) | |
| 261 | + | assert.InDelta(t, 4.0, input["scroll_precise_multiplier"], 0.001) | |
| 262 | 262 | } | |
| 263 | 263 | ||
| 264 | 264 | func TestTransformLegacyEngineConfig_PreservesCustomLegacyTouchpadScrollMultiplier(t *testing.T) { | |
| @@ -276,7 +276,7 @@ func TestTransformLegacyEngineConfig_PreservesCustomLegacyTouchpadScrollMultipli | |||
| 276 | 276 | transformer.TransformLegacyEngineConfig(rawConfig) | |
| 277 | 277 | ||
| 278 | 278 | input := rawConfig["engine"].(map[string]any)["cef"].(map[string]any)["input"].(map[string]any) | |
| 279 | - | assert.Equal(t, 4.0, input["scroll_precise_multiplier"]) | |
| 279 | + | assert.InDelta(t, 4.0, input["scroll_precise_multiplier"], 0.001) | |
| 280 | 280 | assert.NotContains(t, input, "scroll_touchpad_multiplier") | |
| 281 | 281 | } | |
| 282 | 282 | ||
| @@ -296,7 +296,7 @@ func TestTransformLegacyEngineConfig_PrefersCustomLegacyTouchpadOverGeneratedPre | |||
| 296 | 296 | transformer.TransformLegacyEngineConfig(rawConfig) | |
| 297 | 297 | ||
| 298 | 298 | input := rawConfig["engine"].(map[string]any)["cef"].(map[string]any)["input"].(map[string]any) | |
| 299 | - | assert.Equal(t, 4.0, input["scroll_precise_multiplier"]) | |
| 299 | + | assert.InDelta(t, 4.0, input["scroll_precise_multiplier"], 0.001) | |
| 300 | 300 | assert.NotContains(t, input, "scroll_touchpad_multiplier") | |
| 301 | 301 | } | |
| 302 | 302 | ||
| @@ -221,7 +221,7 @@ func TestTransformLegacyEngineConfig_UpgradesObsoletePreciseScrollDefault(t *tes | |||||
| 221 | transformer.TransformLegacyEngineConfig(rawConfig) | 221 | transformer.TransformLegacyEngineConfig(rawConfig) | ||
| 222 | 222 | ||||
| 223 | input := rawConfig["engine"].(map[string]any)["cef"].(map[string]any)["input"].(map[string]any) | 223 | input := rawConfig["engine"].(map[string]any)["cef"].(map[string]any)["input"].(map[string]any) | ||
| 224 | - | assert.Equal(t, defaultCEFScrollPreciseMultiplier, input["scroll_precise_multiplier"]) | 224 | + | assert.InDelta(t, defaultCEFScrollPreciseMultiplier, input["scroll_precise_multiplier"], 0.001) |
| 225 | } | 225 | } | ||
| 226 | 226 | ||||
| 227 | func TestTransformLegacyEngineConfig_MigratesLegacyTouchpadScrollKey(t *testing.T) { | 227 | func TestTransformLegacyEngineConfig_MigratesLegacyTouchpadScrollKey(t *testing.T) { | ||
| @@ -239,7 +239,7 @@ func TestTransformLegacyEngineConfig_MigratesLegacyTouchpadScrollKey(t *testing. | |||||
| 239 | transformer.TransformLegacyEngineConfig(rawConfig) | 239 | transformer.TransformLegacyEngineConfig(rawConfig) | ||
| 240 | 240 | ||||
| 241 | input := rawConfig["engine"].(map[string]any)["cef"].(map[string]any)["input"].(map[string]any) | 241 | input := rawConfig["engine"].(map[string]any)["cef"].(map[string]any)["input"].(map[string]any) | ||
| 242 | - | assert.Equal(t, defaultCEFScrollPreciseMultiplier, input["scroll_precise_multiplier"]) | 242 | + | assert.InDelta(t, defaultCEFScrollPreciseMultiplier, input["scroll_precise_multiplier"], 0.001) |
| 243 | assert.NotContains(t, input, "scroll_touchpad_multiplier") | 243 | assert.NotContains(t, input, "scroll_touchpad_multiplier") | ||
| 244 | } | 244 | } | ||
| 245 | 245 | ||||
| @@ -258,7 +258,7 @@ func TestTransformLegacyEngineConfig_PreservesCustomPreciseScrollMultiplier(t *t | |||||
| 258 | transformer.TransformLegacyEngineConfig(rawConfig) | 258 | transformer.TransformLegacyEngineConfig(rawConfig) | ||
| 259 | 259 | ||||
| 260 | input := rawConfig["engine"].(map[string]any)["cef"].(map[string]any)["input"].(map[string]any) | 260 | input := rawConfig["engine"].(map[string]any)["cef"].(map[string]any)["input"].(map[string]any) | ||
| 261 | - | assert.Equal(t, 4.0, input["scroll_precise_multiplier"]) | 261 | + | assert.InDelta(t, 4.0, input["scroll_precise_multiplier"], 0.001) |
| 262 | } | 262 | } | ||
| 263 | 263 | ||||
| 264 | func TestTransformLegacyEngineConfig_PreservesCustomLegacyTouchpadScrollMultiplier(t *testing.T) { | 264 | func TestTransformLegacyEngineConfig_PreservesCustomLegacyTouchpadScrollMultiplier(t *testing.T) { | ||
| @@ -276,7 +276,7 @@ func TestTransformLegacyEngineConfig_PreservesCustomLegacyTouchpadScrollMultipli | |||||
| 276 | transformer.TransformLegacyEngineConfig(rawConfig) | 276 | transformer.TransformLegacyEngineConfig(rawConfig) | ||
| 277 | 277 | ||||
| 278 | input := rawConfig["engine"].(map[string]any)["cef"].(map[string]any)["input"].(map[string]any) | 278 | input := rawConfig["engine"].(map[string]any)["cef"].(map[string]any)["input"].(map[string]any) | ||
| 279 | - | assert.Equal(t, 4.0, input["scroll_precise_multiplier"]) | 279 | + | assert.InDelta(t, 4.0, input["scroll_precise_multiplier"], 0.001) |
| 280 | assert.NotContains(t, input, "scroll_touchpad_multiplier") | 280 | assert.NotContains(t, input, "scroll_touchpad_multiplier") | ||
| 281 | } | 281 | } | ||
| 282 | 282 | ||||
| @@ -296,7 +296,7 @@ func TestTransformLegacyEngineConfig_PrefersCustomLegacyTouchpadOverGeneratedPre | |||||
| 296 | transformer.TransformLegacyEngineConfig(rawConfig) | 296 | transformer.TransformLegacyEngineConfig(rawConfig) | ||
| 297 | 297 | ||||
| 298 | input := rawConfig["engine"].(map[string]any)["cef"].(map[string]any)["input"].(map[string]any) | 298 | input := rawConfig["engine"].(map[string]any)["cef"].(map[string]any)["input"].(map[string]any) | ||
| 299 | - | assert.Equal(t, 4.0, input["scroll_precise_multiplier"]) | 299 | + | assert.InDelta(t, 4.0, input["scroll_precise_multiplier"], 0.001) |
| 300 | assert.NotContains(t, input, "scroll_touchpad_multiplier") | 300 | assert.NotContains(t, input, "scroll_touchpad_multiplier") | ||
| 301 | } | 301 | } | ||
| 302 | 302 | ||||