Closed Bug 1593355 Opened 6 years ago Closed 2 years ago

Add support for dark mode to WebExtensions UI (options, sidebar, popup)

Categories

(WebExtensions :: Frontend, enhancement, P3)

Desktop
All
enhancement

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: yuki, Unassigned)

References

Details

Attachments

(1 file)

Attached image Screenshot

Firefox supports Dark app color on Windows 10, but the color scheme is not applied to the options page embedded in about:addons as the attached screenshot.
(This is originally reported at https://github.com/piroor/treestyletab/issues/2405 )

Steps to reproduce:

  1. Change the default application color to "Dark" on Windows 10. (Settings -> Personalization -> Colors -> Custom -> Choose your default app mode -> Dark)
  2. Start Firefox.
  3. Install any addon with options page embedded in about:addons with browser_style: true. I've confirmed with https://addons.mozilla.org/firefox/addon/tree-style-tab/
  4. Go to the options page of the addon.

Expected result

The options page is shown with Dark color.

Actual result

The options page is shown with bright color.

Environment

  • Windows 10 Home 1903
  • Nightly 72.0a1 build ID 20191101093621

I've not tested this on macOS, so this is possibly a problem not depending on Windows.

Are you hoping that because TST is using browser_style: true we can update the colours automatically? This seems reasonable but I'm not sure how it will work in practice. Extensions can use whatever colours they want in their CSS and those could become unreadable if we change the default background/text colour.

I figured extensions would add dark mode if they felt like supporting it, similar to the original issue report you got. We could hypothetically add another property to the options_ui manifest entry to tell Firefox that the extension's UI supports dark mode and update the defaults.

This is something I knew would look weird but didn't have time to sort out a proper solution. What would you like to see here (that would hopefully not break other extensions).

Flags: needinfo?(yuki)
OS: Windows 10 → All
Type: defect → enhancement
Priority: -- → P3

Here's what was happening in the XUL about:addons for context (which had a transparent background on the extension options browser) bug 1544212.

See Also: → 1544212

(In reply to Mark Striemer [:mstriemer] from comment #2)

Are you hoping that because TST is using browser_style: true we can update the colours automatically?

Yes, I forgot to write about that. Sorry.
https://searchfox.org/mozilla-central/rev/35873cfc312a6285f54aa5e4ec2d4ab911157522/browser/components/extensions/extension.css#9
Style rules applied with browser_style: true are defined in this file, and colors in the file are defined just same as light color scheme. They looks should be overridden with dark colors in something way (for example @media (prefers-color-scheme: dark) { ... }) when the Dark theme is applied.

Flags: needinfo?(yuki)
Summary: Options page in about:addons is still shown with bright color on Dark mode → Options page in about:addons is still shown with bright color on Dark mode, even if `browser_style: true` is specified

(In reply to YUKI "Piro" Hiroshi from comment #4)

(In reply to Mark Striemer [:mstriemer] from comment #2)

Are you hoping that because TST is using browser_style: true we can update the colours automatically?

Yes, I forgot to write about that. Sorry.
https://searchfox.org/mozilla-central/rev/35873cfc312a6285f54aa5e4ec2d4ab911157522/browser/components/extensions/extension.css#9
Style rules applied with browser_style: true are defined in this file, and colors in the file are defined just same as light color scheme. They looks should be overridden with dark colors in something way (for example @media (prefers-color-scheme: dark) { ... }) when the Dark theme is applied.

Main problem with this approach as Mark points out is that some extensions might use that stylesheet without expecting it to switch colors with the OS dark mode.

I think we should just build a better browser_style and deprecate the current one. There's a bunch of issues with the current way browser_style is made and this is just the tip of the iceberg.

So this is not only a missing feature for the options page but also for the sidebar and popups.

I tried to use @media (prefers-color-scheme: dark) for my extension but that also doesn't work and CSS values as set aren't recognized. Same happens when just importing chrome://global/skin/in-content/common.css for testing purposes.

Summary: Options page in about:addons is still shown with bright color on Dark mode, even if `browser_style: true` is specified → Add support for dark mode to WebExtensions UI (options, sidebar, popup)

As mentioned at https://bugzilla.mozilla.org/show_bug.cgi?id=1703206#c15, @media (prefers-color-scheme: dark) currently maps to the theme from the OS.

And I agree with ntim above in comment 5 that browser_style has several defects, to the point that we may as well deprecate/remove it.

I support the goal ("Add support for dark mode to WebExtensions UI"), but the path to the implementation is not as obvious. We can probably not change the defaults implied by browser_style because that would break extensions that aren't designed for it. To me, reasonable alternatives include CSS variables for certain colors/semantics of interest and/or updating the theme API to return the effective set of colors (if that is possible at all*).

* The logic for deriving theme colors are complicated. When a custom extension theme is set, the theme is more obvious (as it's mostly the return value of browser.theme.getCurrent(), provided that the colors are fully set). When an extension specifies a dark theme through the dark_theme key, then the colors are used if some complicated set of conditions is met: https://searchfox.org/mozilla-central/rev/70a94bffbb73d2b0ba751fb3905428fdbcd4d402/toolkit/modules/LightweightThemeConsumer.jsm#270-274 (note that the condition changed recently in bug 1546540, so it's not even that stable).

Depends on: 1529323

After bug 1529323 prefers-color-scheme should work by default.

Severity: normal → S3

(In reply to Emilio Cobos Álvarez (:emilio) from comment #10)

After bug 1529323 prefers-color-scheme should work by default.

Should we close this out, then? Rob?

Flags: needinfo?(rob)

(In reply to Rob Wu [:robwu] from comment #8)

And I agree with ntim above in comment 5 that browser_style has several defects, to the point that we may as well deprecate/remove it.

We have removed browser_style in MV3 (bug 1827910). We cannot make such a change for MV2 because it may negatively affect extensions that expect the current style.

(In reply to :Gijs (he/him) from comment #11)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #10)

After bug 1529323 prefers-color-scheme should work by default.

Should we close this out, then? Rob?

Yes. @media (prefers-color-scheme: dark) should be an acceptable work-around for extension developers. The issue from comment #6 has been fixed.

Status: NEW → RESOLVED
Closed: 2 years ago
Flags: needinfo?(rob)
Resolution: --- → FIXED
See Also: → 1827910

(In reply to Rob Wu [:robwu] from comment #12)

Yes. @media (prefers-color-scheme: dark) should be an acceptable work-around for extension developers. The issue from comment #6 has been fixed.

I finally had the time to update my extension and I can say that it works great at least for the sidebar (it doesn't have any options or popups yet). Thanks!

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: