This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
It would be very useful to clamp the contents of a sequence: [Clamp] sequence<unsigned long> We ran into the need for this in the Vibration API, where clamping of the contents of a vibration pattern would be more appropriate.
If you do not mean sequence<[Clamp] unsigned long>, could you please elaborate on what you are proposing here?
Hi Anne, not sure whether the syntax is the one I posted or the one you posted. But the idea is to clamp the values in the sequence.
Right, that should already work with the syntax I posted.
The spec doesn't allow that currently though, right? [Clamp] goes on things like attributes, operation argument, etc.
Oh really? I guess it's only allowed at a syntax level then. Seems like that always ought to work though. E.g. if we have "[Test] DOMString" it should work regardless of context.
Anne, it's tempting to attach extended attributes to types, but the grammar (and semantics) are significantly easier if we attach to operation arguments (and members) instead. Syntactically: [ExtAttr] sequence<long> foo ...instead of: sequence<[ExtAttr] long> foo This is b/c extended attributes appear at 3 levels: * definitions (interfaces etc.), * members (attributes, operations, etc.), * arguments (to operations). Extended attributes basically don't attach to types; if they did, we'd need to handle nesting, so these would have different meanings: [ExtAttr] sequence<long> foo sequence<[ExtAttr] long> foo ...and there would be ambiguity of whether an ExtAttr applies to a type or an argument (or an attribute etc.); this: [ExtAttr] sequence<long> foo parses 2 ways: ([ExtAttr] sequence<long>) foo [ExtAttr] (sequence<long> foo) ...which is pretty ugly. http://dev.w3.org/2006/webapi/WebIDL/#idl-extended-attributes Note that in the Candidate Recommendation, extended attributes are applicable to typedefs: typedef [Clamp] octet Value; http://www.w3.org/TR/WebIDL/#dfn-typedef ...so: sequence<Value> in principle expands to: sequence<[Clamp] octet> ...but this makes quite a mess (as above), and is not present in the Editor's Draft: http://dev.w3.org/2006/webapi/WebIDL/#dfn-typedef Hope this helps!
So this is specifically talking about [Clamp] applied to a sequence<T> where T is a type that [Clamp] can currently be applied to, right?
(In reply to Boris Zbarsky from comment #7) > So this is specifically talking about [Clamp] applied to a sequence<T> where > T is a type that [Clamp] can currently be applied to, right? Yes, exactly: we want |[Clamp] sequence<T>| to mean "clamp all terms of sequence".
This bug is one of the last dependencies for finalizing the Vibration API. Do you have an estimate for when it might be fixed? Is there anything I could help with? I'm not sure how much work it is, or how much time the Web IDL folks have available for looking at this. Thanks!
Fixed by https://github.com/heycam/webidl/commit/faaaaa9ffb548a303db362a09e4b1504c4605e0c