Re: [css3-values] use cases and the design of 'cycle()'

On Tuesday 2012-04-10 02:11 +0800, Kang-Hao (Kenny) Lu wrote:
> While reviewing CSS3 V&U, I realized that 'cycle()' doesn't really solve
> a use case I thought it would solve.
> 
> Use Case A: In a User Interface built by nesting elements (say,
> <table>), set background color on the elements alternatively along the
> nesting level. See picture[1]

Yes, it doesn't solve this case alone.  (I've also never seen any
other examples of this case.)

It does solve this case in combination with variables, though, and
I think that's a better solution than making cycle() more complex.

For example:

  table {
    var-cycling-background: cycle(white, gray);
    background: var(cycling-background);
  }

> I would guess that my use case is more common than
> 
> Use Case B (example 16): make an element italic, but make it normal if
> it's inside something that's italic.
> 
> though I can't quite prove it. Perhaps Use Case A is really not very
> common. In any case, I believe they are both certainly more common than

This is the standard typographical convention for emphasis within
already-italicized text.

> Proposal A: For non-inheritable properties, define the inherited value I
> as the nearest non-initial computed value of an ancestor element. Make
> no change to the inherited value I for inheritable properties.
> 
> Proposal B: 'cycle()' works as if there's an anonymous counter for each
> declaration with a 'cycle()', which is incremented when entering
> elements where that declaration applies and wins and decremented when
> leaving such elements. 'cycle()' returns the value corresponding to the
> value of the counter. (Some details about what 'a declaration' is
> missing for the moment.)
> 
> I prefer Proposal B, and here some advantages and disadvantages:

I prefer suggesting that authors use variables in combination with
cycle() to address these cases, since that keeps the cycle() feature
substantially simpler.

-David

-- 
𝄞   L. David Baron                         http://dbaron.org/   𝄂
𝄢   Mozilla                           http://www.mozilla.org/   𝄂

Received on Wednesday, 25 April 2012 15:53:03 UTC