Use theme background for browser omnibar chrome in light mode

This commit is contained in:
Lawrence Chen 2026-02-23 15:31:24 -08:00
parent c5d20ae032
commit 561f052fdd
2 changed files with 50 additions and 8 deletions

View file

@ -166,6 +166,18 @@ private extension View {
}
}
func resolvedBrowserChromeBackgroundColor(
for colorScheme: ColorScheme,
themeBackgroundColor: NSColor
) -> NSColor {
switch colorScheme {
case .dark, .light:
return themeBackgroundColor
@unknown default:
return themeBackgroundColor
}
}
/// View for rendering a browser panel with address bar
struct BrowserPanelView: View {
@ObservedObject var panel: BrowserPanel
@ -239,14 +251,10 @@ struct BrowserPanelView: View {
}
private var browserChromeBackgroundColor: NSColor {
switch colorScheme {
case .dark:
return GhosttyApp.shared.defaultBackgroundColor
case .light:
return .windowBackgroundColor
@unknown default:
return .windowBackgroundColor
}
resolvedBrowserChromeBackgroundColor(
for: colorScheme,
themeBackgroundColor: GhosttyApp.shared.defaultBackgroundColor
)
}
var body: some View {

View file

@ -655,6 +655,40 @@ final class BrowserThemeSettingsTests: XCTestCase {
}
}
final class BrowserPanelChromeBackgroundColorTests: XCTestCase {
func testLightModeUsesThemeBackgroundColor() {
assertResolvedColorMatchesTheme(for: .light)
}
func testDarkModeUsesThemeBackgroundColor() {
assertResolvedColorMatchesTheme(for: .dark)
}
private func assertResolvedColorMatchesTheme(
for colorScheme: ColorScheme,
file: StaticString = #filePath,
line: UInt = #line
) {
let themeBackground = NSColor(srgbRed: 0.13, green: 0.29, blue: 0.47, alpha: 1.0)
guard
let actual = resolvedBrowserChromeBackgroundColor(
for: colorScheme,
themeBackgroundColor: themeBackground
).usingColorSpace(.sRGB),
let expected = themeBackground.usingColorSpace(.sRGB)
else {
XCTFail("Expected sRGB-convertible colors", file: file, line: line)
return
}
XCTAssertEqual(actual.redComponent, expected.redComponent, accuracy: 0.001, file: file, line: line)
XCTAssertEqual(actual.greenComponent, expected.greenComponent, accuracy: 0.001, file: file, line: line)
XCTAssertEqual(actual.blueComponent, expected.blueComponent, accuracy: 0.001, file: file, line: line)
XCTAssertEqual(actual.alphaComponent, expected.alphaComponent, accuracy: 0.001, file: file, line: line)
}
}
final class BrowserDeveloperToolsShortcutDefaultsTests: XCTestCase {
func testSafariDefaultShortcutForToggleDeveloperTools() {
let shortcut = KeyboardShortcutSettings.Action.toggleBrowserDeveloperTools.defaultShortcut