W3C home > Mailing lists > Public > www-style@w3.org > May 1999

Re: CSS3: font-style

From: Ian Hickson <py8ieh@bath.ac.uk>
Date: Wed, 26 May 1999 10:48:27 +0100 (BST)
To: "L. David Baron" <dbaron@fas.harvard.edu>
cc: www-style@w3.org
Message-ID: <Pine.GSO.4.04.9905261014280.23683-100000@amos.bath.ac.uk>
On Tue, 25 May 1999, L. David Baron wrote:

> One could even have a more general syntax for this called, say, a
> property selector. It would be able to do alternation and other
> things.

Sounds good, but when it comes to the cascade affecting the cascade, I
am very, very wary...


> You could *not* use such a selector on the subject [1] of the
> selector (just like pseudo-elements can't go anywhere other than the
> subject of the selector) because it could create infinite loops. It
> would also create infinite loops with parent selectors, if they were
> ever used.

   (font-style:normal) * { font-style:italic; }
   (font-style:italic) * { font-style:normal; }
   :matches(* (font-style:italic)) { font-style: italic; } /* [1] */

Yeah, that would be dodgy too.


> There also are probably some other theoretical problems with it that
> I can't think of right now. It would be neat, though.

It would be neat, but as you say, there are probably some problems.
Can't think of what they are, though.


> What I don't know is whether it would be too hard to implement (too
> slow) in a current cascading engine.

This, I believe, is the main problem with the suggestion.

Take the following _very simple_ document:

   <html:style type="text/css">
      (font-weight=normal) a { font-weight: bold; }
      (font-weight=bold) a { font-weight: normal; }
   </html:style>

   <a> 1
    <a> 2
     <a> 3 <!-- resolve for this element -->
     </a>
    </a>
   </a>

Imagine you wanted to resolve the style context for element 3. There
are only two rules, and only four (five) elements in the DOM. It
should not be very difficult. Lets see:

   Find rules that match.
   Rule 1: Is there a parent element with font-weight:normal?
           Must check all elements. Begin with outermost:
           1. Is it normal? Must resolve style context.
              Rule 1: Cannot be true, no parents.
              Rule 2: Cannot be true, no parents.
              No rules apply; Inheritance? No parents.
              Hence, Actual Value = Initial Value = normal.
           Hence there _is_ a parent with font-weight:normal.
           First rule applies.
   Rule 2: Is there a parent element with font-weight:bold?
           Must check all elements. Begin with outermost:
           1. Is it bold? Must resolve style context.
              Rule 1: Cannot be true, no parents.
              Rule 2: Cannot be true, no parents.
              No rules apply; Inheritance? No parents.
              Hence, Actual Value = Initial Value = normal.
              Does not contribute.
           2. Is it bold? Must resolve style context.
              Rule 1: Is there a parent element with font-weight:normal?
                      Must check all elements. Begin with outermost:
                      1. Is it normal? Must resolve style context.
                         Rule 1: Cannot be true, no parents. 
                         Rule 2: Cannot be true, no parents.
                         No rules apply; Inheritance? No parents.
                         Hence, Actual Value = Initial Value = normal.
                      Hence there _is_ a parent with
                      font-weight:normal. First rule applies.
              Rule 2: Is there a parent element with font-weight:bold?
                      Must check all elements. Begin with outermost:
                      1. Is it bold? Must resolve style context.
                         Rule 1: Cannot be true, no parents. 
                         Rule 2: Cannot be true, no parents.
                         No rules apply; Inheritance? No parents.
                         Hence, Actual Value = Initial Value = normal.
                         Does not contribute.
                      Hence there are no parent elements with
                      font-weight:bold. Second rule doesn't apply.
              Only one rule applies. Therefore second element is
              bold. 
           Hence there _is_ an element with font-weight:bold. Second
           rule applies also.
   More than one rule:
      Sort by weight&origin. Only one weight&origin.
      Sort by specificity. Only one specificity.
      Sort by order specified.
      Applicable declarations now are:
         font-weight:bold
         font-weight:normal
   Hence font-weight:normal applies.


Now imagine that multiplied thousand fold for only small real-world
documents, and million fold for large, complex documents.
 
-- 
Ian Hickson 
U+2642 U+2651
U+262E U+2603 U+263A
Received on Wednesday, 26 May 1999 05:48:33 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:53:59 GMT