Myk Melez wrote:
We have nsIStylesheetService for adding a user stylesheet, and we also have a CSS extension providing URL-based selectors, so we could just load a single user stylesheet with rules for every site and page being styled.
Right.
But then the stylesheet will get applied to every page the user loads, even though most pages won't be styled by it.
Also right. Although this will be more or less a one-time cost per pageload (since this sheet will be immutable and we only filter by moz-document rule when we construct the rule cascade, which only happens when there isn't one already or when the sheet changes).
Another option is for the style context to query the settings object for a page-specific stylesheet on page load.
(I assume you mean style set here, not style context, btw... Or possibly even the document viewer, which is where we put in UA/user sheets right now).
Right. So this would also be a one-time cost. Which one is more expensive probably depends on how long it takes to query the settings object and how many rules you expect to have.
There's one more thing to think about, I guess, and that's whether it would be easier to create/edit one sheet per page or a single sheet. I'm not sure where the sheets are coming from, so....
In that case we would need to modify the style context to do the query and apply the result (if any). And, if we wanted to implement this as a JS component, we'd also have to expose a way to instantiate a stylesheet from script (unless there's such a way already; I haven't found one).
So how complicated do you expect the answers to the "what sheets should I apply to this site" question be? If we're talking just a hostname match, we could just extend nsIStylesheetService to allow registering sheets for a particular hostname. If we'll take various information and then compute what sheets should apply, the way to go is probably to return a list of URIs and then have layout use the stylesheet cache to actually get sheets for the URIs or something...
Not sure any of this answers your question, of course.... sorry this became so stream-of-consciousness...
-Boris _______________________________________________ dev-tech-layout mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-layout

