W3C home > Mailing lists > Public > www-style@w3.org > April 2000

Re: eval()

From: Matthew Brealey <webmaster@richinstyle.com>
Date: Wed, 19 Apr 2000 13:44:37 -0700
Message-ID: <38FE1AB5.19C2@richinstyle.com>
To: Daniel.Glazman@polytechnique.org
CC: www-style@w3.org
Daniel Glazman wrote:
> 
> Matthew Brealey wrote:
> 
> > There has been some talk of using the value of attributes as the value
> > of another attributes and similar such things, and I think the best way
> > to do this would be by means of an eval() function, since, for example,
> > attr(size)+1px clearly isn't right, and (attr(size)+1)px isn't really
> 
> Size ? Value ?

Sorry. I was referring to the (relatively) recent thread on HR and its
size attribute, and in particular the fact that the 'height' is actually
one pixel less than the value of the size attribute.

> > satisfactory. Therefore I propose that eval() be used wherever an author
> > wishes to mainpulate a value or get the value of a property to use as
> > the value of another property. For example, HR {height:
> > eval(attr(size)-1)px}. This is preferable to what is proposed, namely
> 
> I still don't know what this size is or what "a value" is for
> you. But let's imagine that this size contains a length.
> What is exactly the value of attr(size) and which unit is it
> using ? 12cm for instance ? What is "12cm-1" ? And "12cm-1" px ?

Yes, it's pixels, as I'm sure you'll see now I've made it clear what I'm
talking about.

Since the value is an integer (in pixels) rather than (say) 12cm, the
issue of 12cm-1 doesn't arise - we have one integer minus another.

I don't think the issue you point out would ever arise, simply because
attributes in HTML don't take dimensions.

> > only allowing this on an arbitrary subset of properties (viz. access-key
> > and tab-index), and has greater flexibility.
> >
> > On a separate but related subject, I think there should be a change to
> > the attr() function. At present, given, for example, <p>Hello, then P
> > {content: attr(title)} would result in P being rendered as empty, but I
> 
> Invalid rule... For the moment, content property does not apply to a P,
> does it ?

Yes, I know. I'm talking at the moment as being under CSS3; i.e., under
the UI WD, which redefines content so that this is ok.
 
> > suggest that when attr() returns a null value, the declaration is
> > invalid and should be ignored. The reason for this is to allow things
> > like:
> >
> > A[href]:tooltip:hover {visibility: visible;
> > content: attr(href);
> > content: attr(title)}
> >
> > , which provides a tooltip with the value of 'title' as its content, but
> > if that returns null, then the href would be the value.
> 
> Ah! Interesting, very interesting. **BUT** making the rule invalid
> does not help at all because error handling in CSS is done at parsing,
> not at evaluation time !

Good point. 

Incidentally your point is significant for using values of attributes in
general, since something like ELEMENT {background: white; background:
eval(attr(bgcolor))} would be valid, but it might subsequently turn out
that in fact the author had specified an invalid colour (or for other
attributes a multilength or other HTML-specific concept).

One could change this of course, so that the UA effectively validates
twice, and therefore the UA is required when it encounters a
declaration, either of the type eval() that might turn out to be invalid
or of type that could return a null value, to remember the previous
declaration. For example, if there was BODY {background:  white;
background: eval(attr(bgcolor)) in the UA style sheet, then the UA would
say 'Aha! This might not be valid, I'd best not forget my earlier
declaration'.
 
> Can I ask you a question which is not connected at all with your message ?
> Where do you find the time to produce so long messages ??? I hardly
> find the time to read them !-)

By working too hard.

------------------------------------------------------------------
Please visit RichInStyle com.
If it's style-related, it's here. And now:
MySite v2 - offer your users a choice between predefined styles or
they can create their own, with control over font sizes, colors,
background colors, background images, borders, margins, line heights,
add a custom style rule, font faces, link underlining, etc.

Download now FREE: http://richinstyle.com/free/mysite.html.
Received on Wednesday, 19 April 2000 08:40:21 GMT

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