Closed Bug 369676 Opened 19 years ago Closed 19 years ago

Shouldn't be possible to style scrollbars in XUL

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: sicking, Assigned: sicking)

References

Details

Attachments

(1 file)

It is currently possible to write selectors that will style scrollbars. However this only works in XUL documents. For example in a document stylesheet the selector window.myCool scrollbar { ... } will apply to all scrollbars in all <window class="myCool">s. This only works inside XUL documents, but shouldn't work anywhere. You can use the above selector inside UA stylesheets though, which should be enough if anyone wants to create themes or apps with custom scrollbars. Would be good to get input from the XUL guys if this is a bad idea for some reason.
Note that themes are treated as document sheets, not UA sheets....
Really? How come pinstripe contains stylerules for styling scrollbars then?
What sort of rules? chrome://global/skin/xulscrollbars.css and chrome://global/skin/nativescrollbars.css are hardcoded in layout and applied as UA sheets to all documents. So if that's where the skin is putting its rules they'll be fine. If they're putting them in chrome://global/skin/, however, they won't be. So I guess ignore comment 2. I forgot about the special handling for the scrollbars sheets...
Attachment #254379 - Flags: superreview?(bzbarsky)
Attachment #254379 - Flags: review?(bzbarsky)
Ok, so I'm requesting review for this and will land unless someone speaks up.
which scrollbars does this patch prevent from styling?
The ones created via nsIAnonymousContentCreator (typically for scrollframes). With this patch, document sheets cannot style them.
Comment on attachment 254379 [details] [diff] [review] Patch to fix The change looks fine; please OK it with enn and/or neil.
Attachment #254379 - Flags: superreview?(bzbarsky)
Attachment #254379 - Flags: superreview+
Attachment #254379 - Flags: review?(bzbarsky)
Attachment #254379 - Flags: review+
In that case, this is ok.
It prevents document authors from styling any scrollbars. I.e. a webpage can not stick scrollbar { background: green } in their stylesheet. This has been disabled forever for HTML pages, but with this patch it is also disabled for XUL pages. You can however still style scrollbars when creating a theme just as before. You could even create a theme with rules like xul|*[scollbar-style="small"] > scrollbar { ... } to allow different scrollbars on different elements. So the difference with this patch is simply that the above rule only works in the theme css, not in page css.
> It prevents document authors from styling any scrollbars Not ones that are an actual <scrollbar> tag in the document, though. You can still style those. I think that was enn's worry.
What's the point of doing that?
So you can build widgets with a scrollbar in them? We have some code in the tree that does this; see http://lxr.mozilla.org/seamonkey/search?string=%253Cscrollbar
Checked in.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Blocks: 377292
Why was this changed? This breaks some extensions (including mine) which relied on applying bindings to scrollbars in order to access them. See Bug 377292 for a bug report. Can extensions add UA stylesheets?
Hi John, I put a script here: http://martijn.martijn.googlepages.com/scrpttest.htm that perhaps can serve as an example for what you want.
Thanks Martijn, by using that code to set my stylesheet as a UA stylesheet I can apply bindings to the scrollbar again. I'm still not certain this is a useful change, but at least extensions can work around it (it still makes unprivileged XUL pages unable to script their overflow:auto scrollbars without wrapping them in a scrollbox though).
> Why was this changed? Because it was a rather pointless inconsistency between XUL and non-XUL documents and had security and code complexity implications that were a bit troubling.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: