W3C home > Mailing lists > Public > www-style@w3.org > February 2016

Re: [css-values] Comments on Serialization of calc

From: L. David Baron <dbaron@dbaron.org>
Date: Wed, 17 Feb 2016 19:02:22 -0800
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: Francois Remy <frremy@microsoft.com>, CSS WG <www-style@w3.org>
Message-ID: <20160218030222.GA31132@pescadero.dbaron.org>
On Wednesday 2016-02-17 15:48 -0800, Tab Atkins Jr. wrote:
> On Wed, Feb 17, 2016 at 11:39 AM, Francois Remy <frremy@microsoft.com> wrote:
> > Hi Tab, Fantasai,
> >
> > Here are a few comments regarding the "calc" serialization section I just reviewed:
> > https://drafts.csswg.org/css-values-3/#calc-serialize
> >
> >
> > ----[0] Thanks for looking into this, you rock, as always!
> >
> >
> > ----[1] I am not confident with the "compatible units" notion, mostly because it isn't defined anywhere (except by example). It is not clear, for instance, what calc(100vw - 20px) resolves to at specified time. Technically, the viewport width does not depend on the element this value is applied on, but at the same time it may vary which would somehow require to keep the values separate to provide the right result over time. It is also not clear to me what happens if we have calc(1cm + 1mm) vs calc(1mm + 1cm). The units are compatible, but which one should we keep? Does order matter?
> 
> It probably does need to be expanded on, but it's the same concept of
> "absolutization" that transforms em into px at computed-value time.

But it seems wrong to apply a computed-value type of process to a
specified value.

Perhaps what should be combined are *identical* units?  Then, for
computed values, many units will have been converted to identical
units, but for specified values, they won't be.

> > ----[2] I have no opinion on the clamping of values at step 2 of the algorithm you want to add. For me it looks fine to drop this step altogether and just serialize "calc(<value>)" whatever <value> is, but I understand some browsers might want to simplify it as soon as possible in order to save memory. This is such an edge case I doubt it is really worth it, though.
> 
> Yeah, this step is based on browsers' current behavior. I'd prefer to
> drop it if specifying fresh.

Gecko and Chromium don't do this.  Testcase:

<!DOCTYPE html>
<p style="margin-left: calc(3px)">
<script>
document.write(document.getElementsByTagName("p")[0].style.marginLeft);
</script>

or
http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Cp%20style%3D%22margin-left%3A%20calc(3px)%22%3E%3C%2Fp%3E%0A%3Cscript%3E%0Adocument.write(document.getElementsByTagName(%22p%22)%5B0%5D.style.marginLeft)%3B%0A%3C%2Fscript%3E

Perhaps what you were observing was part of the calc *computation*
process rather than the calc *serialization* process?

-David

-- 
𝄞   L. David Baron                         http://dbaron.org/   𝄂
𝄢   Mozilla                          https://www.mozilla.org/   𝄂
             Before I built a wall I'd ask to know
             What I was walling in or walling out,
             And to whom I was like to give offense.
               - Robert Frost, Mending Wall (1914)

Received on Thursday, 18 February 2016 03:02:52 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:09:00 UTC