Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Investigate switching from AGENT to AUTHOR stylesheet registration #78

Closed
JasonBarnabe opened this issue Dec 26, 2012 · 7 comments
Closed

Comments

@JasonBarnabe
Copy link
Contributor

Added in https://bugzilla.mozilla.org/show_bug.cgi?id=676054

@stanio
Copy link

stanio commented Dec 26, 2012

It should actually be AUTHOR sheet. I've tried the following works for me (no more !important declarations necessary) with Firefox 19:

diff -r 1d91a3971d2a stylish-firefox/components/stylishStyle.js
--- a/stylish-firefox/components/stylishStyle.js    Sat Dec 01 17:50:43 2012 -0600
+++ b/stylish-firefox/components/stylishStyle.js    Thu Dec 27 00:21:44 2012 +0200
@@ -665,26 +665,26 @@
    register: function() {
        if (!this.stylishOn) {
            return;
        }
        var dataUrl = this.dataUrl;
        if (!dataUrl)
            return;
        this.appliedUrl = dataUrl;
-       this.sss.loadAndRegisterSheet(this.appliedUrl, this.sss.AGENT_SHEET);
+       this.sss.loadAndRegisterSheet(this.appliedUrl, this.sss.AUTHOR_SHEET || this.sss.AGENT_SHEET);
    },

    unregister: function() {
        var unregisterUrl = this.shouldUnregisterOnLoad() ? this.dataUrl : this.appliedUrl;
        if (unregisterUrl == null) {
            return;
        }
-       if (this.sss.sheetRegistered(unregisterUrl, this.sss.AGENT_SHEET))
-           this.sss.unregisterSheet(unregisterUrl, this.sss.AGENT_SHEET);
+       if (this.sss.sheetRegistered(unregisterUrl, this.sss.AUTHOR_SHEET || this.sss.AGENT_SHEET))
+           this.sss.unregisterSheet(unregisterUrl, this.sss.AUTHOR_SHEET || this.sss.AGENT_SHEET);
        // ignore unregistered styles if stylish isn't on
        else if (this.stylishOn)
            Components.utils.reportError("Stylesheet is supposed to be unregistered, but it's not registered in the first place.");
        this.appliedUrl = null;
    },

    bind: function(statement, name, value) {
        var index;

The given form appears backwards compatible, also.

@stanio
Copy link

stanio commented Apr 6, 2013

Now that Firefox 20 has been released and the necessary Mozilla feature has been in place for two public versions, do you think you could make a release using the new feature? I think it will enable creating styles customizing existing sites (and other content) much easier.

@JasonBarnabe
Copy link
Contributor Author

Stylish for Firefox currently uses the AGENT sheet type. This has the benefit of being able to style things that other types can't, like scrollbars. As you mention, the downside is that you need !important otherwise you'll get beat by author sheets.

Stylish used to use USER sheet type. This is arguably the correct type, as in it's what something like Stylish should do according to the spec. This can't style scrollbars, and also has the disadvantage of needing !important.

You're proposing the AUTHOR sheet type. This also can't style scrollbars, but would not require !important in all cases (depending on the specificity). It would also match the behaviour on Chrome and Opera.

There's some discussion of all this in http://forum.userstyles.org/discussion/36136/my-style-works-perfectly-in-chrome-but-not-in-firefox . One of the proposals is to switch the type depending on the content of the CSS. I'm not sure if this would be good or be adding a magical complication to everything.

@JasonBarnabe
Copy link
Contributor Author

More discussion at https://bugzilla.mozilla.org/show_bug.cgi?id=541506

@stanio
Copy link

stanio commented Dec 1, 2013

Do you think adding a setting to use AUTHOR instead AGENT (default) per style (for example, a check-box in the "Editing" window) would be acceptable?

@JasonBarnabe
Copy link
Contributor Author

5265cbe

Users can include /* AGENT_SHEET */ in their style which will do what you expect. Absence of this will make it use AUTHOR_SHEET. See the linked tickets for some consequences of this.

@JasonBarnabe
Copy link
Contributor Author

0a56d3e

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants