Open Bug 1692243 Opened 4 years ago Updated 5 months ago

Allow @media queries, @-moz-document and content styling in theme_experiments

Categories

(Thunderbird :: Add-Ons: Extensions API, enhancement)

enhancement

Tracking

(Not tracked)

People

(Reporter: TbSync, Assigned: TbSync)

Details

Attachments

(2 files, 2 obsolete files)

Bug 1691560 is only a fallback solution. What I really want is to be able to use @media queries again: They can be used to identify win, linux and mac, but also what system theme is running. We use that in our css files as well:
@media (-moz-windows-default-theme)

I also want to be able to propose styles per document:
@-moz-document url(chrome://messenger/content/messenger.xhtml)

Furthermore, theme developers should be able to propose styles for content areas, like settings and add-on manager.

All this is currently not possible, because the theme_experiment CSS file is treated as content (because it has a moz-extension URL).

I found a few ways to fix this:

  1. Enable layout.css.moz-document.content.enabled in Thunderbird
  • @media: -
  • @-moz-document: +
  • content: -
  • Enables this also in emails and real content, might be not desired
  1. Setup a chrome:// or resoure:// URL for the css files of the theme:
  • @media: +
  • @-moz-document: +
  • content: -
  • Could be deemed to powerful as an entire folder has to be made accessible via chrome:// or resource://. Use random short-name suffix?
  1. use nsIStyleSheetService
  • @media: +
  • @-moz-document: +
  • content: +
  • Is this on death row? Not used in m-c.

This patch goes for option 3. Instead of changing the behavior of the CSS file defined via
the stylesheet manifest entry, I added a new one (thunderbird_stylesheet). Only if stylesheet is not set, the other one is used.

I do not really know the difference between AGENT_SHEET, USER_SHEET and AUTHOR_SHEET, or which one we should use. It looks like AUTHOR_SHEET does not support @media and @-moz-document. But what is the difference between the other two?

Are there other options to get this done?

@Mark: Do you know if nsIStyleSheetService should not be used anymore?
@Richard: What do you think? This should also allow tree theming.

Attachment #9202620 - Flags: feedback?(standard8)
Attachment #9202620 - Flags: feedback?(richard.marti)
Attached file theme_experiment.xpi (obsolete) —

A simple theme using the new features.

Standard text color is purple, on windows (-moz-windows-default-theme) green.
For mail3pane it's blue.

Comment on attachment 9202620 [details] [diff] [review]
bug1692243_empower_theme_experiments.patch

Looks good. But I'm not sure with the limitation to not use thunderbird_stylesheet when a normal stylesheet is present as this makes it impossible to create themes that work under FX and TB and additionally use the special power for TB.

Attachment #9202620 - Flags: feedback?(richard.marti) → feedback+

Themes using thunderbird_stylesheet will not work at all in Firefox (throws error on install), as that does not know the new manifest key.

To get around this, we could clone theme_experiment and add a full new manifest entrythunderbird_theme_experiment which then uses the default stylesheet key but gives the advanced power to it. Thunderbird will ignore theme_experiment if thunderbird_theme_experiment is given. Firefox will throw a warning about the unknown manifest entry but will work as before using the theme_experiment.

The other option is to simply change the behavior of the standard stylesheet entry for Thunderbird. But I oppose that, as it may change behavior tested for in toolkit tests which we cannot change and which could cause fails.

It turned out to be not very difficult to implement thunderbird_theme_experiment. It does feel cleaner.

Attachment #9202620 - Attachment is obsolete: true
Attachment #9202620 - Flags: feedback?(standard8)

Updated example theme, using thunderbird_theme_experiment.

Attachment #9202621 - Attachment is obsolete: true
Attachment #9203125 - Flags: review?(geoff)

I will add tests when I know this is ok in general.

Status: NEW → ASSIGNED

I'm not a big fan of this. It feels a bit awkward.

I wonder if we can get moz-extension URLs for stylesheets to be considered "not content", on the grounds that (1) they're not scripts so not a big risk and (2) they're only available where experiments are enabled and in that case the extension can already do whatever it wants. There may be other implications I haven't thought of, but I think it would be worth asking. (I'm not sure who to ask.)

(In reply to John Bieling (:TbSync) from comment #4)

The other option is to simply change the behavior of the standard stylesheet entry for Thunderbird. But I oppose that, as it may change behavior tested for in toolkit tests which we cannot change and which could cause fails.

FWIW, we already fail almost all of the toolkit tests for themes on account of differences between Thunderbird and Firefox (in a lot of cases it's just elements the test are looking for that we don't have). However, if you take the change of behaviour and apply it to the toolkit version of ext-themes.js, all of the tests still pass in Firefox. So that's something.

Attachment #9203125 - Flags: review?(geoff) → review-
Status: ASSIGNED → NEW
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: