Re: [css-syntax, ideas-needed] Merge/inherit lists of values.

On Tue, Apr 10, 2012 at 2:55 PM, L. David Baron <dbaron@dbaron.org> wrote:
>
> On Tuesday 2012-04-10 14:44 -0700, Andrew Fedoniouk wrote:
> > used value of background-image-transformation will be this:
> >
> >    background-image-transformation: gamma(1.4) flip-x();
> >
> > I suspect that for implementation of such inheritance some change on
> > CSS grammar/syntax level is required.
> >
> > I am thinking about something like !inherit modifier:
> >
> > div:dir(rtl) {
> >    background-image-transformation: flip-x() !inherit;
> > }
>
> But this isn't about inheritance at all: this is about handling of
> multiple rules applying to the same element (cascading) rather than
> propagation of computed values from ancestor to descendant
> (inheritance).

That is debatable of course.
"In classical inheritance ... classes can inherit attributes and behavior..."
src: http://en.wikipedia.org/wiki/Inheritance_(computer_science)

Process of applying multiple matching rules can be seen as runtime or
dynamic or prototype inheritance - final/used style is a set of
properties and values
 inherited from all matched rules in order of selector specificity.

But the term does not matter indeed as soon as concept is clear.

>
>
> We've previously discussed this sort of thing a few times under the
> name "additive cascade", though never really come to any conclusion.

Yeah, I can imagine.

If to treat the process as a "dynamic inheritance" :) then I think
problem can be solved relatively easy:

Let's say we have !inherit or !combine modifier.

We start cascade from empty set of properties  F that at the end will
contain final set of properties.
For each rule R in specificity order and property P defined in it we
apply following steps while doing cascade:

1. If either F.P or R.P has !combine modifier then the value of
property P will be:
  F.P = F.P + R.P
2. If either F.P or R.P has !combine modifier then property
   value F.P will have (keep or gain) !combine modifier too.

Problem here is that once used the !combine cannot be removed.
But I am not sure is this problem at all.


>
> > I suspect that such inheritance feature could be useful for any other
> > properties that accept lists of values. For example 'background'
> > property that accepts lists of image definitions. In some cases
> > it could be useful to combine two or more such list rather than
> > to just override by heaviest rule.
>
> Also counter-* and a few other things.
>
> -David
>
> --
> 𝄞   L. David Baron                         http://dbaron.org/   𝄂
> 𝄢   Mozilla                           http://www.mozilla.org/   𝄂

--
Andrew Fedoniouk.

http://terrainformatica.com

Received on Tuesday, 10 April 2012 22:35:04 UTC