Closed Bug 305026 Opened 19 years ago Closed 19 years ago

[FIXr]Document how calls on nsIStyleSheetService interact with userContent.css

Categories

(Core :: Layout, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla1.8beta4

People

(Reporter: sfraser_bugs, Assigned: bzbarsky)

References

Details

(Keywords: fixed1.8)

Attachments

(1 file, 2 obsolete files)

When loading stylesheets (e.g. for ad blocking) via nsIStyleSheetService, it's
unclear how they will interact with userContent.css. Specifically, it's unclear
whether rules in the dynamically-loaded stylesheet will override those in
userContent.css, or whether it depends on which was loaded last.
Attached patch Documentation (obsolete) — Splinter Review
The nsStyleSet.h change just makes the docs match the code change made in bug
252578
Attachment #193183 - Flags: superreview?(dbaron)
Attachment #193183 - Flags: review?(dbaron)
Comment on attachment 193183 [details] [diff] [review]
Documentation

r+sr=dbaron, except I think the comment that you're changing in nsStyleSet.h
was actually a comment describing the ordering of the arrays within
mRuleProcessors, which was *removed* in bug 252578.  I think the comment should
say "Levels of the cascade, from least significant to most".  The use of "All"
seems incorrect.
Attachment #193183 - Flags: superreview?(dbaron)
Attachment #193183 - Flags: superreview+
Attachment #193183 - Flags: review?(dbaron)
Attachment #193183 - Flags: review+
...except that wording on significance is backward for !important, so I'd say:

// The "origins" of the CSS cascade, from lowest precedence to highest (for
// non-!important rules).
If I'm reading this right, rules in userContent.css will be clobbered by rules
in sheets loaded via nsIStyleSheetService (is this true for !important rules
too?). This is unfortunate, since it prevents the user from overriding rules in
an application-provided stylesheet with rules in their user-editable stylesheet
(i.e. the user no longer has ultimate control).
> (is this true for !important rules too?).

!important rules in userContent.css will be overridden by !important rules
loaded via the stylesheet service if the selectors ahve the same specificity.

I see no problem with putting userContent.css after the nsIStyleSheetService
sheets for the user level (though I still think that they should come after
ua.css for the UA leve).  David, Brian, what do you think?
Attached patch With those changes (obsolete) — Splinter Review
This addresses the comments, and I changed the relative ordering of
userChrome/Content.css and the sheets added via this API; I think Simon makes a
good argument for having userChrome/Content.css be last.
Attachment #193209 - Flags: superreview?(dbaron)
Attachment #193209 - Flags: review?(dbaron)
Oh, I'm going to add another sentence or two saying that relative ordering of
sheets added via this API is undefined.
Comment on attachment 193209 [details] [diff] [review]
With those changes

>-    sheetService->UserStyleSheets()->EnumerateForwards(AppendUserSheet,
>+    sheetService->UserStyleSheets()->EnumerateForwards(PrependUserSheet,

why not make this EnumerateBackwards and not have the relative ordering be
undefined?
Because then I'd have to document that the relative ordering is dependent on the
order of sheet registration and I'm not really happy doing that.  Especially
because right now that's only true because of the data storage we're using
internally (an array).
I don't suppose this would get onto the 1.8 branch, would it? Camino is using
nsIStyleSheetService for ad blocking, and it would be cool if they could disable
certain ad blocking rules via userContent.css.
Blocks: 305259
If that gets reviewed, I plan to try and land it on branch...
Comment on attachment 193209 [details] [diff] [review]
With those changes

OK, but could you change it to EnumerateBackwards anyway?  Somebody might
accidentally start depending on current behavior, and if so, I'd at least like
to have them depend on something that's consistent.
Attachment #193209 - Flags: superreview?(dbaron)
Attachment #193209 - Flags: superreview+
Attachment #193209 - Flags: review?(dbaron)
Attachment #193209 - Flags: review+
This is very safe and makes this API easier to use (and documents it better).
Assignee: nobody → bzbarsky
Attachment #193183 - Attachment is obsolete: true
Attachment #193209 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #193231 - Flags: approval1.8b4?
Priority: -- → P1
Summary: Document how calls on nsIStyleSheetService interact with userContent.css → [FIXr]Document how calls on nsIStyleSheetService interact with userContent.css
Target Milestone: --- → mozilla1.8beta4
Fixed on trunk.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Flags: blocking1.8b4+
Attachment #193231 - Flags: approval1.8b4? → approval1.8b4+
Fixed on branch.
Keywords: fixed1.8
Product: Core → Core Graveyard
Component: Layout: Misc Code → Layout
Product: Core Graveyard → Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: