W3C home > Mailing lists > Public > www-style@w3.org > July 2013

Re: [cssom] Proposal for obtaining robust style information via Javascript - getStyle()

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 3 Jul 2013 12:41:42 -0700
Message-ID: <CAAWBYDCGY264KBSbi70aZAu3mC4SCEOCDQF1j6bPSVJa8yk0Ng@mail.gmail.com>
To: Simon Pieters <simonp@opera.com>
Cc: "www-style@w3.org" <www-style@w3.org>, Mike Sherov <mike.sherov@gmail.com>
On Tue, May 7, 2013 at 2:56 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> On Tue, May 7, 2013 at 2:26 PM, Simon Pieters <simonp@opera.com> wrote:
>> On Tue, 07 May 2013 18:47:20 +0200, Tab Atkins Jr. <jackalmage@gmail.com>
>> wrote:
>>> On Tue, May 7, 2013 at 8:33 AM, Simon Pieters <simonp@opera.com> wrote:
>>>>
>>>> The spec currently has getComputedStyle which returns "resolved value"
>>>> which
>>>> can be computed style or used style.
>>>>
>>>> Recently I added a method getDefaultComputedStyle which returns the
>>>> computed
>>>> value but ignores author CSS.
>>>>
>>>> The use case presented above asks for specified style. Are there use
>>>> cases
>>>> for the other kinds of values? Would cascaded value instead of specified
>>>> value be better (i.e. return 'initial', 'inherit' and 'default' instead
>>>> of
>>>> specified value)?
>>>
>>>
>>> There's definitely use-cases for always getting used styles, due to
>>> them being "close enough" to the final values used in rendering.  For
>>> example, see the Grid spec, which is currently trying to specify that
>>> getComputedStyle() must return used values for its grid-definition-*
>>> properties.
>>
>>
>> Thanks. However, the grid spec doesn't state use cases for getting used
>> value, as far as I can tell. If it is documented somewhere else, please give
>> a pointer.
>
> The use-case is figuring out how wide your tracks actually ended up,
> after the grid layout algorithm was run, so you can, for example,
> position abspos things around it, size canvases, etc.

Talking this over with fantasai on Monday, we've come to the
conclusion that it's probably not a good idea to expose .usedStyle at
this point, for two reasons:

1. Not all properties *have* a used style.  If a property doesn't
apply to an element, we don't define what the used value is.  You
could just say that it's the same as the computed value in that case,
but that's just filling in a hole with something meaningless; there's
still not really any concept of "used value" for the property.

2. We can do *so much better* at used-value time. At that point we
have all the necessary information to expose lengths in *any* unit you
ask for, rather than just px.

Because of this, fantasai and I think we should hold on doing
.usedStyle, in favor of pursuing the long-discussed idea of the Values
API, which allows asking rules for their values in various units.

~TJ
Received on Wednesday, 3 July 2013 19:42:29 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:32 UTC