RE CSS: inheriting styles in the OO sense (was: Are more font variants in the pipeline?)

David Grieve david.grieve at oracle.com
Thu Aug 23 15:17:52 PDT 2012


I agree wholeheartedly that we don't want to introduce things that are not in the standard.
You are correct that this concept is not in CSS nor in CSS Selectors 4 draft. My suggestion was that this concept could be proposed to the working committee for inclusion in the draft. 

On Aug 23, 2012, at 5:49 PM, Pedro Duque Vieira wrote:

> Sorry I forgot to put the subject. Apoligies for sending a duplicate mail.
> 
> Hi,
> 
> I don't think the idea is bad but it doesn't exist in the CSS universe. And
> if you want to conform to the W3C CSS as is the objective as was mentioned
> sometime ago in this mailing list than you don't want to introduce things
> that are not present on the standard.
> 
> I haven't seen any mention on this kind of inheritance on the  CSS
> Selectors 4 draft. Have I missed it?
> 
> Thanks, best regards,
> 
> 
>> Not a bad idea. Certainly the idea has merit and there is a W3C working
>> draft on CSS Selectors 4 so maybe this could be proposed.
>> 
>> For JavaFX purposes, it might be possible to use a functional
>> pseudo-element to accomplish this:
>> 
>> .my-specific-label-style::-fx-
>> inherit(.my-base-label-style) { ? }
>> 
>> The function syntax could allow multiple args for your multiple
>> inheritance. Declarations would be copied from the inherited rules in the
>> order given in the args (thus, later declarations override earlier ones)
>> but coming before the declarations in the child rule.
>> 
>> As an alternative, it would be fairly straight forward to pre-process a
>> file with suitable "extends" syntax and generate a new file with all of the
>> "inherited" declarations rolled into the normalized selector that would be
>> parseable by standard CSS syntax.
>> 
>> It never hurts to create a feature request so ideas like these aren't lost.
>> 
>> On Aug 23, 2012, at 9:19 AM, Daniel Zwolenski wrote:
>> 
>>> This is maybe a good opening to ask what the thoughts would be on adding
>> some stuff beyond web-css, in particular "inheritance" (in the OO sense,
>> not the containment sense that CSS already supports).
>>> 
>>> So if I have a base style like:
>>> 
>>>   .my-base-label-style {
>>>       -fx-font: 15px "Open Sans";
>>>       -fx-background-color: red;
>>>   }
>>> 
>>> Then we have specific instances that then extend this, and override as
>> needed:
>>> 
>>>   .my-specific-label-style extends my-base-label-style {
>>>       -fx-border: 1px solid green;
>>>       -fx-background-color: red;
>>>   }
>>> 
>>> (syntax used is for descriptive purposes only, not a suggestion).
>>> 
>>> So the resulting styles would be the merged set of these two (with the
>> base class overriding the parent class styles).
>>> 
>>> This would mean we could avoid adding both styles in the code, and just
>> add the actual specific class (which implies the base class), which means
>> styling is kept nicely in the stylesheet. If I want to change my button to
>> not use the base class, that's a CSS change, not a code change.
>>> 
>>> Multiple inheritance would be bonus points (where each 'extends'
>> overrides the last).
>>> 
>>> I don't know the ramifications of doing this and if it is possible in
>> the JFX implementation. I just know this type of usage is something I have
>> often wanted and wondered about.
>>> 
>>> If 'extends' style doesn't work, what about an -fx-base-class attribute:
>>> 
>>>   .my-specific-label-style  {
>>>       -fx-base-class:  my-base-label-style1, my-base-label-style2;
>>>       -fx-border: 1px solid green;
>>>       -fx-background-color: red;
>>>   }
>>> 
>>> Bad idea?
>>> 
>>> 
>> 
> 
> -- 
> Pedro Duque Vieira


David Grieve | Principal Member of Technical Staff
Mobile: +16033121013 
Oracle Java Client UI and Tools
Durham, NH 03824 
 Oracle is committed to developing practices and products that help protect the environment



More information about the openjfx-dev mailing list