Last Comment Bug 363250 - implement toggle() expression
: implement toggle() expression
Status: NEW
: dev-doc-needed
Product: Core
Classification: Components
Component: CSS Parsing and Computation (show other bugs)
: Trunk
: All All
: -- normal with 21 votes (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
Mentors:
http://dev.w3.org/csswg/css-values/#t...
: 864009 1001365 (view as bug list)
Depends on: 332335
Blocks: 119753 177496 css3-values css3test
  Show dependency treegraph
 
Reported: 2006-12-08 22:31 PST by David Baron :dbaron: ⌚️UTC+2 (review requests must explain patch)
Modified: 2014-05-20 06:05 PDT (History)
27 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments

Description David Baron :dbaron: ⌚️UTC+2 (review requests must explain patch) 2006-12-08 22:31:55 PST
We should implement -moz-cycle() as described in:

http://lists.w3.org/Archives/Public/www-style/1999May/0067
http://lists.w3.org/Archives/Public/www-style/1999Jun/0026
http://lists.w3.org/Archives/Member/w3c-css-wg/2006JanMar/0310


The last of those messages is member-confidential, but since I wrote it, the entire contents are the following:

I'd like to resurrect an old proposal for addition to css3-values [1]:
  http://lists.w3.org/Archives/Public/www-style/1999May/0067
  http://lists.w3.org/Archives/Public/www-style/1999Jun/0026
This is particularly useful for styling HTML's UL and EM elements.

Proposed text that could be used in the specification is the following:

=====

The cycle() expression allows descendant elements to cycle over a list
of values instead of inheriting the same value.  The syntax of the
cycle() expression is:

  cycle( <value> [, <value> ]*)

where <value> is a CSS value that is valid where the expression is
placed.  If any of the values inside are not valid, then the entire
cycle() expression is invalid.

The value returned by cycle() must be determined by comparing the
inherited value I (the computed value on the parent, or, for the root,
the initial value) to the computed values C[n] returned by the n-th
argument to cycle().  For the earliest C[n] such that C[n] == I, the
value returned by cycle is C[n+1].  However, if this C[n] is the last
value, or if there are no C[n] that equal I, the computed value of the
first value is returned instead.

Example 1:

  /* make em elements italic, but make them normal if they're inside
     something that's italic */
  em { font-style: cycle(italic, normal); }

Example 2:

  /* cycle between markers for nested lists, so that the top level has
     disk markers, but nested lists use circle, square, box, and then
     (for the 5th list deep) repeat */
  ul { list-style-type: disk; }
  li > ul { list-style-type: cycle(disk, circle, square, box); }

=====

It could also be used in other interesting ways -- probably some bizarre
ones that I haven't even thought of yet.  Although I admit I have
already thought of:
  list-style-type: cycle(cycle(disc,disc,circle,circle), cycle(disc,circle),
                         cycle(square,square,box,box), cycle(square,box));
Understanding this is left as an exercise to the reader.

-David
Comment 1 Jesse Ruderman 2006-12-09 17:43:03 PST
The last example hurts my brain.
Comment 2 d 2010-01-23 11:12:40 PST
This is very interesting, and while it probably has missed the CSS3 spec now, have you considered proposing it for CSS4?
Comment 3 David Baron :dbaron: ⌚️UTC+2 (review requests must explain patch) 2010-01-23 11:28:15 PST
The working group agreed to add it to css3-values; it just hasn't been added.
Comment 4 d 2010-04-12 06:22:39 PDT
Perhaps they need a reminder :-) When was it discussed?
Comment 5 David Baron :dbaron: ⌚️UTC+2 (review requests must explain patch) 2013-04-20 10:12:37 PDT
This was renamed from cycle() to toggle().
Comment 6 David Baron :dbaron: ⌚️UTC+2 (review requests must explain patch) 2013-04-20 10:12:59 PDT
*** Bug 864009 has been marked as a duplicate of this bug. ***
Comment 7 :Gijs Kruitbosch (Gone July 28 - Aug 11) 2014-04-25 04:05:30 PDT
*** Bug 1001365 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.