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

Re: [cssom] CSS Value API

From: Brad Kemper <brad.kemper@gmail.com>
Date: Thu, 22 Apr 2010 10:56:34 -0700
Cc: Anne van Kesteren <annevk@opera.com>, Boris Zbarsky <bzbarsky@mit.edu>, Fran??ois REMY <fremycompany_pub@yahoo.fr>, www-style@w3.org
Message-Id: <B8393CFE-BFC2-4842-8304-8369080D181E@gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>

On Apr 22, 2010, at 10:23 AM, Tab Atkins Jr. wrote:

> It matters very much which space the specified value is in.  This is
> unambiguous in normal CSS, because it's defined simply by whatever
> unit you use to specify the value.  But this new get/set method makes
> it ambiguous.  If you specify a width in %s, then say width.px++, what
> happens?  Does it convert it to an equivalent value in % space?  Does
> it switch it to absolute space?  

These are the questions. My answer was to convert to the absolute space on the get to add the px, then convert back to % to set.

> Does it mix the two, implicitly
> creating a calc() expression?  

That is what Fremy seemed to ask for, but I didn't think it would be appropriate to change the "space" just to add a pixel. But maybe. Either would be better than throwing an error, I feel.

> What if you then say width.em++?  What
> about more complex values, such as if we introduce a flex unit and I
> say width.flex++?  Does it even make *sense* to talk about converting
> between flexes?

That just makes my head hurt. 

> There are multiple ways to approach this, but we need to settle on a
> definite way.


>> If you actually wanted to go further and change the margin-top to a calc value, you would instead do something like this:
>> style.margin.m.top.calc.px++
>> Then, if the margin-top in the example would become "calc(15%+1px)", and in a different example where margin-top already had a calc value, then it would become "calc((<previous-formula>)+1px)". If you wanted to convert a value to calc when getting it (for whatever strange reason), you could do that like this:
>> style.margin.m.top.calc // --> "calc(15%)" in the first example
> Making calc()ing an explicit option would be pretty cool, but let's
> solve the base problem first.  ^_^

True enough, but it is something to keep in mind while solving the base problem. Especially if we are considering setting a value to 'calc()' as the result of incrementing a pixel value on a percentage. Which I don't think is the best way as long as we are going to allow calc values to be got and set explicitly.

Received on Thursday, 22 April 2010 17:57:14 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:07:45 UTC