Re: [css-values] Adding a <length-percentage> production

On Thu, 10 Dec 2015 20:05:33 +0100, Tab Atkins Jr. <jackalmage@gmail.com>  
wrote:

> At TPAC, in the unofficial Houdini meetup on Thursday, we realized
> that our property grammars were kinda ambiguous, and that was
> troublesome for the Custom Properties API.  In particular, when you
> see a grammar like "<length> | <percentage>", it's not clear whether
> the <percentage> is a distinct type, or a length-equivalent type.
> This is an important distinction, because the latter allows `calc(5px
> + 10%)`, but the former does not.  CSS has examples of both: most
> instances are the latter, but 'word-spacing' is the former, and
> 'background-position' is *technically* the former, but we hack things
> around to make it work like the latter anyway.  CSS currently resolves
> the ambiguity with prose (the "Percentages" line in the
>
> The solution we hit on in the meeting was to define a new grammar
> non-terminal, <length-percentage>, that indicates the
> "length-equivalent" percentage case.  This also simplifies grammars -
> I've always been slightly, vaguely annoyed at the clumsiness that "[
> <length> | <percentage> ]" introduces into my grammars, and this
> simplifies things a bit.
>
> We'll need similar non-terminals for the other base types: frequence,
> angle, time, and number.  I don't think we need a non-terminal for the
> length-percentage-number triplet that line-height uses - that "number"
> case probably should really have been a new unit that was a
> used-value-time 'em'.
>
> So, I plan to add these to V&U. Specs can gradually adopt it - the
> current grammars are non-ambiguous due to the accompanying prose.
> This is just an attempt to slightly simplify CSS, and make sure that
> Houdini and CSS grow together.
>
> Thoughts?

I support this. I think would be good to have the Houdini value grammar be  
a strict subset of the full CSS value grammar, and this is a step in that  
direction.

-- 
Simon Pieters
Opera Software

Received on Friday, 18 December 2015 09:27:57 UTC