Have you ever written an add-on to Firefox or Thunderbird that has really different styles depending on the platform but does not use binary components? I have. And I find it painful that I have to release more than one XPI package in that case. Even worse, if I want to take advantage of the XUL pre-processor, I need much more than a basic directory and the zip command line to write my add-on.

Stylesheets are attached to XUL documents through the xml-stylesheet processing instruction (PI in short). In theory, using the media pseudo-attribute in conjunction with an extension of CSS Media Queries to query the platform would do the trick. Think:

<?xml-stylesheet href="foo.css" type="text/css" media="screen and (platform: win)"?>

But Media Queries don't do that. That's not in The Original Spirit of CSS.

So let's extend the xml-stylesheet PI and add a platform pseudo-attribute. Let it take a comma-separated list of idents representing platforms (win, mac, unix, linux) and let's have a bit of code disabling stylesheets on load depending on that platform pseudo-attribute on one hand, and navigator.* on the other. Lack of platform pseudo-attribute means all platforms are ok.

<?xml-stylesheet href="foo.css" type="text/css" platform="win"?>

It's not ideal, since the stylesheet is loaded to be immediately disabled but it works well and I'm using it. It's also probably better to stay away from XBLs in such stylesheets... I also wrote code to be able to use the same platform attribute in <link> and <style> elements in HTML, although the situation is more complex here: stylesheets could be not already loaded at onload time, disabling a stylesheet only when it's loaded could lead to visual glitches. Anyway, you can uncomment a portion of the code to try it.

Honestly, I'd love Gecko to natively (hear load stylesheet depending on the platform w/o having to disable after load) handle that platform pseudo-attribute for the xml-stylesheet PI in the case of XUL only. It would help a lot of add-on authors, and possibly even XULrunner-based apps' authors. In the meantime, enjoy.