Closed
Bug 1310026
Opened 8 years ago
Closed 8 years ago
Insert user CSS
Categories
(WebExtensions :: Frontend, defect, P3)
WebExtensions
Frontend
Tracking
(firefox53 fixed)
People
(Reporter: andy+bugzilla, Assigned: evilpies)
References
Details
(Keywords: dev-doc-complete, Whiteboard: triaged)
Attachments
(1 file, 1 obsolete file)
6.34 KB,
patch
|
kmag
:
review+
|
Details | Diff | Splinter Review |
We have tabs.insertCSS, but in bug 1226547 comment 1 its mentioned why we'd want a user CSS to be installed. This would be a CSS that:
"The latter likely needs to come with a "super-power" over its Chrome counterpart, which gives inserted stylesheets lower priority than content and does not honor !important: we should have an "overrideContent" flag or something like that, in order to prevent web pages from trumping extension-provided CSS rules."
Reporter | ||
Comment 1•8 years ago
|
||
Currently tabs.insertCSS inserts a CSS as a USER_SHEET:
https://dxr.mozilla.org/mozilla-central/source/toolkit/components/extensions/ExtensionContent.jsm#193
If we allowed it to be inserted as an AUTHOR_SHEET:
https://dxr.mozilla.org/mozilla-central/source/layout/base/nsIStyleSheetService.idl
Then it would be able to override the content sheets.
Reporter | ||
Comment 2•8 years ago
|
||
Correction. It's currently inserted as AUTHOR_SHEET. This bug would allow insertion as a USER_SHEET.
Sorry for the confusion.
Updated•8 years ago
|
Priority: -- → P3
Whiteboard: triaged
Comment 3•8 years ago
|
||
This can be easily done by adding an `origin` property which defaults to `AUTHOR_SHEET` to the `details` argument of `tabs.insertCSS` and `tabs.removeCSS` (bug 1247455). This is also useful to Stylish-y add-ons, both to override `!important` style attributes and to style scrollers in the page.
I am open to naming suggestion, I don't feel like "origin" is really that great. Origin has another much more common meaning in the context of HTTP. Uh and we seem to share InjectDetails between JS and CSS.
I'm not really involved in the details here, but I like naming things.
What about 'definer' or 'cssDefiner'? It gets at the heart of what an AUTHOR or USER _SHEET means.
Reporter | ||
Comment 7•8 years ago
|
||
I got to about the same point you did with a patch, which naughty me, I didn't add it to bugzilla. I called it type, purely because the SDK calls it that: https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/stylesheet_utils
But I agree origin is so overloaded with other meanings.
Reporter | ||
Updated•8 years ago
|
webextensions: --- → +
Comment 8•8 years ago
|
||
(In reply to Matt from comment #6)
> I'm not really involved in the details here, but I like naming things.
>
> What about 'definer' or 'cssDefiner'? It gets at the heart of what an AUTHOR
> or USER _SHEET means.
Or it could be something like 'precedence'. That's even more clear as to its role, being similar in meaning to "priority" but with more of a "which wins" connotation than priority's "what's the ordering?"
Comment 9•8 years ago
|
||
I don't think "priority" or "precedence" is appropriate because the cascading order is
1. user "!important"
2. author "!important"
3. author non-"!important"
4. user non-"!important"
.
Comment 10•8 years ago
|
||
Hmm. You make a good point. I'd forgotten that customizing the browser default and overriding a site's choices were two sides of the same mechanism.
I'd suggest "role" but that's already taken.
That said, I still think using an -er suffix sounds wrong unless used to name a class which implements some action. (eg. FooDownloader, BarCopier, BazHasher)
Assignee | ||
Comment 11•8 years ago
|
||
I like "role"! In which sense is it taken? It's not a property of InjectDetails.
Comment 12•8 years ago
|
||
Huh. You're right. For some reason, my tired mind was telling me that screen/print/etc. were "roles" rather than "media types" and, if that were true, it'd have the same kind of problem as "origin".
However, I'd say that stylesheets and HTML element accessibility are distinct enough for such a common English word to be used by both without confusion.
Assignee | ||
Comment 13•8 years ago
|
||
Attachment #8817543 -
Attachment is obsolete: true
Attachment #8821688 -
Flags: review?(aswan)
Comment 14•8 years ago
|
||
Comment on attachment 8821688 [details] [diff] [review]
Add "role" option for insertCSS/removeCSS
Redirecting to Kris. My only minor comment is that you've misspelled the name of the new property in the patch subject (rule/role)
Attachment #8821688 -
Flags: review?(aswan) → review?(kmaglione+bmo)
Attachment #8821688 -
Attachment description: Add "rule" option for insertCSS/removeCSS → Add "role" option for insertCSS/removeCSS
Updated•8 years ago
|
Keywords: dev-doc-needed
Comment 15•8 years ago
|
||
Comment on attachment 8821688 [details] [diff] [review]
Add "role" option for insertCSS/removeCSS
Review of attachment 8821688 [details] [diff] [review]:
-----------------------------------------------------------------
r=me with "role" changed to "origin".
Thanks!
::: browser/components/extensions/ext-tabs.js
@@ +844,4 @@
> } else {
> options.run_at = "document_idle";
> }
> + if (details.role !== null) {
This CSS spec calls this the origin, not the role:
https://www.w3.org/TR/CSS2/cascade.html#cascade
Attachment #8821688 -
Flags: review?(kmaglione+bmo) → review+
Assignee | ||
Comment 16•8 years ago
|
||
Please see the previous discussion, I don't think origin is a good name to use.
Comment 17•8 years ago
|
||
I'm still not comfortable defining a whole new term for this, when one already exists in the spec... How about something like "originRole"?
Assignee | ||
Comment 18•8 years ago
|
||
We agreed to cssOrigin on IRC.
Comment 19•8 years ago
|
||
Pushed by evilpies@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/68402c8f7fd2
webext: Add cssOrigin option to insertCSS/removeCSS. r=kmag
Comment 20•8 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 8 years ago
status-firefox53:
--- → fixed
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
Comment 21•8 years ago
|
||
I've added this here: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/insertCSS
Let me know if this covers it.
Flags: needinfo?(evilpies)
Assignee | ||
Comment 22•8 years ago
|
||
The text looks good. don't forget to add a new row to the compatibility table and update https://developer.mozilla.org/en-US/Firefox/Releases/53.
Flags: needinfo?(evilpies)
Updated•8 years ago
|
Keywords: dev-doc-needed → dev-doc-complete
Comment 23•8 years ago
|
||
Hey, IIUC the cssOrigin arguments should also be added to https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/removeCSS and maybe https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/extensionTypes/InjectDetails (indicating it's specific to *CSS functions)?
Flags: needinfo?(wbamberg)
Comment 24•8 years ago
|
||
I'm using this on https://addons.mozilla.org/en-US/developers/addon/no-transition but it doesn't really works.
I do somethings like that (all the code is on https://github.com/gagarine/no-transition) :
const CSS = `
body * {
/*CSS transition*/
transition: none !important;
/*CSS animations*/
animation: none !important;
}
`;
browser.tabs.insertCSS(tab.id, { code: CSS, cssOrigin: 'user' });
I can overwrite almost all animation, but not all. It seem !important is not taken in account and cssOrigin: 'user' doesn't mean it can't be overwrite.
For example on https://www.zuerich.com/en the "more" button is still changing his with an animation.
Comment 25•7 years ago
|
||
> the cssOrigin arguments should also be added to...
Sorry to be so slow on this. This is done (not by me...)
Flags: needinfo?(wbamberg)
Updated•7 years ago
|
Product: Toolkit → WebExtensions
You need to log in
before you can comment on or make changes to this bug.
Description
•