Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[mdt-papyrus.dev] CSS Rules & Cascading Priorities

Hi all,

 

 

Here’s an important notice for everyone making strong usage of Stylesheets in Papyrus. The following task has been reported and completed in master/Mars:

 

451104: [CSS] Support Author/User/User Agent stylesheets

https://bugs.eclipse.org/bugs/show_bug.cgi?id=451104

 

According to the W3C CSS specification [1], different stylesheets should have different priorities/weight, depending on “who” contributed them:

 

-          “USER_AGENT” stylesheets have a low priority

o   In the HTML world, the User Agent is the browser. In Papyrus, it corresponds to the default values provided for UML elements (i.e. the hidden base.css stylesheet)

-          “USER” stylesheets have a medium priority

o   In Papyrus, this corresponds to the current workspace Theme (Which can be selected/changed by each user)

-          “AUTHOR” stylesheets have a high priority

o   In Papyrus, this corresponds to all other stylesheets: Project, Model, Diagram

 

When two stylesheets have the same “Cascading scope”, the former priority mechanism is used (i.e. rules are sorted by complexity (“specificity”)), as described in [2]. When two rules have the same Scope and Specificity, the order of the rules is taken into account.

 

This should make life simpler for Stylesheet developers (And allow us to improve the customizability of diagrams Papyrus Mars), but please be aware that this will affect existing Stylesheets and Models. You may need to tweak (a little bit) your existing stylesheets to avoid regressions/behavior changes.

 

Also, we currently have a single “USER_AGENT” stylesheet. If this makes sense, we may provide an extension point for contributing new user agent stylesheets (e.g. for profile-specific styles). Currently, Profile-specific stylesheets are contributed as CSS Themes (“USER” scope, medium prority), which means that a user can disable them, and must be careful about the Theme he picks (If the profile doesn’t contribute to a user-specific Theme, then the rules are not applied). The problem is that, since USER_AGENT stylesheets have a very low priority, they will be easily overridden by the User Theme anyway. So… I’m not sure this is really a good idea. If you use such a Stylesheet (or have a similar use case), please comment!

 

 

Regards,

Camille

 

[1] http://www.w3.org/TR/CSS2/cascade.html#cascade

[2] http://www.w3.org/TR/CSS2/cascade.html#specificity

 

 


Back to the top